From 7d2e3d53122911327dbe02064afed110d763a073 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Wed, 19 Aug 2020 01:14:02 +0530 Subject: [PATCH 01/15] Update pubkey references --- client/debug/main.go | 2 +- client/keys/show_test.go | 2 +- crypto/armor_test.go | 2 +- crypto/codec/amino.go | 6 +- crypto/hd/algo.go | 3 +- crypto/hd/fundraiser_test.go | 1 - crypto/keyring/keyring_test.go | 4 +- crypto/keyring/output_test.go | 2 +- crypto/keyring/types_test.go | 2 +- crypto/keys/ed25519/ed25519.go | 2 + crypto/keys/ed25519/ed25519_test.go | 1 - crypto/keys/secp256k1/secp256k1.go | 2 + crypto/keys/secp256k1/secp256k1_test.go | 1 - crypto/keys/sr25519/encoding.go | 3 + crypto/keys/sr25519/sr25519_test.go | 4 +- crypto/ledger/ledger_mock.go | 1 - crypto/ledger/ledger_secp256k1.go | 6 +- crypto/types/multisig/codec.go | 7 +- .../types/multisig/threshold_pubkey_test.go | 9 ++- go.sum | 1 + simapp/genesis_account_test.go | 2 +- simapp/state.go | 2 +- simapp/test_helpers.go | 2 +- std/pubkey.go | 16 ++--- std/pubkey_test.go | 6 +- tests/mocks/account_retriever.go | 65 +++++++++++++++++++ tests/mocks/types_module_module.go | 11 ++-- testutil/testdata/test_tx.go | 2 +- types/address_bench_test.go | 3 +- types/address_test.go | 5 +- types/context_test.go | 2 +- types/rest/rest_test.go | 1 - types/simulation/account.go | 4 +- x/auth/ante/ante_test.go | 2 - x/auth/ante/sigverify.go | 11 ++-- x/auth/ante/sigverify_test.go | 13 ++-- x/auth/client/tx_test.go | 1 - x/auth/signing/handler_map_test.go | 3 +- x/auth/simulation/decoder_test.go | 1 - x/auth/types/account_test.go | 2 +- x/auth/types/amino_signing_test.go | 2 +- x/auth/types/genesis_test.go | 2 +- x/auth/types/stdtx_test.go | 1 - x/auth/vesting/types/genesis_test.go | 1 - x/auth/vesting/types/test_common.go | 2 +- x/auth/vesting/types/vesting_account_test.go | 2 +- x/bank/app_test.go | 2 +- x/distribution/client/cli/tx_test.go | 2 +- x/distribution/legacy/v0_36/migrate_test.go | 2 - x/distribution/proposal_handler_test.go | 1 - x/distribution/simulation/decoder_test.go | 1 - x/distribution/types/common_test.go | 2 +- x/evidence/genesis_test.go | 2 +- x/evidence/handler_test.go | 2 +- x/evidence/keeper/keeper_test.go | 2 +- x/evidence/simulation/decoder_test.go | 1 - x/evidence/types/genesis_test.go | 2 +- x/evidence/types/msgs_test.go | 1 - x/genaccounts/legacy/v0_36/migrate_test.go | 2 +- x/genutil/gentx_test.go | 4 +- x/genutil/types/genesis_state_test.go | 1 - x/gov/common_test.go | 2 +- x/gov/simulation/decoder_test.go | 2 +- x/gov/types/keys_test.go | 2 +- x/ibc/07-tendermint/types/msgs_test.go | 1 - x/ibc/testing/chain.go | 2 +- x/slashing/app_test.go | 2 - x/slashing/simulation/decoder_test.go | 2 +- x/staking/client/cli/cli_test.go | 2 +- x/staking/common_test.go | 4 +- x/staking/genesis_test.go | 1 - x/staking/handler_test.go | 2 +- x/staking/simulation/decoder_test.go | 2 +- x/staking/types/keys_test.go | 2 +- x/staking/types/test_utils.go | 2 +- x/staking/types/validator_test.go | 3 +- 76 files changed, 163 insertions(+), 120 deletions(-) create mode 100644 tests/mocks/account_retriever.go diff --git a/client/debug/main.go b/client/debug/main.go index 5ce659721add..7a9a3c49480d 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -9,9 +9,9 @@ import ( "github.com/spf13/cobra" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" ) diff --git a/client/keys/show_test.go b/client/keys/show_test.go index dc102c97280b..a18644207973 100644 --- a/client/keys/show_test.go +++ b/client/keys/show_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" "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/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/crypto/armor_test.go b/crypto/armor_test.go index 120b88e045da..3e5f256faa75 100644 --- a/crypto/armor_test.go +++ b/crypto/armor_test.go @@ -11,7 +11,6 @@ import ( "github.com/tendermint/crypto/bcrypt" tmcrypto "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/armor" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/xsalsa20symmetric" "github.com/cosmos/cosmos-sdk/codec/legacy" @@ -19,6 +18,7 @@ import ( cryptoAmino "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/hd" "github.com/cosmos/cosmos-sdk/crypto/keyring" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/types" ) diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index b5a7c0e86fe5..87fcda6067a0 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -2,11 +2,11 @@ package codec import ( "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" ) diff --git a/crypto/hd/algo.go b/crypto/hd/algo.go index 9a32835d0531..d88b88e4aba2 100644 --- a/crypto/hd/algo.go +++ b/crypto/hd/algo.go @@ -3,7 +3,8 @@ package hd import ( bip39 "github.com/cosmos/go-bip39" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" ) // PubKeyType defines an algorithm to derive key-pairs which can be used for cryptographic signing. diff --git a/crypto/hd/fundraiser_test.go b/crypto/hd/fundraiser_test.go index 255a2696b993..595d857befcb 100644 --- a/crypto/hd/fundraiser_test.go +++ b/crypto/hd/fundraiser_test.go @@ -12,7 +12,6 @@ import ( bip39 "github.com/cosmos/go-bip39" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/hd" ) diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index 918eb5e5e0fe..569698125a6d 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -9,11 +9,11 @@ import ( bip39 "github.com/cosmos/go-bip39" "github.com/stretchr/testify/require" tmcrypto "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/crypto" "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/crypto/keyring/output_test.go b/crypto/keyring/output_test.go index 150a546b589f..dd92a0e1d0eb 100644 --- a/crypto/keyring/output_test.go +++ b/crypto/keyring/output_test.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/crypto/keyring/types_test.go b/crypto/keyring/types_test.go index 50981d177bed..18e818c0d17a 100644 --- a/crypto/keyring/types_test.go +++ b/crypto/keyring/types_test.go @@ -5,9 +5,9 @@ import ( "testing" "github.com/stretchr/testify/assert" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index 73574c01693e..e0c1257310f1 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -17,6 +17,8 @@ import ( var _ crypto.PrivKey = PrivKey{} const ( + PrivKeyName = "tendermint/PrivKeyEd25519" + PubKeyName = "tendermint/PubKeyEd25519" // PubKeySize is is the size, in bytes, of public keys as used in this package. PubKeySize = 32 // PrivateKeySize is the size, in bytes, of private keys as used in this package. diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 8c48847c0759..9c81921d0de2 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" ) func TestSignAndValidateEd25519(t *testing.T) { diff --git a/crypto/keys/secp256k1/secp256k1.go b/crypto/keys/secp256k1/secp256k1.go index 68a5239463e2..2ff2685b3a05 100644 --- a/crypto/keys/secp256k1/secp256k1.go +++ b/crypto/keys/secp256k1/secp256k1.go @@ -19,6 +19,8 @@ var _ crypto.PrivKey = PrivKey{} const ( PrivKeySize = 32 keyType = "secp256k1" + PrivKeyName = "tendermint/PrivKeySecp256k1" + PubKeyName = "tendermint/PubKeySecp256k1" ) // PrivKey implements PrivKey. diff --git a/crypto/keys/secp256k1/secp256k1_test.go b/crypto/keys/secp256k1/secp256k1_test.go index 869773a198f2..582e2165e6d5 100644 --- a/crypto/keys/secp256k1/secp256k1_test.go +++ b/crypto/keys/secp256k1/secp256k1_test.go @@ -10,7 +10,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" underlyingSecp256k1 "github.com/btcsuite/btcd/btcec" ) diff --git a/crypto/keys/sr25519/encoding.go b/crypto/keys/sr25519/encoding.go index 58debb7d2b95..03e7fa7e91b0 100644 --- a/crypto/keys/sr25519/encoding.go +++ b/crypto/keys/sr25519/encoding.go @@ -7,6 +7,9 @@ import ( var _ crypto.PrivKey = PrivKey{} const ( + PrivKeyName = "tendermint/PrivKeySr25519" + PubKeyName = "tendermint/PubKeySr25519" + // SignatureSize is the size of an Edwards25519 signature. Namely the size of a compressed // Sr25519 point, and a field element. Both of which are 32 bytes. SignatureSize = 64 diff --git a/crypto/keys/sr25519/sr25519_test.go b/crypto/keys/sr25519/sr25519_test.go index 1efe31cad8b5..a35bd8684a41 100644 --- a/crypto/keys/sr25519/sr25519_test.go +++ b/crypto/keys/sr25519/sr25519_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/sr25519" + + "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" ) func TestSignAndValidateSr25519(t *testing.T) { diff --git a/crypto/ledger/ledger_mock.go b/crypto/ledger/ledger_mock.go index cb75a00884a9..ced2f29fcfd6 100644 --- a/crypto/ledger/ledger_mock.go +++ b/crypto/ledger/ledger_mock.go @@ -10,7 +10,6 @@ import ( secp256k1 "github.com/tendermint/btcd/btcec" "github.com/tendermint/tendermint/crypto" - tmsecp256k1 "github.com/tendermint/tendermint/crypto/secp256k1" bip39 "github.com/cosmos/go-bip39" diff --git a/crypto/ledger/ledger_secp256k1.go b/crypto/ledger/ledger_secp256k1.go index 6ad8c7ff43d8..0884e36eb449 100644 --- a/crypto/ledger/ledger_secp256k1.go +++ b/crypto/ledger/ledger_secp256k1.go @@ -9,9 +9,9 @@ import ( tmbtcec "github.com/tendermint/btcd/btcec" tmcrypto "github.com/tendermint/tendermint/crypto" - tmsecp256k1 "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" ) var ( @@ -246,7 +246,7 @@ func getPubKeyUnsafe(device SECP256K1, path hd.BIP44Params) (tmcrypto.PubKey, er return nil, fmt.Errorf("error parsing public key: %v", err) } - compressedPublicKey := make(tmsecp256k1.PubKey, tmsecp256k1.PubKeySize) + compressedPublicKey := make(secp256k1.PubKey, secp256k1.PubKeySize) copy(compressedPublicKey, cmp.SerializeCompressed()) return compressedPublicKey, nil @@ -270,7 +270,7 @@ func getPubKeyAddrSafe(device SECP256K1, path hd.BIP44Params, hrp string) (tmcry return nil, "", fmt.Errorf("error parsing public key: %v", err) } - compressedPublicKey := make(tmsecp256k1.PubKey, tmsecp256k1.PubKeySize) + compressedPublicKey := make(secp256k1.PubKey, secp256k1.PubKeySize) copy(compressedPublicKey, cmp.SerializeCompressed()) return compressedPublicKey, addr, nil diff --git a/crypto/types/multisig/codec.go b/crypto/types/multisig/codec.go index a18c6968a72a..bfaa01978f71 100644 --- a/crypto/types/multisig/codec.go +++ b/crypto/types/multisig/codec.go @@ -4,9 +4,10 @@ import ( amino "github.com/tendermint/go-amino" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto/sr25519" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" ) // TODO: Figure out API for others to either add their own pubkey types, or diff --git a/crypto/types/multisig/threshold_pubkey_test.go b/crypto/types/multisig/threshold_pubkey_test.go index cb406460325a..18715fc94c30 100644 --- a/crypto/types/multisig/threshold_pubkey_test.go +++ b/crypto/types/multisig/threshold_pubkey_test.go @@ -5,17 +5,16 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" - - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto/sr25519" ) // This tests multisig functionality, but it expects the first k signatures to be valid diff --git a/go.sum b/go.sum index 029fe6c0137e..662fbaf7f793 100644 --- a/go.sum +++ b/go.sum @@ -689,6 +689,7 @@ golang.org/x/tools v0.0.0-20191029041327-9cc4af7d6b2c/go.mod h1:b+2E5dAYhXwXZwtn golang.org/x/tools v0.0.0-20191029190741-b9c20aec41a5/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200103221440-774c71fcf114/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= +golang.org/x/tools v0.0.0-20200110213125-a7a6caa82ab2 h1:V9r/14uGBqLgNlHRYWdVqjMdWkcOHnE2KG8DwVqQSEc= golang.org/x/tools v0.0.0-20200110213125-a7a6caa82ab2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/simapp/genesis_account_test.go b/simapp/genesis_account_test.go index 385bb7b217b6..5d5c59003e6b 100644 --- a/simapp/genesis_account_test.go +++ b/simapp/genesis_account_test.go @@ -4,13 +4,13 @@ import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" ) func TestSimGenesisAccountValidate(t *testing.T) { diff --git a/simapp/state.go b/simapp/state.go index 54629441c3dd..f9911ce8e848 100644 --- a/simapp/state.go +++ b/simapp/state.go @@ -8,10 +8,10 @@ import ( "math/rand" "time" - "github.com/tendermint/tendermint/crypto/secp256k1" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" simapparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/types/module" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index 6d96fa05348a..335f6698d3e8 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -12,7 +12,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" @@ -20,6 +19,7 @@ import ( bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp/helpers" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/std/pubkey.go b/std/pubkey.go index ff7a636b7877..0183b9d041c6 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -3,13 +3,13 @@ package std import ( "fmt" + "github.com/tendermint/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" - - "github.com/tendermint/tendermint/crypto" - ed255192 "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto/sr25519" ) // DefaultPublicKeyCodec implements the standard PublicKeyCodec for the SDK which @@ -32,11 +32,11 @@ func (cdc DefaultPublicKeyCodec) Decode(key *types.PublicKey) (crypto.PubKey, er return res, nil case *types.PublicKey_Ed25519: n := len(key.Ed25519) - if n != ed255192.PubKeySize { + if n != ed25519.PubKeySize { return nil, fmt.Errorf("wrong length %d for ed25519 public key", n) } - res := make(ed255192.PubKey, ed255192.PubKeySize) + res := make(ed25519.PubKey, ed25519.PubKeySize) copy(res, key.Ed25519) return res, nil case *types.PublicKey_Sr25519: @@ -71,7 +71,7 @@ func (cdc DefaultPublicKeyCodec) Encode(key crypto.PubKey) (*types.PublicKey, er switch key := key.(type) { case secp256k1.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Secp256K1{Secp256K1: key}}, nil - case ed255192.PubKey: + case ed25519.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Ed25519{Ed25519: key}}, nil case sr25519.PubKey: return &types.PublicKey{Sum: &types.PublicKey_Sr25519{Sr25519: key}}, nil diff --git a/std/pubkey_test.go b/std/pubkey_test.go index 22397a4b78c4..f87c15b4a5c3 100644 --- a/std/pubkey_test.go +++ b/std/pubkey_test.go @@ -3,13 +3,13 @@ package std_test import ( "testing" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/std" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" ) diff --git a/tests/mocks/account_retriever.go b/tests/mocks/account_retriever.go new file mode 100644 index 000000000000..f571fcbd1516 --- /dev/null +++ b/tests/mocks/account_retriever.go @@ -0,0 +1,65 @@ +// Code generated by MockGen. DO NOT EDIT. +// Source: client/account_retriever.go + +// Package mocks is a generated GoMock package. +package mocks + +import ( + client "github.com/cosmos/cosmos-sdk/client" + types "github.com/cosmos/cosmos-sdk/types" + gomock "github.com/golang/mock/gomock" + reflect "reflect" +) + +// MockAccountRetriever is a mock of AccountRetriever interface +type MockAccountRetriever struct { + ctrl *gomock.Controller + recorder *MockAccountRetrieverMockRecorder +} + +// MockAccountRetrieverMockRecorder is the mock recorder for MockAccountRetriever +type MockAccountRetrieverMockRecorder struct { + mock *MockAccountRetriever +} + +// NewMockAccountRetriever creates a new mock instance +func NewMockAccountRetriever(ctrl *gomock.Controller) *MockAccountRetriever { + mock := &MockAccountRetriever{ctrl: ctrl} + mock.recorder = &MockAccountRetrieverMockRecorder{mock} + return mock +} + +// EXPECT returns an object that allows the caller to indicate expected use +func (m *MockAccountRetriever) EXPECT() *MockAccountRetrieverMockRecorder { + return m.recorder +} + +// EnsureExists mocks base method +func (m *MockAccountRetriever) EnsureExists(clientCtx client.Context, addr types.AccAddress) error { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "EnsureExists", clientCtx, addr) + ret0, _ := ret[0].(error) + return ret0 +} + +// EnsureExists indicates an expected call of EnsureExists +func (mr *MockAccountRetrieverMockRecorder) EnsureExists(clientCtx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "EnsureExists", reflect.TypeOf((*MockAccountRetriever)(nil).EnsureExists), clientCtx, addr) +} + +// GetAccountNumberSequence mocks base method +func (m *MockAccountRetriever) GetAccountNumberSequence(clientCtx client.Context, addr types.AccAddress) (uint64, uint64, error) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetAccountNumberSequence", clientCtx, addr) + ret0, _ := ret[0].(uint64) + ret1, _ := ret[1].(uint64) + ret2, _ := ret[2].(error) + return ret0, ret1, ret2 +} + +// GetAccountNumberSequence indicates an expected call of GetAccountNumberSequence +func (mr *MockAccountRetrieverMockRecorder) GetAccountNumberSequence(clientCtx, addr interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetAccountNumberSequence", reflect.TypeOf((*MockAccountRetriever)(nil).GetAccountNumberSequence), clientCtx, addr) +} diff --git a/tests/mocks/types_module_module.go b/tests/mocks/types_module_module.go index cf32937f8094..291409d121c1 100644 --- a/tests/mocks/types_module_module.go +++ b/tests/mocks/types_module_module.go @@ -6,8 +6,6 @@ package mocks import ( json "encoding/json" - reflect "reflect" - client "github.com/cosmos/cosmos-sdk/client" codec "github.com/cosmos/cosmos-sdk/codec" types "github.com/cosmos/cosmos-sdk/codec/types" @@ -17,6 +15,7 @@ import ( mux "github.com/gorilla/mux" cobra "github.com/spf13/cobra" types1 "github.com/tendermint/tendermint/abci/types" + reflect "reflect" ) // MockAppModuleBasic is a mock of AppModuleBasic interface @@ -503,17 +502,17 @@ func (mr *MockAppModuleMockRecorder) QuerierRoute() *gomock.Call { } // LegacyQuerierHandler mocks base method -func (m *MockAppModule) LegacyQuerierHandler(codec.JSONMarshaler) types0.Querier { +func (m *MockAppModule) LegacyQuerierHandler(arg0 codec.JSONMarshaler) types0.Querier { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LegacyQuerierHandler") + ret := m.ctrl.Call(m, "LegacyQuerierHandler", arg0) ret0, _ := ret[0].(types0.Querier) return ret0 } // LegacyQuerierHandler indicates an expected call of LegacyQuerierHandler -func (mr *MockAppModuleMockRecorder) NewQuerierHandler() *gomock.Call { +func (mr *MockAppModuleMockRecorder) LegacyQuerierHandler(arg0 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LegacyQuerierHandler", reflect.TypeOf((*MockAppModule)(nil).LegacyQuerierHandler)) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LegacyQuerierHandler", reflect.TypeOf((*MockAppModule)(nil).LegacyQuerierHandler), arg0) } // RegisterQueryService mocks base method diff --git a/testutil/testdata/test_tx.go b/testutil/testdata/test_tx.go index 92972fe41744..bbcfde5f8195 100644 --- a/testutil/testdata/test_tx.go +++ b/testutil/testdata/test_tx.go @@ -4,8 +4,8 @@ import ( "encoding/json" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/types/address_bench_test.go b/types/address_bench_test.go index 640d18041177..e6ddc506740a 100644 --- a/types/address_bench_test.go +++ b/types/address_bench_test.go @@ -7,9 +7,8 @@ import ( "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/types" - - "github.com/tendermint/tendermint/crypto/ed25519" ) func BenchmarkBech32ifyPubKey(b *testing.B) { diff --git a/types/address_test.go b/types/address_test.go index 0b2701dcae9a..2a89425ff5e9 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -12,9 +12,8 @@ import ( "github.com/tendermint/tendermint/crypto" yaml "gopkg.in/yaml.v2" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/types" ) diff --git a/types/context_test.go b/types/context_test.go index 0698199a0a6b..64e4141659e3 100644 --- a/types/context_test.go +++ b/types/context_test.go @@ -7,11 +7,11 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" dbm "github.com/tendermint/tm-db" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/store" "github.com/cosmos/cosmos-sdk/types" ) diff --git a/types/rest/rest_test.go b/types/rest/rest_test.go index e05deb18771d..f917a79bf60e 100644 --- a/types/rest/rest_test.go +++ b/types/rest/rest_test.go @@ -13,7 +13,6 @@ import ( "github.com/spf13/viper" "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/types/simulation/account.go b/types/simulation/account.go index 2078cddc2d87..b0c6b7bd687a 100644 --- a/types/simulation/account.go +++ b/types/simulation/account.go @@ -4,9 +4,9 @@ import ( "math/rand" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index e5c701c8bae3..6c0e1b9a222f 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -9,8 +9,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil/testdata" diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index a11dd6ec885e..20be659fa7e6 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -5,16 +5,13 @@ import ( "encoding/hex" "fmt" - authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" - - "github.com/cosmos/cosmos-sdk/types/tx/signing" - - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" - + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" + "github.com/cosmos/cosmos-sdk/types/tx/signing" + authsigning "github.com/cosmos/cosmos-sdk/x/auth/signing" "github.com/cosmos/cosmos-sdk/x/auth/types" ) diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index 7e78a31dd9f9..524c85a8dfab 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -3,18 +3,15 @@ package ante_test import ( "fmt" - "github.com/cosmos/cosmos-sdk/testutil/testdata" - - "github.com/cosmos/cosmos-sdk/types/tx/signing" - - "github.com/cosmos/cosmos-sdk/simapp" - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" + "github.com/cosmos/cosmos-sdk/simapp" + "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/ante" "github.com/cosmos/cosmos-sdk/x/auth/types" ) diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index 1a5847d42499..5d8a970e271d 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -13,7 +13,6 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" diff --git a/x/auth/signing/handler_map_test.go b/x/auth/signing/handler_map_test.go index e419cff836e9..bc8f6598d456 100644 --- a/x/auth/signing/handler_map_test.go +++ b/x/auth/signing/handler_map_test.go @@ -5,8 +5,7 @@ import ( "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/secp256k1" - + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" "github.com/cosmos/cosmos-sdk/x/auth/signing" diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index 453966a1fd8b..42107c1fbab8 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -6,7 +6,6 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/auth/types/account_test.go b/x/auth/types/account_test.go index aab4893fc5f8..f59499126fbf 100644 --- a/x/auth/types/account_test.go +++ b/x/auth/types/account_test.go @@ -7,9 +7,9 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/secp256k1" yaml "gopkg.in/yaml.v2" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/auth/types/amino_signing_test.go b/x/auth/types/amino_signing_test.go index b451fe26b1ea..5ce12680b98e 100644 --- a/x/auth/types/amino_signing_test.go +++ b/x/auth/types/amino_signing_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" signingtypes "github.com/cosmos/cosmos-sdk/types/tx/signing" diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 2c4d5cea002a..1030885e799e 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -6,9 +6,9 @@ import ( proto "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" ) diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index eb1f94c71a07..dbfada069a85 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" yaml "gopkg.in/yaml.v2" diff --git a/x/auth/vesting/types/genesis_test.go b/x/auth/vesting/types/genesis_test.go index 79913adf7de5..95f3bcdd4116 100644 --- a/x/auth/vesting/types/genesis_test.go +++ b/x/auth/vesting/types/genesis_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/auth/vesting/types/test_common.go b/x/auth/vesting/types/test_common.go index 948e506b3c25..347faba046a9 100644 --- a/x/auth/vesting/types/test_common.go +++ b/x/auth/vesting/types/test_common.go @@ -2,8 +2,8 @@ package types import ( "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/auth/vesting/types/vesting_account_test.go b/x/auth/vesting/types/vesting_account_test.go index eb6e13412b0c..01a5e2ad9804 100644 --- a/x/auth/vesting/types/vesting_account_test.go +++ b/x/auth/vesting/types/vesting_account_test.go @@ -5,9 +5,9 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/secp256k1" tmtime "github.com/tendermint/tendermint/types/time" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/bank/app_test.go b/x/bank/app_test.go index 42122d0bca9b..ddebcb449881 100644 --- a/x/bank/app_test.go +++ b/x/bank/app_test.go @@ -5,9 +5,9 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/distribution/client/cli/tx_test.go b/x/distribution/client/cli/tx_test.go index bc40c1510582..3ab4808ecd1d 100644 --- a/x/distribution/client/cli/tx_test.go +++ b/x/distribution/client/cli/tx_test.go @@ -5,13 +5,13 @@ import ( "github.com/spf13/pflag" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" "github.com/stretchr/testify/require" "github.com/stretchr/testify/assert" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/distribution/legacy/v0_36/migrate_test.go b/x/distribution/legacy/v0_36/migrate_test.go index 1aadbe29a4e7..e3a56a50746e 100644 --- a/x/distribution/legacy/v0_36/migrate_test.go +++ b/x/distribution/legacy/v0_36/migrate_test.go @@ -3,8 +3,6 @@ package v0_36 import ( "testing" - "github.com/tendermint/tendermint/crypto/secp256k1" - "github.com/cosmos/cosmos-sdk/types" v034distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_34" diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index 34e99fb27bd3..bfcda99f98a4 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -4,7 +4,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 8b65d08a09e5..8a3d28d4c0e7 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -5,7 +5,6 @@ import ( "testing" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/distribution/types/common_test.go b/x/distribution/types/common_test.go index c9dbfde6f0b1..a8301b4e42bd 100644 --- a/x/distribution/types/common_test.go +++ b/x/distribution/types/common_test.go @@ -2,8 +2,8 @@ package types import ( "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index dbd69dca34c5..bbe8a529e9b3 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/types/time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence" diff --git a/x/evidence/handler_test.go b/x/evidence/handler_test.go index 1d5388b7c88e..e30950bf7875 100644 --- a/x/evidence/handler_test.go +++ b/x/evidence/handler_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence" diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 849676e381a7..f43a26c408d1 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -8,11 +8,11 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index b8d1e70c179c..4677fe350b0e 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -6,7 +6,6 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index b8b8ee0e1a16..1107e244f501 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -6,11 +6,11 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" tmbytes "github.com/tendermint/tendermint/libs/bytes" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) diff --git a/x/evidence/types/msgs_test.go b/x/evidence/types/msgs_test.go index 6c1297ea64b7..ed9214e745ee 100644 --- a/x/evidence/types/msgs_test.go +++ b/x/evidence/types/msgs_test.go @@ -9,7 +9,6 @@ import ( "github.com/cosmos/cosmos-sdk/x/evidence/types" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" ) func testMsgSubmitEvidence(t *testing.T, e exported.Evidence, s sdk.AccAddress) exported.MsgSubmitEvidence { diff --git a/x/genaccounts/legacy/v0_36/migrate_test.go b/x/genaccounts/legacy/v0_36/migrate_test.go index 250dd85474f1..7fbd9f66a4f9 100644 --- a/x/genaccounts/legacy/v0_36/migrate_test.go +++ b/x/genaccounts/legacy/v0_36/migrate_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/types" v034distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_34" v034accounts "github.com/cosmos/cosmos-sdk/x/genaccounts/legacy/v0_34" diff --git a/x/genutil/gentx_test.go b/x/genutil/gentx_test.go index 2f690c0ee90c..c88d33fef956 100644 --- a/x/genutil/gentx_test.go +++ b/x/genutil/gentx_test.go @@ -6,9 +6,9 @@ import ( "testing" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/simapp/helpers" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" @@ -16,7 +16,7 @@ import ( banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" "github.com/cosmos/cosmos-sdk/x/genutil" "github.com/cosmos/cosmos-sdk/x/genutil/types" - staking "github.com/cosmos/cosmos-sdk/x/staking" + "github.com/cosmos/cosmos-sdk/x/staking" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" ) diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index adb771548973..710fc77e575d 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -6,7 +6,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/simapp" diff --git a/x/gov/common_test.go b/x/gov/common_test.go index 81bfd32fd85b..aef391d794aa 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index c5c9e720d92e..7a5b0fc1bc9d 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/gov/types/keys_test.go b/x/gov/types/keys_test.go index 80d77c66043a..80dfa7d207a3 100644 --- a/x/gov/types/keys_test.go +++ b/x/gov/types/keys_test.go @@ -5,8 +5,8 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/ibc/07-tendermint/types/msgs_test.go b/x/ibc/07-tendermint/types/msgs_test.go index 8c516ec28791..d984622f0ebf 100644 --- a/x/ibc/07-tendermint/types/msgs_test.go +++ b/x/ibc/07-tendermint/types/msgs_test.go @@ -2,7 +2,6 @@ package types_test import ( ics23 "github.com/confio/ics23/go" - "github.com/tendermint/tendermint/crypto/secp256k1" tmtypes "github.com/tendermint/tendermint/types" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/ibc/testing/chain.go b/x/ibc/testing/chain.go index 9d79910fe612..2c64875535a4 100644 --- a/x/ibc/testing/chain.go +++ b/x/ibc/testing/chain.go @@ -9,7 +9,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1" "github.com/tendermint/tendermint/crypto/tmhash" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/proto/tendermint/version" @@ -17,6 +16,7 @@ import ( "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 2191ede320f0..868febe58b24 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -6,8 +6,6 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/simapp" diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index 493645392f1f..e6122f0e0a98 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -7,8 +7,8 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/staking/client/cli/cli_test.go b/x/staking/client/cli/cli_test.go index faae7613284b..22d7bc983523 100644 --- a/x/staking/client/cli/cli_test.go +++ b/x/staking/client/cli/cli_test.go @@ -5,11 +5,11 @@ import ( "testing" "github.com/stretchr/testify/suite" - "github.com/tendermint/tendermint/crypto/ed25519" "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/ed25519" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/common_test.go b/x/staking/common_test.go index f029e4eac8ae..1dafa2ecd709 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -2,11 +2,11 @@ package staking_test import ( "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/staking/keeper" diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index 989bf56bf00d..ad7a2610f691 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -7,7 +7,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/handler_test.go b/x/staking/handler_test.go index 2e9f6f51ae2f..481484ad92f0 100644 --- a/x/staking/handler_test.go +++ b/x/staking/handler_test.go @@ -9,10 +9,10 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" - "github.com/tendermint/tendermint/crypto/secp256k1" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index f442f648dd6e..b5fdfb479092 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -6,10 +6,10 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/staking/types/keys_test.go b/x/staking/types/keys_test.go index 0f11cf27f7f6..725438707c76 100644 --- a/x/staking/types/keys_test.go +++ b/x/staking/types/keys_test.go @@ -8,8 +8,8 @@ import ( "time" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/staking/types/test_utils.go b/x/staking/types/test_utils.go index 9ab8aabfe82c..a65a0ee9e078 100644 --- a/x/staking/types/test_utils.go +++ b/x/staking/types/test_utils.go @@ -2,8 +2,8 @@ package types import ( "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index c4714c1f5374..e86bd1b82721 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -8,11 +8,12 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto/ed25519" + cryptoenc "github.com/tendermint/tendermint/crypto/encoding" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec/legacy" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) From dccf1ef803edf75df1e24340050b7d26ce3fe8ee Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Thu, 20 Aug 2020 00:25:20 +0530 Subject: [PATCH 02/15] Update ledger_mock --- crypto/ledger/ledger_mock.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crypto/ledger/ledger_mock.go b/crypto/ledger/ledger_mock.go index ced2f29fcfd6..d2cf07a0128e 100644 --- a/crypto/ledger/ledger_mock.go +++ b/crypto/ledger/ledger_mock.go @@ -14,6 +14,7 @@ import ( bip39 "github.com/cosmos/go-bip39" "github.com/cosmos/cosmos-sdk/crypto/hd" + csecp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/testutil" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -76,7 +77,7 @@ func (mock LedgerSECP256K1Mock) GetAddressPubKeySECP256K1(derivationPath []uint3 return nil, "", fmt.Errorf("error parsing public key: %v", err) } - compressedPublicKey := make(tmsecp256k1.PubKey, tmsecp256k1.PubKeySize) + compressedPublicKey := make(csecp256k1.PubKey, csecp256k1.PubKeySize) copy(compressedPublicKey, cmp.SerializeCompressed()) // Generate the bech32 addr using existing tmcrypto/etc. From 71e415b790fa24837b1a977104bc881031151b3c Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Thu, 20 Aug 2020 02:11:02 +0530 Subject: [PATCH 03/15] Migrate encoding from tm --- crypto/hd/fundraiser_test.go | 1 + crypto/keys/ed25519/ed25519_test.go | 2 + crypto/keys/encoding/codec.go | 76 +++++++++++++++++++++ crypto/keys/secp256k1/secp256k1_cgo.go | 2 +- crypto/keys/secp256k1/secp256k1_test.go | 2 + crypto/ledger/ledger_mock.go | 2 +- x/auth/ante/ante_test.go | 2 + x/auth/client/tx_test.go | 1 + x/auth/simulation/decoder_test.go | 1 + x/auth/types/stdtx_test.go | 1 + x/auth/vesting/types/genesis_test.go | 1 + x/distribution/legacy/v0_36/migrate_test.go | 1 + x/distribution/proposal_handler_test.go | 1 + x/distribution/simulation/decoder_test.go | 1 + x/evidence/simulation/decoder_test.go | 1 + x/evidence/types/msgs_test.go | 1 + x/genutil/types/genesis_state_test.go | 1 + x/slashing/app_test.go | 2 + x/staking/genesis_test.go | 1 + x/staking/types/validator.go | 8 +-- x/staking/types/validator_test.go | 6 +- 21 files changed, 105 insertions(+), 9 deletions(-) create mode 100644 crypto/keys/encoding/codec.go diff --git a/crypto/hd/fundraiser_test.go b/crypto/hd/fundraiser_test.go index 595d857befcb..2bc396721cb2 100644 --- a/crypto/hd/fundraiser_test.go +++ b/crypto/hd/fundraiser_test.go @@ -14,6 +14,7 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/hd" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" ) type addrData struct { diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 9c81921d0de2..22f966845440 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -7,6 +7,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" ) func TestSignAndValidateEd25519(t *testing.T) { diff --git a/crypto/keys/encoding/codec.go b/crypto/keys/encoding/codec.go new file mode 100644 index 000000000000..a5f8ba8c70c3 --- /dev/null +++ b/crypto/keys/encoding/codec.go @@ -0,0 +1,76 @@ +package encoding + +import ( + "errors" + "fmt" + + "github.com/tendermint/tendermint/crypto" + pc "github.com/tendermint/tendermint/proto/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" +) + +// PubKeyToProto takes crypto.PubKey and transforms it to a protobuf Pubkey +func PubKeyToProto(k crypto.PubKey) (pc.PublicKey, error) { + var kp pc.PublicKey + switch k := k.(type) { + case ed25519.PubKey: + kp = pc.PublicKey{ + Sum: &pc.PublicKey_Ed25519{ + Ed25519: k, + }, + } + default: + return kp, fmt.Errorf("toproto: key type %v is not supported", k) + } + return kp, nil +} + +// PubKeyFromProto takes a protobuf Pubkey and transforms it to a crypto.Pubkey +func PubKeyFromProto(k pc.PublicKey) (crypto.PubKey, error) { + switch k := k.Sum.(type) { + case *pc.PublicKey_Ed25519: + if len(k.Ed25519) != ed25519.PubKeySize { + return nil, fmt.Errorf("invalid size for PubKeyEd25519. Got %d, expected %d", + len(k.Ed25519), ed25519.PubKeySize) + } + pk := make(ed25519.PubKey, ed25519.PubKeySize) + copy(pk, k.Ed25519) + return pk, nil + default: + return nil, fmt.Errorf("fromproto: key type %v is not supported", k) + } +} + +// PrivKeyToProto takes crypto.PrivKey and transforms it to a protobuf PrivKey +func PrivKeyToProto(k crypto.PrivKey) (pc.PrivateKey, error) { + var kp pc.PrivateKey + switch k := k.(type) { + case ed25519.PrivKey: + kp = pc.PrivateKey{ + Sum: &pc.PrivateKey_Ed25519{ + Ed25519: k, + }, + } + default: + return kp, errors.New("toproto: key type is not supported") + } + return kp, nil +} + +// PrivKeyFromProto takes a protobuf PrivateKey and transforms it to a crypto.PrivKey +func PrivKeyFromProto(k pc.PrivateKey) (crypto.PrivKey, error) { + switch k := k.Sum.(type) { + case *pc.PrivateKey_Ed25519: + + if len(k.Ed25519) != ed25519.PubKeySize { + return nil, fmt.Errorf("invalid size for PubKeyEd25519. Got %d, expected %d", + len(k.Ed25519), ed25519.PubKeySize) + } + pk := make(ed25519.PrivKey, ed25519.PrivateKeySize) + copy(pk, k.Ed25519) + return pk, nil + default: + return nil, errors.New("fromproto: key type not supported") + } +} diff --git a/crypto/keys/secp256k1/secp256k1_cgo.go b/crypto/keys/secp256k1/secp256k1_cgo.go index e44899fb5dd8..59ba3f14ddc0 100644 --- a/crypto/keys/secp256k1/secp256k1_cgo.go +++ b/crypto/keys/secp256k1/secp256k1_cgo.go @@ -3,8 +3,8 @@ package secp256k1 import ( + "github.com/cosmos/cosmos-sdk/crypto/secp256k1/internal/secp256k1" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/secp256k1/internal/secp256k1" ) // Sign creates an ECDSA signature on curve Secp256k1, using SHA256 on the msg. diff --git a/crypto/keys/secp256k1/secp256k1_test.go b/crypto/keys/secp256k1/secp256k1_test.go index 582e2165e6d5..8f7b9bc4e93a 100644 --- a/crypto/keys/secp256k1/secp256k1_test.go +++ b/crypto/keys/secp256k1/secp256k1_test.go @@ -12,6 +12,8 @@ import ( "github.com/tendermint/tendermint/crypto" underlyingSecp256k1 "github.com/btcsuite/btcd/btcec" + + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" ) type keyData struct { diff --git a/crypto/ledger/ledger_mock.go b/crypto/ledger/ledger_mock.go index d2cf07a0128e..45efc5c3010d 100644 --- a/crypto/ledger/ledger_mock.go +++ b/crypto/ledger/ledger_mock.go @@ -11,7 +11,7 @@ import ( secp256k1 "github.com/tendermint/btcd/btcec" "github.com/tendermint/tendermint/crypto" - bip39 "github.com/cosmos/go-bip39" + "github.com/cosmos/go-bip39" "github.com/cosmos/cosmos-sdk/crypto/hd" csecp256k1 "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 6c0e1b9a222f..a2e20b2e0563 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -10,6 +10,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index 5d8a970e271d..4848002967e3 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -5,6 +5,7 @@ import ( "strings" "testing" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index 42107c1fbab8..c7ececcf95cc 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -7,6 +7,7 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index dbfada069a85..c795a6f672d1 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -12,6 +12,7 @@ import ( "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil/testdata" diff --git a/x/auth/vesting/types/genesis_test.go b/x/auth/vesting/types/genesis_test.go index 95f3bcdd4116..98aabb15cfde 100644 --- a/x/auth/vesting/types/genesis_test.go +++ b/x/auth/vesting/types/genesis_test.go @@ -5,6 +5,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) diff --git a/x/distribution/legacy/v0_36/migrate_test.go b/x/distribution/legacy/v0_36/migrate_test.go index e3a56a50746e..fcffc7fe9a1b 100644 --- a/x/distribution/legacy/v0_36/migrate_test.go +++ b/x/distribution/legacy/v0_36/migrate_test.go @@ -3,6 +3,7 @@ package v0_36 import ( "testing" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/types" v034distr "github.com/cosmos/cosmos-sdk/x/distribution/legacy/v0_34" diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index bfcda99f98a4..575dbb199cbe 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution" diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 8a3d28d4c0e7..7a705f97da10 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -6,6 +6,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index 4677fe350b0e..4fca07099903 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/evidence/types/msgs_test.go b/x/evidence/types/msgs_test.go index ed9214e745ee..66c955f4200a 100644 --- a/x/evidence/types/msgs_test.go +++ b/x/evidence/types/msgs_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/types" diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index 710fc77e575d..5b430a192ccd 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index 868febe58b24..ae7e9b2ee1f8 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -8,6 +8,8 @@ import ( abci "github.com/tendermint/tendermint/abci/types" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index ad7a2610f691..55daa7935a50 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -8,6 +8,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index ef7af32a42fe..a907dcd57fed 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -9,11 +9,11 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" - cryptoenc "github.com/tendermint/tendermint/crypto/encoding" tmtypes "github.com/tendermint/tendermint/types" - yaml "gopkg.in/yaml.v2" + "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/encoding" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/staking/exported" @@ -224,7 +224,7 @@ func (d Description) EnsureLength() (Description, error) { // ABCIValidatorUpdate returns an abci.ValidatorUpdate from a staking validator type // with the full validator power func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate { - pk, err := cryptoenc.PubKeyToProto(v.GetConsPubKey()) + pk, err := encoding.PubKeyToProto(v.GetConsPubKey()) if err != nil { panic(err) } @@ -238,7 +238,7 @@ func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate { // ABCIValidatorUpdateZero returns an abci.ValidatorUpdate from a staking validator type // with zero power used for validator updates. func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate { - pk, err := cryptoenc.PubKeyToProto(v.GetConsPubKey()) + pk, err := encoding.PubKeyToProto(v.GetConsPubKey()) if err != nil { panic(err) } diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index e86bd1b82721..c02041fb2d32 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -9,11 +9,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - cryptoenc "github.com/tendermint/tendermint/crypto/encoding" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/encoding" sdk "github.com/cosmos/cosmos-sdk/types" ) @@ -63,7 +63,7 @@ func TestABCIValidatorUpdate(t *testing.T) { validator := NewValidator(valAddr1, pk1, Description{}) abciVal := validator.ABCIValidatorUpdate() - pk, err := cryptoenc.PubKeyToProto(validator.GetConsPubKey()) + pk, err := encoding.PubKeyToProto(validator.GetConsPubKey()) require.NoError(t, err) require.Equal(t, pk, abciVal.PubKey) require.Equal(t, validator.BondedTokens().Int64(), abciVal.Power) @@ -73,7 +73,7 @@ func TestABCIValidatorUpdateZero(t *testing.T) { validator := NewValidator(valAddr1, pk1, Description{}) abciVal := validator.ABCIValidatorUpdateZero() - pk, err := cryptoenc.PubKeyToProto(validator.GetConsPubKey()) + pk, err := encoding.PubKeyToProto(validator.GetConsPubKey()) require.NoError(t, err) require.Equal(t, pk, abciVal.PubKey) require.Equal(t, int64(0), abciVal.Power) From 78b1b22062f2af1be92575efc43d46768c39c175 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Wed, 26 Aug 2020 02:23:18 +0530 Subject: [PATCH 04/15] Update pubkey prefix --- crypto/keys/ed25519/ed25519.go | 4 ++-- crypto/keys/secp256k1/secp256k1.go | 4 ++-- crypto/keys/sr25519/encoding.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go index e0c1257310f1..ac21f59ddef5 100644 --- a/crypto/keys/ed25519/ed25519.go +++ b/crypto/keys/ed25519/ed25519.go @@ -17,8 +17,8 @@ import ( var _ crypto.PrivKey = PrivKey{} const ( - PrivKeyName = "tendermint/PrivKeyEd25519" - PubKeyName = "tendermint/PubKeyEd25519" + PrivKeyName = "cosmos-sdk/PrivKeyEd25519" + PubKeyName = "cosmos-sdk/PubKeyEd25519" // PubKeySize is is the size, in bytes, of public keys as used in this package. PubKeySize = 32 // PrivateKeySize is the size, in bytes, of private keys as used in this package. diff --git a/crypto/keys/secp256k1/secp256k1.go b/crypto/keys/secp256k1/secp256k1.go index 2ff2685b3a05..365f29b0b83f 100644 --- a/crypto/keys/secp256k1/secp256k1.go +++ b/crypto/keys/secp256k1/secp256k1.go @@ -19,8 +19,8 @@ var _ crypto.PrivKey = PrivKey{} const ( PrivKeySize = 32 keyType = "secp256k1" - PrivKeyName = "tendermint/PrivKeySecp256k1" - PubKeyName = "tendermint/PubKeySecp256k1" + PrivKeyName = "cosmos-sdk/PrivKeySecp256k1" + PubKeyName = "cosmos-sdk/PubKeySecp256k1" ) // PrivKey implements PrivKey. diff --git a/crypto/keys/sr25519/encoding.go b/crypto/keys/sr25519/encoding.go index 03e7fa7e91b0..6168e9aaa5ed 100644 --- a/crypto/keys/sr25519/encoding.go +++ b/crypto/keys/sr25519/encoding.go @@ -7,8 +7,8 @@ import ( var _ crypto.PrivKey = PrivKey{} const ( - PrivKeyName = "tendermint/PrivKeySr25519" - PubKeyName = "tendermint/PubKeySr25519" + PrivKeyName = "cosmos-sdk/PrivKeySr25519" + PubKeyName = "cosmos-sdk/PubKeySr25519" // SignatureSize is the size of an Edwards25519 signature. Namely the size of a compressed // Sr25519 point, and a field element. Both of which are 32 bytes. From 6e28dab691ea0f391daaf9b2ad2f01f41654a0fb Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Wed, 26 Aug 2020 15:54:32 +0200 Subject: [PATCH 05/15] revert ed25519 to tendermint key --- crypto/codec/amino.go | 5 +++++ x/ibc/07-tendermint/types/msgs_test.go | 1 + x/ibc/testing/solomachine.go | 2 +- x/staking/common_test.go | 2 +- x/staking/simulation/decoder_test.go | 2 +- x/staking/types/keys_test.go | 2 +- x/staking/types/test_utils.go | 2 +- x/staking/types/validator.go | 3 ++- x/staking/types/validator_test.go | 2 +- 9 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 87fcda6067a0..92cd2e513a2b 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -2,6 +2,7 @@ package codec import ( "github.com/tendermint/tendermint/crypto" + tmed "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" @@ -21,6 +22,8 @@ func init() { // codec. func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PubKey)(nil), nil) + cdc.RegisterConcrete(tmed.PubKey{}, + tmed.PubKeyName, nil) cdc.RegisterConcrete(ed25519.PubKey{}, ed25519.PubKeyName, nil) cdc.RegisterConcrete(sr25519.PubKey{}, @@ -33,6 +36,8 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) cdc.RegisterConcrete(ed25519.PrivKey{}, ed25519.PrivKeyName, nil) + cdc.RegisterConcrete(tmed.PrivKey{}, + tmed.PrivKeyName, nil) cdc.RegisterConcrete(sr25519.PrivKey{}, sr25519.PrivKeyName, nil) cdc.RegisterConcrete(secp256k1.PrivKey{}, diff --git a/x/ibc/07-tendermint/types/msgs_test.go b/x/ibc/07-tendermint/types/msgs_test.go index ead2824c3454..6cfc111b5390 100644 --- a/x/ibc/07-tendermint/types/msgs_test.go +++ b/x/ibc/07-tendermint/types/msgs_test.go @@ -4,6 +4,7 @@ import ( ics23 "github.com/confio/ics23/go" tmtypes "github.com/tendermint/tendermint/types" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/ibc/02-client/exported" types "github.com/cosmos/cosmos-sdk/x/ibc/07-tendermint/types" diff --git a/x/ibc/testing/solomachine.go b/x/ibc/testing/solomachine.go index 6a6a8cd2915b..ee415181dd21 100644 --- a/x/ibc/testing/solomachine.go +++ b/x/ibc/testing/solomachine.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" solomachinetypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types" diff --git a/x/staking/common_test.go b/x/staking/common_test.go index 1dafa2ecd709..52dd0ec6c812 100644 --- a/x/staking/common_test.go +++ b/x/staking/common_test.go @@ -2,10 +2,10 @@ package staking_test import ( "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/simulation/decoder_test.go b/x/staking/simulation/decoder_test.go index b5fdfb479092..f442f648dd6e 100644 --- a/x/staking/simulation/decoder_test.go +++ b/x/staking/simulation/decoder_test.go @@ -6,10 +6,10 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/staking/types/keys_test.go b/x/staking/types/keys_test.go index 725438707c76..0f11cf27f7f6 100644 --- a/x/staking/types/keys_test.go +++ b/x/staking/types/keys_test.go @@ -8,8 +8,8 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/staking/types/test_utils.go b/x/staking/types/test_utils.go index a65a0ee9e078..9ab8aabfe82c 100644 --- a/x/staking/types/test_utils.go +++ b/x/staking/types/test_utils.go @@ -2,8 +2,8 @@ package types import ( "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index a907dcd57fed..159e6318d76e 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -9,11 +9,12 @@ import ( abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/encoding" tmtypes "github.com/tendermint/tendermint/types" "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/encoding" + // "github.com/cosmos/cosmos-sdk/crypto/keys/encoding" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/staking/exported" diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index c02041fb2d32..228ab0a74f41 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -13,8 +13,8 @@ import ( "github.com/cosmos/cosmos-sdk/codec/legacy" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/encoding" sdk "github.com/cosmos/cosmos-sdk/types" + "github.com/tendermint/tendermint/crypto/encoding" ) func TestValidatorTestEquivalent(t *testing.T) { From 0f581613f0372d214171e04abd4304308b02edff Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Wed, 26 Aug 2020 16:15:36 +0200 Subject: [PATCH 06/15] random account revert --- types/simulation/account.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/simulation/account.go b/types/simulation/account.go index b0c6b7bd687a..2f45ad43d688 100644 --- a/types/simulation/account.go +++ b/types/simulation/account.go @@ -4,8 +4,8 @@ import ( "math/rand" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" sdk "github.com/cosmos/cosmos-sdk/types" ) From 9e3af96ecf8fee6f8f33fa7af5ec834728d5d332 Mon Sep 17 00:00:00 2001 From: sahith-narahari Date: Thu, 27 Aug 2020 02:52:33 +0530 Subject: [PATCH 07/15] Revert ed25519 references --- client/debug/main.go | 2 +- crypto/keyring/keyring_test.go | 2 +- crypto/keys/ed25519/ed25519_test.go | 1 - crypto/keys/encoding/codec.go | 3 +-- crypto/types/multisig/codec.go | 2 +- crypto/types/multisig/threshold_pubkey_test.go | 2 +- simapp/test_helpers.go | 2 +- std/pubkey.go | 2 +- std/pubkey_test.go | 3 ++- types/address_bench_test.go | 2 +- types/address_test.go | 2 +- x/auth/ante/ante_test.go | 2 +- x/auth/ante/sigverify.go | 3 ++- x/auth/ante/sigverify_test.go | 2 +- x/auth/client/tx_test.go | 3 ++- x/auth/simulation/decoder_test.go | 2 +- x/auth/types/genesis_test.go | 2 +- x/auth/types/stdtx_test.go | 2 +- x/auth/vesting/types/genesis_test.go | 2 +- x/distribution/proposal_handler_test.go | 2 +- x/distribution/simulation/decoder_test.go | 2 +- x/distribution/types/common_test.go | 2 +- x/evidence/genesis_test.go | 2 +- x/evidence/handler_test.go | 2 +- x/evidence/keeper/keeper_test.go | 2 +- x/evidence/simulation/decoder_test.go | 2 +- x/evidence/types/genesis_test.go | 2 +- x/evidence/types/msgs_test.go | 3 ++- x/genutil/types/genesis_state_test.go | 2 +- x/gov/common_test.go | 2 +- x/gov/simulation/decoder_test.go | 2 +- x/gov/types/keys_test.go | 2 +- x/ibc/testing/solomachine.go | 2 +- x/slashing/app_test.go | 2 +- x/slashing/simulation/decoder_test.go | 2 +- x/staking/client/cli/cli_test.go | 2 +- x/staking/genesis_test.go | 2 +- x/staking/types/validator_test.go | 2 +- 38 files changed, 41 insertions(+), 39 deletions(-) diff --git a/client/debug/main.go b/client/debug/main.go index d3ecfbc4644d..a35fdecf01ab 100644 --- a/client/debug/main.go +++ b/client/debug/main.go @@ -9,9 +9,9 @@ import ( "github.com/spf13/cobra" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/version" ) diff --git a/crypto/keyring/keyring_test.go b/crypto/keyring/keyring_test.go index 569698125a6d..e586fe38a0b9 100644 --- a/crypto/keyring/keyring_test.go +++ b/crypto/keyring/keyring_test.go @@ -9,10 +9,10 @@ import ( bip39 "github.com/cosmos/go-bip39" "github.com/stretchr/testify/require" tmcrypto "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/crypto" "github.com/cosmos/cosmos-sdk/crypto/hd" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil" diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go index 22f966845440..487097692804 100644 --- a/crypto/keys/ed25519/ed25519_test.go +++ b/crypto/keys/ed25519/ed25519_test.go @@ -5,7 +5,6 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" diff --git a/crypto/keys/encoding/codec.go b/crypto/keys/encoding/codec.go index a5f8ba8c70c3..bf4250f680d4 100644 --- a/crypto/keys/encoding/codec.go +++ b/crypto/keys/encoding/codec.go @@ -5,9 +5,8 @@ import ( "fmt" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" pc "github.com/tendermint/tendermint/proto/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" ) // PubKeyToProto takes crypto.PubKey and transforms it to a protobuf Pubkey diff --git a/crypto/types/multisig/codec.go b/crypto/types/multisig/codec.go index bfaa01978f71..72ea2d58c658 100644 --- a/crypto/types/multisig/codec.go +++ b/crypto/types/multisig/codec.go @@ -2,10 +2,10 @@ package multisig import ( amino "github.com/tendermint/go-amino" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/crypto" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" ) diff --git a/crypto/types/multisig/threshold_pubkey_test.go b/crypto/types/multisig/threshold_pubkey_test.go index 18715fc94c30..6c656791b518 100644 --- a/crypto/types/multisig/threshold_pubkey_test.go +++ b/crypto/types/multisig/threshold_pubkey_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types" diff --git a/simapp/test_helpers.go b/simapp/test_helpers.go index b25b7399eb29..d694cb0b7159 100644 --- a/simapp/test_helpers.go +++ b/simapp/test_helpers.go @@ -12,6 +12,7 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" tmtypes "github.com/tendermint/tendermint/types" @@ -19,7 +20,6 @@ import ( bam "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp/helpers" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/std/pubkey.go b/std/pubkey.go index a2fae4f90e5b..58ec9cfa8fc1 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types" diff --git a/std/pubkey_test.go b/std/pubkey_test.go index 4e9be87f87f1..910cac3e6c72 100644 --- a/std/pubkey_test.go +++ b/std/pubkey_test.go @@ -3,7 +3,8 @@ package std_test import ( "testing" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/std" diff --git a/types/address_bench_test.go b/types/address_bench_test.go index e6ddc506740a..d9c1aa7325cd 100644 --- a/types/address_bench_test.go +++ b/types/address_bench_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/types" ) diff --git a/types/address_test.go b/types/address_test.go index 2a89425ff5e9..67e3add6c0ba 100644 --- a/types/address_test.go +++ b/types/address_test.go @@ -10,9 +10,9 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" yaml "gopkg.in/yaml.v2" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/auth/ante/ante_test.go b/x/auth/ante/ante_test.go index 56745ef9b11b..84602abcb98f 100644 --- a/x/auth/ante/ante_test.go +++ b/x/auth/ante/ante_test.go @@ -9,8 +9,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil/testdata" diff --git a/x/auth/ante/sigverify.go b/x/auth/ante/sigverify.go index 622b5b864359..fc783c6b8523 100644 --- a/x/auth/ante/sigverify.go +++ b/x/auth/ante/sigverify.go @@ -5,7 +5,8 @@ import ( "encoding/hex" "fmt" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/auth/ante/sigverify_test.go b/x/auth/ante/sigverify_test.go index 470a5fd7a7a3..d757f720cf0d 100644 --- a/x/auth/ante/sigverify_test.go +++ b/x/auth/ante/sigverify_test.go @@ -4,8 +4,8 @@ import ( "fmt" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/simapp" diff --git a/x/auth/client/tx_test.go b/x/auth/client/tx_test.go index 4848002967e3..3483f17f4a59 100644 --- a/x/auth/client/tx_test.go +++ b/x/auth/client/tx_test.go @@ -5,7 +5,8 @@ import ( "strings" "testing" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/cosmos/cosmos-sdk/simapp" "github.com/cosmos/cosmos-sdk/testutil" "github.com/cosmos/cosmos-sdk/testutil/testdata" diff --git a/x/auth/simulation/decoder_test.go b/x/auth/simulation/decoder_test.go index c7ececcf95cc..453966a1fd8b 100644 --- a/x/auth/simulation/decoder_test.go +++ b/x/auth/simulation/decoder_test.go @@ -6,8 +6,8 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/auth/types/genesis_test.go b/x/auth/types/genesis_test.go index 1030885e799e..2c4d5cea002a 100644 --- a/x/auth/types/genesis_test.go +++ b/x/auth/types/genesis_test.go @@ -6,9 +6,9 @@ import ( proto "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/auth/types" ) diff --git a/x/auth/types/stdtx_test.go b/x/auth/types/stdtx_test.go index c795a6f672d1..eb1f94c71a07 100644 --- a/x/auth/types/stdtx_test.go +++ b/x/auth/types/stdtx_test.go @@ -6,13 +6,13 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/tendermint/tendermint/libs/log" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" yaml "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/testutil/testdata" diff --git a/x/auth/vesting/types/genesis_test.go b/x/auth/vesting/types/genesis_test.go index 98aabb15cfde..79913adf7de5 100644 --- a/x/auth/vesting/types/genesis_test.go +++ b/x/auth/vesting/types/genesis_test.go @@ -4,8 +4,8 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" ) diff --git a/x/distribution/proposal_handler_test.go b/x/distribution/proposal_handler_test.go index 575dbb199cbe..34e99fb27bd3 100644 --- a/x/distribution/proposal_handler_test.go +++ b/x/distribution/proposal_handler_test.go @@ -4,9 +4,9 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/distribution" diff --git a/x/distribution/simulation/decoder_test.go b/x/distribution/simulation/decoder_test.go index 7a705f97da10..8b65d08a09e5 100644 --- a/x/distribution/simulation/decoder_test.go +++ b/x/distribution/simulation/decoder_test.go @@ -5,8 +5,8 @@ import ( "testing" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/distribution/types/common_test.go b/x/distribution/types/common_test.go index a8301b4e42bd..c9dbfde6f0b1 100644 --- a/x/distribution/types/common_test.go +++ b/x/distribution/types/common_test.go @@ -2,8 +2,8 @@ package types import ( "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/evidence/genesis_test.go b/x/evidence/genesis_test.go index bbe8a529e9b3..dbd69dca34c5 100644 --- a/x/evidence/genesis_test.go +++ b/x/evidence/genesis_test.go @@ -5,10 +5,10 @@ import ( "testing" "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/tendermint/tendermint/types/time" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence" diff --git a/x/evidence/handler_test.go b/x/evidence/handler_test.go index e30950bf7875..1d5388b7c88e 100644 --- a/x/evidence/handler_test.go +++ b/x/evidence/handler_test.go @@ -7,9 +7,9 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence" diff --git a/x/evidence/keeper/keeper_test.go b/x/evidence/keeper/keeper_test.go index 216f96d9a256..664ea9595470 100644 --- a/x/evidence/keeper/keeper_test.go +++ b/x/evidence/keeper/keeper_test.go @@ -8,10 +8,10 @@ import ( "github.com/stretchr/testify/suite" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" "github.com/cosmos/cosmos-sdk/baseapp" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" diff --git a/x/evidence/simulation/decoder_test.go b/x/evidence/simulation/decoder_test.go index 4fca07099903..b8d1e70c179c 100644 --- a/x/evidence/simulation/decoder_test.go +++ b/x/evidence/simulation/decoder_test.go @@ -6,8 +6,8 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/evidence/types/genesis_test.go b/x/evidence/types/genesis_test.go index 1107e244f501..b8b8ee0e1a16 100644 --- a/x/evidence/types/genesis_test.go +++ b/x/evidence/types/genesis_test.go @@ -6,11 +6,11 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" tmbytes "github.com/tendermint/tendermint/libs/bytes" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/types" ) diff --git a/x/evidence/types/msgs_test.go b/x/evidence/types/msgs_test.go index 66c955f4200a..5947065a727a 100644 --- a/x/evidence/types/msgs_test.go +++ b/x/evidence/types/msgs_test.go @@ -4,7 +4,8 @@ import ( "testing" "time" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" + "github.com/tendermint/tendermint/crypto/ed25519" + sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/evidence/exported" "github.com/cosmos/cosmos-sdk/x/evidence/types" diff --git a/x/genutil/types/genesis_state_test.go b/x/genutil/types/genesis_state_test.go index 770baa09dd3f..5d2b2d8627b2 100644 --- a/x/genutil/types/genesis_state_test.go +++ b/x/genutil/types/genesis_state_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/gov/common_test.go b/x/gov/common_test.go index aef391d794aa..81bfd32fd85b 100644 --- a/x/gov/common_test.go +++ b/x/gov/common_test.go @@ -8,8 +8,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/x/gov/types" stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" diff --git a/x/gov/simulation/decoder_test.go b/x/gov/simulation/decoder_test.go index 7a5b0fc1bc9d..c5c9e720d92e 100644 --- a/x/gov/simulation/decoder_test.go +++ b/x/gov/simulation/decoder_test.go @@ -7,8 +7,8 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/gov/types/keys_test.go b/x/gov/types/keys_test.go index 80dfa7d207a3..80d77c66043a 100644 --- a/x/gov/types/keys_test.go +++ b/x/gov/types/keys_test.go @@ -5,8 +5,8 @@ import ( "time" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" ) diff --git a/x/ibc/testing/solomachine.go b/x/ibc/testing/solomachine.go index ee415181dd21..6a6a8cd2915b 100644 --- a/x/ibc/testing/solomachine.go +++ b/x/ibc/testing/solomachine.go @@ -5,8 +5,8 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/std" sdk "github.com/cosmos/cosmos-sdk/types" solomachinetypes "github.com/cosmos/cosmos-sdk/x/ibc/light-clients/solomachine/types" diff --git a/x/slashing/app_test.go b/x/slashing/app_test.go index a8959fb610c3..bfe8c8b45bee 100644 --- a/x/slashing/app_test.go +++ b/x/slashing/app_test.go @@ -6,9 +6,9 @@ import ( "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/crypto/ed25519" tmproto "github.com/tendermint/tendermint/proto/tendermint/types" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/slashing/simulation/decoder_test.go b/x/slashing/simulation/decoder_test.go index e6122f0e0a98..493645392f1f 100644 --- a/x/slashing/simulation/decoder_test.go +++ b/x/slashing/simulation/decoder_test.go @@ -7,8 +7,8 @@ import ( gogotypes "github.com/gogo/protobuf/types" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/kv" diff --git a/x/staking/client/cli/cli_test.go b/x/staking/client/cli/cli_test.go index c79b7a3e7020..0981df3b4f72 100644 --- a/x/staking/client/cli/cli_test.go +++ b/x/staking/client/cli/cli_test.go @@ -6,11 +6,11 @@ import ( "github.com/gogo/protobuf/proto" "github.com/stretchr/testify/suite" + "github.com/tendermint/tendermint/crypto/ed25519" "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/ed25519" clitestutil "github.com/cosmos/cosmos-sdk/testutil/cli" "github.com/cosmos/cosmos-sdk/testutil/network" sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/x/staking/genesis_test.go b/x/staking/genesis_test.go index 55daa7935a50..989bf56bf00d 100644 --- a/x/staking/genesis_test.go +++ b/x/staking/genesis_test.go @@ -7,8 +7,8 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" abci "github.com/tendermint/tendermint/abci/types" + "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/simapp" sdk "github.com/cosmos/cosmos-sdk/types" banktypes "github.com/cosmos/cosmos-sdk/x/bank/types" diff --git a/x/staking/types/validator_test.go b/x/staking/types/validator_test.go index 228ab0a74f41..beb6c22ffd10 100644 --- a/x/staking/types/validator_test.go +++ b/x/staking/types/validator_test.go @@ -8,11 +8,11 @@ import ( "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto/ed25519" tmtypes "github.com/tendermint/tendermint/types" "github.com/cosmos/cosmos-sdk/codec/legacy" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/tendermint/tendermint/crypto/encoding" ) From ea744da389f268451c1a5776d81a0472f59b0bb5 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 27 Aug 2020 10:50:29 +0200 Subject: [PATCH 08/15] revert secp key name --- crypto/keys/secp256k1/secp256k1.go | 4 ++-- types/rest/rest_test.go | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crypto/keys/secp256k1/secp256k1.go b/crypto/keys/secp256k1/secp256k1.go index 365f29b0b83f..2ff2685b3a05 100644 --- a/crypto/keys/secp256k1/secp256k1.go +++ b/crypto/keys/secp256k1/secp256k1.go @@ -19,8 +19,8 @@ var _ crypto.PrivKey = PrivKey{} const ( PrivKeySize = 32 keyType = "secp256k1" - PrivKeyName = "cosmos-sdk/PrivKeySecp256k1" - PubKeyName = "cosmos-sdk/PubKeySecp256k1" + PrivKeyName = "tendermint/PrivKeySecp256k1" + PubKeyName = "tendermint/PubKeySecp256k1" ) // PrivKey implements PrivKey. diff --git a/types/rest/rest_test.go b/types/rest/rest_test.go index 5102e223debc..b6ff87be5cf9 100644 --- a/types/rest/rest_test.go +++ b/types/rest/rest_test.go @@ -18,6 +18,7 @@ import ( "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" simappparams "github.com/cosmos/cosmos-sdk/simapp/params" "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/rest" From fd2ebe266065297beee0217c052049ecc453cf8f Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 27 Aug 2020 11:04:39 +0200 Subject: [PATCH 09/15] test revert --- tests/mocks/types_module_module.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/mocks/types_module_module.go b/tests/mocks/types_module_module.go index 042e03503165..81221aef036f 100644 --- a/tests/mocks/types_module_module.go +++ b/tests/mocks/types_module_module.go @@ -539,17 +539,17 @@ func (mr *MockAppModuleMockRecorder) QuerierRoute() *gomock.Call { } // LegacyQuerierHandler mocks base method -func (m *MockAppModule) LegacyQuerierHandler(arg0 *codec.LegacyAmino) types0.Querier { +func (m *MockAppModule) LegacyQuerierHandler(*codec.LegacyAmino) types0.Querier { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "LegacyQuerierHandler", arg0) + ret := m.ctrl.Call(m, "LegacyQuerierHandler") ret0, _ := ret[0].(types0.Querier) return ret0 } // LegacyQuerierHandler indicates an expected call of LegacyQuerierHandler -func (mr *MockAppModuleMockRecorder) LegacyQuerierHandler(arg0 interface{}) *gomock.Call { +func (mr *MockAppModuleMockRecorder) NewQuerierHandler() *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LegacyQuerierHandler", reflect.TypeOf((*MockAppModule)(nil).LegacyQuerierHandler), arg0) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LegacyQuerierHandler", reflect.TypeOf((*MockAppModule)(nil).LegacyQuerierHandler)) } // RegisterQueryService mocks base method From 66d2e1d061aeae81c4c0a3daf718536b09dda19e Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Thu, 27 Aug 2020 17:02:03 +0200 Subject: [PATCH 10/15] remove ed25519 --- crypto/codec/amino.go | 7 +- crypto/keys/ed25519/bench_test.go | 27 ----- crypto/keys/ed25519/ed25519.go | 165 ---------------------------- crypto/keys/ed25519/ed25519_test.go | 30 ----- 4 files changed, 1 insertion(+), 228 deletions(-) delete mode 100644 crypto/keys/ed25519/bench_test.go delete mode 100644 crypto/keys/ed25519/ed25519.go delete mode 100644 crypto/keys/ed25519/ed25519_test.go diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 92cd2e513a2b..6395aba725e3 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -2,10 +2,9 @@ package codec import ( "github.com/tendermint/tendermint/crypto" - tmed "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" @@ -22,8 +21,6 @@ func init() { // codec. func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PubKey)(nil), nil) - cdc.RegisterConcrete(tmed.PubKey{}, - tmed.PubKeyName, nil) cdc.RegisterConcrete(ed25519.PubKey{}, ed25519.PubKeyName, nil) cdc.RegisterConcrete(sr25519.PubKey{}, @@ -36,8 +33,6 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) cdc.RegisterConcrete(ed25519.PrivKey{}, ed25519.PrivKeyName, nil) - cdc.RegisterConcrete(tmed.PrivKey{}, - tmed.PrivKeyName, nil) cdc.RegisterConcrete(sr25519.PrivKey{}, sr25519.PrivKeyName, nil) cdc.RegisterConcrete(secp256k1.PrivKey{}, diff --git a/crypto/keys/ed25519/bench_test.go b/crypto/keys/ed25519/bench_test.go deleted file mode 100644 index d3961c4247ff..000000000000 --- a/crypto/keys/ed25519/bench_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package ed25519 - -import ( - "io" - "testing" - - "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" -) - -func BenchmarkKeyGeneration(b *testing.B) { - benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { - return genPrivKey(reader) - } - benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) -} - -func BenchmarkSigning(b *testing.B) { - priv := GenPrivKey() - benchmarking.BenchmarkSigning(b, priv) -} - -func BenchmarkVerification(b *testing.B) { - priv := GenPrivKey() - benchmarking.BenchmarkVerification(b, priv) -} diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go deleted file mode 100644 index ac21f59ddef5..000000000000 --- a/crypto/keys/ed25519/ed25519.go +++ /dev/null @@ -1,165 +0,0 @@ -package ed25519 - -import ( - "bytes" - "crypto/subtle" - "fmt" - "io" - - "golang.org/x/crypto/ed25519" - - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/tmhash" -) - -//------------------------------------- - -var _ crypto.PrivKey = PrivKey{} - -const ( - PrivKeyName = "cosmos-sdk/PrivKeyEd25519" - PubKeyName = "cosmos-sdk/PubKeyEd25519" - // PubKeySize is is the size, in bytes, of public keys as used in this package. - PubKeySize = 32 - // PrivateKeySize is the size, in bytes, of private keys as used in this package. - PrivateKeySize = 64 - // Size of an Edwards25519 signature. Namely the size of a compressed - // Edwards25519 point, and a field element. Both of which are 32 bytes. - SignatureSize = 64 - // SeedSize is the size, in bytes, of private key seeds. These are the - // private key representations used by RFC 8032. - SeedSize = 32 - - keyType = "ed25519" -) - -// PrivKey implements crypto.PrivKey. -type PrivKey []byte - -// Bytes returns the privkey byte format. -func (privKey PrivKey) Bytes() []byte { - return []byte(privKey) -} - -// Sign produces a signature on the provided message. -// This assumes the privkey is wellformed in the golang format. -// The first 32 bytes should be random, -// corresponding to the normal ed25519 private key. -// The latter 32 bytes should be the compressed public key. -// If these conditions aren't met, Sign will panic or produce an -// incorrect signature. -func (privKey PrivKey) Sign(msg []byte) ([]byte, error) { - signatureBytes := ed25519.Sign(ed25519.PrivateKey(privKey), msg) - return signatureBytes, nil -} - -// PubKey gets the corresponding public key from the private key. -// -// Panics if the private key is not initialized. -func (privKey PrivKey) PubKey() crypto.PubKey { - // If the latter 32 bytes of the privkey are all zero, privkey is not - // initialized. - initialized := false - for _, v := range privKey[32:] { - if v != 0 { - initialized = true - break - } - } - - if !initialized { - panic("Expected ed25519 PrivKey to include concatenated pubkey bytes") - } - - pubkeyBytes := make([]byte, PubKeySize) - copy(pubkeyBytes, privKey[32:]) - return PubKey(pubkeyBytes) -} - -// Equals - you probably don't need to use this. -// Runs in constant time based on length of the keys. -func (privKey PrivKey) Equals(other crypto.PrivKey) bool { - if otherEd, ok := other.(PrivKey); ok { - return subtle.ConstantTimeCompare(privKey[:], otherEd[:]) == 1 - } - - return false -} - -func (privKey PrivKey) Type() string { - return keyType -} - -// GenPrivKey generates a new ed25519 private key. -// It uses OS randomness in conjunction with the current global random seed -// in tendermint/libs/common to generate the private key. -func GenPrivKey() PrivKey { - return genPrivKey(crypto.CReader()) -} - -// genPrivKey generates a new ed25519 private key using the provided reader. -func genPrivKey(rand io.Reader) PrivKey { - seed := make([]byte, SeedSize) - - _, err := io.ReadFull(rand, seed) - if err != nil { - panic(err) - } - - return PrivKey(ed25519.NewKeyFromSeed(seed)) -} - -// GenPrivKeyFromSecret hashes the secret with SHA2, and uses -// that 32 byte output to create the private key. -// NOTE: secret should be the output of a KDF like bcrypt, -// if it's derived from user input. -func GenPrivKeyFromSecret(secret []byte) PrivKey { - seed := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. - - return PrivKey(ed25519.NewKeyFromSeed(seed)) -} - -//------------------------------------- - -var _ crypto.PubKey = PubKey{} - -// PubKeyEd25519 implements crypto.PubKey for the Ed25519 signature scheme. -type PubKey []byte - -// Address is the SHA256-20 of the raw pubkey bytes. -func (pubKey PubKey) Address() crypto.Address { - if len(pubKey) != PubKeySize { - panic("pubkey is incorrect size") - } - return crypto.Address(tmhash.SumTruncated(pubKey)) -} - -// Bytes returns the PubKey byte format. -func (pubKey PubKey) Bytes() []byte { - return []byte(pubKey) -} - -func (pubKey PubKey) VerifySignature(msg []byte, sig []byte) bool { - // make sure we use the same algorithm to sign - if len(sig) != SignatureSize { - return false - } - - return ed25519.Verify(ed25519.PublicKey(pubKey), msg, sig) -} - -func (pubKey PubKey) String() string { - return fmt.Sprintf("PubKeyEd25519{%X}", []byte(pubKey)) -} - -func (pubKey PubKey) Type() string { - return keyType -} - -func (pubKey PubKey) Equals(other crypto.PubKey) bool { - if otherEd, ok := other.(PubKey); ok { - return bytes.Equal(pubKey[:], otherEd[:]) - } - - return false -} diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go deleted file mode 100644 index 487097692804..000000000000 --- a/crypto/keys/ed25519/ed25519_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package ed25519_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" -) - -func TestSignAndValidateEd25519(t *testing.T) { - - privKey := ed25519.GenPrivKey() - pubKey := privKey.PubKey() - - msg := crypto.CRandBytes(128) - sig, err := privKey.Sign(msg) - require.Nil(t, err) - - // Test the signature - assert.True(t, pubKey.VerifySignature(msg, sig)) - - // Mutate the signature, just one bit. - // TODO: Replace this with a much better fuzzer, tendermint/ed25519/issues/10 - sig[7] ^= byte(0x01) - - assert.False(t, pubKey.VerifySignature(msg, sig)) -} From 00d040c2da20b78b51c8ac862607f02f95e0b2b2 Mon Sep 17 00:00:00 2001 From: SaReN Date: Fri, 28 Aug 2020 18:24:56 +0530 Subject: [PATCH 11/15] Update x/staking/types/validator.go Co-authored-by: Amaury Martiny --- x/staking/types/validator.go | 1 - 1 file changed, 1 deletion(-) diff --git a/x/staking/types/validator.go b/x/staking/types/validator.go index 159e6318d76e..7328bfbc80a2 100644 --- a/x/staking/types/validator.go +++ b/x/staking/types/validator.go @@ -14,7 +14,6 @@ import ( "gopkg.in/yaml.v2" "github.com/cosmos/cosmos-sdk/codec" - // "github.com/cosmos/cosmos-sdk/crypto/keys/encoding" sdk "github.com/cosmos/cosmos-sdk/types" sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" "github.com/cosmos/cosmos-sdk/x/staking/exported" From 42dd530e8ef2c58e0078879dd6e445d4d8c584da Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Fri, 28 Aug 2020 15:11:27 +0200 Subject: [PATCH 12/15] Revert "remove ed25519" This reverts commit 66d2e1d061aeae81c4c0a3daf718536b09dda19e. --- crypto/codec/amino.go | 7 +- crypto/keys/ed25519/bench_test.go | 27 +++++ crypto/keys/ed25519/ed25519.go | 165 ++++++++++++++++++++++++++++ crypto/keys/ed25519/ed25519_test.go | 30 +++++ 4 files changed, 228 insertions(+), 1 deletion(-) create mode 100644 crypto/keys/ed25519/bench_test.go create mode 100644 crypto/keys/ed25519/ed25519.go create mode 100644 crypto/keys/ed25519/ed25519_test.go diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 6395aba725e3..92cd2e513a2b 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -2,9 +2,10 @@ package codec import ( "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" + tmed "github.com/tendermint/tendermint/crypto/ed25519" "github.com/cosmos/cosmos-sdk/codec" + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" @@ -21,6 +22,8 @@ func init() { // codec. func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PubKey)(nil), nil) + cdc.RegisterConcrete(tmed.PubKey{}, + tmed.PubKeyName, nil) cdc.RegisterConcrete(ed25519.PubKey{}, ed25519.PubKeyName, nil) cdc.RegisterConcrete(sr25519.PubKey{}, @@ -33,6 +36,8 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) cdc.RegisterConcrete(ed25519.PrivKey{}, ed25519.PrivKeyName, nil) + cdc.RegisterConcrete(tmed.PrivKey{}, + tmed.PrivKeyName, nil) cdc.RegisterConcrete(sr25519.PrivKey{}, sr25519.PrivKeyName, nil) cdc.RegisterConcrete(secp256k1.PrivKey{}, diff --git a/crypto/keys/ed25519/bench_test.go b/crypto/keys/ed25519/bench_test.go new file mode 100644 index 000000000000..d3961c4247ff --- /dev/null +++ b/crypto/keys/ed25519/bench_test.go @@ -0,0 +1,27 @@ +package ed25519 + +import ( + "io" + "testing" + + "github.com/tendermint/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" +) + +func BenchmarkKeyGeneration(b *testing.B) { + benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { + return genPrivKey(reader) + } + benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) +} + +func BenchmarkSigning(b *testing.B) { + priv := GenPrivKey() + benchmarking.BenchmarkSigning(b, priv) +} + +func BenchmarkVerification(b *testing.B) { + priv := GenPrivKey() + benchmarking.BenchmarkVerification(b, priv) +} diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go new file mode 100644 index 000000000000..ac21f59ddef5 --- /dev/null +++ b/crypto/keys/ed25519/ed25519.go @@ -0,0 +1,165 @@ +package ed25519 + +import ( + "bytes" + "crypto/subtle" + "fmt" + "io" + + "golang.org/x/crypto/ed25519" + + "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/tmhash" +) + +//------------------------------------- + +var _ crypto.PrivKey = PrivKey{} + +const ( + PrivKeyName = "cosmos-sdk/PrivKeyEd25519" + PubKeyName = "cosmos-sdk/PubKeyEd25519" + // PubKeySize is is the size, in bytes, of public keys as used in this package. + PubKeySize = 32 + // PrivateKeySize is the size, in bytes, of private keys as used in this package. + PrivateKeySize = 64 + // Size of an Edwards25519 signature. Namely the size of a compressed + // Edwards25519 point, and a field element. Both of which are 32 bytes. + SignatureSize = 64 + // SeedSize is the size, in bytes, of private key seeds. These are the + // private key representations used by RFC 8032. + SeedSize = 32 + + keyType = "ed25519" +) + +// PrivKey implements crypto.PrivKey. +type PrivKey []byte + +// Bytes returns the privkey byte format. +func (privKey PrivKey) Bytes() []byte { + return []byte(privKey) +} + +// Sign produces a signature on the provided message. +// This assumes the privkey is wellformed in the golang format. +// The first 32 bytes should be random, +// corresponding to the normal ed25519 private key. +// The latter 32 bytes should be the compressed public key. +// If these conditions aren't met, Sign will panic or produce an +// incorrect signature. +func (privKey PrivKey) Sign(msg []byte) ([]byte, error) { + signatureBytes := ed25519.Sign(ed25519.PrivateKey(privKey), msg) + return signatureBytes, nil +} + +// PubKey gets the corresponding public key from the private key. +// +// Panics if the private key is not initialized. +func (privKey PrivKey) PubKey() crypto.PubKey { + // If the latter 32 bytes of the privkey are all zero, privkey is not + // initialized. + initialized := false + for _, v := range privKey[32:] { + if v != 0 { + initialized = true + break + } + } + + if !initialized { + panic("Expected ed25519 PrivKey to include concatenated pubkey bytes") + } + + pubkeyBytes := make([]byte, PubKeySize) + copy(pubkeyBytes, privKey[32:]) + return PubKey(pubkeyBytes) +} + +// Equals - you probably don't need to use this. +// Runs in constant time based on length of the keys. +func (privKey PrivKey) Equals(other crypto.PrivKey) bool { + if otherEd, ok := other.(PrivKey); ok { + return subtle.ConstantTimeCompare(privKey[:], otherEd[:]) == 1 + } + + return false +} + +func (privKey PrivKey) Type() string { + return keyType +} + +// GenPrivKey generates a new ed25519 private key. +// It uses OS randomness in conjunction with the current global random seed +// in tendermint/libs/common to generate the private key. +func GenPrivKey() PrivKey { + return genPrivKey(crypto.CReader()) +} + +// genPrivKey generates a new ed25519 private key using the provided reader. +func genPrivKey(rand io.Reader) PrivKey { + seed := make([]byte, SeedSize) + + _, err := io.ReadFull(rand, seed) + if err != nil { + panic(err) + } + + return PrivKey(ed25519.NewKeyFromSeed(seed)) +} + +// GenPrivKeyFromSecret hashes the secret with SHA2, and uses +// that 32 byte output to create the private key. +// NOTE: secret should be the output of a KDF like bcrypt, +// if it's derived from user input. +func GenPrivKeyFromSecret(secret []byte) PrivKey { + seed := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. + + return PrivKey(ed25519.NewKeyFromSeed(seed)) +} + +//------------------------------------- + +var _ crypto.PubKey = PubKey{} + +// PubKeyEd25519 implements crypto.PubKey for the Ed25519 signature scheme. +type PubKey []byte + +// Address is the SHA256-20 of the raw pubkey bytes. +func (pubKey PubKey) Address() crypto.Address { + if len(pubKey) != PubKeySize { + panic("pubkey is incorrect size") + } + return crypto.Address(tmhash.SumTruncated(pubKey)) +} + +// Bytes returns the PubKey byte format. +func (pubKey PubKey) Bytes() []byte { + return []byte(pubKey) +} + +func (pubKey PubKey) VerifySignature(msg []byte, sig []byte) bool { + // make sure we use the same algorithm to sign + if len(sig) != SignatureSize { + return false + } + + return ed25519.Verify(ed25519.PublicKey(pubKey), msg, sig) +} + +func (pubKey PubKey) String() string { + return fmt.Sprintf("PubKeyEd25519{%X}", []byte(pubKey)) +} + +func (pubKey PubKey) Type() string { + return keyType +} + +func (pubKey PubKey) Equals(other crypto.PubKey) bool { + if otherEd, ok := other.(PubKey); ok { + return bytes.Equal(pubKey[:], otherEd[:]) + } + + return false +} diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go new file mode 100644 index 000000000000..487097692804 --- /dev/null +++ b/crypto/keys/ed25519/ed25519_test.go @@ -0,0 +1,30 @@ +package ed25519_test + +import ( + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "github.com/tendermint/tendermint/crypto" + + "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" +) + +func TestSignAndValidateEd25519(t *testing.T) { + + privKey := ed25519.GenPrivKey() + pubKey := privKey.PubKey() + + msg := crypto.CRandBytes(128) + sig, err := privKey.Sign(msg) + require.Nil(t, err) + + // Test the signature + assert.True(t, pubKey.VerifySignature(msg, sig)) + + // Mutate the signature, just one bit. + // TODO: Replace this with a much better fuzzer, tendermint/ed25519/issues/10 + sig[7] ^= byte(0x01) + + assert.False(t, pubKey.VerifySignature(msg, sig)) +} From 2c1585f9dc6e0612386f507ffa2cf01acbdc1cb1 Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Fri, 28 Aug 2020 16:39:09 +0200 Subject: [PATCH 13/15] remove ed25519 & sr25519 --- crypto/codec/amino.go | 9 +- crypto/keys/ed25519/bench_test.go | 27 --- crypto/keys/ed25519/ed25519.go | 165 ------------------ crypto/keys/ed25519/ed25519_test.go | 30 ---- crypto/keys/sr25519/bench_test.go | 27 --- crypto/keys/sr25519/encoding.go | 16 -- crypto/keys/sr25519/privkey.go | 110 ------------ crypto/keys/sr25519/pubkey.go | 77 -------- crypto/keys/sr25519/sr25519_test.go | 31 ---- crypto/types/multisig/codec.go | 5 +- .../types/multisig/threshold_pubkey_test.go | 2 +- std/pubkey.go | 2 +- std/pubkey_test.go | 10 +- 13 files changed, 10 insertions(+), 501 deletions(-) delete mode 100644 crypto/keys/ed25519/bench_test.go delete mode 100644 crypto/keys/ed25519/ed25519.go delete mode 100644 crypto/keys/ed25519/ed25519_test.go delete mode 100644 crypto/keys/sr25519/bench_test.go delete mode 100644 crypto/keys/sr25519/encoding.go delete mode 100644 crypto/keys/sr25519/privkey.go delete mode 100644 crypto/keys/sr25519/pubkey.go delete mode 100644 crypto/keys/sr25519/sr25519_test.go diff --git a/crypto/codec/amino.go b/crypto/codec/amino.go index 92cd2e513a2b..027a831e499e 100644 --- a/crypto/codec/amino.go +++ b/crypto/codec/amino.go @@ -2,12 +2,11 @@ package codec import ( "github.com/tendermint/tendermint/crypto" - tmed "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" ) @@ -22,8 +21,6 @@ func init() { // codec. func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PubKey)(nil), nil) - cdc.RegisterConcrete(tmed.PubKey{}, - tmed.PubKeyName, nil) cdc.RegisterConcrete(ed25519.PubKey{}, ed25519.PubKeyName, nil) cdc.RegisterConcrete(sr25519.PubKey{}, @@ -36,8 +33,6 @@ func RegisterCrypto(cdc *codec.LegacyAmino) { cdc.RegisterInterface((*crypto.PrivKey)(nil), nil) cdc.RegisterConcrete(ed25519.PrivKey{}, ed25519.PrivKeyName, nil) - cdc.RegisterConcrete(tmed.PrivKey{}, - tmed.PrivKeyName, nil) cdc.RegisterConcrete(sr25519.PrivKey{}, sr25519.PrivKeyName, nil) cdc.RegisterConcrete(secp256k1.PrivKey{}, diff --git a/crypto/keys/ed25519/bench_test.go b/crypto/keys/ed25519/bench_test.go deleted file mode 100644 index d3961c4247ff..000000000000 --- a/crypto/keys/ed25519/bench_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package ed25519 - -import ( - "io" - "testing" - - "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" -) - -func BenchmarkKeyGeneration(b *testing.B) { - benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { - return genPrivKey(reader) - } - benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) -} - -func BenchmarkSigning(b *testing.B) { - priv := GenPrivKey() - benchmarking.BenchmarkSigning(b, priv) -} - -func BenchmarkVerification(b *testing.B) { - priv := GenPrivKey() - benchmarking.BenchmarkVerification(b, priv) -} diff --git a/crypto/keys/ed25519/ed25519.go b/crypto/keys/ed25519/ed25519.go deleted file mode 100644 index ac21f59ddef5..000000000000 --- a/crypto/keys/ed25519/ed25519.go +++ /dev/null @@ -1,165 +0,0 @@ -package ed25519 - -import ( - "bytes" - "crypto/subtle" - "fmt" - "io" - - "golang.org/x/crypto/ed25519" - - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/tmhash" -) - -//------------------------------------- - -var _ crypto.PrivKey = PrivKey{} - -const ( - PrivKeyName = "cosmos-sdk/PrivKeyEd25519" - PubKeyName = "cosmos-sdk/PubKeyEd25519" - // PubKeySize is is the size, in bytes, of public keys as used in this package. - PubKeySize = 32 - // PrivateKeySize is the size, in bytes, of private keys as used in this package. - PrivateKeySize = 64 - // Size of an Edwards25519 signature. Namely the size of a compressed - // Edwards25519 point, and a field element. Both of which are 32 bytes. - SignatureSize = 64 - // SeedSize is the size, in bytes, of private key seeds. These are the - // private key representations used by RFC 8032. - SeedSize = 32 - - keyType = "ed25519" -) - -// PrivKey implements crypto.PrivKey. -type PrivKey []byte - -// Bytes returns the privkey byte format. -func (privKey PrivKey) Bytes() []byte { - return []byte(privKey) -} - -// Sign produces a signature on the provided message. -// This assumes the privkey is wellformed in the golang format. -// The first 32 bytes should be random, -// corresponding to the normal ed25519 private key. -// The latter 32 bytes should be the compressed public key. -// If these conditions aren't met, Sign will panic or produce an -// incorrect signature. -func (privKey PrivKey) Sign(msg []byte) ([]byte, error) { - signatureBytes := ed25519.Sign(ed25519.PrivateKey(privKey), msg) - return signatureBytes, nil -} - -// PubKey gets the corresponding public key from the private key. -// -// Panics if the private key is not initialized. -func (privKey PrivKey) PubKey() crypto.PubKey { - // If the latter 32 bytes of the privkey are all zero, privkey is not - // initialized. - initialized := false - for _, v := range privKey[32:] { - if v != 0 { - initialized = true - break - } - } - - if !initialized { - panic("Expected ed25519 PrivKey to include concatenated pubkey bytes") - } - - pubkeyBytes := make([]byte, PubKeySize) - copy(pubkeyBytes, privKey[32:]) - return PubKey(pubkeyBytes) -} - -// Equals - you probably don't need to use this. -// Runs in constant time based on length of the keys. -func (privKey PrivKey) Equals(other crypto.PrivKey) bool { - if otherEd, ok := other.(PrivKey); ok { - return subtle.ConstantTimeCompare(privKey[:], otherEd[:]) == 1 - } - - return false -} - -func (privKey PrivKey) Type() string { - return keyType -} - -// GenPrivKey generates a new ed25519 private key. -// It uses OS randomness in conjunction with the current global random seed -// in tendermint/libs/common to generate the private key. -func GenPrivKey() PrivKey { - return genPrivKey(crypto.CReader()) -} - -// genPrivKey generates a new ed25519 private key using the provided reader. -func genPrivKey(rand io.Reader) PrivKey { - seed := make([]byte, SeedSize) - - _, err := io.ReadFull(rand, seed) - if err != nil { - panic(err) - } - - return PrivKey(ed25519.NewKeyFromSeed(seed)) -} - -// GenPrivKeyFromSecret hashes the secret with SHA2, and uses -// that 32 byte output to create the private key. -// NOTE: secret should be the output of a KDF like bcrypt, -// if it's derived from user input. -func GenPrivKeyFromSecret(secret []byte) PrivKey { - seed := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. - - return PrivKey(ed25519.NewKeyFromSeed(seed)) -} - -//------------------------------------- - -var _ crypto.PubKey = PubKey{} - -// PubKeyEd25519 implements crypto.PubKey for the Ed25519 signature scheme. -type PubKey []byte - -// Address is the SHA256-20 of the raw pubkey bytes. -func (pubKey PubKey) Address() crypto.Address { - if len(pubKey) != PubKeySize { - panic("pubkey is incorrect size") - } - return crypto.Address(tmhash.SumTruncated(pubKey)) -} - -// Bytes returns the PubKey byte format. -func (pubKey PubKey) Bytes() []byte { - return []byte(pubKey) -} - -func (pubKey PubKey) VerifySignature(msg []byte, sig []byte) bool { - // make sure we use the same algorithm to sign - if len(sig) != SignatureSize { - return false - } - - return ed25519.Verify(ed25519.PublicKey(pubKey), msg, sig) -} - -func (pubKey PubKey) String() string { - return fmt.Sprintf("PubKeyEd25519{%X}", []byte(pubKey)) -} - -func (pubKey PubKey) Type() string { - return keyType -} - -func (pubKey PubKey) Equals(other crypto.PubKey) bool { - if otherEd, ok := other.(PubKey); ok { - return bytes.Equal(pubKey[:], otherEd[:]) - } - - return false -} diff --git a/crypto/keys/ed25519/ed25519_test.go b/crypto/keys/ed25519/ed25519_test.go deleted file mode 100644 index 487097692804..000000000000 --- a/crypto/keys/ed25519/ed25519_test.go +++ /dev/null @@ -1,30 +0,0 @@ -package ed25519_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" -) - -func TestSignAndValidateEd25519(t *testing.T) { - - privKey := ed25519.GenPrivKey() - pubKey := privKey.PubKey() - - msg := crypto.CRandBytes(128) - sig, err := privKey.Sign(msg) - require.Nil(t, err) - - // Test the signature - assert.True(t, pubKey.VerifySignature(msg, sig)) - - // Mutate the signature, just one bit. - // TODO: Replace this with a much better fuzzer, tendermint/ed25519/issues/10 - sig[7] ^= byte(0x01) - - assert.False(t, pubKey.VerifySignature(msg, sig)) -} diff --git a/crypto/keys/sr25519/bench_test.go b/crypto/keys/sr25519/bench_test.go deleted file mode 100644 index 8f9207a2a957..000000000000 --- a/crypto/keys/sr25519/bench_test.go +++ /dev/null @@ -1,27 +0,0 @@ -package sr25519 - -import ( - "io" - "testing" - - "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/crypto/keys/internal/benchmarking" -) - -func BenchmarkKeyGeneration(b *testing.B) { - benchmarkKeygenWrapper := func(reader io.Reader) crypto.PrivKey { - return genPrivKey(reader) - } - benchmarking.BenchmarkKeyGeneration(b, benchmarkKeygenWrapper) -} - -func BenchmarkSigning(b *testing.B) { - priv := GenPrivKey() - benchmarking.BenchmarkSigning(b, priv) -} - -func BenchmarkVerification(b *testing.B) { - priv := GenPrivKey() - benchmarking.BenchmarkVerification(b, priv) -} diff --git a/crypto/keys/sr25519/encoding.go b/crypto/keys/sr25519/encoding.go deleted file mode 100644 index 6168e9aaa5ed..000000000000 --- a/crypto/keys/sr25519/encoding.go +++ /dev/null @@ -1,16 +0,0 @@ -package sr25519 - -import ( - "github.com/tendermint/tendermint/crypto" -) - -var _ crypto.PrivKey = PrivKey{} - -const ( - PrivKeyName = "cosmos-sdk/PrivKeySr25519" - PubKeyName = "cosmos-sdk/PubKeySr25519" - - // SignatureSize is the size of an Edwards25519 signature. Namely the size of a compressed - // Sr25519 point, and a field element. Both of which are 32 bytes. - SignatureSize = 64 -) diff --git a/crypto/keys/sr25519/privkey.go b/crypto/keys/sr25519/privkey.go deleted file mode 100644 index e77ca375ce30..000000000000 --- a/crypto/keys/sr25519/privkey.go +++ /dev/null @@ -1,110 +0,0 @@ -package sr25519 - -import ( - "crypto/subtle" - "fmt" - "io" - - "github.com/tendermint/tendermint/crypto" - - schnorrkel "github.com/ChainSafe/go-schnorrkel" -) - -// PrivKeySize is the number of bytes in an Sr25519 private key. -const PrivKeySize = 32 - -// PrivKeySr25519 implements crypto.PrivKey. -type PrivKey []byte - -// Bytes returns the byte representation of the PrivKey. -func (privKey PrivKey) Bytes() []byte { - return []byte(privKey) -} - -// Sign produces a signature on the provided message. -func (privKey PrivKey) Sign(msg []byte) ([]byte, error) { - var p [PrivKeySize]byte - copy(p[:], privKey) - miniSecretKey, err := schnorrkel.NewMiniSecretKeyFromRaw(p) - if err != nil { - return []byte{}, err - } - secretKey := miniSecretKey.ExpandEd25519() - - signingContext := schnorrkel.NewSigningContext([]byte{}, msg) - - sig, err := secretKey.Sign(signingContext) - if err != nil { - return []byte{}, err - } - - sigBytes := sig.Encode() - return sigBytes[:], nil -} - -// PubKey gets the corresponding public key from the private key. -func (privKey PrivKey) PubKey() crypto.PubKey { - var p [PrivKeySize]byte - copy(p[:], privKey) - miniSecretKey, err := schnorrkel.NewMiniSecretKeyFromRaw(p) - if err != nil { - panic(fmt.Sprintf("Invalid private key: %v", err)) - } - secretKey := miniSecretKey.ExpandEd25519() - - pubkey, err := secretKey.Public() - if err != nil { - panic(fmt.Sprintf("Could not generate public key: %v", err)) - } - key := pubkey.Encode() - return PubKey(key[:]) -} - -// Equals - you probably don't need to use this. -// Runs in constant time based on length of the keys. -func (privKey PrivKey) Equals(other crypto.PrivKey) bool { - if otherEd, ok := other.(PrivKey); ok { - return subtle.ConstantTimeCompare(privKey[:], otherEd[:]) == 1 - } - return false -} - -func (privKey PrivKey) Type() string { - return keyType -} - -// GenPrivKey generates a new sr25519 private key. -// It uses OS randomness in conjunction with the current global random seed -// in tendermint/libs/common to generate the private key. -func GenPrivKey() PrivKey { - return genPrivKey(crypto.CReader()) -} - -// genPrivKey generates a new sr25519 private key using the provided reader. -func genPrivKey(rand io.Reader) PrivKey { - var seed [64]byte - - out := make([]byte, 64) - _, err := io.ReadFull(rand, out) - if err != nil { - panic(err) - } - - copy(seed[:], out) - - key := schnorrkel.NewMiniSecretKey(seed).ExpandEd25519().Encode() - return key[:] -} - -// GenPrivKeyFromSecret hashes the secret with SHA2, and uses -// that 32 byte output to create the private key. -// NOTE: secret should be the output of a KDF like bcrypt, -// if it's derived from user input. -func GenPrivKeyFromSecret(secret []byte) PrivKey { - seed := crypto.Sha256(secret) // Not Ripemd160 because we want 32 bytes. - var bz [PrivKeySize]byte - copy(bz[:], seed) - privKey, _ := schnorrkel.NewMiniSecretKeyFromRaw(bz) - key := privKey.ExpandEd25519().Encode() - return key[:] -} diff --git a/crypto/keys/sr25519/pubkey.go b/crypto/keys/sr25519/pubkey.go deleted file mode 100644 index 87805cacbad5..000000000000 --- a/crypto/keys/sr25519/pubkey.go +++ /dev/null @@ -1,77 +0,0 @@ -package sr25519 - -import ( - "bytes" - "fmt" - - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/tmhash" - - schnorrkel "github.com/ChainSafe/go-schnorrkel" -) - -var _ crypto.PubKey = PubKey{} - -// PubKeySize is the number of bytes in an Sr25519 public key. -const ( - PubKeySize = 32 - keyType = "sr25519" -) - -// PubKeySr25519 implements crypto.PubKey for the Sr25519 signature scheme. -type PubKey []byte - -// Address is the SHA256-20 of the raw pubkey bytes. -func (pubKey PubKey) Address() crypto.Address { - return crypto.Address(tmhash.SumTruncated(pubKey[:])) -} - -// Bytes returns the byte representation of the PubKey. -func (pubKey PubKey) Bytes() []byte { - return []byte(pubKey) -} - -func (pubKey PubKey) VerifySignature(msg []byte, sig []byte) bool { - // make sure we use the same algorithm to sign - if len(sig) != SignatureSize { - return false - } - var sig64 [SignatureSize]byte - copy(sig64[:], sig) - - publicKey := &(schnorrkel.PublicKey{}) - var p [PubKeySize]byte - copy(p[:], pubKey) - err := publicKey.Decode(p) - if err != nil { - return false - } - - signingContext := schnorrkel.NewSigningContext([]byte{}, msg) - - signature := &(schnorrkel.Signature{}) - err = signature.Decode(sig64) - if err != nil { - return false - } - - return publicKey.Verify(signature, signingContext) -} - -func (pubKey PubKey) String() string { - return fmt.Sprintf("PubKeySr25519{%X}", []byte(pubKey)) -} - -// Equals - checks that two public keys are the same time -// Runs in constant time based on length of the keys. -func (pubKey PubKey) Equals(other crypto.PubKey) bool { - if otherEd, ok := other.(PubKey); ok { - return bytes.Equal(pubKey[:], otherEd[:]) - } - return false -} - -func (pubKey PubKey) Type() string { - return keyType - -} diff --git a/crypto/keys/sr25519/sr25519_test.go b/crypto/keys/sr25519/sr25519_test.go deleted file mode 100644 index a35bd8684a41..000000000000 --- a/crypto/keys/sr25519/sr25519_test.go +++ /dev/null @@ -1,31 +0,0 @@ -package sr25519_test - -import ( - "testing" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" - "github.com/tendermint/tendermint/crypto" - - "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" -) - -func TestSignAndValidateSr25519(t *testing.T) { - - privKey := sr25519.GenPrivKey() - pubKey := privKey.PubKey() - - msg := crypto.CRandBytes(128) - sig, err := privKey.Sign(msg) - require.Nil(t, err) - - // Test the signature - assert.True(t, pubKey.VerifySignature(msg, sig)) - assert.True(t, pubKey.VerifySignature(msg, sig)) - - // Mutate the signature, just one bit. - // TODO: Replace this with a much better fuzzer, tendermint/ed25519/issues/10 - sig[7] ^= byte(0x01) - - assert.False(t, pubKey.VerifySignature(msg, sig)) -} diff --git a/crypto/types/multisig/codec.go b/crypto/types/multisig/codec.go index 72ea2d58c658..54bd0f225a96 100644 --- a/crypto/types/multisig/codec.go +++ b/crypto/types/multisig/codec.go @@ -2,12 +2,11 @@ package multisig import ( amino "github.com/tendermint/go-amino" - "github.com/tendermint/tendermint/crypto/ed25519" - "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" ) // TODO: Figure out API for others to either add their own pubkey types, or diff --git a/crypto/types/multisig/threshold_pubkey_test.go b/crypto/types/multisig/threshold_pubkey_test.go index 6c656791b518..2396e09ad54b 100644 --- a/crypto/types/multisig/threshold_pubkey_test.go +++ b/crypto/types/multisig/threshold_pubkey_test.go @@ -7,10 +7,10 @@ import ( "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" "github.com/cosmos/cosmos-sdk/types/tx/signing" diff --git a/std/pubkey.go b/std/pubkey.go index 58ec9cfa8fc1..72f71933af4e 100644 --- a/std/pubkey.go +++ b/std/pubkey.go @@ -5,9 +5,9 @@ import ( "github.com/tendermint/tendermint/crypto" "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/sr25519" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" ) diff --git a/std/pubkey_test.go b/std/pubkey_test.go index 910cac3e6c72..302ba2238799 100644 --- a/std/pubkey_test.go +++ b/std/pubkey_test.go @@ -3,16 +3,14 @@ package std_test import ( "testing" - "github.com/tendermint/tendermint/crypto/ed25519" - - "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - "github.com/cosmos/cosmos-sdk/crypto/keys/sr25519" - "github.com/cosmos/cosmos-sdk/std" - "github.com/stretchr/testify/require" "github.com/tendermint/tendermint/crypto" + "github.com/tendermint/tendermint/crypto/ed25519" + "github.com/tendermint/tendermint/crypto/sr25519" + "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" "github.com/cosmos/cosmos-sdk/crypto/types/multisig" + "github.com/cosmos/cosmos-sdk/std" ) func roundTripTest(t *testing.T, pubKey crypto.PubKey) { From 9b97e9cb3d316745a0c0679301f9d0cc7d8bfd37 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 28 Aug 2020 17:48:24 +0200 Subject: [PATCH 14/15] Apply suggestions from code review --- crypto/keys/encoding/codec.go | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/crypto/keys/encoding/codec.go b/crypto/keys/encoding/codec.go index bf4250f680d4..960ba39af2e7 100644 --- a/crypto/keys/encoding/codec.go +++ b/crypto/keys/encoding/codec.go @@ -40,36 +40,3 @@ func PubKeyFromProto(k pc.PublicKey) (crypto.PubKey, error) { return nil, fmt.Errorf("fromproto: key type %v is not supported", k) } } - -// PrivKeyToProto takes crypto.PrivKey and transforms it to a protobuf PrivKey -func PrivKeyToProto(k crypto.PrivKey) (pc.PrivateKey, error) { - var kp pc.PrivateKey - switch k := k.(type) { - case ed25519.PrivKey: - kp = pc.PrivateKey{ - Sum: &pc.PrivateKey_Ed25519{ - Ed25519: k, - }, - } - default: - return kp, errors.New("toproto: key type is not supported") - } - return kp, nil -} - -// PrivKeyFromProto takes a protobuf PrivateKey and transforms it to a crypto.PrivKey -func PrivKeyFromProto(k pc.PrivateKey) (crypto.PrivKey, error) { - switch k := k.Sum.(type) { - case *pc.PrivateKey_Ed25519: - - if len(k.Ed25519) != ed25519.PubKeySize { - return nil, fmt.Errorf("invalid size for PubKeyEd25519. Got %d, expected %d", - len(k.Ed25519), ed25519.PubKeySize) - } - pk := make(ed25519.PrivKey, ed25519.PrivateKeySize) - copy(pk, k.Ed25519) - return pk, nil - default: - return nil, errors.New("fromproto: key type not supported") - } -} From a6319ae39ebf9312c5e4f06cda17b995cbab1cac Mon Sep 17 00:00:00 2001 From: Marko Baricevic Date: Fri, 28 Aug 2020 17:53:30 +0200 Subject: [PATCH 15/15] remove codec --- crypto/keys/encoding/codec.go | 75 ----------------------------------- 1 file changed, 75 deletions(-) delete mode 100644 crypto/keys/encoding/codec.go diff --git a/crypto/keys/encoding/codec.go b/crypto/keys/encoding/codec.go deleted file mode 100644 index bf4250f680d4..000000000000 --- a/crypto/keys/encoding/codec.go +++ /dev/null @@ -1,75 +0,0 @@ -package encoding - -import ( - "errors" - "fmt" - - "github.com/tendermint/tendermint/crypto" - "github.com/tendermint/tendermint/crypto/ed25519" - pc "github.com/tendermint/tendermint/proto/tendermint/crypto" -) - -// PubKeyToProto takes crypto.PubKey and transforms it to a protobuf Pubkey -func PubKeyToProto(k crypto.PubKey) (pc.PublicKey, error) { - var kp pc.PublicKey - switch k := k.(type) { - case ed25519.PubKey: - kp = pc.PublicKey{ - Sum: &pc.PublicKey_Ed25519{ - Ed25519: k, - }, - } - default: - return kp, fmt.Errorf("toproto: key type %v is not supported", k) - } - return kp, nil -} - -// PubKeyFromProto takes a protobuf Pubkey and transforms it to a crypto.Pubkey -func PubKeyFromProto(k pc.PublicKey) (crypto.PubKey, error) { - switch k := k.Sum.(type) { - case *pc.PublicKey_Ed25519: - if len(k.Ed25519) != ed25519.PubKeySize { - return nil, fmt.Errorf("invalid size for PubKeyEd25519. Got %d, expected %d", - len(k.Ed25519), ed25519.PubKeySize) - } - pk := make(ed25519.PubKey, ed25519.PubKeySize) - copy(pk, k.Ed25519) - return pk, nil - default: - return nil, fmt.Errorf("fromproto: key type %v is not supported", k) - } -} - -// PrivKeyToProto takes crypto.PrivKey and transforms it to a protobuf PrivKey -func PrivKeyToProto(k crypto.PrivKey) (pc.PrivateKey, error) { - var kp pc.PrivateKey - switch k := k.(type) { - case ed25519.PrivKey: - kp = pc.PrivateKey{ - Sum: &pc.PrivateKey_Ed25519{ - Ed25519: k, - }, - } - default: - return kp, errors.New("toproto: key type is not supported") - } - return kp, nil -} - -// PrivKeyFromProto takes a protobuf PrivateKey and transforms it to a crypto.PrivKey -func PrivKeyFromProto(k pc.PrivateKey) (crypto.PrivKey, error) { - switch k := k.Sum.(type) { - case *pc.PrivateKey_Ed25519: - - if len(k.Ed25519) != ed25519.PubKeySize { - return nil, fmt.Errorf("invalid size for PubKeyEd25519. Got %d, expected %d", - len(k.Ed25519), ed25519.PubKeySize) - } - pk := make(ed25519.PrivKey, ed25519.PrivateKeySize) - copy(pk, k.Ed25519) - return pk, nil - default: - return nil, errors.New("fromproto: key type not supported") - } -}