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

     1  // Package AwsKmsEcdhKeyring
     2  // Dafny module AwsKmsEcdhKeyring compiled into Go
     3  
     4  package AwsKmsEcdhKeyring
     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_AwsKmsDiscoveryKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsDiscoveryKeyring"
    19  	m_AwsKmsHierarchicalKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsHierarchicalKeyring"
    20  	m_AwsKmsKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsKeyring"
    21  	m_AwsKmsMrkAreUnique "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkAreUnique"
    22  	m_AwsKmsMrkDiscoveryKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkDiscoveryKeyring"
    23  	m_AwsKmsMrkKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkKeyring"
    24  	m_AwsKmsMrkMatchForDecrypt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsMrkMatchForDecrypt"
    25  	m_AwsKmsRsaKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsRsaKeyring"
    26  	m_AwsKmsUtils "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/AwsKmsUtils"
    27  	m_CacheConstants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CacheConstants"
    28  	m_CanonicalEncryptionContext "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CanonicalEncryptionContext"
    29  	m_Constants "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Constants"
    30  	m_CreateKeyStoreTable "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeyStoreTable"
    31  	m_CreateKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/CreateKeys"
    32  	m_DDBKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DDBKeystoreOperations"
    33  	m_DiscoveryMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/DiscoveryMultiKeyring"
    34  	m_EcdhEdkWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/EcdhEdkWrapping"
    35  	m_EdkWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/EdkWrapping"
    36  	m_ErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/ErrorMessages"
    37  	m_GetKeys "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/GetKeys"
    38  	m_IntermediateKeyWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/IntermediateKeyWrapping"
    39  	m_KMSKeystoreOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KMSKeystoreOperations"
    40  	m_KeyStore "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStore"
    41  	m_KeyStoreErrorMessages "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KeyStoreErrorMessages"
    42  	m_Keyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Keyring"
    43  	m_KmsArn "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/KmsArn"
    44  	m_LocalCMC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/LocalCMC"
    45  	m_MaterialWrapping "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MaterialWrapping"
    46  	m_Materials "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Materials"
    47  	m_MrkAwareDiscoveryMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MrkAwareDiscoveryMultiKeyring"
    48  	m_MrkAwareStrictMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MrkAwareStrictMultiKeyring"
    49  	m_MultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/MultiKeyring"
    50  	m_RawECDHKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/RawECDHKeyring"
    51  	m_StormTracker "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StormTracker"
    52  	m_StormTrackingCMC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StormTrackingCMC"
    53  	m_StrictMultiKeyring "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/StrictMultiKeyring"
    54  	m_Structure "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/Structure"
    55  	m_SynchronizedLocalCMC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/mpl/SynchronizedLocalCMC"
    56  	m_AtomicPrimitives "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AtomicPrimitives"
    57  	m_AwsCryptographyPrimitivesOperations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesOperations"
    58  	m_AwsCryptographyPrimitivesTypes "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/AwsCryptographyPrimitivesTypes"
    59  	m_Digest "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Digest"
    60  	m_HKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/HKDF"
    61  	m_KdfCtr "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/KdfCtr"
    62  	m_Random "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/Random"
    63  	m_WrappedHKDF "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHKDF"
    64  	m_WrappedHMAC "github.com/aws/aws-cryptographic-material-providers-library/releases/go/primitives/WrappedHMAC"
    65  	m_Actions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Actions"
    66  	m_Base64 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64"
    67  	m_Base64Lemmas "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Base64Lemmas"
    68  	m_BoundedInts "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/BoundedInts"
    69  	m_DivInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternals"
    70  	m_DivInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivInternalsNonlinear"
    71  	m_DivMod "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/DivMod"
    72  	m_FileIO "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FileIO"
    73  	m_FloatCompare "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/FloatCompare"
    74  	m_Functions "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Functions"
    75  	m_GeneralInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GeneralInternals"
    76  	m_GetOpt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/GetOpt"
    77  	m_HexStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/HexStrings"
    78  	m_Logarithm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Logarithm"
    79  	m__Math "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Math_"
    80  	m_ModInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternals"
    81  	m_ModInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/ModInternalsNonlinear"
    82  	m_Mul "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Mul"
    83  	m_MulInternals "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternals"
    84  	m_MulInternalsNonlinear "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/MulInternalsNonlinear"
    85  	m_Power "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Power"
    86  	m_Relations "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Relations"
    87  	m_Seq "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq"
    88  	m_Seq_MergeSort "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Seq_MergeSort"
    89  	m_Sorting "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Sorting"
    90  	m_StandardLibrary "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary"
    91  	m_StandardLibraryInterop "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibraryInterop"
    92  	m_StandardLibrary_Sequence "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_Sequence"
    93  	m_StandardLibrary_String "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_String"
    94  	m_StandardLibrary_UInt "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/StandardLibrary_UInt"
    95  	m_Streams "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Streams"
    96  	m_UTF8 "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UTF8"
    97  	m_UnicodeStrings "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/UnicodeStrings"
    98  	m__Unicode "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Unicode_"
    99  	m_Utf16EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf16EncodingForm"
   100  	m_Utf8EncodingForm "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Utf8EncodingForm"
   101  	m_Wrappers "github.com/aws/aws-cryptographic-material-providers-library/releases/go/smithy-dafny-standard-library/Wrappers"
   102  	m__System "github.com/dafny-lang/DafnyRuntimeGo/v4/System_"
   103  	_dafny "github.com/dafny-lang/DafnyRuntimeGo/v4/dafny"
   104  )
   105  
   106  var _ = os.Args
   107  var _ _dafny.Dummy__
   108  var _ m__System.Dummy__
   109  var _ m_Wrappers.Dummy__
   110  var _ m_BoundedInts.Dummy__
   111  var _ m_StandardLibrary_UInt.Dummy__
   112  var _ m_StandardLibrary_Sequence.Dummy__
   113  var _ m_StandardLibrary_String.Dummy__
   114  var _ m_StandardLibrary.Dummy__
   115  var _ m_AwsCryptographyPrimitivesTypes.Dummy__
   116  var _ m_Random.Dummy__
   117  var _ m_Digest.Dummy__
   118  var _ m_WrappedHMAC.Dummy__
   119  var _ m_HKDF.Dummy__
   120  var _ m_WrappedHKDF.Dummy__
   121  var _ m_KdfCtr.Dummy__
   122  var _ m_AwsCryptographyPrimitivesOperations.Dummy__
   123  var _ m_AtomicPrimitives.Dummy__
   124  var _ m_ComAmazonawsDynamodbTypes.Dummy__
   125  var _ m_ComAmazonawsKmsTypes.Dummy__
   126  var _ m_Relations.Dummy__
   127  var _ m_Seq_MergeSort.Dummy__
   128  var _ m__Math.Dummy__
   129  var _ m_Seq.Dummy__
   130  var _ m__Unicode.Dummy__
   131  var _ m_Functions.Dummy__
   132  var _ m_Utf8EncodingForm.Dummy__
   133  var _ m_Utf16EncodingForm.Dummy__
   134  var _ m_UnicodeStrings.Dummy__
   135  var _ m_FileIO.Dummy__
   136  var _ m_GeneralInternals.Dummy__
   137  var _ m_MulInternalsNonlinear.Dummy__
   138  var _ m_MulInternals.Dummy__
   139  var _ m_Mul.Dummy__
   140  var _ m_ModInternalsNonlinear.Dummy__
   141  var _ m_DivInternalsNonlinear.Dummy__
   142  var _ m_ModInternals.Dummy__
   143  var _ m_DivInternals.Dummy__
   144  var _ m_DivMod.Dummy__
   145  var _ m_Power.Dummy__
   146  var _ m_Logarithm.Dummy__
   147  var _ m_StandardLibraryInterop.Dummy__
   148  var _ m_Streams.Dummy__
   149  var _ m_Sorting.Dummy__
   150  var _ m_HexStrings.Dummy__
   151  var _ m_GetOpt.Dummy__
   152  var _ m_FloatCompare.Dummy__
   153  var _ m_Base64.Dummy__
   154  var _ m_Base64Lemmas.Dummy__
   155  var _ m_Actions.Dummy__
   156  var _ m_AwsCryptographyKeyStoreTypes.Dummy__
   157  var _ m_AwsCryptographyMaterialProvidersTypes.Dummy__
   158  var _ m_AwsArnParsing.Dummy__
   159  var _ m_AwsKmsMrkMatchForDecrypt.Dummy__
   160  var _ m_AwsKmsUtils.Dummy__
   161  var _ m_KeyStoreErrorMessages.Dummy__
   162  var _ m_KmsArn.Dummy__
   163  var _ m_Structure.Dummy__
   164  var _ m_KMSKeystoreOperations.Dummy__
   165  var _ m_DDBKeystoreOperations.Dummy__
   166  var _ m_CreateKeys.Dummy__
   167  var _ m_CreateKeyStoreTable.Dummy__
   168  var _ m_GetKeys.Dummy__
   169  var _ m_AwsCryptographyKeyStoreOperations.Dummy__
   170  var _ m_Com_Amazonaws_Kms.Dummy__
   171  var _ m_Com_Amazonaws_Dynamodb.Dummy__
   172  var _ m_KeyStore.Dummy__
   173  var _ m_AlgorithmSuites.Dummy__
   174  var _ m_Materials.Dummy__
   175  var _ m_Keyring.Dummy__
   176  var _ m_MultiKeyring.Dummy__
   177  var _ m_AwsKmsMrkAreUnique.Dummy__
   178  var _ m_Constants.Dummy__
   179  var _ m_MaterialWrapping.Dummy__
   180  var _ m_CanonicalEncryptionContext.Dummy__
   181  var _ m_IntermediateKeyWrapping.Dummy__
   182  var _ m_EdkWrapping.Dummy__
   183  var _ m_ErrorMessages.Dummy__
   184  var _ m_AwsKmsKeyring.Dummy__
   185  var _ m_StrictMultiKeyring.Dummy__
   186  var _ m_AwsKmsDiscoveryKeyring.Dummy__
   187  var _ m_DiscoveryMultiKeyring.Dummy__
   188  var _ m_AwsKmsMrkDiscoveryKeyring.Dummy__
   189  var _ m_MrkAwareDiscoveryMultiKeyring.Dummy__
   190  var _ m_AwsKmsMrkKeyring.Dummy__
   191  var _ m_MrkAwareStrictMultiKeyring.Dummy__
   192  var _ m_LocalCMC.Dummy__
   193  var _ m_SynchronizedLocalCMC.Dummy__
   194  var _ m_StormTracker.Dummy__
   195  var _ m_StormTrackingCMC.Dummy__
   196  var _ m_CacheConstants.Dummy__
   197  var _ m_AwsKmsHierarchicalKeyring.Dummy__
   198  var _ m_AwsKmsRsaKeyring.Dummy__
   199  var _ m_EcdhEdkWrapping.Dummy__
   200  var _ m_RawECDHKeyring.Dummy__
   201  
   202  type Dummy__ struct{}
   203  
   204  // Definition of class Default__
   205  type Default__ struct {
   206  	dummy byte
   207  }
   208  
   209  func New_Default___() *Default__ {
   210  	_this := Default__{}
   211  
   212  	return &_this
   213  }
   214  
   215  type CompanionStruct_Default___ struct {
   216  }
   217  
   218  var Companion_Default___ = CompanionStruct_Default___{}
   219  
   220  func (_this *Default__) Equals(other *Default__) bool {
   221  	return _this == other
   222  }
   223  
   224  func (_this *Default__) EqualsGeneric(x interface{}) bool {
   225  	other, ok := x.(*Default__)
   226  	return ok && _this.Equals(other)
   227  }
   228  
   229  func (*Default__) String() string {
   230  	return "AwsKmsEcdhKeyring.Default__"
   231  }
   232  func (_this *Default__) ParentTraits_() []*_dafny.TraitID {
   233  	return [](*_dafny.TraitID){}
   234  }
   235  
   236  var _ _dafny.TraitOffspring = &Default__{}
   237  
   238  func (_static *CompanionStruct_Default___) DeriveSharedSecret(client m_ComAmazonawsKmsTypes.IKMSClient, senderAwsKmsKey _dafny.Sequence, recipientPublicKey _dafny.Sequence, grantTokens _dafny.Sequence) m_Wrappers.Result {
   239  	var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   240  	_ = res
   241  	var _0_deriveSharedSecretRequest m_ComAmazonawsKmsTypes.DeriveSharedSecretRequest
   242  	_ = _0_deriveSharedSecretRequest
   243  	_0_deriveSharedSecretRequest = m_ComAmazonawsKmsTypes.Companion_DeriveSharedSecretRequest_.Create_DeriveSharedSecretRequest_(senderAwsKmsKey, m_ComAmazonawsKmsTypes.Companion_KeyAgreementAlgorithmSpec_.Create_ECDH_(), recipientPublicKey, m_Wrappers.Companion_Option_.Create_Some_(grantTokens), m_Wrappers.Companion_Option_.Create_None_(), m_Wrappers.Companion_Option_.Create_None_())
   244  	var _1_maybeDeriveSharedSecret m_Wrappers.Result
   245  	_ = _1_maybeDeriveSharedSecret
   246  	var _out0 m_Wrappers.Result
   247  	_ = _out0
   248  	_out0 = (client).DeriveSharedSecret(_0_deriveSharedSecretRequest)
   249  	_1_maybeDeriveSharedSecret = _out0
   250  	var _2_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_ComAmazonawsKmsTypes.Companion_DeriveSharedSecretResponse_.Default())
   251  	_ = _2_valueOrError0
   252  	_2_valueOrError0 = (_1_maybeDeriveSharedSecret).MapFailure(func(coer117 func(m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} {
   253  		return func(arg118 interface{}) interface{} {
   254  			return coer117(arg118.(m_ComAmazonawsKmsTypes.Error))
   255  		}
   256  	}(func(_3_e m_ComAmazonawsKmsTypes.Error) m_AwsCryptographyMaterialProvidersTypes.Error {
   257  		return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_ComAmazonawsKms_(_3_e)
   258  	}))
   259  	if (_2_valueOrError0).IsFailure() {
   260  		res = (_2_valueOrError0).PropagateFailure()
   261  		return res
   262  	}
   263  	var _4_deriveSharedSecretResponse m_ComAmazonawsKmsTypes.DeriveSharedSecretResponse
   264  	_ = _4_deriveSharedSecretResponse
   265  	_4_deriveSharedSecretResponse = (_2_valueOrError0).Extract().(m_ComAmazonawsKmsTypes.DeriveSharedSecretResponse)
   266  	var _5_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   267  	_ = _5_valueOrError1
   268  	_5_valueOrError1 = m_Wrappers.Companion_Default___.Need(((((((_4_deriveSharedSecretResponse).Dtor_KeyId()).Is_Some()) && (((_4_deriveSharedSecretResponse).Dtor_SharedSecret()).Is_Some())) && (((_4_deriveSharedSecretResponse).Dtor_KeyAgreementAlgorithm()).Is_Some())) && (_dafny.Companion_Sequence_.Equal(((_4_deriveSharedSecretResponse).Dtor_KeyId()).Dtor_value().(_dafny.Sequence), senderAwsKmsKey))) && ((((_4_deriveSharedSecretResponse).Dtor_KeyAgreementAlgorithm()).Dtor_value().(m_ComAmazonawsKmsTypes.KeyAgreementAlgorithmSpec)).Equals(m_ComAmazonawsKmsTypes.Companion_KeyAgreementAlgorithmSpec_.Create_ECDH_())), Companion_Default___.E(_dafny.SeqOfString("Invalid response from KMS DeriveSharedSecret")))
   269  	if (_5_valueOrError1).IsFailure() {
   270  		res = (_5_valueOrError1).PropagateFailure()
   271  		return res
   272  	}
   273  	res = m_Wrappers.Companion_Result_.Create_Success_(((_4_deriveSharedSecretResponse).Dtor_SharedSecret()).Dtor_value().(_dafny.Sequence))
   274  	return res
   275  	return res
   276  }
   277  func (_static *CompanionStruct_Default___) E(s _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error {
   278  	return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(s)
   279  }
   280  func (_static *CompanionStruct_Default___) AWS__KMS__ECDH__KEYRING__VERSION() _dafny.Sequence {
   281  	return m_RawECDHKeyring.Companion_Default___.RAW__ECDH__KEYRING__VERSION()
   282  }
   283  
   284  // End of class Default__
   285  
   286  // Definition of class AwsKmsEcdhKeyring
   287  type AwsKmsEcdhKeyring struct {
   288  	_client                       m_ComAmazonawsKmsTypes.IKMSClient
   289  	_cryptoPrimitives             *m_AtomicPrimitives.AtomicPrimitivesClient
   290  	_keyAgreementScheme           m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations
   291  	_curveSpec                    m_AwsCryptographyPrimitivesTypes.ECDHCurveSpec
   292  	_grantTokens                  _dafny.Sequence
   293  	_recipientPublicKey           _dafny.Sequence
   294  	_senderPublicKey              m_Wrappers.Option
   295  	_compressedSenderPublicKey    m_Wrappers.Option
   296  	_compressedRecipientPublicKey _dafny.Sequence
   297  	_senderKmsKeyId               m_Wrappers.Option
   298  }
   299  
   300  func New_AwsKmsEcdhKeyring_() *AwsKmsEcdhKeyring {
   301  	_this := AwsKmsEcdhKeyring{}
   302  
   303  	_this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil)
   304  	_this._cryptoPrimitives = (*m_AtomicPrimitives.AtomicPrimitivesClient)(nil)
   305  	_this._keyAgreementScheme = m_AwsCryptographyMaterialProvidersTypes.Companion_KmsEcdhStaticConfigurations_.Default()
   306  	_this._curveSpec = m_AwsCryptographyPrimitivesTypes.Companion_ECDHCurveSpec_.Default()
   307  	_this._grantTokens = _dafny.EmptySeq
   308  	_this._recipientPublicKey = _dafny.EmptySeq
   309  	_this._senderPublicKey = m_Wrappers.Companion_Option_.Default()
   310  	_this._compressedSenderPublicKey = m_Wrappers.Companion_Option_.Default()
   311  	_this._compressedRecipientPublicKey = _dafny.EmptySeq
   312  	_this._senderKmsKeyId = m_Wrappers.Companion_Option_.Default()
   313  	return &_this
   314  }
   315  
   316  type CompanionStruct_AwsKmsEcdhKeyring_ struct {
   317  }
   318  
   319  var Companion_AwsKmsEcdhKeyring_ = CompanionStruct_AwsKmsEcdhKeyring_{}
   320  
   321  func (_this *AwsKmsEcdhKeyring) Equals(other *AwsKmsEcdhKeyring) bool {
   322  	return _this == other
   323  }
   324  
   325  func (_this *AwsKmsEcdhKeyring) EqualsGeneric(x interface{}) bool {
   326  	other, ok := x.(*AwsKmsEcdhKeyring)
   327  	return ok && _this.Equals(other)
   328  }
   329  
   330  func (*AwsKmsEcdhKeyring) String() string {
   331  	return "AwsKmsEcdhKeyring.AwsKmsEcdhKeyring"
   332  }
   333  
   334  func Type_AwsKmsEcdhKeyring_() _dafny.TypeDescriptor {
   335  	return type_AwsKmsEcdhKeyring_{}
   336  }
   337  
   338  type type_AwsKmsEcdhKeyring_ struct {
   339  }
   340  
   341  func (_this type_AwsKmsEcdhKeyring_) Default() interface{} {
   342  	return (*AwsKmsEcdhKeyring)(nil)
   343  }
   344  
   345  func (_this type_AwsKmsEcdhKeyring_) String() string {
   346  	return "AwsKmsEcdhKeyring.AwsKmsEcdhKeyring"
   347  }
   348  func (_this *AwsKmsEcdhKeyring) ParentTraits_() []*_dafny.TraitID {
   349  	return [](*_dafny.TraitID){m_Keyring.Companion_VerifiableInterface_.TraitID_, m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.TraitID_}
   350  }
   351  
   352  var _ m_Keyring.VerifiableInterface = &AwsKmsEcdhKeyring{}
   353  var _ m_AwsCryptographyMaterialProvidersTypes.IKeyring = &AwsKmsEcdhKeyring{}
   354  var _ _dafny.TraitOffspring = &AwsKmsEcdhKeyring{}
   355  
   356  func (_this *AwsKmsEcdhKeyring) OnDecrypt(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result {
   357  	var _out9 m_Wrappers.Result
   358  	_ = _out9
   359  	_out9 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnDecrypt(_this, input)
   360  	return _out9
   361  }
   362  func (_this *AwsKmsEcdhKeyring) OnEncrypt(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result {
   363  	var _out9 m_Wrappers.Result
   364  	_ = _out9
   365  	_out9 = m_AwsCryptographyMaterialProvidersTypes.Companion_IKeyring_.OnEncrypt(_this, input)
   366  	return _out9
   367  }
   368  func (_this *AwsKmsEcdhKeyring) Ctor__(KeyAgreementScheme m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations, curveSpec m_AwsCryptographyPrimitivesTypes.ECDHCurveSpec, client m_ComAmazonawsKmsTypes.IKMSClient, grantTokens _dafny.Sequence, senderKmsKeyId m_Wrappers.Option, senderPublicKey m_Wrappers.Option, recipientPublicKey _dafny.Sequence, compressedSenderPublicKey m_Wrappers.Option, compressedRecipientPublicKey _dafny.Sequence, cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient) {
   369  	{
   370  		(_this)._keyAgreementScheme = KeyAgreementScheme
   371  		(_this)._curveSpec = curveSpec
   372  		(_this)._client = client
   373  		(_this)._grantTokens = grantTokens
   374  		(_this)._recipientPublicKey = recipientPublicKey
   375  		(_this)._senderPublicKey = senderPublicKey
   376  		(_this)._compressedSenderPublicKey = compressedSenderPublicKey
   377  		(_this)._compressedRecipientPublicKey = compressedRecipientPublicKey
   378  		(_this)._senderKmsKeyId = senderKmsKeyId
   379  		(_this)._cryptoPrimitives = cryptoPrimitives
   380  	}
   381  }
   382  func (_this *AwsKmsEcdhKeyring) OnEncrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnEncryptInput) m_Wrappers.Result {
   383  	{
   384  		var res m_Wrappers.Result = m_Wrappers.Result{}
   385  		_ = res
   386  		var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   387  		_ = _0_valueOrError0
   388  		_0_valueOrError0 = m_Wrappers.Companion_Default___.Need(!(((_this).KeyAgreementScheme()).Is_KmsPublicKeyDiscovery()), Companion_Default___.E(_dafny.SeqOfString("KmsPublicKeyDiscovery Key Agreement Scheme is forbidden on encrypt.")))
   389  		if (_0_valueOrError0).IsFailure() {
   390  			res = (_0_valueOrError0).PropagateFailure()
   391  			return res
   392  		}
   393  		var _1_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   394  		_ = _1_valueOrError1
   395  		_1_valueOrError1 = m_Wrappers.Companion_Default___.Need(((_this).SenderKmsKeyId()).Is_Some(), Companion_Default___.E(_dafny.SeqOfString("Keyring MUST be configured with a sender KMS Key ID")))
   396  		if (_1_valueOrError1).IsFailure() {
   397  			res = (_1_valueOrError1).PropagateFailure()
   398  			return res
   399  		}
   400  		var _2_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   401  		_ = _2_valueOrError2
   402  		_2_valueOrError2 = m_Wrappers.Companion_Default___.Need(((_this).SenderPublicKey()).Is_Some(), Companion_Default___.E(_dafny.SeqOfString("Keyring MUST be configured with a senderPublicKey")))
   403  		if (_2_valueOrError2).IsFailure() {
   404  			res = (_2_valueOrError2).PropagateFailure()
   405  			return res
   406  		}
   407  		var _3_senderKmsKeyId _dafny.Sequence
   408  		_ = _3_senderKmsKeyId
   409  		_3_senderKmsKeyId = ((_this).SenderKmsKeyId()).Dtor_value().(_dafny.Sequence)
   410  		var _4_materials m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials
   411  		_ = _4_materials
   412  		_4_materials = (input).Dtor_materials()
   413  		var _5_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo
   414  		_ = _5_suite
   415  		_5_suite = ((input).Dtor_materials()).Dtor_algorithmSuite()
   416  		var _6_valueOrError3 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptyMap)
   417  		_ = _6_valueOrError3
   418  		_6_valueOrError3 = m_AwsKmsUtils.Companion_Default___.StringifyEncryptionContext(((input).Dtor_materials()).Dtor_encryptionContext())
   419  		if (_6_valueOrError3).IsFailure() {
   420  			res = (_6_valueOrError3).PropagateFailure()
   421  			return res
   422  		}
   423  		var _7_stringifiedEncCtx _dafny.Map
   424  		_ = _7_stringifiedEncCtx
   425  		_7_stringifiedEncCtx = (_6_valueOrError3).Extract().(_dafny.Map)
   426  		var _8_valueOrError4 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   427  		_ = _8_valueOrError4
   428  		var _out0 m_Wrappers.Result
   429  		_ = _out0
   430  		_out0 = Companion_Default___.DeriveSharedSecret((_this).Client(), _3_senderKmsKeyId, (_this).RecipientPublicKey(), (_this).GrantTokens())
   431  		_8_valueOrError4 = _out0
   432  		if (_8_valueOrError4).IsFailure() {
   433  			res = (_8_valueOrError4).PropagateFailure()
   434  			return res
   435  		}
   436  		var _9_sharedSecret _dafny.Sequence
   437  		_ = _9_sharedSecret
   438  		_9_sharedSecret = (_8_valueOrError4).Extract().(_dafny.Sequence)
   439  		var _10_operationCompressedSenderPublicKey _dafny.Sequence
   440  		_ = _10_operationCompressedSenderPublicKey
   441  		if ((_this).CompressedSenderPublicKey()).Is_None() {
   442  			_10_operationCompressedSenderPublicKey = _dafny.SeqOf()
   443  		} else {
   444  			_10_operationCompressedSenderPublicKey = ((_this).CompressedSenderPublicKey()).Dtor_value().(_dafny.Sequence)
   445  		}
   446  		var _11_valueOrError5 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_UTF8.Companion_ValidUTF8Bytes_.Witness())
   447  		_ = _11_valueOrError5
   448  		_11_valueOrError5 = (m_UTF8.Encode(m_RawECDHKeyring.Companion_Default___.CurveSpecTypeToString((_this).CurveSpec()))).MapFailure(func(coer118 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} {
   449  			return func(arg119 interface{}) interface{} {
   450  				return coer118(arg119.(_dafny.Sequence))
   451  			}
   452  		}(m_AwsKmsUtils.Companion_Default___.WrapStringToError))
   453  		if (_11_valueOrError5).IsFailure() {
   454  			res = (_11_valueOrError5).PropagateFailure()
   455  			return res
   456  		}
   457  		var _12_curveSpecUtf8 _dafny.Sequence
   458  		_ = _12_curveSpecUtf8
   459  		_12_curveSpecUtf8 = (_11_valueOrError5).Extract().(_dafny.Sequence)
   460  		var _13_valueOrError6 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   461  		_ = _13_valueOrError6
   462  		_13_valueOrError6 = m_CanonicalEncryptionContext.Companion_Default___.EncryptionContextToAAD(((input).Dtor_materials()).Dtor_encryptionContext())
   463  		if (_13_valueOrError6).IsFailure() {
   464  			res = (_13_valueOrError6).PropagateFailure()
   465  			return res
   466  		}
   467  		var _14_canonicalizedEC _dafny.Sequence
   468  		_ = _14_canonicalizedEC
   469  		_14_canonicalizedEC = (_13_valueOrError6).Extract().(_dafny.Sequence)
   470  		var _15_fixedInfo _dafny.Sequence
   471  		_ = _15_fixedInfo
   472  		_15_fixedInfo = m_EcdhEdkWrapping.Companion_Default___.SerializeFixedInfo(m_Constants.Companion_Default___.ECDH__KDF__UTF8(), _12_curveSpecUtf8, _10_operationCompressedSenderPublicKey, (_this).CompressedRecipientPublicKey(), _14_canonicalizedEC, Companion_Default___.AWS__KMS__ECDH__KEYRING__VERSION())
   473  		var _16_ecdhGenerateAndWrap *m_EcdhEdkWrapping.EcdhGenerateAndWrapKeyMaterial
   474  		_ = _16_ecdhGenerateAndWrap
   475  		var _nw0 *m_EcdhEdkWrapping.EcdhGenerateAndWrapKeyMaterial = m_EcdhEdkWrapping.New_EcdhGenerateAndWrapKeyMaterial_()
   476  		_ = _nw0
   477  		_nw0.Ctor__(_9_sharedSecret, _15_fixedInfo, (_this).CryptoPrimitives())
   478  		_16_ecdhGenerateAndWrap = _nw0
   479  		var _17_ecdhWrap *m_EcdhEdkWrapping.EcdhWrapKeyMaterial
   480  		_ = _17_ecdhWrap
   481  		var _nw1 *m_EcdhEdkWrapping.EcdhWrapKeyMaterial = m_EcdhEdkWrapping.New_EcdhWrapKeyMaterial_()
   482  		_ = _nw1
   483  		_nw1.Ctor__(_9_sharedSecret, _15_fixedInfo, (_this).CryptoPrimitives())
   484  		_17_ecdhWrap = _nw1
   485  		var _18_valueOrError7 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_EdkWrapping.Companion_WrapEdkMaterialOutput_.Default(m_EcdhEdkWrapping.Companion_EcdhWrapInfo_.Default()))
   486  		_ = _18_valueOrError7
   487  		var _out1 m_Wrappers.Result
   488  		_ = _out1
   489  		_out1 = m_EdkWrapping.Companion_Default___.WrapEdkMaterial(_4_materials, _17_ecdhWrap, _16_ecdhGenerateAndWrap)
   490  		_18_valueOrError7 = _out1
   491  		if (_18_valueOrError7).IsFailure() {
   492  			res = (_18_valueOrError7).PropagateFailure()
   493  			return res
   494  		}
   495  		var _19_wrapOutput m_EdkWrapping.WrapEdkMaterialOutput
   496  		_ = _19_wrapOutput
   497  		_19_wrapOutput = (_18_valueOrError7).Extract().(m_EdkWrapping.WrapEdkMaterialOutput)
   498  		var _20_symmetricSigningKeyList m_Wrappers.Option
   499  		_ = _20_symmetricSigningKeyList
   500  		if ((_19_wrapOutput).Dtor_symmetricSigningKey()).Is_Some() {
   501  			_20_symmetricSigningKeyList = m_Wrappers.Companion_Option_.Create_Some_(_dafny.SeqOf(((_19_wrapOutput).Dtor_symmetricSigningKey()).Dtor_value().(_dafny.Sequence)))
   502  		} else {
   503  			_20_symmetricSigningKeyList = m_Wrappers.Companion_Option_.Create_None_()
   504  		}
   505  		var _21_valueOrError8 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   506  		_ = _21_valueOrError8
   507  		_21_valueOrError8 = m_Wrappers.Companion_Default___.Need((m_RawECDHKeyring.Companion_Default___.ValidCompressedPublicKeyLength(_10_operationCompressedSenderPublicKey)) && (m_RawECDHKeyring.Companion_Default___.ValidCompressedPublicKeyLength((_this).CompressedRecipientPublicKey())), Companion_Default___.E(_dafny.SeqOfString("Invalid compressed public key length.")))
   508  		if (_21_valueOrError8).IsFailure() {
   509  			res = (_21_valueOrError8).PropagateFailure()
   510  			return res
   511  		}
   512  		var _22_edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey
   513  		_ = _22_edk
   514  		_22_edk = m_AwsCryptographyMaterialProvidersTypes.Companion_EncryptedDataKey_.Create_EncryptedDataKey_(m_Constants.Companion_Default___.KMS__ECDH__PROVIDER__ID(), m_RawECDHKeyring.Companion_Default___.SerializeProviderInfo(_10_operationCompressedSenderPublicKey, (_this).CompressedRecipientPublicKey()), (_19_wrapOutput).Dtor_wrappedMaterial())
   515  		if (_19_wrapOutput).Is_GenerateAndWrapEdkMaterialOutput() {
   516  			var _23_valueOrError9 m_Wrappers.Result = m_Wrappers.Result{}
   517  			_ = _23_valueOrError9
   518  			_23_valueOrError9 = m_Materials.Companion_Default___.EncryptionMaterialAddDataKey(_4_materials, (_19_wrapOutput).Dtor_plaintextDataKey(), _dafny.SeqOf(_22_edk), _20_symmetricSigningKeyList)
   519  			if (_23_valueOrError9).IsFailure() {
   520  				res = (_23_valueOrError9).PropagateFailure()
   521  				return res
   522  			}
   523  			var _24_result m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials
   524  			_ = _24_result
   525  			_24_result = (_23_valueOrError9).Extract().(m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials)
   526  			res = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnEncryptOutput_.Create_OnEncryptOutput_(_24_result))
   527  			return res
   528  		} else if (_19_wrapOutput).Is_WrapOnlyEdkMaterialOutput() {
   529  			var _25_valueOrError10 m_Wrappers.Result = m_Wrappers.Result{}
   530  			_ = _25_valueOrError10
   531  			_25_valueOrError10 = m_Materials.Companion_Default___.EncryptionMaterialAddEncryptedDataKeys(_4_materials, _dafny.SeqOf(_22_edk), _20_symmetricSigningKeyList)
   532  			if (_25_valueOrError10).IsFailure() {
   533  				res = (_25_valueOrError10).PropagateFailure()
   534  				return res
   535  			}
   536  			var _26_result m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials
   537  			_ = _26_result
   538  			_26_result = (_25_valueOrError10).Extract().(m_AwsCryptographyMaterialProvidersTypes.EncryptionMaterials)
   539  			res = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnEncryptOutput_.Create_OnEncryptOutput_(_26_result))
   540  			return res
   541  		}
   542  		return res
   543  	}
   544  }
   545  func (_this *AwsKmsEcdhKeyring) OnDecrypt_k(input m_AwsCryptographyMaterialProvidersTypes.OnDecryptInput) m_Wrappers.Result {
   546  	{
   547  		var res m_Wrappers.Result = m_Wrappers.Result{}
   548  		_ = res
   549  		var _0_materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials
   550  		_ = _0_materials
   551  		_0_materials = (input).Dtor_materials()
   552  		var _1_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo
   553  		_ = _1_suite
   554  		_1_suite = ((input).Dtor_materials()).Dtor_algorithmSuite()
   555  		var _2_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   556  		_ = _2_valueOrError0
   557  		_2_valueOrError0 = m_Wrappers.Companion_Default___.Need(m_Materials.Companion_Default___.DecryptionMaterialsWithoutPlaintextDataKey(_0_materials), Companion_Default___.E(_dafny.SeqOfString("Keyring received decryption materials that already contain a plaintext data key.")))
   558  		if (_2_valueOrError0).IsFailure() {
   559  			res = (_2_valueOrError0).PropagateFailure()
   560  			return res
   561  		}
   562  		var _3_filter *OnDecryptEcdhDataKeyFilter
   563  		_ = _3_filter
   564  		var _nw0 *OnDecryptEcdhDataKeyFilter = New_OnDecryptEcdhDataKeyFilter_()
   565  		_ = _nw0
   566  		_nw0.Ctor__((_this).KeyAgreementScheme(), (_this).CompressedRecipientPublicKey(), (_this).CompressedSenderPublicKey())
   567  		_3_filter = _nw0
   568  		var _4_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   569  		_ = _4_valueOrError1
   570  		var _out0 m_Wrappers.Result
   571  		_ = _out0
   572  		_out0 = m_Actions.Companion_Default___.FilterWithResult(_3_filter, (input).Dtor_encryptedDataKeys())
   573  		_4_valueOrError1 = _out0
   574  		if (_4_valueOrError1).IsFailure() {
   575  			res = (_4_valueOrError1).PropagateFailure()
   576  			return res
   577  		}
   578  		var _5_edksToAttempt _dafny.Sequence
   579  		_ = _5_edksToAttempt
   580  		_5_edksToAttempt = (_4_valueOrError1).Extract().(_dafny.Sequence)
   581  		if (_dafny.IntOfUint32((_5_edksToAttempt).Cardinality())).Sign() == 0 {
   582  			var _6_valueOrError2 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq.SetString())
   583  			_ = _6_valueOrError2
   584  			_6_valueOrError2 = m_ErrorMessages.Companion_Default___.IncorrectDataKeys((input).Dtor_encryptedDataKeys(), ((input).Dtor_materials()).Dtor_algorithmSuite(), _dafny.SeqOfString(""))
   585  			if (_6_valueOrError2).IsFailure() {
   586  				res = (_6_valueOrError2).PropagateFailure()
   587  				return res
   588  			}
   589  			var _7_errorMessage _dafny.Sequence
   590  			_ = _7_errorMessage
   591  			_7_errorMessage = (_6_valueOrError2).Extract().(_dafny.Sequence)
   592  			res = m_Wrappers.Companion_Result_.Create_Failure_(Companion_Default___.E(_7_errorMessage))
   593  			return res
   594  		}
   595  		var _8_decryptClosure m_Actions.ActionWithResult
   596  		_ = _8_decryptClosure
   597  		var _nw1 *DecryptSingleEncryptedDataKey = New_DecryptSingleEncryptedDataKey_()
   598  		_ = _nw1
   599  		_nw1.Ctor__(_0_materials, (_this).CryptoPrimitives(), (_this).CompressedRecipientPublicKey(), (_this).Client(), (_this).GrantTokens(), (_this).KeyAgreementScheme(), (_this).CurveSpec())
   600  		_8_decryptClosure = _nw1
   601  		var _9_outcome m_Wrappers.Result
   602  		_ = _9_outcome
   603  		var _out1 m_Wrappers.Result
   604  		_ = _out1
   605  		_out1 = m_Actions.Companion_Default___.ReduceToSuccess(_8_decryptClosure, _5_edksToAttempt)
   606  		_9_outcome = _out1
   607  		var _10_valueOrError3 m_Wrappers.Result = m_Wrappers.Result{}
   608  		_ = _10_valueOrError3
   609  		_10_valueOrError3 = (_9_outcome).MapFailure(func(coer119 func(_dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error) func(interface{}) interface{} {
   610  			return func(arg120 interface{}) interface{} {
   611  				return coer119(arg120.(_dafny.Sequence))
   612  			}
   613  		}(func(_11_errors _dafny.Sequence) m_AwsCryptographyMaterialProvidersTypes.Error {
   614  			return m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_CollectionOfErrors_(_11_errors, _dafny.SeqOfString("No Configured KMS Key was able to decrypt the Data Key. The list of encountered Exceptions is available via `list`."))
   615  		}))
   616  		if (_10_valueOrError3).IsFailure() {
   617  			res = (_10_valueOrError3).PropagateFailure()
   618  			return res
   619  		}
   620  		var _12_SealedDecryptionMaterials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials
   621  		_ = _12_SealedDecryptionMaterials
   622  		_12_SealedDecryptionMaterials = (_10_valueOrError3).Extract().(m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials)
   623  		res = m_Wrappers.Companion_Result_.Create_Success_(m_AwsCryptographyMaterialProvidersTypes.Companion_OnDecryptOutput_.Create_OnDecryptOutput_(_12_SealedDecryptionMaterials))
   624  		return res
   625  		return res
   626  	}
   627  }
   628  func (_this *AwsKmsEcdhKeyring) Client() m_ComAmazonawsKmsTypes.IKMSClient {
   629  	{
   630  		return _this._client
   631  	}
   632  }
   633  func (_this *AwsKmsEcdhKeyring) CryptoPrimitives() *m_AtomicPrimitives.AtomicPrimitivesClient {
   634  	{
   635  		return _this._cryptoPrimitives
   636  	}
   637  }
   638  func (_this *AwsKmsEcdhKeyring) KeyAgreementScheme() m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations {
   639  	{
   640  		return _this._keyAgreementScheme
   641  	}
   642  }
   643  func (_this *AwsKmsEcdhKeyring) CurveSpec() m_AwsCryptographyPrimitivesTypes.ECDHCurveSpec {
   644  	{
   645  		return _this._curveSpec
   646  	}
   647  }
   648  func (_this *AwsKmsEcdhKeyring) GrantTokens() _dafny.Sequence {
   649  	{
   650  		return _this._grantTokens
   651  	}
   652  }
   653  func (_this *AwsKmsEcdhKeyring) RecipientPublicKey() _dafny.Sequence {
   654  	{
   655  		return _this._recipientPublicKey
   656  	}
   657  }
   658  func (_this *AwsKmsEcdhKeyring) SenderPublicKey() m_Wrappers.Option {
   659  	{
   660  		return _this._senderPublicKey
   661  	}
   662  }
   663  func (_this *AwsKmsEcdhKeyring) CompressedSenderPublicKey() m_Wrappers.Option {
   664  	{
   665  		return _this._compressedSenderPublicKey
   666  	}
   667  }
   668  func (_this *AwsKmsEcdhKeyring) CompressedRecipientPublicKey() _dafny.Sequence {
   669  	{
   670  		return _this._compressedRecipientPublicKey
   671  	}
   672  }
   673  func (_this *AwsKmsEcdhKeyring) SenderKmsKeyId() m_Wrappers.Option {
   674  	{
   675  		return _this._senderKmsKeyId
   676  	}
   677  }
   678  
   679  // End of class AwsKmsEcdhKeyring
   680  
   681  // Definition of class DecryptSingleEncryptedDataKey
   682  type DecryptSingleEncryptedDataKey struct {
   683  	_materials          m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials
   684  	_cryptoPrimitives   *m_AtomicPrimitives.AtomicPrimitivesClient
   685  	_recipientPublicKey _dafny.Sequence
   686  	_keyAgreementScheme m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations
   687  	_client             m_ComAmazonawsKmsTypes.IKMSClient
   688  	_curveSpec          m_AwsCryptographyPrimitivesTypes.ECDHCurveSpec
   689  	_grantTokens        _dafny.Sequence
   690  }
   691  
   692  func New_DecryptSingleEncryptedDataKey_() *DecryptSingleEncryptedDataKey {
   693  	_this := DecryptSingleEncryptedDataKey{}
   694  
   695  	_this._materials = m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials{}
   696  	_this._cryptoPrimitives = (*m_AtomicPrimitives.AtomicPrimitivesClient)(nil)
   697  	_this._recipientPublicKey = _dafny.EmptySeq
   698  	_this._keyAgreementScheme = m_AwsCryptographyMaterialProvidersTypes.Companion_KmsEcdhStaticConfigurations_.Default()
   699  	_this._client = (m_ComAmazonawsKmsTypes.IKMSClient)(nil)
   700  	_this._curveSpec = m_AwsCryptographyPrimitivesTypes.Companion_ECDHCurveSpec_.Default()
   701  	_this._grantTokens = _dafny.EmptySeq
   702  	return &_this
   703  }
   704  
   705  type CompanionStruct_DecryptSingleEncryptedDataKey_ struct {
   706  }
   707  
   708  var Companion_DecryptSingleEncryptedDataKey_ = CompanionStruct_DecryptSingleEncryptedDataKey_{}
   709  
   710  func (_this *DecryptSingleEncryptedDataKey) Equals(other *DecryptSingleEncryptedDataKey) bool {
   711  	return _this == other
   712  }
   713  
   714  func (_this *DecryptSingleEncryptedDataKey) EqualsGeneric(x interface{}) bool {
   715  	other, ok := x.(*DecryptSingleEncryptedDataKey)
   716  	return ok && _this.Equals(other)
   717  }
   718  
   719  func (*DecryptSingleEncryptedDataKey) String() string {
   720  	return "AwsKmsEcdhKeyring.DecryptSingleEncryptedDataKey"
   721  }
   722  
   723  func Type_DecryptSingleEncryptedDataKey_() _dafny.TypeDescriptor {
   724  	return type_DecryptSingleEncryptedDataKey_{}
   725  }
   726  
   727  type type_DecryptSingleEncryptedDataKey_ struct {
   728  }
   729  
   730  func (_this type_DecryptSingleEncryptedDataKey_) Default() interface{} {
   731  	return (*DecryptSingleEncryptedDataKey)(nil)
   732  }
   733  
   734  func (_this type_DecryptSingleEncryptedDataKey_) String() string {
   735  	return "AwsKmsEcdhKeyring.DecryptSingleEncryptedDataKey"
   736  }
   737  func (_this *DecryptSingleEncryptedDataKey) ParentTraits_() []*_dafny.TraitID {
   738  	return [](*_dafny.TraitID){m_Actions.Companion_ActionWithResult_.TraitID_, m_Actions.Companion_Action_.TraitID_}
   739  }
   740  
   741  var _ m_Actions.ActionWithResult = &DecryptSingleEncryptedDataKey{}
   742  var _ m_Actions.Action = &DecryptSingleEncryptedDataKey{}
   743  var _ _dafny.TraitOffspring = &DecryptSingleEncryptedDataKey{}
   744  
   745  func (_this *DecryptSingleEncryptedDataKey) Ctor__(materials m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials, cryptoPrimitives *m_AtomicPrimitives.AtomicPrimitivesClient, recipientPublicKey _dafny.Sequence, client m_ComAmazonawsKmsTypes.IKMSClient, grantTokens _dafny.Sequence, keyAgreementScheme m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations, curveSpec m_AwsCryptographyPrimitivesTypes.ECDHCurveSpec) {
   746  	{
   747  		(_this)._materials = materials
   748  		(_this)._cryptoPrimitives = cryptoPrimitives
   749  		(_this)._recipientPublicKey = recipientPublicKey
   750  		(_this)._keyAgreementScheme = keyAgreementScheme
   751  		(_this)._client = client
   752  		(_this)._curveSpec = curveSpec
   753  		(_this)._grantTokens = grantTokens
   754  	}
   755  }
   756  func (_this *DecryptSingleEncryptedDataKey) Invoke(edk interface{}) interface{} {
   757  	{
   758  		var edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey = edk.(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey)
   759  		_ = edk
   760  		var res m_Wrappers.Result = m_Wrappers.Result{}
   761  		_ = res
   762  		var _0_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   763  		_ = _0_valueOrError0
   764  		_0_valueOrError0 = m_Wrappers.Companion_Default___.Need(m_UTF8.Companion_Default___.ValidUTF8Seq((edk).Dtor_keyProviderId()), m_AwsCryptographyMaterialProvidersTypes.Companion_Error_.Create_AwsCryptographicMaterialProvidersException_(_dafny.SeqOfString("Received invalid EDK provider id for AWS KMS ECDH Keyring")))
   765  		if (_0_valueOrError0).IsFailure() {
   766  			res = (_0_valueOrError0).PropagateFailure()
   767  			return res
   768  		}
   769  		var _1_suite m_AwsCryptographyMaterialProvidersTypes.AlgorithmSuiteInfo
   770  		_ = _1_suite
   771  		_1_suite = ((_this).Materials()).Dtor_algorithmSuite()
   772  		var _2_keyProviderId _dafny.Sequence
   773  		_ = _2_keyProviderId
   774  		_2_keyProviderId = (edk).Dtor_keyProviderId()
   775  		var _3_providerInfo _dafny.Sequence
   776  		_ = _3_providerInfo
   777  		_3_providerInfo = (edk).Dtor_keyProviderInfo()
   778  		var _4_ciphertext _dafny.Sequence
   779  		_ = _4_ciphertext
   780  		_4_ciphertext = (edk).Dtor_ciphertext()
   781  		var _5_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   782  		_ = _5_valueOrError1
   783  		_5_valueOrError1 = m_EdkWrapping.Companion_Default___.GetProviderWrappedMaterial(_4_ciphertext, _1_suite)
   784  		if (_5_valueOrError1).IsFailure() {
   785  			res = (_5_valueOrError1).PropagateFailure()
   786  			return res
   787  		}
   788  		var _6_providerWrappedMaterial _dafny.Sequence
   789  		_ = _6_providerWrappedMaterial
   790  		_6_providerWrappedMaterial = (_5_valueOrError1).Extract().(_dafny.Sequence)
   791  		var _7_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   792  		_ = _7_valueOrError2
   793  		_7_valueOrError2 = m_Wrappers.Companion_Default___.Need(((_dafny.IntOfUint32((_3_providerInfo).Cardinality())).Cmp(_dafny.IntOfUint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__521__LEN())) <= 0) && (m_RawECDHKeyring.Companion_Default___.ValidProviderInfoLength(_3_providerInfo)), Companion_Default___.E(_dafny.SeqOfString("EDK ProviderInfo longer than expected")))
   794  		if (_7_valueOrError2).IsFailure() {
   795  			res = (_7_valueOrError2).PropagateFailure()
   796  			return res
   797  		}
   798  		var _8_keyringVersion uint8
   799  		_ = _8_keyringVersion
   800  		_8_keyringVersion = (_3_providerInfo).Select(0).(uint8)
   801  		var _9_valueOrError3 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   802  		_ = _9_valueOrError3
   803  		_9_valueOrError3 = m_Wrappers.Companion_Default___.Need(_dafny.Companion_Sequence_.Equal(_dafny.SeqOf(_8_keyringVersion), Companion_Default___.AWS__KMS__ECDH__KEYRING__VERSION()), Companion_Default___.E(_dafny.SeqOfString("Incorrect Keyring version found in provider info.")))
   804  		if (_9_valueOrError3).IsFailure() {
   805  			res = (_9_valueOrError3).PropagateFailure()
   806  			return res
   807  		}
   808  		var _10_recipientPublicKeyLength _dafny.Int
   809  		_ = _10_recipientPublicKeyLength
   810  		_10_recipientPublicKeyLength = _dafny.IntOfUint32(m_StandardLibrary_UInt.Companion_Default___.SeqToUInt32((_3_providerInfo).Subsequence(uint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPL__INDEX()), uint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPK__INDEX()))))
   811  		var _11_recipientPublicKeyLengthIndex _dafny.Int
   812  		_ = _11_recipientPublicKeyLengthIndex
   813  		_11_recipientPublicKeyLengthIndex = (_dafny.IntOfUint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPK__INDEX())).Plus(_10_recipientPublicKeyLength)
   814  		var _12_senderPublicKeyIndex _dafny.Int
   815  		_ = _12_senderPublicKeyIndex
   816  		_12_senderPublicKeyIndex = (_11_recipientPublicKeyLengthIndex).Plus(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__PUBLIC__KEY__LEN())
   817  		var _13_valueOrError4 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   818  		_ = _13_valueOrError4
   819  		_13_valueOrError4 = m_Wrappers.Companion_Default___.Need(((_11_recipientPublicKeyLengthIndex).Plus(_dafny.IntOfInt64(4))).Cmp(_dafny.IntOfUint32((_3_providerInfo).Cardinality())) < 0, Companion_Default___.E(_dafny.SeqOfString("Key Provider Info Serialization Error. Serialized length less than expected.")))
   820  		if (_13_valueOrError4).IsFailure() {
   821  			res = (_13_valueOrError4).PropagateFailure()
   822  			return res
   823  		}
   824  		var _14_providerInfoRecipientPublicKey _dafny.Sequence
   825  		_ = _14_providerInfoRecipientPublicKey
   826  		_14_providerInfoRecipientPublicKey = (_3_providerInfo).Subsequence(uint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPK__INDEX()), (_11_recipientPublicKeyLengthIndex).Uint32())
   827  		var _15_providerInfoSenderPublicKey _dafny.Sequence
   828  		_ = _15_providerInfoSenderPublicKey
   829  		_15_providerInfoSenderPublicKey = (_3_providerInfo).Drop((_12_senderPublicKeyIndex).Uint32())
   830  		var _16_valueOrError5 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   831  		_ = _16_valueOrError5
   832  		var _out0 m_Wrappers.Result
   833  		_ = _out0
   834  		_out0 = m_RawECDHKeyring.Companion_Default___.DecompressPublicKey(_15_providerInfoSenderPublicKey, (_this).CurveSpec(), (_this).CryptoPrimitives())
   835  		_16_valueOrError5 = _out0
   836  		if (_16_valueOrError5).IsFailure() {
   837  			res = (_16_valueOrError5).PropagateFailure()
   838  			return res
   839  		}
   840  		var _17_senderPublicKey _dafny.Sequence
   841  		_ = _17_senderPublicKey
   842  		_17_senderPublicKey = (_16_valueOrError5).Extract().(_dafny.Sequence)
   843  		var _18_valueOrError6 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   844  		_ = _18_valueOrError6
   845  		var _out1 m_Wrappers.Result
   846  		_ = _out1
   847  		_out1 = m_RawECDHKeyring.Companion_Default___.DecompressPublicKey(_14_providerInfoRecipientPublicKey, (_this).CurveSpec(), (_this).CryptoPrimitives())
   848  		_18_valueOrError6 = _out1
   849  		if (_18_valueOrError6).IsFailure() {
   850  			res = (_18_valueOrError6).PropagateFailure()
   851  			return res
   852  		}
   853  		var _19_recipientPublicKey _dafny.Sequence
   854  		_ = _19_recipientPublicKey
   855  		_19_recipientPublicKey = (_18_valueOrError6).Extract().(_dafny.Sequence)
   856  		var _20_valueOrError7 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(false)
   857  		_ = _20_valueOrError7
   858  		var _out2 m_Wrappers.Result
   859  		_ = _out2
   860  		_out2 = m_RawECDHKeyring.Companion_Default___.ValidatePublicKey((_this).CryptoPrimitives(), (_this).CurveSpec(), _17_senderPublicKey)
   861  		_20_valueOrError7 = _out2
   862  		if (_20_valueOrError7).IsFailure() {
   863  			res = (_20_valueOrError7).PropagateFailure()
   864  			return res
   865  		}
   866  		var _21___v0 bool
   867  		_ = _21___v0
   868  		_21___v0 = (_20_valueOrError7).Extract().(bool)
   869  		var _22_valueOrError8 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(false)
   870  		_ = _22_valueOrError8
   871  		var _out3 m_Wrappers.Result
   872  		_ = _out3
   873  		_out3 = m_RawECDHKeyring.Companion_Default___.ValidatePublicKey((_this).CryptoPrimitives(), (_this).CurveSpec(), _19_recipientPublicKey)
   874  		_22_valueOrError8 = _out3
   875  		if (_22_valueOrError8).IsFailure() {
   876  			res = (_22_valueOrError8).PropagateFailure()
   877  			return res
   878  		}
   879  		var _23___v1 bool
   880  		_ = _23___v1
   881  		_23___v1 = (_22_valueOrError8).Extract().(bool)
   882  		var _24_valueOrError9 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   883  		_ = _24_valueOrError9
   884  		_24_valueOrError9 = m_Wrappers.Companion_Default___.Need((m_ComAmazonawsKmsTypes.Companion_Default___.IsValid__PublicKeyType(_17_senderPublicKey)) && (m_ComAmazonawsKmsTypes.Companion_Default___.IsValid__PublicKeyType((_this).RecipientPublicKey())), Companion_Default___.E(_dafny.SeqOfString("Received serialized sender public key of incorrect length")))
   885  		if (_24_valueOrError9).IsFailure() {
   886  			res = (_24_valueOrError9).PropagateFailure()
   887  			return res
   888  		}
   889  		var _25_sharedSecretPublicKey _dafny.Sequence = _dafny.EmptySeq
   890  		_ = _25_sharedSecretPublicKey
   891  		var _26_sharedSecretKmsKeyId _dafny.Sequence = _dafny.EmptySeq.SetString()
   892  		_ = _26_sharedSecretKmsKeyId
   893  		var _source0 m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations = (_this).KeyAgreementScheme()
   894  		_ = _source0
   895  		{
   896  			{
   897  				if _source0.Is_KmsPublicKeyDiscovery() {
   898  					var _27_kmsPublicKeyDiscovery m_AwsCryptographyMaterialProvidersTypes.KmsPublicKeyDiscoveryInput = _source0.Get_().(m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations_KmsPublicKeyDiscovery).KmsPublicKeyDiscovery
   899  					_ = _27_kmsPublicKeyDiscovery
   900  					{
   901  						var _28_valueOrError10 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf())
   902  						_ = _28_valueOrError10
   903  						_28_valueOrError10 = m_AwsKmsUtils.Companion_Default___.ValidateKmsKeyId((_27_kmsPublicKeyDiscovery).Dtor_recipientKmsIdentifier())
   904  						if (_28_valueOrError10).IsFailure() {
   905  							res = (_28_valueOrError10).PropagateFailure()
   906  							return res
   907  						}
   908  						var _29___v2 _dafny.Tuple
   909  						_ = _29___v2
   910  						_29___v2 = (_28_valueOrError10).Extract().(_dafny.Tuple)
   911  						_25_sharedSecretPublicKey = _17_senderPublicKey
   912  						_26_sharedSecretKmsKeyId = (_27_kmsPublicKeyDiscovery).Dtor_recipientKmsIdentifier()
   913  					}
   914  					goto Lmatch0
   915  				}
   916  			}
   917  			{
   918  				var _30_kmsPrivateKeyToStaticPublicKey m_AwsCryptographyMaterialProvidersTypes.KmsPrivateKeyToStaticPublicKeyInput = _source0.Get_().(m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations_KmsPrivateKeyToStaticPublicKey).KmsPrivateKeyToStaticPublicKey
   919  				_ = _30_kmsPrivateKeyToStaticPublicKey
   920  				{
   921  					var _31_valueOrError11 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.TupleOf())
   922  					_ = _31_valueOrError11
   923  					_31_valueOrError11 = m_AwsKmsUtils.Companion_Default___.ValidateKmsKeyId((_30_kmsPrivateKeyToStaticPublicKey).Dtor_senderKmsIdentifier())
   924  					if (_31_valueOrError11).IsFailure() {
   925  						res = (_31_valueOrError11).PropagateFailure()
   926  						return res
   927  					}
   928  					var _32___v3 _dafny.Tuple
   929  					_ = _32___v3
   930  					_32___v3 = (_31_valueOrError11).Extract().(_dafny.Tuple)
   931  					_26_sharedSecretKmsKeyId = (_30_kmsPrivateKeyToStaticPublicKey).Dtor_senderKmsIdentifier()
   932  					if _dafny.Companion_Sequence_.Equal((_30_kmsPrivateKeyToStaticPublicKey).Dtor_recipientPublicKey(), _19_recipientPublicKey) {
   933  						_25_sharedSecretPublicKey = _19_recipientPublicKey
   934  					} else {
   935  						_25_sharedSecretPublicKey = _17_senderPublicKey
   936  					}
   937  				}
   938  			}
   939  			goto Lmatch0
   940  		}
   941  	Lmatch0:
   942  		var _33_valueOrError12 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
   943  		_ = _33_valueOrError12
   944  		_33_valueOrError12 = m_Wrappers.Companion_Default___.Need(m_ComAmazonawsKmsTypes.Companion_Default___.IsValid__PublicKeyType(_25_sharedSecretPublicKey), Companion_Default___.E(_dafny.SeqOfString("Received Recipient Public Key of incorrect expected length")))
   945  		if (_33_valueOrError12).IsFailure() {
   946  			res = (_33_valueOrError12).PropagateFailure()
   947  			return res
   948  		}
   949  		var _34_valueOrError13 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(_dafny.EmptySeq)
   950  		_ = _34_valueOrError13
   951  		var _out4 m_Wrappers.Result
   952  		_ = _out4
   953  		_out4 = Companion_Default___.DeriveSharedSecret((_this).Client(), _26_sharedSecretKmsKeyId, _25_sharedSecretPublicKey, (_this).GrantTokens())
   954  		_34_valueOrError13 = _out4
   955  		if (_34_valueOrError13).IsFailure() {
   956  			res = (_34_valueOrError13).PropagateFailure()
   957  			return res
   958  		}
   959  		var _35_sharedSecret _dafny.Sequence
   960  		_ = _35_sharedSecret
   961  		_35_sharedSecret = (_34_valueOrError13).Extract().(_dafny.Sequence)
   962  		var _36_ecdhUnwrap *m_EcdhEdkWrapping.EcdhUnwrap
   963  		_ = _36_ecdhUnwrap
   964  		var _nw0 *m_EcdhEdkWrapping.EcdhUnwrap = m_EcdhEdkWrapping.New_EcdhUnwrap_()
   965  		_ = _nw0
   966  		_nw0.Ctor__(_15_providerInfoSenderPublicKey, _14_providerInfoRecipientPublicKey, _35_sharedSecret, Companion_Default___.AWS__KMS__ECDH__KEYRING__VERSION(), (_this).CurveSpec(), (_this).CryptoPrimitives())
   967  		_36_ecdhUnwrap = _nw0
   968  		var _37_unwrapOutputRes m_Wrappers.Result
   969  		_ = _37_unwrapOutputRes
   970  		var _out5 m_Wrappers.Result
   971  		_ = _out5
   972  		_out5 = m_EdkWrapping.Companion_Default___.UnwrapEdkMaterial((edk).Dtor_ciphertext(), (_this).Materials(), _36_ecdhUnwrap)
   973  		_37_unwrapOutputRes = _out5
   974  		var _38_valueOrError14 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_EdkWrapping.Companion_UnwrapEdkMaterialOutput_.Default(m_EcdhEdkWrapping.Companion_EcdhUnwrapInfo_.Default()))
   975  		_ = _38_valueOrError14
   976  		_38_valueOrError14 = _37_unwrapOutputRes
   977  		if (_38_valueOrError14).IsFailure() {
   978  			res = (_38_valueOrError14).PropagateFailure()
   979  			return res
   980  		}
   981  		var _39_unwrapOutput m_EdkWrapping.UnwrapEdkMaterialOutput
   982  		_ = _39_unwrapOutput
   983  		_39_unwrapOutput = (_38_valueOrError14).Extract().(m_EdkWrapping.UnwrapEdkMaterialOutput)
   984  		var _40_valueOrError15 m_Wrappers.Result = m_Wrappers.Result{}
   985  		_ = _40_valueOrError15
   986  		_40_valueOrError15 = m_Materials.Companion_Default___.DecryptionMaterialsAddDataKey((_this).Materials(), (_39_unwrapOutput).Dtor_plaintextDataKey(), (_39_unwrapOutput).Dtor_symmetricSigningKey())
   987  		if (_40_valueOrError15).IsFailure() {
   988  			res = (_40_valueOrError15).PropagateFailure()
   989  			return res
   990  		}
   991  		var _41_result m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials
   992  		_ = _41_result
   993  		_41_result = (_40_valueOrError15).Extract().(m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials)
   994  		res = m_Wrappers.Companion_Result_.Create_Success_(_41_result)
   995  		return res
   996  		return res
   997  	}
   998  }
   999  func (_this *DecryptSingleEncryptedDataKey) Materials() m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials {
  1000  	{
  1001  		return _this._materials
  1002  	}
  1003  }
  1004  func (_this *DecryptSingleEncryptedDataKey) CryptoPrimitives() *m_AtomicPrimitives.AtomicPrimitivesClient {
  1005  	{
  1006  		return _this._cryptoPrimitives
  1007  	}
  1008  }
  1009  func (_this *DecryptSingleEncryptedDataKey) RecipientPublicKey() _dafny.Sequence {
  1010  	{
  1011  		return _this._recipientPublicKey
  1012  	}
  1013  }
  1014  func (_this *DecryptSingleEncryptedDataKey) KeyAgreementScheme() m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations {
  1015  	{
  1016  		return _this._keyAgreementScheme
  1017  	}
  1018  }
  1019  func (_this *DecryptSingleEncryptedDataKey) Client() m_ComAmazonawsKmsTypes.IKMSClient {
  1020  	{
  1021  		return _this._client
  1022  	}
  1023  }
  1024  func (_this *DecryptSingleEncryptedDataKey) CurveSpec() m_AwsCryptographyPrimitivesTypes.ECDHCurveSpec {
  1025  	{
  1026  		return _this._curveSpec
  1027  	}
  1028  }
  1029  func (_this *DecryptSingleEncryptedDataKey) GrantTokens() _dafny.Sequence {
  1030  	{
  1031  		return _this._grantTokens
  1032  	}
  1033  }
  1034  
  1035  // End of class DecryptSingleEncryptedDataKey
  1036  
  1037  // Definition of class OnDecryptEcdhDataKeyFilter
  1038  type OnDecryptEcdhDataKeyFilter struct {
  1039  	_keyAgreementScheme           m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations
  1040  	_compressedRecipientPublicKey _dafny.Sequence
  1041  	_compressedSenderPublicKey    _dafny.Sequence
  1042  }
  1043  
  1044  func New_OnDecryptEcdhDataKeyFilter_() *OnDecryptEcdhDataKeyFilter {
  1045  	_this := OnDecryptEcdhDataKeyFilter{}
  1046  
  1047  	_this._keyAgreementScheme = m_AwsCryptographyMaterialProvidersTypes.Companion_KmsEcdhStaticConfigurations_.Default()
  1048  	_this._compressedRecipientPublicKey = _dafny.EmptySeq
  1049  	_this._compressedSenderPublicKey = _dafny.EmptySeq
  1050  	return &_this
  1051  }
  1052  
  1053  type CompanionStruct_OnDecryptEcdhDataKeyFilter_ struct {
  1054  }
  1055  
  1056  var Companion_OnDecryptEcdhDataKeyFilter_ = CompanionStruct_OnDecryptEcdhDataKeyFilter_{}
  1057  
  1058  func (_this *OnDecryptEcdhDataKeyFilter) Equals(other *OnDecryptEcdhDataKeyFilter) bool {
  1059  	return _this == other
  1060  }
  1061  
  1062  func (_this *OnDecryptEcdhDataKeyFilter) EqualsGeneric(x interface{}) bool {
  1063  	other, ok := x.(*OnDecryptEcdhDataKeyFilter)
  1064  	return ok && _this.Equals(other)
  1065  }
  1066  
  1067  func (*OnDecryptEcdhDataKeyFilter) String() string {
  1068  	return "AwsKmsEcdhKeyring.OnDecryptEcdhDataKeyFilter"
  1069  }
  1070  
  1071  func Type_OnDecryptEcdhDataKeyFilter_() _dafny.TypeDescriptor {
  1072  	return type_OnDecryptEcdhDataKeyFilter_{}
  1073  }
  1074  
  1075  type type_OnDecryptEcdhDataKeyFilter_ struct {
  1076  }
  1077  
  1078  func (_this type_OnDecryptEcdhDataKeyFilter_) Default() interface{} {
  1079  	return (*OnDecryptEcdhDataKeyFilter)(nil)
  1080  }
  1081  
  1082  func (_this type_OnDecryptEcdhDataKeyFilter_) String() string {
  1083  	return "AwsKmsEcdhKeyring.OnDecryptEcdhDataKeyFilter"
  1084  }
  1085  func (_this *OnDecryptEcdhDataKeyFilter) ParentTraits_() []*_dafny.TraitID {
  1086  	return [](*_dafny.TraitID){m_Actions.Companion_DeterministicActionWithResult_.TraitID_, m_Actions.Companion_DeterministicAction_.TraitID_}
  1087  }
  1088  
  1089  var _ m_Actions.DeterministicActionWithResult = &OnDecryptEcdhDataKeyFilter{}
  1090  var _ m_Actions.DeterministicAction = &OnDecryptEcdhDataKeyFilter{}
  1091  var _ _dafny.TraitOffspring = &OnDecryptEcdhDataKeyFilter{}
  1092  
  1093  func (_this *OnDecryptEcdhDataKeyFilter) Ctor__(keyAgreementScheme m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations, compressedRecipientPublicKey _dafny.Sequence, compressedSenderPublicKey m_Wrappers.Option) {
  1094  	{
  1095  		(_this)._keyAgreementScheme = keyAgreementScheme
  1096  		(_this)._compressedRecipientPublicKey = compressedRecipientPublicKey
  1097  		if (compressedSenderPublicKey).Is_Some() {
  1098  			(_this)._compressedSenderPublicKey = (compressedSenderPublicKey).Dtor_value().(_dafny.Sequence)
  1099  		} else {
  1100  			(_this)._compressedSenderPublicKey = _dafny.SeqOf()
  1101  		}
  1102  	}
  1103  }
  1104  func (_this *OnDecryptEcdhDataKeyFilter) Invoke(edk interface{}) interface{} {
  1105  	{
  1106  		var edk m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey = edk.(m_AwsCryptographyMaterialProvidersTypes.EncryptedDataKey)
  1107  		_ = edk
  1108  		var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(false)
  1109  		_ = res
  1110  		var _0_providerInfo _dafny.Sequence
  1111  		_ = _0_providerInfo
  1112  		_0_providerInfo = (edk).Dtor_keyProviderInfo()
  1113  		var _1_providerId _dafny.Sequence
  1114  		_ = _1_providerId
  1115  		_1_providerId = (edk).Dtor_keyProviderId()
  1116  		if (!_dafny.Companion_Sequence_.Equal(_1_providerId, m_Constants.Companion_Default___.RAW__ECDH__PROVIDER__ID())) && (!_dafny.Companion_Sequence_.Equal(_1_providerId, m_Constants.Companion_Default___.KMS__ECDH__PROVIDER__ID())) {
  1117  			res = m_Wrappers.Companion_Result_.Create_Success_(false)
  1118  			return res
  1119  		}
  1120  		var _2_valueOrError0 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
  1121  		_ = _2_valueOrError0
  1122  		_2_valueOrError0 = m_Wrappers.Companion_Default___.Need(((_dafny.IntOfUint32((_0_providerInfo).Cardinality())).Cmp(_dafny.IntOfUint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__521__LEN())) <= 0) && (m_RawECDHKeyring.Companion_Default___.ValidProviderInfoLength(_0_providerInfo)), Companion_Default___.E(_dafny.SeqOfString("EDK ProviderInfo longer than expected")))
  1123  		if (_2_valueOrError0).IsFailure() {
  1124  			res = (_2_valueOrError0).PropagateFailure()
  1125  			return res
  1126  		}
  1127  		var _3_keyringVersion uint8
  1128  		_ = _3_keyringVersion
  1129  		_3_keyringVersion = (_0_providerInfo).Select(0).(uint8)
  1130  		var _4_valueOrError1 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
  1131  		_ = _4_valueOrError1
  1132  		_4_valueOrError1 = m_Wrappers.Companion_Default___.Need(_dafny.Companion_Sequence_.Equal(_dafny.SeqOf(_3_keyringVersion), Companion_Default___.AWS__KMS__ECDH__KEYRING__VERSION()), Companion_Default___.E(_dafny.SeqOfString("Incorrect Keyring version found in provider info.")))
  1133  		if (_4_valueOrError1).IsFailure() {
  1134  			res = (_4_valueOrError1).PropagateFailure()
  1135  			return res
  1136  		}
  1137  		var _5_recipientPublicKeyLength _dafny.Int
  1138  		_ = _5_recipientPublicKeyLength
  1139  		_5_recipientPublicKeyLength = _dafny.IntOfUint32(m_StandardLibrary_UInt.Companion_Default___.SeqToUInt32((_0_providerInfo).Subsequence(uint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPL__INDEX()), uint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPK__INDEX()))))
  1140  		var _6_recipientPublicKeyLengthIndex _dafny.Int
  1141  		_ = _6_recipientPublicKeyLengthIndex
  1142  		_6_recipientPublicKeyLengthIndex = (_dafny.IntOfUint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPK__INDEX())).Plus(_5_recipientPublicKeyLength)
  1143  		var _7_senderPublicKeyIndex _dafny.Int
  1144  		_ = _7_senderPublicKeyIndex
  1145  		_7_senderPublicKeyIndex = (_6_recipientPublicKeyLengthIndex).Plus(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__PUBLIC__KEY__LEN())
  1146  		var _8_valueOrError2 m_Wrappers.Outcome = m_Wrappers.Companion_Outcome_.Default()
  1147  		_ = _8_valueOrError2
  1148  		_8_valueOrError2 = m_Wrappers.Companion_Default___.Need(((_6_recipientPublicKeyLengthIndex).Plus(_dafny.IntOfInt64(4))).Cmp(_dafny.IntOfUint32((_0_providerInfo).Cardinality())) < 0, Companion_Default___.E(_dafny.SeqOfString("Key Provider Info Serialization Error. Serialized length less than expected.")))
  1149  		if (_8_valueOrError2).IsFailure() {
  1150  			res = (_8_valueOrError2).PropagateFailure()
  1151  			return res
  1152  		}
  1153  		var _9_providerInfoRecipientPublicKey _dafny.Sequence
  1154  		_ = _9_providerInfoRecipientPublicKey
  1155  		_9_providerInfoRecipientPublicKey = (_0_providerInfo).Subsequence(uint32(m_Constants.Companion_Default___.ECDH__PROVIDER__INFO__RPK__INDEX()), (_6_recipientPublicKeyLengthIndex).Uint32())
  1156  		var _10_providerInfoSenderPublicKey _dafny.Sequence
  1157  		_ = _10_providerInfoSenderPublicKey
  1158  		_10_providerInfoSenderPublicKey = (_0_providerInfo).Drop((_7_senderPublicKeyIndex).Uint32())
  1159  		if ((_this).KeyAgreementScheme()).Is_KmsPublicKeyDiscovery() {
  1160  			res = m_Wrappers.Companion_Result_.Create_Success_(_dafny.Companion_Sequence_.Equal((_this).CompressedRecipientPublicKey(), _9_providerInfoRecipientPublicKey))
  1161  			return res
  1162  		} else {
  1163  			res = m_Wrappers.Companion_Result_.Create_Success_(((_dafny.Companion_Sequence_.Equal((_this).CompressedSenderPublicKey(), _10_providerInfoSenderPublicKey)) && (_dafny.Companion_Sequence_.Equal((_this).CompressedRecipientPublicKey(), _9_providerInfoRecipientPublicKey))) || ((_dafny.Companion_Sequence_.Equal((_this).CompressedSenderPublicKey(), _9_providerInfoRecipientPublicKey)) && (_dafny.Companion_Sequence_.Equal((_this).CompressedRecipientPublicKey(), _10_providerInfoSenderPublicKey))))
  1164  			return res
  1165  		}
  1166  		return res
  1167  	}
  1168  }
  1169  func (_this *OnDecryptEcdhDataKeyFilter) KeyAgreementScheme() m_AwsCryptographyMaterialProvidersTypes.KmsEcdhStaticConfigurations {
  1170  	{
  1171  		return _this._keyAgreementScheme
  1172  	}
  1173  }
  1174  func (_this *OnDecryptEcdhDataKeyFilter) CompressedRecipientPublicKey() _dafny.Sequence {
  1175  	{
  1176  		return _this._compressedRecipientPublicKey
  1177  	}
  1178  }
  1179  func (_this *OnDecryptEcdhDataKeyFilter) CompressedSenderPublicKey() _dafny.Sequence {
  1180  	{
  1181  		return _this._compressedSenderPublicKey
  1182  	}
  1183  }
  1184  
  1185  // End of class OnDecryptEcdhDataKeyFilter