Skip to content

Commit fcc7c6e

Browse files
authored
feat: Global Parts List (#442)
* feat: Global Parts List * add BeaconStylesSearchableEncryptionExample.java
1 parent 5a75c43 commit fcc7c6e

File tree

16 files changed

+985
-170
lines changed

16 files changed

+985
-170
lines changed

DynamoDbEncryption/dafny/DynamoDbEncryption/Model/AwsCryptographyDbEncryptionSdkDynamoDbTypes.dfy

+3-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ include "../../../../submodules/MaterialProviders/StandardLibrary/src/Index.dfy"
4444
nameonly keySource: BeaconKeySource ,
4545
nameonly standardBeacons: StandardBeaconList ,
4646
nameonly compoundBeacons: Option<CompoundBeaconList> ,
47-
nameonly virtualFields: Option<VirtualFieldList>
47+
nameonly virtualFields: Option<VirtualFieldList> ,
48+
nameonly encryptedParts: Option<EncryptedPartsList> ,
49+
nameonly signedParts: Option<SignedPartsList>
4850
)
4951
type BeaconVersionList = x: seq<BeaconVersion> | IsValid_BeaconVersionList(x) witness *
5052
predicate method IsValid_BeaconVersionList(x: seq<BeaconVersion>) {

DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy

+5
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,11 @@ structure BeaconVersion {
722722
compoundBeacons : CompoundBeaconList,
723723
@javadoc("The Virtual Fields to be calculated, supporting other searchable enryption configurations.")
724724
virtualFields : VirtualFieldList,
725+
726+
@javadoc("The list of Encrypted Parts that may be included in any compound beacon.")
727+
encryptedParts : EncryptedPartsList,
728+
@javadoc("The list of Signed Parts that may be included in any compound beacon.")
729+
signedParts : SignedPartsList,
725730
}
726731

727732
//= specification/searchable-encryption/search-config.md#initialization

DynamoDbEncryption/dafny/DynamoDbEncryption/src/Beacon.dfy

+14-11
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,6 @@ module BaseBeacon {
194194
}
195195

196196
function method {:opaque} ValueToSet(value : DDB.AttributeValue, key : Bytes) : (ret : Result<DDB.AttributeValue, Error>)
197-
requires asSet
198197
ensures ret.Success? ==> ret.value.SS?
199198
ensures !value.SS? && !value.NS? && !value.BS? ==> ret.Failure?
200199
ensures ret.Success? ==> HasNoDuplicates(ret.value.SS)
@@ -241,11 +240,20 @@ module BaseBeacon {
241240
//= type=implication
242241
//# * The resulting set MUST NOT contain duplicates.
243242
&& (ret.value.Some? ==> HasNoDuplicates(ret.value.value.SS))
243+
//= specification/searchable-encryption/beacons.md#asset-initialization
244+
//= type=implication
245+
//# * Writing an item MUST fail if the item contains this beacon's attribute,
246+
//# and that attribute is not of type Set.
247+
&& var value := TermLoc.TermToAttr(loc, item, None);
248+
&& (value.Some? && !(value.value.SS? || value.value.NS? || value.value.BS?) ==> ret.Failure?)
244249
{
245250
var value := TermLoc.TermToAttr(loc, item, None);
246251
if value.None? then
247252
Success(None)
248253
else
254+
//= specification/searchable-encryption/beacons.md#asset-initialization
255+
//# * The Standard Beacon MUST be stored in the item as a Set,
256+
//# comprised of the [beacon values](#beacon-value) of all the elements in the original Set.
249257
var setValue :- ValueToSet(value.value, key);
250258
Success(Some(setValue))
251259
}
@@ -346,18 +354,13 @@ module BaseBeacon {
346354
BeaconizeBinarySet(value[1..], key, converted + [h])
347355
}
348356

349-
function method GetBeaconValue(value : DDB.AttributeValue, key : Bytes)
357+
function method GetBeaconValue(value : DDB.AttributeValue, key : Bytes, forContains : bool)
350358
: (ret : Result<DDB.AttributeValue, Error>)
351-
//= specification/searchable-encryption/beacons.md#asset-initialization
352-
//= type=implication
353-
//# * Writing an item MUST fail if the item contains this beacon's attribute,
354-
//# and that attribute is not of type Set.
355-
ensures asSet && !value.SS? && !value.NS? && !value.BS? ==> ret.Failure?
356359
{
357-
//= specification/searchable-encryption/beacons.md#asset-initialization
358-
//# * The Standard Beacon MUST be stored in the item as a Set,
359-
//# comprised of the [beacon values](#beacon-value) of all the elements in the original Set.
360-
if asSet then
360+
// in query, allow beaconization of terminals
361+
if asSet && !value.S? && !value.N? && !value.B? then
362+
ValueToSet(value, key)
363+
else if forContains && (value.SS? || value.NS? || value.BS?) then
361364
ValueToSet(value, key)
362365
else
363366
var bytes :- DynamoToStruct.TopLevelAttributeToBytes(value).MapFailure(e => E(e));

0 commit comments

Comments
 (0)