github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl@v0.2.0/Materials/Materials.go (about)

     1  // Package Materials
     2  // Dafny module Materials compiled into Go
     3  
     4  package Materials
     5  
     6  import (
     7  	os "os"
     8  
     9  	m_ComAmazonawsDynamodbTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb/ComAmazonawsDynamodbTypes"
    10  	m_Com_Amazonaws_Dynamodb "github.com/aws/aws-cryptographic-material-providers-library/releases/go/dynamodb/Com_Amazonaws_Dynamodb"
    11  	m_ComAmazonawsKmsTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms/ComAmazonawsKmsTypes"
    12  	m_Com_Amazonaws_Kms "github.com/aws/aws-cryptographic-material-providers-library/releases/go/kms/Com_Amazonaws_Kms"
    13  	m_AlgorithmSuites "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AlgorithmSuites"
    14  	m_AwsArnParsing "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsArnParsing"
    15  	m_AwsCryptographyKeyStoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyKeyStoreOperations"
    16  	m_AwsCryptographyKeyStoreTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyKeyStoreTypes"
    17  	m_AwsCryptographyMaterialProvidersTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsCryptographyMaterialProvidersTypes"
    18  	m_AwsKmsMrkMatchForDecrypt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkMatchForDecrypt"
    19  	m_AwsKmsUtils "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsUtils"
    20  	m_CreateKeyStoreTable "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeyStoreTable"
    21  	m_CreateKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeys"
    22  	m_DDBKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DDBKeystoreOperations"
    23  	m_GetKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/GetKeys"
    24  	m_KMSKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KMSKeystoreOperations"
    25  	m_KeyStore "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStore"
    26  	m_KeyStoreErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStoreErrorMessages"
    27  	m_KmsArn "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KmsArn"
    28  	m_Structure "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Structure"
    29  	m_AtomicPrimitives "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AtomicPrimitives"
    30  	m_AwsCryptographyPrimitivesOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesOperations"
    31  	m_AwsCryptographyPrimitivesTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesTypes"
    32  	m_Digest "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Digest"
    33  	m_HKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/HKDF"
    34  	m_KdfCtr "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/KdfCtr"
    35  	m_Random "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Random"
    36  	m_WrappedHKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHKDF"
    37  	m_WrappedHMAC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHMAC"
    38  	m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions"
    39  	m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64"
    40  	m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas"
    41  	m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts"
    42  	m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals"
    43  	m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear"
    44  	m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod"
    45  	m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO"
    46  	m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare"
    47  	m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions"
    48  	m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals"
    49  	m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt"
    50  	m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings"
    51  	m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm"
    52  	m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_"
    53  	m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals"
    54  	m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear"
    55  	m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul"
    56  	m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals"
    57  	m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear"
    58  	m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power"
    59  	m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations"
    60  	m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq"
    61  	m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort"
    62  	m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting"
    63  	m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary"
    64  	m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop"
    65  	m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence"
    66  	m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String"
    67  	m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt"
    68  	m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams"
    69  	m_UTF8 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UTF8"
    70  	m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings"
    71  	m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_"
    72  	m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm"
    73  	m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm"
    74  	m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers"
    75  	m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_"
    76  	_dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny"
    77  )
    78  
    79  var _ = os.Args
    80  var _ _dafny.Dummy__
    81  var _ m__System.Dummy__
    82  var _ m_Wrappers.Dummy__
    83  var _ m_BoundedInts.Dummy__
    84  var _ m_StandardLibrary_UInt.Dummy__
    85  var _ m_StandardLibrary_Sequence.Dummy__
    86  var _ m_StandardLibrary_String.Dummy__
    87  var _ m_StandardLibrary.Dummy__
    88  var _ m_AwsCryptographyPrimitivesTypes.Dummy__
    89  var _ m_Random.Dummy__
    90  var _ m_Digest.Dummy__
    91  var _ m_WrappedHMAC.Dummy__
    92  var _ m_HKDF.Dummy__
    93  var _ m_WrappedHKDF.Dummy__
    94  var _ m_KdfCtr.Dummy__
    95  var _ m_AwsCryptographyPrimitivesOperations.Dummy__
    96  var _ m_AtomicPrimitives.Dummy__
    97  var _ m_ComAmazonawsDynamodbTypes.Dummy__
    98  var _ m_ComAmazonawsKmsTypes.Dummy__
    99  var _ m_Relations.Dummy__
   100  var _ m_Seq_MergeSort.Dummy__
   101  var _ m__Math.Dummy__
   102  var _ m_Seq.Dummy__
   103  var _ m__Unicode.Dummy__
   104  var _ m_Functions.Dummy__
   105  var _ m_Utf8EncodingForm.Dummy__
   106  var _ m_Utf16EncodingForm.Dummy__
   107  var _ m_UnicodeStrings.Dummy__
   108  var _ m_FileIO.Dummy__
   109  var _ m_GeneralInternals.Dummy__
   110  var _ m_MulInternalsNonlinear.Dummy__
   111  var _ m_MulInternals.Dummy__
   112  var _ m_Mul.Dummy__
   113  var _ m_ModInternalsNonlinear.Dummy__
   114  var _ m_DivInternalsNonlinear.Dummy__
   115  var _ m_ModInternals.Dummy__
   116  var _ m_DivInternals.Dummy__
   117  var _ m_DivMod.Dummy__
   118  var _ m_Power.Dummy__
   119  var _ m_Logarithm.Dummy__
   120  var _ m_StandardLibraryInterop.Dummy__
   121  var _ m_Streams.Dummy__
   122  var _ m_Sorting.Dummy__
   123  var _ m_HexStrings.Dummy__
   124  var _ m_GetOpt.Dummy__
   125  var _ m_FloatCompare.Dummy__
   126  var _ m_Base64.Dummy__
   127  var _ m_Base64Lemmas.Dummy__
   128  var _ m_Actions.Dummy__
   129  var _ m_AwsCryptographyKeyStoreTypes.Dummy__
   130  var _ m_AwsCryptographyMaterialProvidersTypes.Dummy__
   131  var _ m_AwsArnParsing.Dummy__
   132  var _ m_AwsKmsMrkMatchForDecrypt.Dummy__
   133  var _ m_AwsKmsUtils.Dummy__
   134  var _ m_KeyStoreErrorMessages.Dummy__
   135  var _ m_KmsArn.Dummy__
   136  var _ m_Structure.Dummy__
   137  var _ m_KMSKeystoreOperations.Dummy__
   138  var _ m_DDBKeystoreOperations.Dummy__
   139  var _ m_CreateKeys.Dummy__
   140  var _ m_CreateKeyStoreTable.Dummy__
   141  var _ m_GetKeys.Dummy__
   142  var _ m_AwsCryptographyKeyStoreOperations.Dummy__
   143  var _ m_Com_Amazonaws_Kms.Dummy__
   144  var _ m_Com_Amazonaws_Dynamodb.Dummy__
   145  var _ m_KeyStore.Dummy__
   146  var _ m_AlgorithmSuites.Dummy__
   147  
   148  type Dummy__ struct{}
   149  
   150  // Definition of class Default__
   151  type Default__ struct {
   152  	dummy byte
   153  }
   154  
   155  func New_Default___() *Default__ {
   156  	_this := Default__{}
   157  
   158  	return &_this
   159  }
   160  
   161  type CompanionStruct_Default___ struct {
   162  }
   163  
   164  var Companion_Default___ = CompanionStruct_Default___{}
   165  
   166  func (_this *Default__) Equals(other *Default__) bool {
   167  	return _this == other
   168  }
   169  
   170  func (_this *Default__) EqualsGeneric(x interface{}) bool {
   171  	other, ok := x.(*Default__)
   172  	return ok && _this.Equals(other)
   173  }
   174  
   175  func (*Default__) String() string {
   176  	return "Materials.Default__"
   177  }
   178  func (_this *Default__) ParentTraits_() []*_dafny.TraitID {
   179  	return [](*_dafny.TraitID){}
   180  }
   181  
   182  var _ _dafny.TraitOffspring = &Default__{}
   183  
   184  func (_static *CompanionStruct_Default___) InitializeEncryptionMaterials(input m_AwsCryptographyMaterialProvidersTypes.InitializeEncryptionMaterialsInput) m_Wrappers.Result {
   185  	var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(!((input).Dtor_encryptionContext()).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Encryption Context ")))
   186  	_ = _0_valueOrError0
   187  	if (_0_valueOrError0).IsFailure() {
   188  		return (_0_valueOrError0).PropagateFailure()
   189  	} else {
   190  		var _1_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(_dafny.Quantifier(((input).Dtor_requiredEncryptionContextKeys()).UniqueElements(), true, func(_forall_var_0 _dafny.Sequence) bool {
   191  			var _2_key _dafny.Sequence
   192  			_2_key = interface{}(_forall_var_0).(_dafny.Sequence)
   193  			if m_UTF8.Companion_ValidUTF8Bytes_.Is_(_2_key) {
   194  				return !(_dafny.Companion_Sequence_.Contains((input).Dtor_requiredEncryptionContextKeys(), _2_key)) || (((input).Dtor_encryptionContext()).Contains(_2_key))
   195  			} else {
   196  				return true
   197  			}
   198  		}), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Required encryption context keys do not exist in provided encryption context.")))
   199  		_ = _1_valueOrError1
   200  		if (_1_valueOrError1).IsFailure() {
   201  			return (_1_valueOrError1).PropagateFailure()
   202  		} else {
   203  			var _3_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo = m_AlgorithmSuites.Companion_Default___.GetSuite((input).Dtor_algorithmSuiteId())
   204  			_ = _3_suite
   205  			var _4_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need((((_3_suite).Dtor_signature()).Is_ECDSA()) == ((((input).Dtor_signingKey()).Is_Some()) && (((input).Dtor_verificationKey()).Is_Some())), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Missing signature key for signed suite.")))
   206  			_ = _4_valueOrError2
   207  			if (_4_valueOrError2).IsFailure() {
   208  				return (_4_valueOrError2).PropagateFailure()
   209  			} else {
   210  				var _5_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need((((_3_suite).Dtor_signature()).Is_None()) == ((((input).Dtor_signingKey()).Is_None()) && (((input).Dtor_verificationKey()).Is_None())), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Signature key not allowed for non-signed suites.")))
   211  				_ = _5_valueOrError3
   212  				if (_5_valueOrError3).IsFailure() {
   213  					return (_5_valueOrError3).PropagateFailure()
   214  				} else {
   215  					var _6_valueOrError4 m_Wrappers.Result = func() m_Wrappers.Result {
   216  						var _source0 m_AwsCryptographyMaterialProvidersTypes.SignatureAlgorithm = (_3_suite).Dtor_signature()
   217  						_ = _source0
   218  						{
   219  							if _source0.Is_ECDSA() {
   220  								var _7_curve m_AwsCryptographyMaterialProvidersTypes.ECDSA = _source0.Get_().(m_AwsCryptographyMaterialProvidersTypes.SignatureAlgorithm_ECDSA).ECDSA
   221  								_ = _7_curve
   222  								var _8_valueOrError5 m_Wrappers.Result = (m_UTF8.Encode(m_Base64.Companion_Default___.Encode(((input).Dtor_verificationKey()).Dtor_value().(_dafny.Sequence)))).MapFailure(func(coer29 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} {
   223  									return func(arg29 interface{}) interface{} {
   224  										return coer29(arg29.(_dafny.Sequence))
   225  									}
   226  								}(func(_9_e _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error {
   227  									return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_9_e)
   228  								}))
   229  								_ = _8_valueOrError5
   230  								if (_8_valueOrError5).IsFailure() {
   231  									return (_8_valueOrError5).PropagateFailure()
   232  								} else {
   233  									var _10_enc__vk _dafny.Sequence = (_8_valueOrError5).Extract().(_dafny.Sequence)
   234  									_ = _10_enc__vk
   235  									return m_Wrappers.Companion_Result_.Create_Success_(((input).Dtor_encryptionContext()).Update(Companion_Default___.EC__PUBLIC__KEY__FIELD(), _10_enc__vk))
   236  								}
   237  							}
   238  						}
   239  						{
   240  							var _11_None m_AwsCryptographyMaterialProvidersTypes.SignatureAlgorithm = _source0
   241  							_ = _11_None
   242  							return m_Wrappers.Companion_Result_.Create_Success_((input).Dtor_encryptionContext())
   243  						}
   244  					}()
   245  					_ = _6_valueOrError4
   246  					if (_6_valueOrError4).IsFailure() {
   247  						return (_6_valueOrError4).PropagateFailure()
   248  					} else {
   249  						var _12_encryptionContext _dafny.Map = (_6_valueOrError4).Extract().(_dafny.Map)
   250  						_ = _12_encryptionContext
   251  						return m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_EncryptionMaterials_.Create_EncryptionMaterials_(_3_suite, _12_encryptionContext, _dafny.SeqOf(), (input).Dtor_requiredEncryptionContextKeys(), m_Wrappers.Companion_Option_.Create_None_(), (input).Dtor_signingKey(), (func() m_Wrappers.Option {
   252  							if ((_3_suite).Dtor_symmetricSignature()).Is_None() {
   253  								return m_Wrappers.Companion_Option_.Create_None_()
   254  							}
   255  							return m_Wrappers.Companion_Option_.Create_Some_(_dafny.SeqOf())
   256  						})()))
   257  					}
   258  				}
   259  			}
   260  		}
   261  	}
   262  }
   263  func (_static *CompanionStruct_Default___) InitializeDecryptionMaterials(input m_AwsCryptographyMaterialProvidersTypes.InitializeDecryptionMaterialsInput) m_Wrappers.Result {
   264  	var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(_dafny.Quantifier(((input).Dtor_requiredEncryptionContextKeys()).UniqueElements(), true, func(_forall_var_0 _dafny.Sequence) bool {
   265  		var _1_key _dafny.Sequence
   266  		_1_key = interface{}(_forall_var_0).(_dafny.Sequence)
   267  		if m_UTF8.Companion_ValidUTF8Bytes_.Is_(_1_key) {
   268  			return !(_dafny.Companion_Sequence_.Contains((input).Dtor_requiredEncryptionContextKeys(), _1_key)) || (((input).Dtor_encryptionContext()).Contains(_1_key))
   269  		} else {
   270  			return true
   271  		}
   272  	}), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Reporoduced encryption context key did not exist in provided encryption context.")))
   273  	_ = _0_valueOrError0
   274  	if (_0_valueOrError0).IsFailure() {
   275  		return (_0_valueOrError0).PropagateFailure()
   276  	} else {
   277  		var _2_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo = m_AlgorithmSuites.Companion_Default___.GetSuite((input).Dtor_algorithmSuiteId())
   278  		_ = _2_suite
   279  		var _3_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need((((_2_suite).Dtor_signature()).Is_ECDSA()) == (((input).Dtor_encryptionContext()).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD())), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Encryption Context missing verification key.")))
   280  		_ = _3_valueOrError1
   281  		if (_3_valueOrError1).IsFailure() {
   282  			return (_3_valueOrError1).PropagateFailure()
   283  		} else {
   284  			var _4_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need((((_2_suite).Dtor_signature()).Is_None()) == (!((input).Dtor_encryptionContext()).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD())), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Verification key can not exist in non-signed Algorithm Suites.")))
   285  			_ = _4_valueOrError2
   286  			if (_4_valueOrError2).IsFailure() {
   287  				return (_4_valueOrError2).PropagateFailure()
   288  			} else {
   289  				var _5_valueOrError3 m_Wrappers.Result = Companion_Default___.DecodeVerificationKey((input).Dtor_encryptionContext())
   290  				_ = _5_valueOrError3
   291  				if (_5_valueOrError3).IsFailure() {
   292  					return (_5_valueOrError3).PropagateFailure()
   293  				} else {
   294  					var _6_verificationKey m_Wrappers.Option = (_5_valueOrError3).Extract().(m_Wrappers.Option)
   295  					_ = _6_verificationKey
   296  					return m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_DecryptionMaterials_.Create_DecryptionMaterials_(_2_suite, (input).Dtor_encryptionContext(), (input).Dtor_requiredEncryptionContextKeys(), m_Wrappers.Companion_Option_.Create_None_(), _6_verificationKey, m_Wrappers.Companion_Option_.Create_None_()))
   297  				}
   298  			}
   299  		}
   300  	}
   301  }
   302  func (_static *CompanionStruct_Default___) DecodeVerificationKey(encryptionContext _dafny.Map) m_Wrappers.Result {
   303  	if (encryptionContext).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD()) {
   304  		var _0_utf8Key _dafny.Sequence = (encryptionContext).Get(Companion_Default___.EC__PUBLIC__KEY__FIELD()).(_dafny.Sequence)
   305  		_ = _0_utf8Key
   306  		var _1_valueOrError0 m_Wrappers.Result = (m_UTF8.Decode(_0_utf8Key)).MapFailure(func(coer30 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} {
   307  			return func(arg30 interface{}) interface{} {
   308  				return coer30(arg30.(_dafny.Sequence))
   309  			}
   310  		}(func(_2_e _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error {
   311  			return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_2_e)
   312  		}))
   313  		_ = _1_valueOrError0
   314  		if (_1_valueOrError0).IsFailure() {
   315  			return (_1_valueOrError0).PropagateFailure()
   316  		} else {
   317  			var _3_base64Key _dafny.Sequence = (_1_valueOrError0).Extract().(_dafny.Sequence)
   318  			_ = _3_base64Key
   319  			var _4_valueOrError1 m_Wrappers.Result = (m_Base64.Companion_Default___.Decode(_3_base64Key)).MapFailure(func(coer31 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} {
   320  				return func(arg31 interface{}) interface{} {
   321  					return coer31(arg31.(_dafny.Sequence))
   322  				}
   323  			}(func(_5_e _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error {
   324  				return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_5_e)
   325  			}))
   326  			_ = _4_valueOrError1
   327  			if (_4_valueOrError1).IsFailure() {
   328  				return (_4_valueOrError1).PropagateFailure()
   329  			} else {
   330  				var _6_key _dafny.Sequence = (_4_valueOrError1).Extract().(_dafny.Sequence)
   331  				_ = _6_key
   332  				return m_Wrappers.Companion_Result_.Create_Success_(m_Wrappers.Companion_Option_.Create_Some_(_6_key))
   333  			}
   334  		}
   335  	} else {
   336  		return m_Wrappers.Companion_Result_.Create_Success_(m_Wrappers.Companion_Option_.Create_None_())
   337  	}
   338  }
   339  func (_static *CompanionStruct_Default___) ValidEncryptionMaterialsTransition(oldMat m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials, newMat m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials) bool {
   340  	return ((((((((((((newMat).Dtor_algorithmSuite()).Equals((oldMat).Dtor_algorithmSuite())) && (((newMat).Dtor_encryptionContext()).Equals((oldMat).Dtor_encryptionContext()))) && (_dafny.Companion_Sequence_.Equal((newMat).Dtor_requiredEncryptionContextKeys(), (oldMat).Dtor_requiredEncryptionContextKeys()))) && (((newMat).Dtor_signingKey()).Equals((oldMat).Dtor_signingKey()))) && (((((oldMat).Dtor_plaintextDataKey()).Is_None()) && (((newMat).Dtor_plaintextDataKey()).Is_Some())) || (((oldMat).Dtor_plaintextDataKey()).Equals((newMat).Dtor_plaintextDataKey())))) && (((newMat).Dtor_plaintextDataKey()).Is_Some())) && ((_dafny.IntOfUint32(((oldMat).Dtor_encryptedDataKeys()).Cardinality())).Cmp(_dafny.IntOfUint32(((newMat).Dtor_encryptedDataKeys()).Cardinality())) <= 0)) && ((_dafny.MultiSetFromSeq((oldMat).Dtor_encryptedDataKeys())).IsSubsetOf(_dafny.MultiSetFromSeq((newMat).Dtor_encryptedDataKeys())))) && (!(!((((oldMat).Dtor_algorithmSuite()).Dtor_symmetricSignature()).Is_None())) || (((((newMat).Dtor_symmetricSigningKeys()).Is_Some()) && (((oldMat).Dtor_symmetricSigningKeys()).Is_Some())) && ((_dafny.MultiSetFromSeq(((oldMat).Dtor_symmetricSigningKeys()).Dtor_value().(_dafny.Sequence))).IsSubsetOf(_dafny.MultiSetFromSeq(((newMat).Dtor_symmetricSigningKeys()).Dtor_value().(_dafny.Sequence))))))) && (Companion_Default___.ValidEncryptionMaterials(oldMat))) && (Companion_Default___.ValidEncryptionMaterials(newMat))
   341  }
   342  func (_static *CompanionStruct_Default___) ValidEncryptionMaterials(encryptionMaterials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials) bool {
   343  	var _pat_let_tv0 = encryptionMaterials
   344  	_ = _pat_let_tv0
   345  	var _pat_let_tv1 = encryptionMaterials
   346  	_ = _pat_let_tv1
   347  	var _pat_let_tv2 = encryptionMaterials
   348  	_ = _pat_let_tv2
   349  	var _pat_let_tv3 = encryptionMaterials
   350  	_ = _pat_let_tv3
   351  	var _pat_let_tv4 = encryptionMaterials
   352  	_ = _pat_let_tv4
   353  	var _pat_let_tv5 = encryptionMaterials
   354  	_ = _pat_let_tv5
   355  	var _pat_let_tv6 = encryptionMaterials
   356  	_ = _pat_let_tv6
   357  	var _pat_let_tv7 = encryptionMaterials
   358  	_ = _pat_let_tv7
   359  	var _pat_let_tv8 = encryptionMaterials
   360  	_ = _pat_let_tv8
   361  	var _pat_let_tv9 = encryptionMaterials
   362  	_ = _pat_let_tv9
   363  	var _pat_let_tv10 = encryptionMaterials
   364  	_ = _pat_let_tv10
   365  	var _pat_let_tv11 = encryptionMaterials
   366  	_ = _pat_let_tv11
   367  	var _pat_let_tv12 = encryptionMaterials
   368  	_ = _pat_let_tv12
   369  	var _pat_let_tv13 = encryptionMaterials
   370  	_ = _pat_let_tv13
   371  	var _pat_let_tv14 = encryptionMaterials
   372  	_ = _pat_let_tv14
   373  	var _pat_let_tv15 = encryptionMaterials
   374  	_ = _pat_let_tv15
   375  	return (m_AlgorithmSuites.Companion_Default___.AlgorithmSuite_q((encryptionMaterials).Dtor_algorithmSuite())) && (func(_pat_let2_0 m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo) bool {
   376  		return func(_0_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo) bool {
   377  			return ((((((((((((_0_suite).Dtor_signature()).Is_None()) == (((_pat_let_tv0).Dtor_signingKey()).Is_None())) && (!(((_pat_let_tv1).Dtor_plaintextDataKey()).Is_Some()) || ((_dafny.IntOfInt32(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength(_0_suite))).Cmp(_dafny.IntOfUint32((((_pat_let_tv2).Dtor_plaintextDataKey()).Dtor_value().(_dafny.Sequence)).Cardinality())) == 0))) && (!(((_pat_let_tv3).Dtor_plaintextDataKey()).Is_None()) || ((_dafny.IntOfUint32(((_pat_let_tv4).Dtor_encryptedDataKeys()).Cardinality())).Sign() == 0))) && ((!(((_0_suite).Dtor_signature()).Is_None())) == (((_pat_let_tv5).Dtor_encryptionContext()).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD())))) && ((((_0_suite).Dtor_signature()).Is_ECDSA()) == (((_pat_let_tv6).Dtor_signingKey()).Is_Some()))) && ((!(((_0_suite).Dtor_signature()).Is_None())) == (((_pat_let_tv7).Dtor_encryptionContext()).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD())))) && (!((((_0_suite).Dtor_symmetricSignature()).Is_HMAC()) && (((_pat_let_tv8).Dtor_symmetricSigningKeys()).Is_Some())) || ((_dafny.IntOfUint32((((_pat_let_tv9).Dtor_symmetricSigningKeys()).Dtor_value().(_dafny.Sequence)).Cardinality())).Cmp(_dafny.IntOfUint32(((_pat_let_tv10).Dtor_encryptedDataKeys()).Cardinality())) == 0))) && (!(((_0_suite).Dtor_symmetricSignature()).Is_HMAC()) || (((_pat_let_tv11).Dtor_symmetricSigningKeys()).Is_Some()))) && (!(((_0_suite).Dtor_symmetricSignature()).Is_None()) || (((_pat_let_tv12).Dtor_symmetricSigningKeys()).Is_None()))) && (_dafny.Quantifier(((_pat_let_tv13).Dtor_requiredEncryptionContextKeys()).UniqueElements(), true, func(_forall_var_0 _dafny.Sequence) bool {
   378  				var _1_key _dafny.Sequence
   379  				_1_key = interface{}(_forall_var_0).(_dafny.Sequence)
   380  				if m_UTF8.Companion_ValidUTF8Bytes_.Is_(_1_key) {
   381  					return !(_dafny.Companion_Sequence_.Contains((_pat_let_tv14).Dtor_requiredEncryptionContextKeys(), _1_key)) || (((_pat_let_tv15).Dtor_encryptionContext()).Contains(_1_key))
   382  				} else {
   383  					return true
   384  				}
   385  			}))
   386  		}(_pat_let2_0)
   387  	}((encryptionMaterials).Dtor_algorithmSuite()))
   388  }
   389  func (_static *CompanionStruct_Default___) EncryptionMaterialsHasPlaintextDataKey(encryptionMaterials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials) bool {
   390  	return ((((encryptionMaterials).Dtor_plaintextDataKey()).Is_Some()) && ((_dafny.IntOfUint32(((encryptionMaterials).Dtor_encryptedDataKeys()).Cardinality())).Sign() == 1)) && (Companion_Default___.ValidEncryptionMaterials(encryptionMaterials))
   391  }
   392  func (_static *CompanionStruct_Default___) EncryptionMaterialAddEncryptedDataKeys(encryptionMaterials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials, encryptedDataKeysToAdd _dafny.Sequence, symmetricSigningKeysToAdd m_Wrappers.Option) m_Wrappers.Result {
   393  	var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(Companion_Default___.ValidEncryptionMaterials(encryptionMaterials), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Attempt to modify invalid encryption material.")))
   394  	_ = _0_valueOrError0
   395  	if (_0_valueOrError0).IsFailure() {
   396  		return (_0_valueOrError0).PropagateFailure()
   397  	} else {
   398  		var _1_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(((encryptionMaterials).Dtor_plaintextDataKey()).Is_Some(), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Adding encrypted data keys without a plaintext data key is not allowed.")))
   399  		_ = _1_valueOrError1
   400  		if (_1_valueOrError1).IsFailure() {
   401  			return (_1_valueOrError1).PropagateFailure()
   402  		} else {
   403  			var _2_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(!((symmetricSigningKeysToAdd).Is_None()) || ((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_symmetricSignature()).Is_None()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Adding encrypted data keys without a symmetric signing key when using symmetric signing is not allowed.")))
   404  			_ = _2_valueOrError2
   405  			if (_2_valueOrError2).IsFailure() {
   406  				return (_2_valueOrError2).PropagateFailure()
   407  			} else {
   408  				var _3_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(!((symmetricSigningKeysToAdd).Is_Some()) || (!((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_symmetricSignature()).Is_None())), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Adding encrypted data keys with a symmetric signing key when not using symmetric signing is not allowed.")))
   409  				_ = _3_valueOrError3
   410  				if (_3_valueOrError3).IsFailure() {
   411  					return (_3_valueOrError3).PropagateFailure()
   412  				} else {
   413  					var _4_symmetricSigningKeys m_Wrappers.Option = (func() m_Wrappers.Option {
   414  						if (symmetricSigningKeysToAdd).Is_None() {
   415  							return (encryptionMaterials).Dtor_symmetricSigningKeys()
   416  						}
   417  						return m_Wrappers.Companion_Option_.Create_Some_(_dafny.Companion_Sequence_.Concatenate(((encryptionMaterials).Dtor_symmetricSigningKeys()).Dtor_value().(_dafny.Sequence), (symmetricSigningKeysToAdd).Dtor_value().(_dafny.Sequence)))
   418  					})()
   419  					_ = _4_symmetricSigningKeys
   420  					return m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_EncryptionMaterials_.Create_EncryptionMaterials_((encryptionMaterials).Dtor_algorithmSuite(), (encryptionMaterials).Dtor_encryptionContext(), _dafny.Companion_Sequence_.Concatenate((encryptionMaterials).Dtor_encryptedDataKeys(), encryptedDataKeysToAdd), (encryptionMaterials).Dtor_requiredEncryptionContextKeys(), (encryptionMaterials).Dtor_plaintextDataKey(), (encryptionMaterials).Dtor_signingKey(), _4_symmetricSigningKeys))
   421  				}
   422  			}
   423  		}
   424  	}
   425  }
   426  func (_static *CompanionStruct_Default___) EncryptionMaterialAddDataKey(encryptionMaterials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials, plaintextDataKey _dafny.Sequence, encryptedDataKeysToAdd _dafny.Sequence, symmetricSigningKeysToAdd m_Wrappers.Option) m_Wrappers.Result {
   427  	var _0_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo = (encryptionMaterials).Dtor_algorithmSuite()
   428  	_ = _0_suite
   429  	var _1_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(Companion_Default___.ValidEncryptionMaterials(encryptionMaterials), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Attempt to modify invalid encryption material.")))
   430  	_ = _1_valueOrError0
   431  	if (_1_valueOrError0).IsFailure() {
   432  		return (_1_valueOrError0).PropagateFailure()
   433  	} else {
   434  		var _2_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(((encryptionMaterials).Dtor_plaintextDataKey()).Is_None(), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Attempt to modify plaintextDataKey.")))
   435  		_ = _2_valueOrError1
   436  		if (_2_valueOrError1).IsFailure() {
   437  			return (_2_valueOrError1).PropagateFailure()
   438  		} else {
   439  			var _3_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need((_dafny.IntOfInt32(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength(_0_suite))).Cmp(_dafny.IntOfUint32((plaintextDataKey).Cardinality())) == 0, m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("plaintextDataKey does not match Algorithm Suite specification.")))
   440  			_ = _3_valueOrError2
   441  			if (_3_valueOrError2).IsFailure() {
   442  				return (_3_valueOrError2).PropagateFailure()
   443  			} else {
   444  				var _4_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(((symmetricSigningKeysToAdd).Is_None()) == ((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_symmetricSignature()).Is_None()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Adding encrypted data keys without a symmetric signing key when using symmetric signing is not allowed.")))
   445  				_ = _4_valueOrError3
   446  				if (_4_valueOrError3).IsFailure() {
   447  					return (_4_valueOrError3).PropagateFailure()
   448  				} else {
   449  					var _5_valueOrError4 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(((symmetricSigningKeysToAdd).Is_Some()) == (!((((encryptionMaterials).Dtor_algorithmSuite()).Dtor_symmetricSignature()).Is_None())), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidEncryptionMaterialsTransition_(_dafny.SeqOfString("Adding encrypted data keys with a symmetric signing key when not using symmetric signing is not allowed.")))
   450  					_ = _5_valueOrError4
   451  					if (_5_valueOrError4).IsFailure() {
   452  						return (_5_valueOrError4).PropagateFailure()
   453  					} else {
   454  						var _6_symmetricSigningKeys m_Wrappers.Option = (func() m_Wrappers.Option {
   455  							if (symmetricSigningKeysToAdd).Is_None() {
   456  								return (encryptionMaterials).Dtor_symmetricSigningKeys()
   457  							}
   458  							return m_Wrappers.Companion_Option_.Create_Some_(_dafny.Companion_Sequence_.Concatenate(((encryptionMaterials).Dtor_symmetricSigningKeys()).Dtor_value().(_dafny.Sequence), (symmetricSigningKeysToAdd).Dtor_value().(_dafny.Sequence)))
   459  						})()
   460  						_ = _6_symmetricSigningKeys
   461  						return m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_EncryptionMaterials_.Create_EncryptionMaterials_((encryptionMaterials).Dtor_algorithmSuite(), (encryptionMaterials).Dtor_encryptionContext(), _dafny.Companion_Sequence_.Concatenate((encryptionMaterials).Dtor_encryptedDataKeys(), encryptedDataKeysToAdd), (encryptionMaterials).Dtor_requiredEncryptionContextKeys(), m_Wrappers.Companion_Option_.Create_Some_(plaintextDataKey), (encryptionMaterials).Dtor_signingKey(), _6_symmetricSigningKeys))
   462  					}
   463  				}
   464  			}
   465  		}
   466  	}
   467  }
   468  func (_static *CompanionStruct_Default___) DecryptionMaterialsTransitionIsValid(oldMat m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials, newMat m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) bool {
   469  	return ((((((((((newMat).Dtor_algorithmSuite()).Equals((oldMat).Dtor_algorithmSuite())) && (((newMat).Dtor_encryptionContext()).Equals((oldMat).Dtor_encryptionContext()))) && (_dafny.Companion_Sequence_.Equal((newMat).Dtor_requiredEncryptionContextKeys(), (oldMat).Dtor_requiredEncryptionContextKeys()))) && (((newMat).Dtor_verificationKey()).Equals((oldMat).Dtor_verificationKey()))) && (((oldMat).Dtor_plaintextDataKey()).Is_None())) && (((newMat).Dtor_plaintextDataKey()).Is_Some())) && (((oldMat).Dtor_symmetricSigningKey()).Is_None())) && (Companion_Default___.ValidDecryptionMaterials(oldMat))) && (Companion_Default___.ValidDecryptionMaterials(newMat))
   470  }
   471  func (_static *CompanionStruct_Default___) ValidDecryptionMaterials(decryptionMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) bool {
   472  	var _pat_let_tv0 = decryptionMaterials
   473  	_ = _pat_let_tv0
   474  	var _pat_let_tv1 = decryptionMaterials
   475  	_ = _pat_let_tv1
   476  	var _pat_let_tv2 = decryptionMaterials
   477  	_ = _pat_let_tv2
   478  	var _pat_let_tv3 = decryptionMaterials
   479  	_ = _pat_let_tv3
   480  	var _pat_let_tv4 = decryptionMaterials
   481  	_ = _pat_let_tv4
   482  	var _pat_let_tv5 = decryptionMaterials
   483  	_ = _pat_let_tv5
   484  	var _pat_let_tv6 = decryptionMaterials
   485  	_ = _pat_let_tv6
   486  	var _pat_let_tv7 = decryptionMaterials
   487  	_ = _pat_let_tv7
   488  	var _pat_let_tv8 = decryptionMaterials
   489  	_ = _pat_let_tv8
   490  	var _pat_let_tv9 = decryptionMaterials
   491  	_ = _pat_let_tv9
   492  	var _pat_let_tv10 = decryptionMaterials
   493  	_ = _pat_let_tv10
   494  	return (m_AlgorithmSuites.Companion_Default___.AlgorithmSuite_q((decryptionMaterials).Dtor_algorithmSuite())) && (func(_pat_let3_0 m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo) bool {
   495  		return func(_0_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo) bool {
   496  			return ((((((!(((_pat_let_tv0).Dtor_plaintextDataKey()).Is_Some()) || ((_dafny.IntOfInt32(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength(_0_suite))).Cmp(_dafny.IntOfUint32((((_pat_let_tv1).Dtor_plaintextDataKey()).Dtor_value().(_dafny.Sequence)).Cardinality())) == 0)) && ((!(((_0_suite).Dtor_signature()).Is_None())) == (((_pat_let_tv2).Dtor_encryptionContext()).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD())))) && ((((_0_suite).Dtor_signature()).Is_ECDSA()) == (((_pat_let_tv3).Dtor_verificationKey()).Is_Some()))) && ((!(((_0_suite).Dtor_signature()).Is_None())) == (((_pat_let_tv4).Dtor_encryptionContext()).Contains(Companion_Default___.EC__PUBLIC__KEY__FIELD())))) && (!(!(((_0_suite).Dtor_symmetricSignature()).Is_None())) || ((((_pat_let_tv5).Dtor_plaintextDataKey()).Is_Some()) == (((_pat_let_tv6).Dtor_symmetricSigningKey()).Is_Some())))) && (!(((_0_suite).Dtor_symmetricSignature()).Is_None()) || (((_pat_let_tv7).Dtor_symmetricSigningKey()).Is_None()))) && (_dafny.Quantifier(((_pat_let_tv8).Dtor_requiredEncryptionContextKeys()).UniqueElements(), true, func(_forall_var_0 _dafny.Sequence) bool {
   497  				var _1_k _dafny.Sequence
   498  				_1_k = interface{}(_forall_var_0).(_dafny.Sequence)
   499  				if m_UTF8.Companion_ValidUTF8Bytes_.Is_(_1_k) {
   500  					return !(_dafny.Companion_Sequence_.Contains((_pat_let_tv9).Dtor_requiredEncryptionContextKeys(), _1_k)) || (((_pat_let_tv10).Dtor_encryptionContext()).Contains(_1_k))
   501  				} else {
   502  					return true
   503  				}
   504  			}))
   505  		}(_pat_let3_0)
   506  	}((decryptionMaterials).Dtor_algorithmSuite()))
   507  }
   508  func (_static *CompanionStruct_Default___) DecryptionMaterialsAddDataKey(decryptionMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials, plaintextDataKey _dafny.Sequence, symmetricSigningKey m_Wrappers.Option) m_Wrappers.Result {
   509  	var _0_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo = (decryptionMaterials).Dtor_algorithmSuite()
   510  	_ = _0_suite
   511  	var _1_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(Companion_Default___.ValidDecryptionMaterials(decryptionMaterials), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidDecryptionMaterialsTransition_(_dafny.SeqOfString("Attempt to modify invalid decryption material.")))
   512  	_ = _1_valueOrError0
   513  	if (_1_valueOrError0).IsFailure() {
   514  		return (_1_valueOrError0).PropagateFailure()
   515  	} else {
   516  		var _2_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(((decryptionMaterials).Dtor_plaintextDataKey()).Is_None(), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidDecryptionMaterialsTransition_(_dafny.SeqOfString("Attempt to modify plaintextDataKey.")))
   517  		_ = _2_valueOrError1
   518  		if (_2_valueOrError1).IsFailure() {
   519  			return (_2_valueOrError1).PropagateFailure()
   520  		} else {
   521  			var _3_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need((_dafny.IntOfInt32(m_AlgorithmSuites.Companion_Default___.GetEncryptKeyLength(_0_suite))).Cmp(_dafny.IntOfUint32((plaintextDataKey).Cardinality())) == 0, m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidDecryptionMaterialsTransition_(_dafny.SeqOfString("plaintextDataKey does not match Algorithm Suite specification.")))
   522  			_ = _3_valueOrError2
   523  			if (_3_valueOrError2).IsFailure() {
   524  				return (_3_valueOrError2).PropagateFailure()
   525  			} else {
   526  				var _4_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(((symmetricSigningKey).Is_Some()) == (!((((decryptionMaterials).Dtor_algorithmSuite()).Dtor_symmetricSignature()).Is_None())), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidDecryptionMaterialsTransition_(_dafny.SeqOfString("symmetric signature key must be added with plaintextDataKey if using an algorithm suite with symmetric signing.")))
   527  				_ = _4_valueOrError3
   528  				if (_4_valueOrError3).IsFailure() {
   529  					return (_4_valueOrError3).PropagateFailure()
   530  				} else {
   531  					var _5_valueOrError4 m_Wrappers.Outcome = m_Wrappers.Companion_Default___.Need(((symmetricSigningKey).Is_None()) == ((((decryptionMaterials).Dtor_algorithmSuite()).Dtor_symmetricSignature()).Is_None()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_InvalidDecryptionMaterialsTransition_(_dafny.SeqOfString("symmetric signature key cannot be added with plaintextDataKey if using an algorithm suite without symmetric signing.")))
   532  					_ = _5_valueOrError4
   533  					if (_5_valueOrError4).IsFailure() {
   534  						return (_5_valueOrError4).PropagateFailure()
   535  					} else {
   536  						return m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_DecryptionMaterials_.Create_DecryptionMaterials_((decryptionMaterials).Dtor_algorithmSuite(), (decryptionMaterials).Dtor_encryptionContext(), (decryptionMaterials).Dtor_requiredEncryptionContextKeys(), m_Wrappers.Companion_Option_.Create_Some_(plaintextDataKey), (decryptionMaterials).Dtor_verificationKey(), symmetricSigningKey))
   537  					}
   538  				}
   539  			}
   540  		}
   541  	}
   542  }
   543  func (_static *CompanionStruct_Default___) DecryptionMaterialsWithoutPlaintextDataKey(decryptionMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) bool {
   544  	return (((decryptionMaterials).Dtor_plaintextDataKey()).Is_None()) && (Companion_Default___.ValidDecryptionMaterials(decryptionMaterials))
   545  }
   546  func (_static *CompanionStruct_Default___) DecryptionMaterialsWithPlaintextDataKey(decryptionMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) bool {
   547  	return (((decryptionMaterials).Dtor_plaintextDataKey()).Is_Some()) && (Companion_Default___.ValidDecryptionMaterials(decryptionMaterials))
   548  }
   549  func (_static *CompanionStruct_Default___) EC__PUBLIC__KEY__FIELD() _dafny.Sequence {
   550  	var _0_s _dafny.Sequence = _dafny.SeqOf(uint8(97), uint8(119), uint8(115), uint8(45), uint8(99), uint8(114), uint8(121), uint8(112), uint8(116), uint8(111), uint8(45), uint8(112), uint8(117), uint8(98), uint8(108), uint8(105), uint8(99), uint8(45), uint8(107), uint8(101), uint8(121))
   551  	_ = _0_s
   552  	return _0_s
   553  }
   554  func (_static *CompanionStruct_Default___) RESERVED__KEY__VALUES() _dafny.Set {
   555  	return _dafny.SetOf(Companion_Default___.EC__PUBLIC__KEY__FIELD())
   556  }
   557  
   558  // End of class Default__
   559  
   560  // Definition of class DecryptionMaterialsPendingPlaintextDataKey
   561  type DecryptionMaterialsPendingPlaintextDataKey struct {
   562  }
   563  
   564  func New_DecryptionMaterialsPendingPlaintextDataKey_() *DecryptionMaterialsPendingPlaintextDataKey {
   565  	_this := DecryptionMaterialsPendingPlaintextDataKey{}
   566  
   567  	return &_this
   568  }
   569  
   570  type CompanionStruct_DecryptionMaterialsPendingPlaintextDataKey_ struct {
   571  }
   572  
   573  var Companion_DecryptionMaterialsPendingPlaintextDataKey_ = CompanionStruct_DecryptionMaterialsPendingPlaintextDataKey_{}
   574  
   575  func (*DecryptionMaterialsPendingPlaintextDataKey) String() string {
   576  	return "Materials.DecryptionMaterialsPendingPlaintextDataKey"
   577  }
   578  
   579  // End of class DecryptionMaterialsPendingPlaintextDataKey
   580  
   581  func Type_DecryptionMaterialsPendingPlaintextDataKey_() _dafny.TypeDescriptor {
   582  	return type_DecryptionMaterialsPendingPlaintextDataKey_{}
   583  }
   584  
   585  type type_DecryptionMaterialsPendingPlaintextDataKey_ struct {
   586  }
   587  
   588  func (_this type_DecryptionMaterialsPendingPlaintextDataKey_) Default() interface{} {
   589  	return m_AwsCryptographyMaterialProvidersTypes.Companion_DecryptionMaterials_.Default()
   590  }
   591  
   592  func (_this type_DecryptionMaterialsPendingPlaintextDataKey_) String() string {
   593  	return "Materials.DecryptionMaterialsPendingPlaintextDataKey"
   594  }
   595  func (_this *CompanionStruct_DecryptionMaterialsPendingPlaintextDataKey_) Is_(__source m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) bool {
   596  	var _0_d m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials = (__source)
   597  	_ = _0_d
   598  	return Companion_Default___.DecryptionMaterialsWithoutPlaintextDataKey(_0_d)
   599  }
   600  
   601  // Definition of class SealedDecryptionMaterials
   602  type SealedDecryptionMaterials struct {
   603  }
   604  
   605  func New_SealedDecryptionMaterials_() *SealedDecryptionMaterials {
   606  	_this := SealedDecryptionMaterials{}
   607  
   608  	return &_this
   609  }
   610  
   611  type CompanionStruct_SealedDecryptionMaterials_ struct {
   612  }
   613  
   614  var Companion_SealedDecryptionMaterials_ = CompanionStruct_SealedDecryptionMaterials_{}
   615  
   616  func (*SealedDecryptionMaterials) String() string {
   617  	return "Materials.SealedDecryptionMaterials"
   618  }
   619  
   620  // End of class SealedDecryptionMaterials
   621  
   622  func Type_SealedDecryptionMaterials_() _dafny.TypeDescriptor {
   623  	return type_SealedDecryptionMaterials_{}
   624  }
   625  
   626  type type_SealedDecryptionMaterials_ struct {
   627  }
   628  
   629  func (_this type_SealedDecryptionMaterials_) Default() interface{} {
   630  	return m_AwsCryptographyMaterialProvidersTypes.Companion_DecryptionMaterials_.Default()
   631  }
   632  
   633  func (_this type_SealedDecryptionMaterials_) String() string {
   634  	return "Materials.SealedDecryptionMaterials"
   635  }
   636  func (_this *CompanionStruct_SealedDecryptionMaterials_) Is_(__source m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials) bool {
   637  	var _1_d m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials = (__source)
   638  	_ = _1_d
   639  	return Companion_Default___.DecryptionMaterialsWithPlaintextDataKey(_1_d)
   640  }