@@ -188,7 +188,10 @@ func processSig(
188188 consumeSimSigGas (ctx .GasMeter (), pubKey , sig , params )
189189 }
190190
191- consumeSigVerificationGas (ctx .GasMeter (), sig .Signature , pubKey , params )
191+ if res := consumeSigVerificationGas (ctx .GasMeter (), sig .Signature , pubKey , params ); ! res .IsOK () {
192+ return nil , res
193+ }
194+
192195 if ! simulate && ! pubKey .VerifyBytes (signBytes , sig .Signature ) {
193196 return nil , sdk .ErrUnauthorized ("signature verification failed" ).Result ()
194197 }
@@ -256,24 +259,31 @@ func ProcessPubKey(acc Account, sig StdSignature, simulate bool) (crypto.PubKey,
256259// by the concrete type.
257260//
258261// TODO: Design a cleaner and flexible way to match concrete public key types.
259- func consumeSigVerificationGas (meter sdk.GasMeter , sig []byte , pubkey crypto.PubKey , params Params ) {
262+ func consumeSigVerificationGas (
263+ meter sdk.GasMeter , sig []byte , pubkey crypto.PubKey , params Params ,
264+ ) sdk.Result {
265+
260266 pubkeyType := strings .ToLower (fmt .Sprintf ("%T" , pubkey ))
267+
261268 switch {
262269 case strings .Contains (pubkeyType , "ed25519" ):
263270 meter .ConsumeGas (params .SigVerifyCostED25519 , "ante verify: ed25519" )
271+ return sdk .ErrInvalidPubKey ("ED25519 public keys are unsupported" ).Result ()
264272
265273 case strings .Contains (pubkeyType , "secp256k1" ):
266274 meter .ConsumeGas (params .SigVerifyCostSecp256k1 , "ante verify: secp256k1" )
275+ return sdk.Result {}
267276
268277 case strings .Contains (pubkeyType , "multisigthreshold" ):
269278 var multisignature multisig.Multisignature
270279 codec .Cdc .MustUnmarshalBinaryBare (sig , & multisignature )
271280
272281 multisigPubKey := pubkey .(multisig.PubKeyMultisigThreshold )
273282 consumeMultisignatureVerificationGas (meter , multisignature , multisigPubKey , params )
283+ return sdk.Result {}
274284
275285 default :
276- panic (fmt .Sprintf ("unrecognized signature type: %s" , pubkeyType ))
286+ return sdk . ErrInvalidPubKey (fmt .Sprintf ("unrecognized public key type: %s" , pubkeyType )). Result ( )
277287 }
278288}
279289
0 commit comments