From 38d56db428e06818c769d13863db2bcf00fdc7d2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juli=C3=A1n=20Toledano?= Date: Wed, 24 Jan 2024 14:13:25 +0100 Subject: [PATCH] fix(x/auth): check if simulation in verifyIsOnCurve (#19099) Co-authored-by: Marko Co-authored-by: Aleksandr Bezobchuk --- x/auth/CHANGELOG.md | 5 +++++ x/auth/ante/sigverify.go | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/x/auth/CHANGELOG.md b/x/auth/CHANGELOG.md index ffd25882fa..9c7dbacbd0 100644 --- a/x/auth/CHANGELOG.md +++ b/x/auth/CHANGELOG.md @@ -48,3 +48,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ * [#18817](https://github.com/cosmos/cosmos-sdk/pull/18817) SigVerification, GasConsumption, IncreaseSequence ante decorators have all been joined into one SigVerification decorator. Gas consumption during TX validation flow has reduced. * [#19093](https://github.com/cosmos/cosmos-sdk/pull/19093) SetPubKeyDecorator was merged into SigVerification, gas consumption is almost halved for a simple tx. + +### Bug Fixes + +* [#19099](https://github.com/cosmos/cosmos-sdk/pull/19099) `verifyIsOnCurve` now checks if we are simulating to avoid malformed public key error. + diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 4a9109ff6b..99fe0da3f1 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -95,6 +95,11 @@ func OnlyLegacyAminoSigners(sigData signing.SignatureData) bool { } func verifyIsOnCurve(pubKey cryptotypes.PubKey) (err error) { + // when simulating pubKey.Key will always be nil + if pubKey.Bytes() == nil { + return nil + } + switch typedPubKey := pubKey.(type) { case *secp256k1.PubKey: pubKeyObject, err := secp256k1dcrd.ParsePubKey(typedPubKey.Bytes())