Skip to content

Commit d9e6ece

Browse files
committed
feat: change twinned beacons to shared beacons (#522)
* feat: change twinned beacons to shared beacons
1 parent a9539ff commit d9e6ece

File tree

22 files changed

+303
-302
lines changed

22 files changed

+303
-302
lines changed

DynamoDbEncryption/dafny/DynamoDbEncryption/Model/AwsCryptographyDbEncryptionSdkDynamoDbTypes.dfy

+8-8
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,9 @@ include "../../../../submodules/MaterialProviders/StandardLibrary/src/Index.dfy"
3535
| multi(multi: MultiKeyStore)
3636
datatype BeaconStyle =
3737
| partOnly(partOnly: PartOnly)
38-
| twinned(twinned: Twinned)
38+
| shared(shared: Shared)
3939
| asSet(asSet: AsSet)
40-
| twinnedSet(twinnedSet: TwinnedSet)
40+
| sharedSet(sharedSet: SharedSet)
4141
datatype BeaconVersion = | BeaconVersion (
4242
nameonly version: VersionNumber ,
4343
nameonly keyStore: AwsCryptographyKeyStoreTypes.IKeyStoreClient ,
@@ -336,6 +336,12 @@ include "../../../../submodules/MaterialProviders/StandardLibrary/src/Index.dfy"
336336
nameonly versions: BeaconVersionList ,
337337
nameonly writeVersion: VersionNumber
338338
)
339+
datatype Shared = | Shared (
340+
nameonly other: string
341+
)
342+
datatype SharedSet = | SharedSet (
343+
nameonly other: string
344+
)
339345
datatype SignedPart = | SignedPart (
340346
nameonly name: string ,
341347
nameonly prefix: Prefix ,
@@ -363,12 +369,6 @@ include "../../../../submodules/MaterialProviders/StandardLibrary/src/Index.dfy"
363369
predicate method IsValid_TerminalLocation(x: string) {
364370
( 1 <= |x| )
365371
}
366-
datatype Twinned = | Twinned (
367-
nameonly other: string
368-
)
369-
datatype TwinnedSet = | TwinnedSet (
370-
nameonly other: string
371-
)
372372
datatype Upper = | Upper (
373373

374374
)

DynamoDbEncryption/dafny/DynamoDbEncryption/Model/DynamoDbEncryption.smithy

+11-11
Original file line numberDiff line numberDiff line change
@@ -479,25 +479,25 @@ structure PartOnly {}
479479
@javadoc("Attribute must be a Set. Beacon value will also be a Set.")
480480
structure AsSet {}
481481

482-
//= specification/searchable-encryption/beacons.md#twinned-initialization
482+
//= specification/searchable-encryption/beacons.md#shared-initialization
483483
//= type=implication
484-
//# On initialization of a Twinned, the caller MUST provide:
484+
//# On initialization of a Shared, the caller MUST provide:
485485
//#
486486
//# * other : a beacon name
487487
@javadoc("This beacon should calculate values like another beacon, so they can be compared.")
488-
structure Twinned {
488+
structure Shared {
489489
@required
490490
@javadoc("Calculate beacon values as for this beacon.")
491491
other : String,
492492
}
493493

494-
//= specification/searchable-encryption/beacons.md#twinnedset-initialization
494+
//= specification/searchable-encryption/beacons.md#sharedset-initialization
495495
//= type=implication
496-
//# On initialization of a TwinnedSet, the caller MUST provide:
496+
//# On initialization of a SharedSet, the caller MUST provide:
497497
//#
498498
//# * other : a beacon name
499-
@javadoc("Both Twinned and AsSet.")
500-
structure TwinnedSet {
499+
@javadoc("Both Shared and AsSet.")
500+
structure SharedSet {
501501
@required
502502
@javadoc("Calculate beacon values as for this beacon.")
503503
other : String,
@@ -508,15 +508,15 @@ structure TwinnedSet {
508508
//# On initialization of a Beacon Style, the caller MUST provide exactly one of
509509
//#
510510
//# * a [PartOnly](#partonly-initialization)
511-
//# * a [Twinned](#twinned-initialization)
511+
//# * a [Shared](#shared-initialization)
512512
//# * an [AsSet](#asset-initialization)
513-
//# * a [TwinnedSet](#twinnedset-initialization)
513+
//# * a [SharedSet](#sharedset-initialization)
514514

515515
union BeaconStyle {
516516
partOnly: PartOnly,
517-
twinned: Twinned,
517+
shared: Shared,
518518
asSet: AsSet,
519-
twinnedSet: TwinnedSet,
519+
sharedSet: SharedSet,
520520
}
521521

522522
//= specification/searchable-encryption/beacons.md#encrypted-part-initialization

DynamoDbEncryption/dafny/DynamoDbEncryption/src/Beacon.dfy

+6-6
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ module BaseBeacon {
111111
loc : string,
112112
partOnly : bool,
113113
asSet : bool,
114-
twin : Option<string>
114+
share : Option<string>
115115
)
116116
: (ret : Result<ValidStandardBeacon, Error>)
117117
ensures ret.Success? ==>
@@ -131,7 +131,7 @@ module BaseBeacon {
131131
termLoc,
132132
partOnly,
133133
asSet,
134-
twin
134+
share
135135
))
136136
}
137137
datatype StandardBeacon = StandardBeacon (
@@ -140,7 +140,7 @@ module BaseBeacon {
140140
loc : TermLoc.TermLoc,
141141
partOnly : bool,
142142
asSet : bool,
143-
twin : Option<string>
143+
share : Option<string>
144144
) {
145145
function method {:opaque} hash(val : Bytes, key : Bytes)
146146
: (ret : Result<string, Error>)
@@ -155,12 +155,12 @@ module BaseBeacon {
155155
}
156156

157157
// return the name of the hmac key to use
158-
//= specification/searchable-encryption/beacons.md#twinned-initialization
158+
//= specification/searchable-encryption/beacons.md#shared-initialization
159159
//# This beacon MUST calculate its [value](#beacon-value) as if it were the `other` beacon.
160160
function method keyName() : string
161161
{
162-
if twin.Some? then
163-
twin.value
162+
if share.Some? then
163+
share.value
164164
else
165165
base.name
166166
}

DynamoDbEncryption/dafny/DynamoDbEncryption/src/ConfigToInfo.dfy

+32-31
Original file line numberDiff line numberDiff line change
@@ -405,31 +405,31 @@ module SearchConfigToInfo {
405405
Some(badSeq[0])
406406
}
407407

408-
function method IsValidTwin(converted : I.BeaconMap, name : string, length : B.BeaconLength, twin : string)
408+
function method IsValidShare(converted : I.BeaconMap, name : string, length : B.BeaconLength, share : string)
409409
: (ret : Result<bool, Error>)
410410
ensures ret.Success? ==>
411-
&& twin in converted
412-
&& converted[twin].Standard?
413-
&& converted[twin].std.length == length
411+
&& share in converted
412+
&& converted[share].Standard?
413+
&& converted[share].std.length == length
414414
{
415-
if twin in converted then
416-
var tb := converted[twin];
415+
if share in converted then
416+
var tb := converted[share];
417417
if tb.Standard? then
418-
if tb.std.twin.Some? then
419-
if name == twin then
420-
Failure(E("Beacon " + name + " is twinned to itself."))
418+
if tb.std.share.Some? then
419+
if name == share then
420+
Failure(E("Beacon " + name + " is shared to itself."))
421421
else
422-
Failure(E("Beacon " + name + " is twinned to " + twin + " which is in turn twinned to " + tb.std.twin.value
423-
+ ". Twin chains are not allowed."))
422+
Failure(E("Beacon " + name + " is shared to " + share + " which is in turn shared to " + tb.std.share.value
423+
+ ". Share chains are not allowed."))
424424
else if tb.std.length == length then
425425
Success(true)
426426
else
427-
Failure(E("Beacon " + name + " is twinned to " + twin + " but " + name + " has length " + Base10Int2String(length as int)
428-
+ " and " + twin + " has length " + Base10Int2String(tb.std.length as int) + "."))
427+
Failure(E("Beacon " + name + " is shared to " + share + " but " + name + " has length " + Base10Int2String(length as int)
428+
+ " and " + share + " has length " + Base10Int2String(tb.std.length as int) + "."))
429429
else
430-
Failure(E("Beacon " + name + " is twinned to " + twin + " but " + twin + " is a compound beacon."))
430+
Failure(E("Beacon " + name + " is shared to " + share + " but " + share + " is a compound beacon."))
431431
else
432-
Failure(E("Beacon " + name + " is twinned to " + twin + " which is not defined."))
432+
Failure(E("Beacon " + name + " is shared to " + share + " which is not defined."))
433433
}
434434

435435
// convert configured StandardBeacons to internal Beacons
@@ -484,20 +484,20 @@ module SearchConfigToInfo {
484484
var locString := GetLocStr(beacons[0].name, beacons[0].loc);
485485
var isPartOnly := false;
486486
var isAsSet := false;
487-
var twin : Option<string> := None;
487+
var share : Option<string> := None;
488488
if beacons[0].style.Some? {
489489
match beacons[0].style.value {
490490
case partOnly(t) => isPartOnly := true;
491-
case twinned(t) => twin := Some(t.other);
491+
case shared(t) => share := Some(t.other);
492492
case asSet(t) => isAsSet := true;
493-
//= specification/searchable-encryption/beacons.md#twinnedset-initialization
494-
//# A TwinnedSet Beacon MUST behave both as [Twinned](#twinned-initialization) and [AsSet](#asset-initialization).
495-
case twinnedSet(t) => twin := Some(t.other); isAsSet := true;
493+
//= specification/searchable-encryption/beacons.md#sharedset-initialization
494+
//# A SharedSet Beacon MUST behave both as [Shared](#shared-initialization) and [AsSet](#asset-initialization).
495+
case sharedSet(t) => share := Some(t.other); isAsSet := true;
496496
}
497497

498498
}
499499
var newBeacon :- B.MakeStandardBeacon(client, beacons[0].name, beacons[0].length as B.BeaconLength, locString,
500-
isPartOnly, isAsSet, twin);
500+
isPartOnly, isAsSet, share);
501501

502502
//= specification/searchable-encryption/search-config.md#beacon-version-initialization
503503
//# Initialization MUST fail if the [terminal location](virtual.md#terminal-location)
@@ -1072,27 +1072,28 @@ module SearchConfigToInfo {
10721072
//# Initialization MUST fail if the configuration does not use a PartOnly in a [compound beacon](#compound-beacon).
10731073
ensures |names| != 0 && I.IsPartOnly(data[names[0]]) && !ExistsInCompound(allNames, names[0], data) ==> ret.Failure?
10741074

1075-
ensures ret.Success? && 0 < |names| && data[names[0]].Standard? && data[names[0]].std.twin.Some? ==>
1076-
&& var twin := data[names[0]].std.twin.value;
1077-
&& IsValidTwin(data, names[0], data[names[0]].std.length, twin).Success?
1078-
//= specification/searchable-encryption/beacons.md#twinned-initialization
1075+
ensures ret.Success? && 0 < |names| && data[names[0]].Standard? && data[names[0]].std.share.Some? ==>
1076+
&& var share := data[names[0]].std.share.value;
1077+
&& IsValidShare(data, names[0], data[names[0]].std.length, share).Success?
1078+
//= specification/searchable-encryption/beacons.md#shared-initialization
10791079
//= type=implication
10801080
//# This name MUST be the name of a previously defined Standard Beacon.
1081-
&& twin in data
1082-
&& data[twin].Standard?
1083-
//= specification/searchable-encryption/beacons.md#twinned-initialization
1081+
&& share in data
1082+
&& data[share].Standard?
1083+
//= specification/searchable-encryption/beacons.md#shared-initialization
10841084
//= type=implication
10851085
//# This beacon's [length](#beacon-length) MUST be equal to the `other` beacon's [length](#beacon-length).
1086-
&& data[twin].std.length == data[names[0]].std.length
1086+
&& data[share].std.length == data[names[0]].std.length
10871087
{
10881088
if |names| == 0 then
10891089
Success(true)
10901090
else
10911091
var b := data[names[0]];
10921092
if I.IsPartOnly(b) && !ExistsInCompound(allNames, names[0], data) then
10931093
Failure(E("PartOnly beacon " + names[0] + " MUST be used in a compound beacon."))
1094-
else if b.Standard? && b.std.twin.Some? then
1095-
IsValidTwin(data, names[0], b.std.length, b.std.twin.value)
1094+
else if b.Standard? && b.std.share.Some? then
1095+
var _ :- IsValidShare(data, names[0], b.std.length, b.std.share.value);
1096+
CheckAllBeacons(names[1..], allNames, data)
10961097
else
10971098
CheckAllBeacons(names[1..], allNames, data)
10981099
}

0 commit comments

Comments
 (0)