Add support for TM secp256k1 (#7838)
* Add secp256k1 support * Fix test * Add test in handler_test * Use table tests Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
)
|
||||
@@ -17,6 +18,10 @@ func FromTmProtoPublicKey(protoPk tmprotocrypto.PublicKey) (cryptotypes.PubKey,
|
||||
return &ed25519.PubKey{
|
||||
Key: protoPk.Ed25519,
|
||||
}, nil
|
||||
case *tmprotocrypto.PublicKey_Secp256K1:
|
||||
return &secp256k1.PubKey{
|
||||
Key: protoPk.Secp256K1,
|
||||
}, nil
|
||||
default:
|
||||
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v from Tendermint public key", protoPk)
|
||||
}
|
||||
@@ -31,6 +36,12 @@ func ToTmProtoPublicKey(pk cryptotypes.PubKey) (tmprotocrypto.PublicKey, error)
|
||||
Ed25519: pk.Key,
|
||||
},
|
||||
}, nil
|
||||
case *secp256k1.PubKey:
|
||||
return tmprotocrypto.PublicKey{
|
||||
Sum: &tmprotocrypto.PublicKey_Secp256K1{
|
||||
Secp256K1: pk.Key,
|
||||
},
|
||||
}, nil
|
||||
default:
|
||||
return tmprotocrypto.PublicKey{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v to Tendermint public key", pk)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user