Skip to content

chore(dafny): change nat to uint64 in many places #1852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions DynamoDbEncryption/dafny/DynamoDbEncryption/src/ConfigToInfo.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module SearchConfigToInfo {
import opened DynamoDbEncryptionUtil
import opened TermLoc
import opened StandardLibrary.String
import opened MemoryMath
import MaterialProviders
import SortedSets

Expand Down Expand Up @@ -757,15 +758,15 @@ module SearchConfigToInfo {
function method MakeDefaultConstructor(
parts : seq<CB.BeaconPart>,
ghost allParts : seq<CB.BeaconPart>,
ghost numNon : nat,
ghost numNon : uint64,
converted : seq<CB.ConstructorPart> := []
)
: (ret : Result<seq<CB.Constructor>, Error>)
requires 0 < |parts| + |converted|
requires |allParts| == |parts| + |converted|
requires parts == allParts[|converted|..]
requires numNon <= |allParts|
requires CB.OrderedParts(allParts, numNon)
requires numNon as nat <= |allParts|
requires CB.OrderedParts(allParts, numNon as nat)
requires forall i | 0 <= i < |converted| ::
&& converted[i].part == allParts[i]
&& converted[i].required
Expand All @@ -776,7 +777,7 @@ module SearchConfigToInfo {
//= type=implication
//# * This default constructor MUST be all of the signed parts,
//# followed by all the encrypted parts, all parts being required.
&& CB.OrderedParts(allParts, numNon)
&& CB.OrderedParts(allParts, numNon as nat)
&& (forall i | 0 <= i < |ret.value[0].parts| ::
&& ret.value[0].parts[i].part == allParts[i]
&& ret.value[0].parts[i].required)
Expand Down Expand Up @@ -887,13 +888,13 @@ module SearchConfigToInfo {
constructors : Option<ConstructorList>,
name : string,
parts : seq<CB.BeaconPart>,
ghost numSigned : nat
ghost numSigned : uint64
)
: (ret : Result<seq<CB.Constructor>, Error>)
requires 0 < |parts|
requires constructors.Some? ==> 0 < |constructors.value|
requires numSigned <= |parts|
requires CB.OrderedParts(parts, numSigned)
requires numSigned as nat <= |parts|
requires CB.OrderedParts(parts, numSigned as nat)
ensures ret.Success? ==>
&& (constructors.None? ==> |ret.value| == 1)
&& (constructors.Some? ==> |ret.value| == |constructors.value|)
Expand Down Expand Up @@ -1065,10 +1066,11 @@ module SearchConfigToInfo {
:- Need(beacon.constructors.Some? || |signedParts| != 0 || |encryptedParts| != 0,
E("Compound beacon " + beacon.name + " defines no constructors, and also no local parts. Cannot make a default constructor from global parts."));

var numNon := |signed|;
assert CB.OrderedParts(signed, numNon);
SequenceIsSafeBecauseItIsInMemory(signed);
var numNon := |signed| as uint64;
assert CB.OrderedParts(signed, numNon as nat);
var allParts := signed + encrypted;
assert CB.OrderedParts(allParts, numNon);
assert CB.OrderedParts(allParts, numNon as nat);

var isSignedBeacon := |encrypted| == 0;
var _ :- BeaconNameAllowed(outer, virtualFields, beacon.name, "CompoundBeacon", isSignedBeacon);
Expand All @@ -1087,7 +1089,7 @@ module SearchConfigToInfo {
),
beacon.split[0],
allParts,
numNon,
numNon as nat,
constructors
)
}
Expand Down
Loading
Loading