@@ -55,79 +55,6 @@ module {:extern "software.amazon.cryptography.dbencryptionsdk.dynamodb.internald
5555 predicate method IsValid_BeaconVersionList (x: seq <BeaconVersion >) {
5656 ( 1 <= |x| <= 1 )
5757 }
58- type PartitionCount = x: int32 | IsValid_PartitionCount (x) witness *
59- predicate method IsValid_PartitionCount (x: int32 ) {
60- ( 1 <= x <= 255 )
61- }
62- type PartitionNumber = x: int32 | IsValid_PartitionNumber (x) witness *
63- predicate method IsValid_PartitionNumber (x: int32 ) {
64- ( 0 <= x <= 254 )
65- }
66- class IPartitionSelectorCallHistory {
67- ghost constructor () {
68- GetPartitionNumber := [];
69- }
70- ghost var GetPartitionNumber: seq < DafnyCallEvent< GetPartitionNumberInput, Result< GetPartitionNumberOutput, Error>>>
71- }
72- trait {:termination false } IPartitionSelector
73- {
74- // Helper to define any additional modifies/reads clauses.
75- // If your operations need to mutate state,
76- // add it in your constructor function:
77- // Modifies := {your, fields, here, History};
78- // If you do not need to mutate anything:
79- // Modifies := {History};
80-
81- ghost const Modifies: set < object >
82- // For an unassigned field defined in a trait,
83- // Dafny can only assign a value in the constructor.
84- // This means that for Dafny to reason about this value,
85- // it needs some way to know (an invariant),
86- // about the state of the object.
87- // This builds on the Valid/Repr paradigm
88- // To make this kind requires safe to add
89- // to methods called from unverified code,
90- // the predicate MUST NOT take any arguments.
91- // This means that the correctness of this requires
92- // MUST only be evaluated by the class itself.
93- // If you require any additional mutation,
94- // then you MUST ensure everything you need in ValidState.
95- // You MUST also ensure ValidState in your constructor.
96- predicate ValidState ()
97- ensures ValidState () ==> History in Modifies
98- ghost const History: IPartitionSelectorCallHistory
99- predicate GetPartitionNumberEnsuresPublicly (input: GetPartitionNumberInput , output: Result <GetPartitionNumberOutput , Error>)
100- // The public method to be called by library consumers
101- method GetPartitionNumber ( input: GetPartitionNumberInput )
102- returns (output: Result< GetPartitionNumberOutput, Error> )
103- requires
104- && ValidState ()
105- modifies Modifies - {History} ,
106- History`GetPartitionNumber
107- // Dafny will skip type parameters when generating a default decreases clause.
108- decreases Modifies - {History}
109- ensures
110- && ValidState ()
111- ensures GetPartitionNumberEnsuresPublicly (input, output)
112- ensures History. GetPartitionNumber == old (History. GetPartitionNumber) + [DafnyCallEvent (input, output)]
113- {
114- output := GetPartitionNumber' (input);
115- History. GetPartitionNumber := History. GetPartitionNumber + [DafnyCallEvent (input, output)];
116- }
117- // The method to implement in the concrete class.
118- method GetPartitionNumber' ( input: GetPartitionNumberInput )
119- returns (output: Result< GetPartitionNumberOutput, Error> )
120- requires
121- && ValidState ()
122- modifies Modifies - {History}
123- // Dafny will skip type parameters when generating a default decreases clause.
124- decreases Modifies - {History}
125- ensures
126- && ValidState ()
127- ensures GetPartitionNumberEnsuresPublicly (input, output)
128- ensures unchanged (History)
129-
130- }
13158 type Char = x: string | IsValid_Char (x) witness *
13259 predicate method IsValid_Char (x: string ) {
13360 ( 1 <= |x| <= 1 )
@@ -348,14 +275,6 @@ module {:extern "software.amazon.cryptography.dbencryptionsdk.dynamodb.internald
348275 datatype GetBranchKeyIdFromDdbKeyOutput = | GetBranchKeyIdFromDdbKeyOutput (
349276 nameonly branchKeyId: string
350277 )
351- datatype GetPartitionNumberInput = | GetPartitionNumberInput (
352- nameonly item: ComAmazonawsDynamodbTypes .AttributeMap ,
353- nameonly numberOfPartitions: PartitionCount ,
354- nameonly logicalTableName: string
355- )
356- datatype GetPartitionNumberOutput = | GetPartitionNumberOutput (
357- nameonly partitionNumber: PartitionNumber
358- )
359278 datatype GetEncryptedDataKeyDescriptionInput = | GetEncryptedDataKeyDescriptionInput (
360279 nameonly input: GetEncryptedDataKeyDescriptionUnion
361280 )
@@ -365,6 +284,14 @@ module {:extern "software.amazon.cryptography.dbencryptionsdk.dynamodb.internald
365284 datatype GetEncryptedDataKeyDescriptionUnion =
366285 | header (header: seq <uint8 >)
367286 | item (item: ComAmazonawsDynamodbTypes .AttributeMap)
287+ datatype GetPartitionNumberInput = | GetPartitionNumberInput (
288+ nameonly item: ComAmazonawsDynamodbTypes .AttributeMap ,
289+ nameonly numberOfPartitions: PartitionCount ,
290+ nameonly logicalTableName: string
291+ )
292+ datatype GetPartitionNumberOutput = | GetPartitionNumberOutput (
293+ nameonly partitionNumber: PartitionNumber
294+ )
368295 datatype GetPrefix = | GetPrefix (
369296 nameonly length: int32
370297 )
@@ -441,6 +368,79 @@ module {:extern "software.amazon.cryptography.dbencryptionsdk.dynamodb.internald
441368 nameonly cache: Option <AwsCryptographyMaterialProvidersTypes .CacheType> := Option.None ,
442369 nameonly partitionId: Option <string > := Option.None
443370 )
371+ type PartitionCount = x: int32 | IsValid_PartitionCount (x) witness *
372+ predicate method IsValid_PartitionCount (x: int32 ) {
373+ ( 1 <= x <= 255 )
374+ }
375+ type PartitionNumber = x: int32 | IsValid_PartitionNumber (x) witness *
376+ predicate method IsValid_PartitionNumber (x: int32 ) {
377+ ( 0 <= x <= 254 )
378+ }
379+ class IPartitionSelectorCallHistory {
380+ ghost constructor () {
381+ GetPartitionNumber := [];
382+ }
383+ ghost var GetPartitionNumber: seq < DafnyCallEvent< GetPartitionNumberInput, Result< GetPartitionNumberOutput, Error>>>
384+ }
385+ trait {:termination false } IPartitionSelector
386+ {
387+ // Helper to define any additional modifies/reads clauses.
388+ // If your operations need to mutate state,
389+ // add it in your constructor function:
390+ // Modifies := {your, fields, here, History};
391+ // If you do not need to mutate anything:
392+ // Modifies := {History};
393+
394+ ghost const Modifies: set < object >
395+ // For an unassigned field defined in a trait,
396+ // Dafny can only assign a value in the constructor.
397+ // This means that for Dafny to reason about this value,
398+ // it needs some way to know (an invariant),
399+ // about the state of the object.
400+ // This builds on the Valid/Repr paradigm
401+ // To make this kind requires safe to add
402+ // to methods called from unverified code,
403+ // the predicate MUST NOT take any arguments.
404+ // This means that the correctness of this requires
405+ // MUST only be evaluated by the class itself.
406+ // If you require any additional mutation,
407+ // then you MUST ensure everything you need in ValidState.
408+ // You MUST also ensure ValidState in your constructor.
409+ predicate ValidState ()
410+ ensures ValidState () ==> History in Modifies
411+ ghost const History: IPartitionSelectorCallHistory
412+ predicate GetPartitionNumberEnsuresPublicly (input: GetPartitionNumberInput , output: Result <GetPartitionNumberOutput , Error>)
413+ // The public method to be called by library consumers
414+ method GetPartitionNumber ( input: GetPartitionNumberInput )
415+ returns (output: Result< GetPartitionNumberOutput, Error> )
416+ requires
417+ && ValidState ()
418+ modifies Modifies - {History} ,
419+ History`GetPartitionNumber
420+ // Dafny will skip type parameters when generating a default decreases clause.
421+ decreases Modifies - {History}
422+ ensures
423+ && ValidState ()
424+ ensures GetPartitionNumberEnsuresPublicly (input, output)
425+ ensures History. GetPartitionNumber == old (History. GetPartitionNumber) + [DafnyCallEvent (input, output)]
426+ {
427+ output := GetPartitionNumber' (input);
428+ History. GetPartitionNumber := History. GetPartitionNumber + [DafnyCallEvent (input, output)];
429+ }
430+ // The method to implement in the concrete class.
431+ method GetPartitionNumber' ( input: GetPartitionNumberInput )
432+ returns (output: Result< GetPartitionNumberOutput, Error> )
433+ requires
434+ && ValidState ()
435+ modifies Modifies - {History}
436+ // Dafny will skip type parameters when generating a default decreases clause.
437+ decreases Modifies - {History}
438+ ensures
439+ && ValidState ()
440+ ensures GetPartitionNumberEnsuresPublicly (input, output)
441+ ensures unchanged (History)
442+
443+ }
444444 datatype PartOnly = | PartOnly (
445445
446446 )
0 commit comments