Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace tmcrypto.PubKey by our own cryptotypes.PubKey #7419

Merged
merged 37 commits into from
Nov 9, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
735e283
WIP on removing tm pub/privkey
blushi Sep 25, 2020
a328fff
Merge branch 'master' into marie/7357-sdk-pubkey
blushi Sep 30, 2020
c35c504
Fix part of crypto tests
blushi Sep 30, 2020
597e52e
Add PrivKeyLedgerSecp256K1 proto type
blushi Sep 30, 2020
bc80e35
Merge branch 'master' into marie/7357-sdk-pubkey
blushi Sep 30, 2020
73554f8
Use BasePrivKey for ledger priv key type
blushi Oct 1, 2020
dac3a5f
Merge branch 'master' into marie/7357-sdk-pubkey
blushi Oct 1, 2020
40bf06d
Merge branch 'master' into marie/7357-sdk-pubkey
blushi Oct 14, 2020
8b53143
Merge branch 'master' into marie/7357-sdk-pubkey
blushi Oct 15, 2020
b486ced
Refacto continued
blushi Oct 16, 2020
e186e34
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into mari…
amaury1093 Nov 4, 2020
8d30ba4
First round
amaury1093 Nov 4, 2020
8f2d66e
x/staking
amaury1093 Nov 4, 2020
51a353f
Continue porting
amaury1093 Nov 4, 2020
7c9d764
x/* done
amaury1093 Nov 4, 2020
173ff81
Make build pass
amaury1093 Nov 4, 2020
1fdc967
More conversion
amaury1093 Nov 4, 2020
57582ed
Remove IntoTmPubKey
amaury1093 Nov 4, 2020
c4643b9
Fix test
amaury1093 Nov 4, 2020
c1b5137
Remove crypto.PubKey in some other places
amaury1093 Nov 4, 2020
019055e
Revert ledger changes
amaury1093 Nov 6, 2020
ea134ea
Fix comment
amaury1093 Nov 6, 2020
1599b14
Merge branch 'master' into marie/7357-sdk-pubkey
amaury1093 Nov 6, 2020
c9f0aef
Merge branch 'master' into marie/7357-sdk-pubkey
amaury1093 Nov 6, 2020
4684bf0
Remove useless function
amaury1093 Nov 6, 2020
27210a0
Merge branch 'marie/7357-sdk-pubkey' of ssh://github.com/cosmos/cosmo…
amaury1093 Nov 6, 2020
189590a
Add To/FromTmPublicKey
amaury1093 Nov 6, 2020
19be854
Add migrate tests
amaury1093 Nov 6, 2020
a35a905
Fix test
amaury1093 Nov 6, 2020
fffd3f4
Fix another test
amaury1093 Nov 6, 2020
545e619
Rename tm conversion functions
amaury1093 Nov 9, 2020
e422dbb
Less code
amaury1093 Nov 9, 2020
0048063
Rename BasePrivKey to LedgerPrivKey
amaury1093 Nov 9, 2020
f0d97b9
Merge branch 'master' into marie/7357-sdk-pubkey
amaury1093 Nov 9, 2020
62e8f69
Add changelog
amaury1093 Nov 9, 2020
3c72331
Rename functions
amaury1093 Nov 9, 2020
9800d82
Merge branch 'master' into marie/7357-sdk-pubkey
Nov 9, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions client/account_retriever.go
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
package client

import (
"github.com/tendermint/tendermint/crypto"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

// Account defines a read-only version of the auth module's AccountI.
type Account interface {
GetAddress() sdk.AccAddress
GetPubKey() crypto.PubKey // can return nil.
GetPubKey() cryptotypes.PubKey // can return nil.
GetAccountNumber() uint64
GetSequence() uint64
}
Expand Down
4 changes: 2 additions & 2 deletions client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import (
"strings"

"github.com/spf13/cobra"
"github.com/tendermint/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/version"
Expand All @@ -34,7 +34,7 @@ func Cmd() *cobra.Command {
// getPubKeyFromString returns a Tendermint PubKey (PubKeyEd25519) by attempting
// to decode the pubkey string from hex, base64, and finally bech32. If all
// encodings fail, an error is returned.
func getPubKeyFromString(pkstr string) (crypto.PubKey, error) {
func getPubKeyFromString(pkstr string) (cryptotypes.PubKey, error) {
bz, err := hex.DecodeString(pkstr)
if err == nil {
if len(bz) == ed25519.PubKeySize {
Expand Down
6 changes: 3 additions & 3 deletions client/keys/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

bip39 "github.com/cosmos/go-bip39"
"github.com/spf13/cobra"
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/libs/cli"

"github.com/cosmos/cosmos-sdk/client"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -152,7 +152,7 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keyring.Keyring, inBuf *buf

multisigKeys, _ := cmd.Flags().GetStringSlice(flagMultisig)
if len(multisigKeys) != 0 {
var pks []crypto.PubKey
var pks []cryptotypes.PubKey

multisigThreshold, _ := cmd.Flags().GetInt(flagMultiSigThreshold)
if err := validateMultisigThreshold(multisigThreshold, len(multisigKeys)); err != nil {
Expand Down Expand Up @@ -247,7 +247,7 @@ func RunAddCmd(cmd *cobra.Command, args []string, kb keyring.Keyring, inBuf *buf
}

if len(mnemonic) == 0 {
// read entropy seed straight from crypto.Rand and convert to mnemonic
// read entropy seed straight from tmcrypto.Rand and convert to mnemonic
entropySeed, err := bip39.NewEntropy(mnemonicEntropySize)
if err != nil {
return err
Expand Down
4 changes: 2 additions & 2 deletions client/keys/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"fmt"

"github.com/spf13/cobra"
tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/libs/cli"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/ledger"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -61,7 +61,7 @@ func runShowCmd(cmd *cobra.Command, args []string) (err error) {
return fmt.Errorf("%s is not a valid name or address: %v", args[0], err)
}
} else {
pks := make([]tmcrypto.PubKey, len(args))
pks := make([]cryptotypes.PubKey, len(args))
for i, keyref := range args {
info, err := fetchKey(clientCtx.Keyring, keyref)
if err != nil {
Expand Down
5 changes: 2 additions & 3 deletions client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import (

"github.com/stretchr/testify/require"

"github.com/tendermint/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/testutil"
sdk "github.com/cosmos/cosmos-sdk/types"
)
Expand All @@ -23,7 +22,7 @@ func Test_multiSigKey_Properties(t *testing.T) {
tmpKey1 := secp256k1.GenPrivKeyFromSecret([]byte("mySecret"))
pk := multisig.NewLegacyAminoPubKey(
1,
[]crypto.PubKey{tmpKey1.PubKey()},
[]cryptotypes.PubKey{tmpKey1.PubKey()},
)
tmp := keyring.NewMultiInfo("myMultisig", pk)

Expand Down
7 changes: 6 additions & 1 deletion client/rpc/validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/types/rest"
)
Expand Down Expand Up @@ -99,7 +100,11 @@ func (rvo ResultValidatorsOutput) String() string {
}

func bech32ValidatorOutput(validator *tmtypes.Validator) (ValidatorOutput, error) {
bechValPubkey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, validator.PubKey)
pk, err := cryptocodec.FromTmPubKey(validator.PubKey)
if err != nil {
return ValidatorOutput{}, err
}
bechValPubkey, err := sdk.Bech32ifyPubKey(sdk.Bech32PubKeyTypeConsPub, pk)
if err != nil {
return ValidatorOutput{}, err
}
Expand Down
5 changes: 2 additions & 3 deletions client/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ package client
import (
"fmt"

"github.com/tendermint/tendermint/crypto"

cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
)

Expand All @@ -26,7 +25,7 @@ func (t TestAccount) GetAddress() sdk.AccAddress {
}

// GetPubKey implements client Account.GetPubKey
func (t TestAccount) GetPubKey() crypto.PubKey {
func (t TestAccount) GetPubKey() cryptotypes.PubKey {
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions client/tx/tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import (
"os"

"github.com/spf13/pflag"
"github.com/tendermint/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/client/flags"
"github.com/cosmos/cosmos-sdk/client/input"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/rest"
Expand Down Expand Up @@ -343,7 +343,7 @@ func PrepareFactory(clientCtx client.Context, txf Factory) (Factory, error) {
// corresponding SignatureV2 if the signing is successful.
func SignWithPrivKey(
signMode signing.SignMode, signerData authsigning.SignerData,
txBuilder client.TxBuilder, priv crypto.PrivKey, txConfig client.TxConfig,
txBuilder client.TxBuilder, priv cryptotypes.PrivKey, txConfig client.TxConfig,
accSeq uint64,
) (signing.SignatureV2, error) {
var sigV2 signing.SignatureV2
Expand Down
9 changes: 5 additions & 4 deletions crypto/armor.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec/legacy"
cryptoAmino "github.com/cosmos/cosmos-sdk/crypto/codec"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

Expand Down Expand Up @@ -124,7 +125,7 @@ func unarmorBytes(armorStr, blockType string) (bz []byte, header map[string]stri
// encrypt/decrypt with armor

// Encrypt and armor the private key.
func EncryptArmorPrivKey(privKey crypto.PrivKey, passphrase string, algo string) string {
func EncryptArmorPrivKey(privKey cryptotypes.PrivKey, passphrase string, algo string) string {
saltBytes, encBytes := encryptPrivKey(privKey, passphrase)
header := map[string]string{
"kdf": "bcrypt",
Expand All @@ -143,7 +144,7 @@ func EncryptArmorPrivKey(privKey crypto.PrivKey, passphrase string, algo string)
// encrypt the given privKey with the passphrase using a randomly
// generated salt and the xsalsa20 cipher. returns the salt and the
// encrypted priv key.
func encryptPrivKey(privKey crypto.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) {
func encryptPrivKey(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) {
saltBytes = crypto.CRandBytes(16)
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)

Expand All @@ -158,7 +159,7 @@ func encryptPrivKey(privKey crypto.PrivKey, passphrase string) (saltBytes []byte
}

// UnarmorDecryptPrivKey returns the privkey byte slice, a string of the algo type, and an error
func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey crypto.PrivKey, algo string, err error) {
func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey cryptotypes.PrivKey, algo string, err error) {
blockType, header, encBytes, err := armor.DecodeArmor(armorStr)
if err != nil {
return privKey, "", err
Expand Down Expand Up @@ -190,7 +191,7 @@ func UnarmorDecryptPrivKey(armorStr string, passphrase string) (privKey crypto.P
return privKey, header[headerType], err
}

func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey crypto.PrivKey, err error) {
func decryptPrivKey(saltBytes []byte, encBytes []byte, passphrase string) (privKey cryptotypes.PrivKey, err error) {
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), BcryptSecurityParameter)
if err != nil {
return privKey, sdkerrors.Wrap(err, "error generating bcrypt key from passphrase")
Expand Down
3 changes: 2 additions & 1 deletion crypto/armor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/hd"
"github.com/cosmos/cosmos-sdk/crypto/keyring"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
"github.com/cosmos/cosmos-sdk/types"
)

Expand Down Expand Up @@ -46,7 +47,7 @@ func TestArmorUnarmorPrivKey(t *testing.T) {
require.Contains(t, err.Error(), "unrecognized armor type")

// armor key manually
encryptPrivKeyFn := func(privKey tmcrypto.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) {
encryptPrivKeyFn := func(privKey cryptotypes.PrivKey, passphrase string) (saltBytes []byte, encBytes []byte) {
saltBytes = tmcrypto.CRandBytes(16)
key, err := bcrypt.GenerateFromPassword(saltBytes, []byte(passphrase), crypto.BcryptSecurityParameter)
require.NoError(t, err)
Expand Down
18 changes: 3 additions & 15 deletions crypto/codec/amino.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package codec

import (
"github.com/tendermint/tendermint/crypto"
tmed25519 "github.com/tendermint/tendermint/crypto/ed25519"
"github.com/tendermint/tendermint/crypto/sr25519"

"github.com/cosmos/cosmos-sdk/codec"
Expand All @@ -22,43 +20,33 @@ func init() {
// RegisterCrypto registers all crypto dependency types with the provided Amino
// codec.
func RegisterCrypto(cdc *codec.LegacyAmino) {
// TODO We now register both Tendermint's PubKey and our own PubKey. In the
// long-term, we should move away from Tendermint's PubKey, and delete this
// first line.
cdc.RegisterInterface((*crypto.PubKey)(nil), nil)
cdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil)
cdc.RegisterConcrete(sr25519.PubKey{},
sr25519.PubKeyName, nil)
// TODO Same as above, for ED25519
cdc.RegisterConcrete(tmed25519.PubKey{},
tmed25519.PubKeyName, nil)
cdc.RegisterConcrete(&ed25519.PubKey{},
ed25519.PubKeyName, nil)
cdc.RegisterConcrete(&secp256k1.PubKey{},
secp256k1.PubKeyName, nil)
cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{},
kmultisig.PubKeyAminoRoute, nil)

cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
cdc.RegisterInterface((*cryptotypes.PrivKey)(nil), nil)
cdc.RegisterConcrete(sr25519.PrivKey{},
sr25519.PrivKeyName, nil)
// TODO Same as above
cdc.RegisterConcrete(tmed25519.PrivKey{},
tmed25519.PrivKeyName, nil)
cdc.RegisterConcrete(&ed25519.PrivKey{},
ed25519.PrivKeyName, nil)
cdc.RegisterConcrete(&secp256k1.PrivKey{},
secp256k1.PrivKeyName, nil)
}

// PrivKeyFromBytes unmarshals private key bytes and returns a PrivKey
func PrivKeyFromBytes(privKeyBytes []byte) (privKey crypto.PrivKey, err error) {
func PrivKeyFromBytes(privKeyBytes []byte) (privKey cryptotypes.PrivKey, err error) {
err = amino.UnmarshalBinaryBare(privKeyBytes, &privKey)
return
}

// PubKeyFromBytes unmarshals public key bytes and returns a PubKey
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey crypto.PubKey, err error) {
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey cryptotypes.PubKey, err error) {
err = amino.UnmarshalBinaryBare(pubKeyBytes, &pubKey)
return
}
10 changes: 0 additions & 10 deletions crypto/codec/proto.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package codec

import (
tmcrypto "github.com/tendermint/tendermint/crypto"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
Expand All @@ -12,14 +10,6 @@ import (

// RegisterInterfaces registers the sdk.Tx interface.
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
// TODO We now register both Tendermint's PubKey and our own PubKey. In the
// long-term, we should move away from Tendermint's PubKey, and delete
// these lines.
registry.RegisterInterface("tendermint.crypto.PubKey", (*tmcrypto.PubKey)(nil))
registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &ed25519.PubKey{})
registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &secp256k1.PubKey{})
registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &multisig.LegacyAminoPubKey{})
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this need to stay for backwards compat for multisigs?


registry.RegisterInterface("cosmos.crypto.PubKey", (*cryptotypes.PubKey)(nil))
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &ed25519.PubKey{})
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{})
Expand Down
57 changes: 57 additions & 0 deletions crypto/codec/tm.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package codec

import (
tmcrypto "github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/encoding"
tmprotocrypto "github.com/tendermint/tendermint/proto/tendermint/crypto"

"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
)

// FromTmPublicKey converts a TM's tmprotocrypto.PublicKey into our own PubKey.
func FromTmPublicKey(protoPk tmprotocrypto.PublicKey) (cryptotypes.PubKey, error) {
switch protoPk := protoPk.Sum.(type) {
case *tmprotocrypto.PublicKey_Ed25519:
return &ed25519.PubKey{
Key: protoPk.Ed25519,
}, nil
default:
return nil, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v from Tendermint public key", protoPk)
}
robert-zaremba marked this conversation as resolved.
Show resolved Hide resolved
}

// ToTmPublicKey converts our own PubKey to TM's tmprotocrypto.PublicKey.
func ToTmPublicKey(pk cryptotypes.PubKey) (tmprotocrypto.PublicKey, error) {
amaury1093 marked this conversation as resolved.
Show resolved Hide resolved
switch pk := pk.(type) {
case *ed25519.PubKey:
return tmprotocrypto.PublicKey{
Sum: &tmprotocrypto.PublicKey_Ed25519{
Ed25519: pk.Key,
},
}, nil
default:
return tmprotocrypto.PublicKey{}, sdkerrors.Wrapf(sdkerrors.ErrInvalidType, "cannot convert %v to Tendermint public key", pk)
}
}

// FromTmPubKey converts TM's tmcrypto.PubKey to our own PubKey.
func FromTmPubKey(tmPk tmcrypto.PubKey) (cryptotypes.PubKey, error) {
tmProtoPk, err := encoding.PubKeyToProto(tmPk)
if err != nil {
return nil, err
}

return FromTmPublicKey(tmProtoPk)
}

// ToTmPubKey converts our own PubKey to TM's tmcrypto.PubKey.
func ToTmPubKey(pk cryptotypes.PubKey) (tmcrypto.PubKey, error) {
tmProtoPk, err := ToTmPublicKey(pk)
if err != nil {
return nil, err
}

return encoding.PubKeyFromProto(tmProtoPk)
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why don't we use here the tendermint/crypto/ed25519? Public key is bytes we don't need to go through encoding here. We can just cast bytes to the right type using select.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TM supports secp256k1 too now. I could add a switch .(type) here, and do what you suggest. However, I feel it's a bit cleaner to have a central function to do conversion between sdk pubkey <-> tm pubkey (aka FromTmPublicKey). And other conversions (here between tm pubkey <-> tm proto public key) use tm's own functions.

Loading