@@ -14,7 +14,6 @@ module CompoundBeacon {
14
14
import opened AwsCryptographyDbEncryptionSdkDynamoDbTypes
15
15
import opened DynamoDbEncryptionUtil
16
16
import opened DdbVirtualFields
17
- import opened MemoryMath
18
17
19
18
import Prim = AwsCryptographyPrimitivesTypes
20
19
import Primitives = AtomicPrimitives
@@ -91,11 +90,11 @@ module CompoundBeacon {
91
90
base : BeaconBase ,
92
91
split : char ,
93
92
parts : seq <BeaconPart >, // Signed followed by Encrypted
94
- numSigned : uint64 ,
93
+ numSigned : nat ,
95
94
construct : ConstructorList
96
95
)
97
96
: (ret : Result< ValidCompoundBeacon, Error> )
98
- requires numSigned as nat <= |parts|
97
+ requires numSigned <= |parts|
99
98
requires OrderedParts (parts, numSigned)
100
99
101
100
// = specification/searchable-encryption/beacons.md#initialization-failure
@@ -111,36 +110,34 @@ module CompoundBeacon {
111
110
112
111
// are the parts properly ordered?
113
112
// 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|
116
115
{
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?)
120
118
}
121
119
122
120
datatype CompoundBeacon = CompoundBeacon (
123
121
base : BeaconBase ,
124
122
split : char ,
125
123
parts : seq <BeaconPart >,
126
- numSigned : uint64 ,
124
+ numSigned : nat ,
127
125
construct : ConstructorList
128
126
) {
129
127
130
128
predicate ValidState ()
131
129
{
132
130
&& ValidPrefixSet ()
133
- && numSigned as nat <= |parts|
131
+ && numSigned <= |parts|
134
132
&& OrderedParts (parts, numSigned)
135
133
}
136
134
137
135
// no prefix is a prefix of another prefix
138
136
// that is, no ambiguity when determining which prefix is used in a value
139
137
predicate ValidPrefixSet ()
140
138
{
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|
144
141
:: OkPrefixPair (x, y)
145
142
}
146
143
@@ -163,8 +160,7 @@ module CompoundBeacon {
163
160
164
161
// Does this beacon have any encrypted parts
165
162
predicate method isEncrypted () {
166
- SequenceIsSafeBecauseItIsInMemory (parts);
167
- numSigned < |parts| as uint64
163
+ numSigned < |parts|
168
164
}
169
165
170
166
// find the part whose prefix matches this value
@@ -513,9 +509,9 @@ module CompoundBeacon {
513
509
}
514
510
515
511
// 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|
519
515
{
520
516
|| pos1 == pos2
521
517
|| OkPrefixStringPair (parts[pos1].prefix, parts[pos2].prefix)
@@ -525,10 +521,9 @@ module CompoundBeacon {
525
521
function method CheckOnePrefixPart (pos1 : nat , pos2 : nat ) : (ret : Result< bool , Error> )
526
522
requires pos1 < |parts|
527
523
requires pos2 < |parts|
528
- ensures ret. Success? ==> HasUint64Len (parts) && OkPrefixPair (pos1 as uint64 , pos2 as uint64 )
524
+ ensures ret. Success? ==> OkPrefixPair (pos1, pos2)
529
525
{
530
- SequenceIsSafeBecauseItIsInMemory (parts);
531
- if ! OkPrefixPair (pos1 as uint64, pos2 as uint64) then
526
+ if ! OkPrefixPair (pos1, pos2) then
532
527
Failure (E("Compound beacon " + base.name + " defines part " + parts[pos1].getName() + " with prefix " + parts[pos1]. prefix
533
528
+ " which is incompatible with part " + parts[pos2]. getName () + " which has a prefix of " + parts[pos2]. prefix + ". "))
534
529
else
@@ -545,25 +540,23 @@ module CompoundBeacon {
545
540
}
546
541
547
542
// 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
550
545
{
551
- SequenceIsSafeBecauseItIsInMemory (parts);
552
- if |parts| as uint64 <= index then
546
+ if |parts| <= index then
553
547
Success (true)
554
548
else
555
- var _ :- CheckOnePrefix (index as nat );
549
+ var _ :- CheckOnePrefix (index);
556
550
ValidPrefixSetResultPos (index+1)
557
551
}
558
552
559
553
// error if any part's prefix is a prefix of another part's prefix
560
554
function method ValidPrefixSetResult () : (ret : Result< bool , Error> )
561
555
ensures ret. Success? ==> ValidPrefixSet () && ret. value
562
556
{
563
- SequenceIsSafeBecauseItIsInMemory (parts);
564
557
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|
567
560
:: OkPrefixPair (x, y) then
568
561
Success (true)
569
562
else
0 commit comments