Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Update tm pubkey references #7102

Merged
merged 23 commits into from
Aug 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
7d2e3d5
Update pubkey references
sahith-narahari Aug 18, 2020
61efbb3
Merge branch 'master' into sahith/update-keys-ref
sahith-narahari Aug 19, 2020
dccf1ef
Update ledger_mock
sahith-narahari Aug 19, 2020
71e415b
Migrate encoding from tm
sahith-narahari Aug 19, 2020
78b1b22
Update pubkey prefix
sahith-narahari Aug 25, 2020
a33dd58
resolve conflicts
tac0turtle Aug 26, 2020
6e28dab
revert ed25519 to tendermint key
tac0turtle Aug 26, 2020
0f58161
random account revert
tac0turtle Aug 26, 2020
9e3af96
Revert ed25519 references
sahith-narahari Aug 26, 2020
ea744da
revert secp key name
tac0turtle Aug 27, 2020
fd2ebe2
test revert
tac0turtle Aug 27, 2020
bc5ebbd
Merge branch 'master' into sahith/update-keys-ref
tac0turtle Aug 27, 2020
66d2e1d
remove ed25519
tac0turtle Aug 27, 2020
be33f1c
Merge branch 'sahith/update-keys-ref' of https://github.com/cosmos/co…
tac0turtle Aug 27, 2020
f1c6fcc
Merge branch 'master' into sahith/update-keys-ref
tac0turtle Aug 27, 2020
00d040c
Update x/staking/types/validator.go
sahith-narahari Aug 28, 2020
42dd530
Revert "remove ed25519"
tac0turtle Aug 28, 2020
1765d16
Merge branch 'master' into sahith/update-keys-ref
tac0turtle Aug 28, 2020
2c1585f
remove ed25519 & sr25519
tac0turtle Aug 28, 2020
bb6ddb2
Merge branch 'sahith/update-keys-ref' of https://github.com/cosmos/co…
tac0turtle Aug 28, 2020
9b97e9c
Apply suggestions from code review
tac0turtle Aug 28, 2020
a6319ae
remove codec
tac0turtle Aug 28, 2020
96d2d4c
Merge branch 'sahith/update-keys-ref' of https://github.com/cosmos/co…
tac0turtle Aug 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/debug/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crypto/armor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ 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"
"github.com/cosmos/cosmos-sdk/crypto"
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"
)

Expand Down
6 changes: 3 additions & 3 deletions crypto/codec/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
3 changes: 2 additions & 1 deletion crypto/hd/algo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion crypto/hd/fundraiser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
4 changes: 2 additions & 2 deletions crypto/keyring/keyring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion crypto/keyring/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
2 changes: 1 addition & 1 deletion crypto/keyring/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
2 changes: 2 additions & 0 deletions crypto/keys/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
1 change: 0 additions & 1 deletion crypto/keys/ed25519/ed25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 2 additions & 0 deletions crypto/keys/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ var _ crypto.PrivKey = PrivKey{}
const (
PrivKeySize = 32
keyType = "secp256k1"
PrivKeyName = "tendermint/PrivKeySecp256k1"
Copy link
Member

Choose a reason for hiding this comment

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

this is to keep backwards compatibility

PubKeyName = "tendermint/PubKeySecp256k1"
)

// PrivKey implements PrivKey.
Expand Down
1 change: 0 additions & 1 deletion crypto/keys/secp256k1/secp256k1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
3 changes: 3 additions & 0 deletions crypto/keys/sr25519/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions crypto/keys/sr25519/sr25519_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
1 change: 0 additions & 1 deletion crypto/ledger/ledger_mock.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (

secp256k1 "github.com/tendermint/btcd/btcec"
"github.com/tendermint/tendermint/crypto"
tmsecp256k1 "github.com/tendermint/tendermint/crypto/secp256k1"
sahith-narahari marked this conversation as resolved.
Show resolved Hide resolved

bip39 "github.com/cosmos/go-bip39"

Expand Down
6 changes: 3 additions & 3 deletions crypto/ledger/ledger_secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 4 additions & 3 deletions crypto/types/multisig/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 4 additions & 5 deletions crypto/types/multisig/threshold_pubkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
2 changes: 1 addition & 1 deletion simapp/genesis_account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion simapp/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion simapp/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ 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"
dbm "github.com/tendermint/tm-db"

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"
Expand Down
16 changes: 8 additions & 8 deletions std/pubkey.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions std/pubkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down
Loading