func()

in releases/go/encryption-sdk/EncryptDecryptHelpers/EncryptDecryptHelpers.go [314:367]


func (_static *CompanionStruct_Default___) VerifySignature(buffer m_SerializeFunctions.ReadableBuffer, msg _dafny.Sequence, decMat m_AwsCryptographyMaterialProvidersTypes.DecryptionMaterials, crypto *m_AtomicPrimitives.AtomicPrimitivesClient) m_Wrappers.Result {
	var res m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_SerializeFunctions.Companion_ReadableBuffer_.Default())
	_ = res
	if ((decMat).Dtor_verificationKey()).Is_None() {
		res = m_Wrappers.Companion_Result_.Create_Success_(buffer)
		return res
	}
	var _0_valueOrError0 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(m_SerializeFunctions.Companion_SuccessfulRead_.Default(_dafny.EmptySeq))
	_ = _0_valueOrError0
	_0_valueOrError0 = (m_SerializeFunctions.Companion_Default___.ReadShortLengthSeq(buffer)).MapFailure(func(coer15 func(m_SerializeFunctions.ReadProblems) m_AwsCryptographyEncryptionSdkTypes.Error) func(interface{}) interface{} {
		return func(arg16 interface{}) interface{} {
			return coer15(arg16.(m_SerializeFunctions.ReadProblems))
		}
	}(Companion_Default___.MapSerializeFailure(_dafny.SeqOfString(": ReadShortLengthSeq"))))
	if (_0_valueOrError0).IsFailure() {
		res = (_0_valueOrError0).PropagateFailure()
		return res
	}
	var _1_signature m_SerializeFunctions.SuccessfulRead
	_ = _1_signature
	_1_signature = (_0_valueOrError0).Extract().(m_SerializeFunctions.SuccessfulRead)
	var _2_ecdsaParams m_AwsCryptographyPrimitivesTypes.ECDSASignatureAlgorithm
	_ = _2_ecdsaParams
	_2_ecdsaParams = ((((decMat).Dtor_algorithmSuite()).Dtor_signature()).Dtor_ECDSA()).Dtor_curve()
	var _3_maybeSignatureVerifiedResult m_Wrappers.Result
	_ = _3_maybeSignatureVerifiedResult
	var _out0 m_Wrappers.Result
	_ = _out0
	_out0 = (crypto).ECDSAVerify(m_AwsCryptographyPrimitivesTypes.Companion_ECDSAVerifyInput_.Create_ECDSAVerifyInput_(_2_ecdsaParams, ((decMat).Dtor_verificationKey()).Dtor_value().(_dafny.Sequence), msg, (_1_signature).Dtor_data().(_dafny.Sequence)))
	_3_maybeSignatureVerifiedResult = _out0
	var _4_valueOrError1 m_Wrappers.Result = m_Wrappers.Companion_Result_.Default(false)
	_ = _4_valueOrError1
	_4_valueOrError1 = (_3_maybeSignatureVerifiedResult).MapFailure(func(coer16 func(m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error) func(interface{}) interface{} {
		return func(arg17 interface{}) interface{} {
			return coer16(arg17.(m_AwsCryptographyPrimitivesTypes.Error))
		}
	}(func(_5_e m_AwsCryptographyPrimitivesTypes.Error) m_AwsCryptographyEncryptionSdkTypes.Error {
		return m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsCryptographyPrimitives_(_5_e)
	}))
	if (_4_valueOrError1).IsFailure() {
		res = (_4_valueOrError1).PropagateFailure()
		return res
	}
	var _6_signatureVerifiedResult bool
	_ = _6_signatureVerifiedResult
	_6_signatureVerifiedResult = (_4_valueOrError1).Extract().(bool)
	if !(_6_signatureVerifiedResult) {
		res = m_Wrappers.Companion_Result_.Create_Failure_(m_AwsCryptographyEncryptionSdkTypes.Companion_Error_.Create_AwsEncryptionSdkException_(_dafny.SeqOfString("Invalid signature")))
		return res
	}
	res = m_Wrappers.Companion_Result_.Create_Success_((_1_signature).Dtor_tail())
	return res
	return res
}