Skip to content

Commit 76bcb9a

Browse files
authored
feat: change twinned beacons to shared beacons (#522)
* feat: change twinned beacons to shared beacons
1 parent de3a9f3 commit 76bcb9a

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
@@ -403,31 +403,31 @@ module SearchConfigToInfo {
403403
Some(badSeq[0])
404404
}
405405

406-
function method IsValidTwin(converted : I.BeaconMap, name : string, length : B.BeaconLength, twin : string)
406+
function method IsValidShare(converted : I.BeaconMap, name : string, length : B.BeaconLength, share : string)
407407
: (ret : Result<bool, Error>)
408408
ensures ret.Success? ==>
409-
&& twin in converted
410-
&& converted[twin].Standard?
411-
&& converted[twin].std.length == length
409+
&& share in converted
410+
&& converted[share].Standard?
411+
&& converted[share].std.length == length
412412
{
413-
if twin in converted then
414-
var tb := converted[twin];
413+
if share in converted then
414+
var tb := converted[share];
415415
if tb.Standard? then
416-
if tb.std.twin.Some? then
417-
if name == twin then
418-
Failure(E("Beacon " + name + " is twinned to itself."))
416+
if tb.std.share.Some? then
417+
if name == share then
418+
Failure(E("Beacon " + name + " is shared to itself."))
419419
else
420-
Failure(E("Beacon " + name + " is twinned to " + twin + " which is in turn twinned to " + tb.std.twin.value
421-
+ ". Twin chains are not allowed."))
420+
Failure(E("Beacon " + name + " is shared to " + share + " which is in turn shared to " + tb.std.share.value
421+
+ ". Share chains are not allowed."))
422422
else if tb.std.length == length then
423423
Success(true)
424424
else
425-
Failure(E("Beacon " + name + " is twinned to " + twin + " but " + name + " has length " + Base10Int2String(length as int)
426-
+ " and " + twin + " has length " + Base10Int2String(tb.std.length as int) + "."))
425+
Failure(E("Beacon " + name + " is shared to " + share + " but " + name + " has length " + Base10Int2String(length as int)
426+
+ " and " + share + " has length " + Base10Int2String(tb.std.length as int) + "."))
427427
else
428-
Failure(E("Beacon " + name + " is twinned to " + twin + " but " + twin + " is a compound beacon."))
428+
Failure(E("Beacon " + name + " is shared to " + share + " but " + share + " is a compound beacon."))
429429
else
430-
Failure(E("Beacon " + name + " is twinned to " + twin + " which is not defined."))
430+
Failure(E("Beacon " + name + " is shared to " + share + " which is not defined."))
431431
}
432432

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

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

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

1073-
ensures ret.Success? && 0 < |names| && data[names[0]].Standard? && data[names[0]].std.twin.Some? ==>
1074-
&& var twin := data[names[0]].std.twin.value;
1075-
&& IsValidTwin(data, names[0], data[names[0]].std.length, twin).Success?
1076-
//= specification/searchable-encryption/beacons.md#twinned-initialization
1073+
ensures ret.Success? && 0 < |names| && data[names[0]].Standard? && data[names[0]].std.share.Some? ==>
1074+
&& var share := data[names[0]].std.share.value;
1075+
&& IsValidShare(data, names[0], data[names[0]].std.length, share).Success?
1076+
//= specification/searchable-encryption/beacons.md#shared-initialization
10771077
//= type=implication
10781078
//# This name MUST be the name of a previously defined Standard Beacon.
1079-
&& twin in data
1080-
&& data[twin].Standard?
1081-
//= specification/searchable-encryption/beacons.md#twinned-initialization
1079+
&& share in data
1080+
&& data[share].Standard?
1081+
//= specification/searchable-encryption/beacons.md#shared-initialization
10821082
//= type=implication
10831083
//# This beacon's [length](#beacon-length) MUST be equal to the `other` beacon's [length](#beacon-length).
1084-
&& data[twin].std.length == data[names[0]].std.length
1084+
&& data[share].std.length == data[names[0]].std.length
10851085
{
10861086
if |names| == 0 then
10871087
Success(true)
10881088
else
10891089
var b := data[names[0]];
10901090
if I.IsPartOnly(b) && !ExistsInCompound(allNames, names[0], data) then
10911091
Failure(E("PartOnly beacon " + names[0] + " MUST be used in a compound beacon."))
1092-
else if b.Standard? && b.std.twin.Some? then
1093-
IsValidTwin(data, names[0], b.std.length, b.std.twin.value)
1092+
else if b.Standard? && b.std.share.Some? then
1093+
var _ :- IsValidShare(data, names[0], b.std.length, b.std.share.value);
1094+
CheckAllBeacons(names[1..], allNames, data)
10941095
else
10951096
CheckAllBeacons(names[1..], allNames, data)
10961097
}

0 commit comments

Comments
 (0)