@@ -344,31 +344,25 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
344344 )
345345 }
346346
347- // TODO this is a workaround for a very silly issue with case sensitivity between package names,
348- // that prevents this code from always correctly finding `dafny.Function4`.
349- // For now, put all inputs into one datatype so we are only using `dafny.Function1` here.
350- datatype CanonizeForDecryptInput = CanonizeForDecryptInput (
347+ // construct the DecryptCanon
348+ function method {:opaque} {:vcs_split_on_every_assert} CanonizeForDecrypt (
351349 tableName: GoodString ,
352350 data: StructuredDataPlain ,
353351 authSchema: AuthSchemaPlain ,
354352 legend: Header .Legend
355- )
356-
357- // construct the DecryptCanon
358- function method {:opaque} {:vcs_split_on_every_assert} CanonizeForDecrypt (input: CanonizeForDecryptInput )
359- : (ret : Result< DecryptCanon, Error> )
360- requires input. authSchema. Keys == input. data. Keys
353+ ) : (ret : Result< DecryptCanon, Error> )
354+ requires authSchema. Keys == data. Keys
361355 ensures ret. Success? ==>
362- && |ret. value. signedFields_c| == |input . legend|
356+ && |ret. value. signedFields_c| == |legend|
363357 ensures ret. Success? ==>
364- && (forall k :: k in input . data. Keys && input . authSchema[k]. content. Action. SIGN? ==> Paths. SimpleCanon (input. tableName, k) in ret. value. data_c. Keys)
358+ && (forall k :: k in data. Keys && authSchema[k]. content. Action. SIGN? ==> Paths. SimpleCanon (tableName, k) in ret. value. data_c. Keys)
365359 ensures ret. Success? ==>
366- && (forall v :: v in ret. value. data_c. Values ==> v in input . data. Values)
360+ && (forall v :: v in ret. value. data_c. Values ==> v in data. Values)
367361 ensures ret. Success? ==>
368362 && ret. value. cryptoSchema. content. SchemaMap?
369363 && CryptoSchemaMapIsFlat (ret.value.cryptoSchema.content.SchemaMap)
370- && AuthSchemaIsFlat (input. authSchema)
371- && ValidParsedCryptoSchema (ret.value.cryptoSchema.content.SchemaMap, input. authSchema, input. tableName)
364+ && AuthSchemaIsFlat (authSchema)
365+ && ValidParsedCryptoSchema (ret.value.cryptoSchema.content.SchemaMap, authSchema, tableName)
372366 {
373367 // = specification/structured-encryption/decrypt-structure.md#calculate-signed-and-encrypted-field-lists
374368 // # The `signed field list` MUST be all fields for which
@@ -378,18 +372,18 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
378372 // # sorted by the [Canonical Path](header.md.#canonical-path).
379373
380374 reveal Maps. Injective ();
381- Paths. SimpleCanonUnique (input. tableName);
382- var fieldMap := map k < - input . data | input . authSchema[k]. content. Action == SIGN ::
383- Paths. SimpleCanon (input. tableName, k) := k;
375+ Paths. SimpleCanonUnique (tableName);
376+ var fieldMap := map k < - data | authSchema[k]. content. Action == SIGN ::
377+ Paths. SimpleCanon (tableName, k) := k;
384378 assert Maps. Injective (fieldMap);
385379
386- var data_c := map k < - fieldMap :: k := input . data[fieldMap[k]];
380+ var data_c := map k < - fieldMap :: k := data[fieldMap[k]];
387381 var signedFields_c := SortedSets. ComputeSetToOrderedSequence2 (data_c.Keys, ByteLess);
388382
389- if |input . legend| < |signedFields_c| then
383+ if |legend| < |signedFields_c| then
390384 Failure (E("Schema changed : something that was unsigned is now signed."))
391385 else
392- if |input . legend| > |signedFields_c| then
386+ if |legend| > |signedFields_c| then
393387 Failure (E("Schema changed : something that was signed is now unsigned."))
394388 else
395389
@@ -398,11 +392,11 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
398392 // # for which the corresponding byte in the [Encrypt Legend](header.md.#encrypt-legend)
399393 // # is `0x65` indicating [Encrypt and Sign](header.md.#encrypt-legend-bytes),
400394 // # sorted by the field's [canonical path](./header.md#canonical-path).
401- var encFields_c : seq < CanonicalPath> := FilterEncrypted (signedFields_c, input. legend);
395+ var encFields_c : seq < CanonicalPath> := FilterEncrypted (signedFields_c, legend);
402396 :- Need (|encFields_c| < (UINT32_LIMIT / 3), E ("Too many encrypted fields."));
403397
404398 var actionMap := map k < - fieldMap ::
405- fieldMap[k] := if Paths. SimpleCanon (input. tableName, fieldMap[k]) in encFields_c then
399+ fieldMap[k] := if Paths. SimpleCanon (tableName, fieldMap[k]) in encFields_c then
406400 CryptoSchema (
407401 content := CryptoSchemaContent.Action(ENCRYPT_AND_SIGN),
408402 attributes := None
@@ -815,8 +809,7 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
815809 var ok :- head. verifyCommitment (config.primitives, postCMMAlg, commitKey, headerSerialized);
816810
817811 :- Need (ValidString(input.tableName), E ("Bad Table Name"));
818- var canonData :- CanonizeForDecrypt (
819- CanonizeForDecryptInput(input.tableName, encRecord, authSchema, head.legend));
812+ var canonData :- CanonizeForDecrypt (input.tableName, encRecord, authSchema, head.legend);
820813
821814 // = specification/structured-encryption/decrypt-structure.md#calculate-signed-and-encrypted-field-lists
822815 // = type=implication
@@ -899,7 +892,7 @@ module AwsCryptographyDbEncryptionSdkStructuredEncryptionOperations refines Abst
899892 output := Success (decryptOutput);
900893 }
901894
902- // TODO This is here temporarially until it gets merged into the standard library
895+ // predicates/lemmas like this are not yet provided out of the box in the standard library.
903896 predicate {:opaque} Contains< X, Y> (big: map < X, Y> , small: map < X, Y> )
904897 {
905898 && small. Keys <= big. Keys
0 commit comments