@@ -43,7 +43,7 @@ module BaseBeacon {
4343 // = specification/searchable-encryption/beacons.md#basichash
4444 // = type=implication
4545 // # * basicHash MUST take an [hmac key](./search-config.md#hmac-key-generation), a [beacon length](#beacon-length) and a sequence of bytes as input.
46- function method {:opaque} hash (val : Bytes , key : Bytes , length : BeaconLength , bucket : Bytes )
46+ function method {:opaque} hash (val : Bytes , key : Bytes , length : BeaconLength , bucket : BucketBytes )
4747 : (ret : Result< string , Error> )
4848 ensures ret. Success? ==>
4949 // = specification/searchable-encryption/beacons.md#basichash
@@ -70,7 +70,7 @@ module BaseBeacon {
7070 }
7171
7272 // Get the standard hash for the UTF8 encoded representation of this string.
73- function method {:opaque} hashStr (val : string , key : Bytes , length : BeaconLength , bucket : Bytes ) : (res : Result< string , Error> )
73+ function method {:opaque} hashStr (val : string , key : Bytes , length : BeaconLength , bucket : BucketBytes ) : (res : Result< string , Error> )
7474 ensures res. Success? ==> |res. value| > 0
7575 {
7676 var str := UTF8. Encode (val);
@@ -124,7 +124,7 @@ module BaseBeacon {
124124 var beaconName := BeaconPrefix + name;
125125 :- Need (DDB.IsValid_AttributeName(beaconName), E (beaconName + " is not a valid attribute name."));
126126 var numBuckets : nat := if numberOfBuckets. Some? then numberOfBuckets. value as nat else 0;
127- :- Need (numBuckets < 256, E(beaconName + " has numberOfBuckets greater than 255"));
127+ // :- Need(numBuckets < 256, E(beaconName + " has numberOfBuckets greater than 255"));
128128 Success (StandardBeacon.StandardBeacon(
129129 BeaconBase (
130130 client := client,
@@ -136,7 +136,7 @@ module BaseBeacon {
136136 partOnly,
137137 asSet,
138138 share,
139- numBuckets as uint8
139+ numBuckets as OptBucketCount
140140 ))
141141 }
142142 datatype StandardBeacon = StandardBeacon (
@@ -146,21 +146,19 @@ module BaseBeacon {
146146 partOnly : bool ,
147147 asSet : bool ,
148148 share : Option <string >,
149- numberOfBuckets : uint8
149+ numberOfBuckets : OptBucketCount
150150 ) {
151- function method constrained_bucket (bucket : Bytes ) : Bytes
151+
152+ function method constrained_bucket (bucket : BucketNumber ) : BucketBytes
152153 {
153- SequenceIsSafeBecauseItIsInMemory (bucket);
154- if numberOfBuckets == 0 || |bucket| as uint64 == 0 then
155- bucket
154+ if numberOfBuckets == 0 || bucket == 0 then
155+ BucketNumberToBytes (bucket)
156156 else
157- var newBucket : uint8 := bucket[0] % numberOfBuckets;
158- if newBucket == 0 then
159- []
160- else
161- [newBucket]
157+ var newBucket : BucketNumber := (bucket as OptBucketCount % numberOfBuckets) as BucketNumber;
158+ BucketNumberToBytes (newBucket)
162159 }
163- function method {:opaque} hash (val : Bytes , key : Bytes , bucket : Bytes )
160+
161+ function method {:opaque} hash (val : Bytes , key : Bytes , bucket : BucketNumber )
164162 : (ret : Result< string , Error> )
165163 ensures ret. Success? ==>
166164 && |ret. value| > 0
@@ -188,7 +186,7 @@ module BaseBeacon {
188186 // = type=implication
189187 // # * string hash MUST take a string and some [key materials](./search-config.md#get-beacon-key-materials)
190188 // # as input, and produce a string as output.
191- function method {:opaque} hashStr (val : string , keys : HmacKeyMap , bucket : Bytes ) : (res : Result< string , Error> )
189+ function method {:opaque} hashStr (val : string , keys : HmacKeyMap , bucket : BucketNumber ) : (res : Result< string , Error> )
192190 ensures res. Success? ==> |res. value| > 0
193191
194192 // = specification/searchable-encryption/beacons.md#string-hash
@@ -211,7 +209,7 @@ module BaseBeacon {
211209 hash (str.value, keys[keyName()], bucket)
212210 }
213211
214- function method {:opaque} ValueToSet (value : DDB .AttributeValue, key : Bytes , bucket : Bytes ) : (ret : Result< DDB. AttributeValue, Error> )
212+ function method {:opaque} ValueToSet (value : DDB .AttributeValue, key : Bytes , bucket : BucketNumber ) : (ret : Result< DDB. AttributeValue, Error> )
215213 ensures ret. Success? ==> ret. value. SS?
216214 ensures ! value. SS? && ! value. NS? && ! value. BS? ==> ret. Failure?
217215 ensures ret. Success? ==> HasNoDuplicates (ret.value.SS)
@@ -230,7 +228,7 @@ module BaseBeacon {
230228 // = specification/searchable-encryption/beacons.md#value-for-a-standard-beacon
231229 // = type=implication
232230 // # * This operation MUST take an [hmac key](./search-config.md#hmac-key-generation), a record as input, and produce an optional [AttributeValue](https://docs.aws.amazon.com/amazondynamodb/latest/APIReference/API_AttributeValue.html).
233- function method {:opaque} getHash (item : DDB .AttributeMap, vf : VirtualFieldMap , key : Bytes , bucket : Bytes ) : (ret : Result< Option< DDB. AttributeValue> , Error> )
231+ function method {:opaque} getHash (item : DDB .AttributeMap, vf : VirtualFieldMap , key : Bytes , bucket : BucketNumber ) : (ret : Result< Option< DDB. AttributeValue> , Error> )
234232 // = specification/searchable-encryption/beacons.md#value-for-a-standard-beacon
235233 // = type=implication
236234 // # * If this beacon is marked AsSet then this operation MUST return the
@@ -245,7 +243,7 @@ module BaseBeacon {
245243 getHashNonSet (item, vf, key, bucket)
246244 }
247245
248- function method {:opaque} getHashSet (item : DDB .AttributeMap, key : Bytes , bucket : Bytes ) : (ret : Result< Option< DDB. AttributeValue> , Error> )
246+ function method {:opaque} getHashSet (item : DDB .AttributeMap, key : Bytes , bucket : BucketNumber ) : (ret : Result< Option< DDB. AttributeValue> , Error> )
249247 requires asSet
250248 ensures ret. Success? ==>
251249 // = specification/searchable-encryption/beacons.md#value-for-a-set-standard-beacon
@@ -275,7 +273,7 @@ module BaseBeacon {
275273 var setValue :- ValueToSet (value.value, key, bucket);
276274 Success (Some(setValue))
277275 }
278- function method {:opaque} getHashNonSet (item : DDB .AttributeMap, vf : VirtualFieldMap , key : Bytes , bucket : Bytes ) : (ret : Result< Option< DDB. AttributeValue> , Error> )
276+ function method {:opaque} getHashNonSet (item : DDB .AttributeMap, vf : VirtualFieldMap , key : Bytes , bucket : BucketNumber ) : (ret : Result< Option< DDB. AttributeValue> , Error> )
279277 requires ! asSet
280278 ensures ret. Success? ==>
281279 // = specification/searchable-encryption/beacons.md#value-for-a-non-set-standard-beacon
@@ -321,7 +319,7 @@ module BaseBeacon {
321319 [loc[0]. key]
322320 }
323321
324- function method {:tailrecursion} BeaconizeStringSet (value : DDB .StringSetAttributeValue, key : Bytes , bucket : Bytes , converted : seq <string > := [])
322+ function method {:tailrecursion} BeaconizeStringSet (value : DDB .StringSetAttributeValue, key : Bytes , bucket : BucketNumber , converted : seq <string > := [])
325323 : (ret : Result< seq < string > , Error> )
326324 requires HasNoDuplicates (converted)
327325 ensures ret. Success? ==> HasNoDuplicates (ret.value)
@@ -338,7 +336,7 @@ module BaseBeacon {
338336 BeaconizeStringSet (value[1..], key, bucket, converted + [h])
339337 }
340338
341- function method {:tailrecursion} BeaconizeNumberSet (value : DDB .NumberSetAttributeValue, key : Bytes , bucket : Bytes , converted : seq <string > := [])
339+ function method {:tailrecursion} BeaconizeNumberSet (value : DDB .NumberSetAttributeValue, key : Bytes , bucket : BucketNumber , converted : seq <string > := [])
342340 : (ret : Result< seq < string > , Error> )
343341 requires HasNoDuplicates (converted)
344342 ensures ret. Success? ==> HasNoDuplicates (ret.value)
@@ -355,7 +353,7 @@ module BaseBeacon {
355353 BeaconizeNumberSet (value[1..], key, bucket, converted + [h])
356354 }
357355
358- function method {:tailrecursion} BeaconizeBinarySet (value : DDB .BinarySetAttributeValue, key : Bytes , bucket : Bytes , converted : seq <string > := [])
356+ function method {:tailrecursion} BeaconizeBinarySet (value : DDB .BinarySetAttributeValue, key : Bytes , bucket : BucketNumber , converted : seq <string > := [])
359357 : (ret : Result< seq < string > , Error> )
360358 requires HasNoDuplicates (converted)
361359 ensures ret. Success? ==> HasNoDuplicates (ret.value)
@@ -372,7 +370,7 @@ module BaseBeacon {
372370 BeaconizeBinarySet (value[1..], key, bucket, converted + [h])
373371 }
374372
375- function method GetBeaconValue (value : DDB .AttributeValue, key : Bytes , forContains : bool , bucket : Bytes )
373+ function method GetBeaconValue (value : DDB .AttributeValue, key : Bytes , forContains : bool , bucket : BucketNumber )
376374 : (ret : Result< DDB. AttributeValue, Error> )
377375 {
378376 // in query, allow beaconization of terminals
@@ -389,7 +387,7 @@ module BaseBeacon {
389387 // = specification/searchable-encryption/beacons.md#getpart-for-a-standard-beacon
390388 // = type=implication
391389 // # * getPart MUST take an [hmac key](./search-config.md#hmac-key-generation), a sequence of bytes as input, and produce a string.
392- function method {:opaque} getPart (val : Bytes , key : Bytes , bucket : Bytes )
390+ function method {:opaque} getPart (val : Bytes , key : Bytes , bucket : BucketBytes )
393391 : (ret : Result< string , Error> )
394392 requires 0 < |val|
395393
0 commit comments