@@ -14,7 +14,6 @@ module CompoundBeacon {
1414 import opened AwsCryptographyDbEncryptionSdkDynamoDbTypes
1515 import opened DynamoDbEncryptionUtil
1616 import opened DdbVirtualFields
17- import opened MemoryMath
1817
1918 import Prim = AwsCryptographyPrimitivesTypes
2019 import Primitives = AtomicPrimitives
@@ -91,11 +90,11 @@ module CompoundBeacon {
9190 base : BeaconBase ,
9291 split : char ,
9392 parts : seq <BeaconPart >, // Signed followed by Encrypted
94- numSigned : uint64 ,
93+ numSigned : nat ,
9594 construct : ConstructorList
9695 )
9796 : (ret : Result< ValidCompoundBeacon, Error> )
98- requires numSigned as nat <= |parts|
97+ requires numSigned <= |parts|
9998 requires OrderedParts (parts, numSigned)
10099
101100 // = specification/searchable-encryption/beacons.md#initialization-failure
@@ -111,36 +110,34 @@ module CompoundBeacon {
111110
112111 // are the parts properly ordered?
113112 // that is, with the signed parts followed the encrypted parts
114- predicate OrderedParts (p : seq <BeaconPart >, n : uint64 )
115- requires n as nat <= |p|
113+ predicate OrderedParts (p : seq <BeaconPart >, n : nat )
114+ requires n <= |p|
116115 {
117- SequenceIsSafeBecauseItIsInMemory (p);
118- && (forall x : uint64 | 0 <= x < n :: p[x]. Signed?)
119- && (forall x : uint64 | n <= x < |p| as uint64 :: p[x]. Encrypted?)
116+ && (forall x | 0 <= x < n :: p[x]. Signed?)
117+ && (forall x | n <= x < |p| :: p[x]. Encrypted?)
120118 }
121119
122120 datatype CompoundBeacon = CompoundBeacon (
123121 base : BeaconBase ,
124122 split : char ,
125123 parts : seq <BeaconPart >,
126- numSigned : uint64 ,
124+ numSigned : nat ,
127125 construct : ConstructorList
128126 ) {
129127
130128 predicate ValidState ()
131129 {
132130 && ValidPrefixSet ()
133- && numSigned as nat <= |parts|
131+ && numSigned <= |parts|
134132 && OrderedParts (parts, numSigned)
135133 }
136134
137135 // no prefix is a prefix of another prefix
138136 // that is, no ambiguity when determining which prefix is used in a value
139137 predicate ValidPrefixSet ()
140138 {
141- SequenceIsSafeBecauseItIsInMemory (parts);
142- forall x : uint64, y : uint64
143- | 0 <= x < |parts| as uint64 && x < y < |parts| as uint64
139+ forall x : nat , y : nat
140+ | 0 <= x < |parts| && x < y < |parts|
144141 :: OkPrefixPair (x, y)
145142 }
146143
@@ -163,8 +160,7 @@ module CompoundBeacon {
163160
164161 // Does this beacon have any encrypted parts
165162 predicate method isEncrypted () {
166- SequenceIsSafeBecauseItIsInMemory (parts);
167- numSigned < |parts| as uint64
163+ numSigned < |parts|
168164 }
169165
170166 // find the part whose prefix matches this value
@@ -513,9 +509,9 @@ module CompoundBeacon {
513509 }
514510
515511 // true is neither part's prefix is a prefix of the other
516- predicate method OkPrefixPair (pos1 : uint64 , pos2 : uint64 )
517- requires pos1 as nat < |parts|
518- requires pos2 as nat < |parts|
512+ predicate method OkPrefixPair (pos1 : nat , pos2 : nat )
513+ requires pos1 < |parts|
514+ requires pos2 < |parts|
519515 {
520516 || pos1 == pos2
521517 || OkPrefixStringPair (parts[pos1].prefix, parts[pos2].prefix)
@@ -525,10 +521,9 @@ module CompoundBeacon {
525521 function method CheckOnePrefixPart (pos1 : nat , pos2 : nat ) : (ret : Result< bool , Error> )
526522 requires pos1 < |parts|
527523 requires pos2 < |parts|
528- ensures ret. Success? ==> HasUint64Len (parts) && OkPrefixPair (pos1 as uint64 , pos2 as uint64 )
524+ ensures ret. Success? ==> OkPrefixPair (pos1, pos2)
529525 {
530- SequenceIsSafeBecauseItIsInMemory (parts);
531- if ! OkPrefixPair (pos1 as uint64, pos2 as uint64) then
526+ if ! OkPrefixPair (pos1, pos2) then
532527 Failure (E("Compound beacon " + base.name + " defines part " + parts[pos1].getName() + " with prefix " + parts[pos1]. prefix
533528 + " which is incompatible with part " + parts[pos2]. getName () + " which has a prefix of " + parts[pos2]. prefix + ". "))
534529 else
@@ -545,25 +540,23 @@ module CompoundBeacon {
545540 }
546541
547542 // error if any part's prefix is a prefix of another part's prefix
548- function method {:tailrecursion} ValidPrefixSetResultPos (index : uint64 ) : (ret : Result< bool , Error> )
549- decreases |parts| - index as nat
543+ function method {:tailrecursion} ValidPrefixSetResultPos (index : nat ) : (ret : Result< bool , Error> )
544+ decreases |parts| - index
550545 {
551- SequenceIsSafeBecauseItIsInMemory (parts);
552- if |parts| as uint64 <= index then
546+ if |parts| <= index then
553547 Success (true)
554548 else
555- var _ :- CheckOnePrefix (index as nat );
549+ var _ :- CheckOnePrefix (index);
556550 ValidPrefixSetResultPos (index+1)
557551 }
558552
559553 // error if any part's prefix is a prefix of another part's prefix
560554 function method ValidPrefixSetResult () : (ret : Result< bool , Error> )
561555 ensures ret. Success? ==> ValidPrefixSet () && ret. value
562556 {
563- SequenceIsSafeBecauseItIsInMemory (parts);
564557 var _ :- ValidPrefixSetResultPos (0);
565- if forall x : uint64 , y : uint64
566- | 0 <= x < |parts| as uint64 && x < y < |parts| as uint64
558+ if forall x : nat , y : nat
559+ | 0 <= x < |parts| && x < y < |parts|
567560 :: OkPrefixPair (x, y) then
568561 Success (true)
569562 else
0 commit comments