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

Migrate BaseAccount PubKey to use Any #7268

Merged
merged 183 commits into from
Sep 25, 2020
Merged
Show file tree
Hide file tree
Changes from 171 commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
9f216fd
WIP on BaseAccount protobuf pub_key
aaronc Jul 29, 2020
b8a0523
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into aa…
aaronc Jul 29, 2020
8a086a1
WIP on BaseAccount.PubKey
aaronc Jul 29, 2020
78f8d73
Merge branch 'master' into aaronc/revert-5682
aaronc Aug 3, 2020
671edfb
WIP on BaseAccount pub key
aaronc Aug 4, 2020
92d0cdf
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into aa…
aaronc Aug 4, 2020
15b8799
Merge remote-tracking branch 'origin/aaronc/revert-5682' into aaronc/…
aaronc Aug 4, 2020
eec171f
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into aa…
aaronc Aug 4, 2020
7f12c37
Update PubKey
aaronc Aug 17, 2020
5e9a549
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into aa…
aaronc Aug 17, 2020
d145ca1
Update Account
aaronc Aug 17, 2020
a6c6d5c
Docs
aaronc Aug 17, 2020
3a7dbd2
WIP on protobuf keys
aaronc Aug 19, 2020
67ea545
Use Type() and Bytes() in sr25519 pub key Equals
blushi Aug 21, 2020
8f3be04
Add tests
blushi Aug 21, 2020
7c2d693
Add few more tests
blushi Aug 21, 2020
7c53579
Update other pub/priv key types Equals
blushi Aug 21, 2020
92c73ec
Fix PrivKey's Sign method
blushi Aug 21, 2020
d81291e
Rename variables in tests
blushi Aug 24, 2020
03a086d
Fix infinite recursive calls
blushi Aug 24, 2020
ad81bd4
Use tm ed25519 keys
blushi Aug 27, 2020
9587c2b
Add Sign and VerifySignature tests
blushi Aug 27, 2020
a6c6610
Merge branch 'master' into marie/protobuf-pubkeys
blushi Aug 31, 2020
41261d1
Remove ed25519 and sr25519 references
blushi Aug 31, 2020
4c1358b
proto linting
blushi Aug 31, 2020
d6a2751
Add proto crypto file
blushi Aug 31, 2020
eb020c2
Implement some of the new multisig proto type methods
blushi Aug 31, 2020
a4f6dd6
Add tests for MultisigThresholdPubKey
blushi Sep 2, 2020
e1a20ce
Add tests for pubkey pb/amino conversion functions
blushi Sep 2, 2020
c17e7e4
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 2, 2020
0a77078
Merge branch 'aaronc/revert-5682' into marie/6928-baseacc-pk
blushi Sep 2, 2020
a5d2874
Merge branch 'marie/protobuf-pubkeys' into marie/6928-baseacc-pk
blushi Sep 2, 2020
bc5af8b
Move crypto types.go and register new proto pubkeys
blushi Sep 4, 2020
f4a1fd5
Add missing pointer ref
blushi Sep 4, 2020
a0753a0
Merge branch 'marie/protobuf-pubkeys' into marie/6928-baseacc-pk
blushi Sep 4, 2020
ca063bf
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 4, 2020
b9ab6c9
Address review comments
blushi Sep 7, 2020
6fc4073
panic in MultisigThresholdPubKey VerifySignature
blushi Sep 7, 2020
6609369
Merge branch 'marie/protobuf-pubkeys' of github.com:cosmos/cosmos-sdk…
blushi Sep 7, 2020
64d44cb
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 7, 2020
b210837
Merge branch 'marie/protobuf-pubkeys' into marie/6928-baseacc-pk
blushi Sep 7, 2020
09db3e9
Fix compile errors
blushi Sep 7, 2020
3103c29
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 7, 2020
e0fc222
Remove pk conversion in ante handler
blushi Sep 9, 2020
5c30dc6
Merge branch 'master' into marie/6928-baseacc-pk
blushi Sep 9, 2020
d9eee8d
Use internal crypto.PubKey in multisig
blushi Sep 9, 2020
a221994
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 9, 2020
339f460
Add tests for MultisigThresholdPubKey VerifyMultisignature
blushi Sep 9, 2020
9ee65fa
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 9, 2020
190bee2
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 10, 2020
af94272
Only keep LegacyAminoMultisigThresholdPubKey and move to proto keys t…
blushi Sep 10, 2020
b4393b4
Remove conversion functions and introduce internal PubKey type
blushi Sep 10, 2020
b67f9d4
Override Amino marshaling for proto pubkeys
amaury1093 Sep 10, 2020
08cd25a
Merge master
amaury1093 Sep 8, 2020
9a4dc25
Make proto-gen
amaury1093 Sep 10, 2020
fb8e7a9
Start removal of old PubKeyMultisigThreshold references
blushi Sep 10, 2020
4e4ce4e
Fix tests
amaury1093 Sep 10, 2020
d3c76f5
Fix solomachine
amaury1093 Sep 11, 2020
01175d3
Fix ante handler tests
amaury1093 Sep 4, 2020
3c4ddbb
Pull latest go-amino
amaury1093 Sep 11, 2020
cee8f30
Remove ed25519
amaury1093 Sep 11, 2020
ba95f50
Remove old secp256k1 PubKey and PrivKey
blushi Sep 11, 2020
330a0be
Uncomment test case
blushi Sep 11, 2020
e88c126
Fix linting issues
blushi Sep 11, 2020
54fb9a3
More linting
blushi Sep 11, 2020
07228ba
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 11, 2020
2b63374
Merge branch 'marie/protobuf-pubkeys' into marie/7109-multisig
blushi Sep 11, 2020
34ed4a0
Revert tests keys values
blushi Sep 12, 2020
a39dd4c
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into mari…
amaury1093 Sep 14, 2020
34e3f89
Add Amino overrides to proto keys
amaury1093 Sep 14, 2020
ddd1a72
Add pubkey test
amaury1093 Sep 14, 2020
935c51b
Fix tests
amaury1093 Sep 14, 2020
f31d625
Use threshold isntead of K
amaury1093 Sep 14, 2020
f8af7fc
Merge branch 'master' into marie/protobuf-pubkeys
amaury1093 Sep 14, 2020
e410121
Merge branch 'master' into marie/protobuf-pubkeys
amaury1093 Sep 14, 2020
4114ce9
Standardize Type
amaury1093 Sep 14, 2020
af415fc
Revert standardize types commit
amaury1093 Sep 14, 2020
0934a00
Merge branch 'master' into marie/protobuf-pubkeys
alexanderbez Sep 14, 2020
0006cb7
Merge branch 'marie/protobuf-pubkeys' of ssh://github.com/cosmos/cosm…
amaury1093 Sep 14, 2020
d9294ee
Merge branch 'master' into marie/protobuf-pubkeys
amaury1093 Sep 14, 2020
7177df5
Fix build
amaury1093 Sep 14, 2020
794bc35
Fix lint
amaury1093 Sep 14, 2020
8001673
Fix lint
amaury1093 Sep 14, 2020
ee712f1
Add comment
amaury1093 Sep 14, 2020
912561f
Merge branch 'marie/protobuf-pubkeys' of ssh://github.com/cosmos/cosm…
amaury1093 Sep 14, 2020
9623425
Merge branch 'marie/protobuf-pubkeys' of ssh://github.com/cosmos/cosm…
amaury1093 Sep 14, 2020
56ecf47
Register crypto.PubKey
amaury1093 Sep 14, 2020
d3e4d1e
Add empty key in BuildSimTx
amaury1093 Sep 14, 2020
c5d5c81
Simplify proto names
amaury1093 Sep 15, 2020
37be659
Merge branch 'marie/protobuf-pubkeys' of ssh://github.com/cosmos/cosm…
amaury1093 Sep 15, 2020
afddbc9
Unpack interfaces for signing desc
amaury1093 Sep 15, 2020
f70ab56
Fix IBC tests?
amaury1093 Sep 15, 2020
9d0ac0a
Format proto
amaury1093 Sep 15, 2020
d3b2896
Use secp256k1 in ibc
amaury1093 Sep 15, 2020
e8b30d7
Merge branch 'marie/protobuf-pubkeys' of ssh://github.com/cosmos/cosm…
amaury1093 Sep 15, 2020
96c27ec
Fixed merge issues
amaury1093 Sep 15, 2020
9e0a4bb
Uncomment tests
amaury1093 Sep 15, 2020
f2dafe7
Update x/ibc/testing/solomachine.go
colin-axner Sep 15, 2020
ccc3afe
Merge branch 'am-7147-aminojson' of ssh://github.com/cosmos/cosmos-sd…
amaury1093 Sep 15, 2020
e5778a0
UnpackInterfaces for solomachine types
amaury1093 Sep 15, 2020
0a47ff3
Remove old multisig
amaury1093 Sep 15, 2020
bb0b56d
Add amino marshal for multisig
amaury1093 Sep 15, 2020
9f9921e
Fix lint
amaury1093 Sep 15, 2020
f5d3701
Correctly register amino
amaury1093 Sep 16, 2020
18eeb67
One test left!
amaury1093 Sep 16, 2020
bf72fbd
Remove old struct
amaury1093 Sep 16, 2020
9c07e68
Fix test
amaury1093 Sep 16, 2020
66f78cd
Fix test
amaury1093 Sep 16, 2020
9f8aab7
Unpack into tmcrypto
amaury1093 Sep 16, 2020
5a0490f
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into mari…
amaury1093 Sep 16, 2020
c7c289e
Merge branch 'marie/7109-multisig' of ssh://github.com/cosmos/cosmos-…
amaury1093 Sep 16, 2020
7a596dc
Remove old threshold pubkey tests
blushi Sep 16, 2020
04b86d9
Fix register amino
amaury1093 Sep 16, 2020
3211baa
Fix lint
amaury1093 Sep 16, 2020
2103eca
Use sdk crypto PubKey in multisig UnpackInterfaces
blushi Sep 16, 2020
bf3ffbe
Merge branch 'master' into marie/7109-multisig
blushi Sep 16, 2020
421f948
Potential fix?
amaury1093 Sep 17, 2020
fa3840a
Merge branch 'marie/7109-multisig' of ssh://github.com/cosmos/cosmos-…
amaury1093 Sep 17, 2020
c63f3e7
Register LegacyAminoPubKey
amaury1093 Sep 17, 2020
9e5f57c
Merge branch 'master' into marie/7109-multisig
amaury1093 Sep 17, 2020
d195542
Register our own PubKey
amaury1093 Sep 17, 2020
b35c35e
Register tmcrypto PubKey
amaury1093 Sep 17, 2020
b19450f
Register both PubKeys
amaury1093 Sep 17, 2020
7175814
Register interfaces in test
amaury1093 Sep 17, 2020
bf2347d
Refactor fiels
amaury1093 Sep 17, 2020
09e1fbc
Add comments
amaury1093 Sep 17, 2020
49830d2
Merge branch 'am-7147-aminojson' into marie/6928-baseacc-pk
blushi Sep 17, 2020
ed01620
Remove old cosmos-sdk/crypto/keys reference
blushi Sep 17, 2020
ec1c22d
Merge branch 'master' into marie/7109-multisig
alexanderbez Sep 17, 2020
8f1fda1
Use anil's suggestion
amaury1093 Sep 17, 2020
27ae607
Add norace back
amaury1093 Sep 17, 2020
aa0867e
Merge branch 'marie/7109-multisig' into am-7147-aminojson
amaury1093 Sep 17, 2020
529eef4
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Sep 18, 2020
006d596
Use our own ed25519
amaury1093 Sep 18, 2020
6f7555a
Merge branch 'master' into am-7147-aminojson
amaury1093 Sep 18, 2020
57850e7
Fix pubkey types
amaury1093 Sep 18, 2020
56f5ec3
Fix network tests
amaury1093 Sep 18, 2020
fe58118
Fix more tests
amaury1093 Sep 18, 2020
7218bf6
Make ibc work?
amaury1093 Sep 18, 2020
92454ea
Use TM pubkey in NewValidator
amaury1093 Sep 18, 2020
5fe532c
Fix lint
amaury1093 Sep 18, 2020
7a423d8
Put interface in tpyes
amaury1093 Sep 18, 2020
f2e47fb
rerun CI
amaury1093 Sep 18, 2020
99ae231
Better name register
amaury1093 Sep 18, 2020
8ceb11f
Remove stray code
amaury1093 Sep 18, 2020
07c181d
Add ed25519 tests
amaury1093 Sep 18, 2020
c1d283e
Merge branch 'master' into am-7147-aminojson
alexanderbez Sep 18, 2020
3d90dd6
Check nil
amaury1093 Sep 18, 2020
7bd4538
Correct interface impl assert
amaury1093 Sep 18, 2020
ecaac5e
rerun CI
amaury1093 Sep 18, 2020
0b770a3
Merge branch 'master' into am-7147-aminojson
amaury1093 Sep 18, 2020
2d35e5e
Add fix for Bech32
amaury1093 Sep 18, 2020
6f6f3f2
Address comments
amaury1093 Sep 21, 2020
3c14018
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into am-7…
amaury1093 Sep 21, 2020
451e490
FIx lint
amaury1093 Sep 21, 2020
00f6a67
Add tests for solomachine unpack interfaces
amaury1093 Sep 21, 2020
cb16dbc
Fix query tx by hash
amaury1093 Sep 21, 2020
edba7cb
Better name in amino register
amaury1093 Sep 21, 2020
c1dbaa9
Merge branch 'am-7147-aminojson' of ssh://github.com/cosmos/cosmos-sd…
amaury1093 Sep 21, 2020
423b370
Merge branch 'am-own-ed25519' into marie/6928-baseacc-pk
amaury1093 Sep 21, 2020
a5a866e
Fix lint
amaury1093 Sep 21, 2020
990ef48
Add back ed25519 test (fixes #7352)
amaury1093 Sep 21, 2020
0286d53
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into mari…
amaury1093 Sep 21, 2020
572ea4f
go mod tidy
amaury1093 Sep 21, 2020
0e0e11f
Fix merge issues
amaury1093 Sep 21, 2020
afbaec0
Sort import
amaury1093 Sep 22, 2020
69212c3
Add test for backwards-compatibility
amaury1093 Sep 22, 2020
ca916de
Fix tests
amaury1093 Sep 22, 2020
ab924f3
Merge branch 'master' of ssh://github.com/cosmos/cosmos-sdk into mari…
amaury1093 Sep 22, 2020
a849010
Fix merge issue
amaury1093 Sep 22, 2020
ad9814f
Merge branch 'master' into marie/6928-baseacc-pk
amaury1093 Sep 23, 2020
13937d3
Update client/context.go
blushi Sep 24, 2020
1df8513
Update types/address.go
blushi Sep 24, 2020
8df6054
Address feedback
blushi Sep 24, 2020
3cf6ba0
Add comment
blushi Sep 24, 2020
3a664d5
Fix BaseAccount SetPubKey and address further comments
blushi Sep 24, 2020
eb2e0ae
Merge branch 'master' into marie/6928-baseacc-pk
blushi Sep 24, 2020
f282cff
Lint
blushi Sep 24, 2020
ec9b0b1
Remove unnecessary use of copy in getPubKeyFromString
blushi Sep 24, 2020
bc03492
Update comment
blushi Sep 24, 2020
450f1eb
Merge branch 'master' into marie/6928-baseacc-pk
amaury1093 Sep 24, 2020
b8e99aa
Merge branch 'master' into marie/6928-baseacc-pk
mergify[bot] Sep 25, 2020
675e1c5
Merge branch 'master' into marie/6928-baseacc-pk
mergify[bot] Sep 25, 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/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ import (
"os"

"github.com/gogo/protobuf/proto"
"gopkg.in/yaml.v2"

blushi marked this conversation as resolved.
Show resolved Hide resolved
"github.com/pkg/errors"
rpcclient "github.com/tendermint/tendermint/rpc/client"
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
blushi marked this conversation as resolved.
Show resolved Hide resolved
yaml "gopkg.in/yaml.v2"

"github.com/cosmos/cosmos-sdk/codec"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
Expand Down
16 changes: 8 additions & 8 deletions 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 All @@ -34,18 +34,18 @@ func Cmd() *cobra.Command {
// to decode the pubkey string from hex, base64, and finally bech32. If all
// encodings fail, an error is returned.
func getPubKeyFromString(pkstr string) (crypto.PubKey, error) {
pubKey := make(ed25519.PubKey, ed25519.PubKeySize)
pubKey := make([]byte, ed25519.PubKeySize)
blushi marked this conversation as resolved.
Show resolved Hide resolved

bz, err := hex.DecodeString(pkstr)
if err == nil {
copy(pubKey[:], bz)
return pubKey, nil
copy(pubKey, bz)
return &ed25519.PubKey{Key: pubKey}, nil
}

bz, err = base64.StdEncoding.DecodeString(pkstr)
if err == nil {
copy(pubKey[:], bz)
return pubKey, nil
copy(pubKey, bz)
return &ed25519.PubKey{Key: pubKey}, nil
}

pk, err := sdk.GetPubKeyFromBech32(sdk.Bech32PubKeyTypeAccPub, pkstr)
Expand Down Expand Up @@ -85,7 +85,7 @@ $ %s debug pubkey cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
return err
}

edPK, ok := pk.(ed25519.PubKey)
edPK, ok := pk.(*ed25519.PubKey)
if !ok {
return fmt.Errorf("invalid pubkey type; expected ED25519")
blushi marked this conversation as resolved.
Show resolved Hide resolved
}
Expand All @@ -108,7 +108,7 @@ $ %s debug pubkey cosmos1e0jnq2sun3dzjh8p2xq95kk0expwmd7shwjpfg
}

cmd.Println("Address:", edPK.Address())
cmd.Printf("Hex: %X\n", edPK[:])
cmd.Printf("Hex: %X\n", edPK.Key)
cmd.Println("JSON (base64):", string(pubKeyJSONBytes))
cmd.Println("Bech32 Acc:", accPub)
cmd.Println("Bech32 Validator Operator:", valPub)
Expand Down
32 changes: 32 additions & 0 deletions codec/yaml.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package codec

import (
"encoding/json"

"github.com/gogo/protobuf/proto"
"gopkg.in/yaml.v2"
)

// MarshalYAML marshals the provided toPrint content with the provided JSON marshaler
// by encoding JSON, decoding JSON, and then encoding YAML.
func MarshalYAML(jsonMarshaler JSONMarshaler, toPrint proto.Message) ([]byte, error) {
blushi marked this conversation as resolved.
Show resolved Hide resolved
bz, err := jsonMarshaler.MarshalJSON(toPrint)
if err != nil {
return nil, err
}

// generate YAML by decoding and re-encoding JSON as YAML
var j interface{}

err = json.Unmarshal(bz, &j)
if err != nil {
return nil, err
}

bz, err = yaml.Marshal(j)
if err != nil {
return nil, err
}

return bz, nil
blushi marked this conversation as resolved.
Show resolved Hide resolved
}
49 changes: 49 additions & 0 deletions codec/yaml_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package codec_test

import (
"testing"

"github.com/cosmos/cosmos-sdk/codec"

"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
)

func TestMarshalYAML(t *testing.T) {
dog := &testdata.Dog{
Size_: "small",
Name: "Spot",
}
any, err := types.NewAnyWithValue(dog)
require.NoError(t, err)
hasAnimal := &testdata.HasAnimal{
Animal: any,
X: 0,
}

// proto
protoCdc := codec.NewProtoCodec(NewTestInterfaceRegistry())
bz, err := codec.MarshalYAML(protoCdc, hasAnimal)
require.NoError(t, err)
require.Equal(t, `animal:
'@type': /testdata.Dog
name: Spot
size: small
x: "0"
`, string(bz))

// amino
aminoCdc := codec.NewAminoCodec(&codec.LegacyAmino{testdata.NewTestAmino()})
bz, err = codec.MarshalYAML(aminoCdc, hasAnimal)
require.NoError(t, err)
require.Equal(t, `type: testdata/HasAnimal
value:
animal:
type: testdata/Dog
value:
name: Spot
size: small
`, string(bz))
}
16 changes: 11 additions & 5 deletions crypto/codec/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ package codec

import (
"github.com/tendermint/tendermint/crypto"
"github.com/tendermint/tendermint/crypto/ed25519"
tmed25519 "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"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand All @@ -26,20 +27,25 @@ func RegisterCrypto(cdc *codec.LegacyAmino) {
// first line.
cdc.RegisterInterface((*crypto.PubKey)(nil), nil)
cdc.RegisterInterface((*cryptotypes.PubKey)(nil), nil)
cdc.RegisterConcrete(ed25519.PubKey{},
ed25519.PubKeyName, nil)
cdc.RegisterConcrete(sr25519.PubKey{},
sr25519.PubKeyName, nil)
// TODO Same as above, for ED25519
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do we have an issue for that, so we can link this code?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure if we have that as this would require a large refacto because tendermint pubkeys are still used quite a lot in calling methods from tendermint (one of the reason we do this #7268 (comment)), eg https://github.com/tendermint/tendermint/blob/e8eef856196697c803ac54fa625d83fb276d5977/crypto/encoding/codec.go#L12 called in x/staking/types/validator.go
I believe that might require a larger architecture decision.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

actually this could be covered by #7357 @robert-zaremba

cdc.RegisterConcrete(tmed25519.PubKey{},
tmed25519.PubKeyName, nil)
cdc.RegisterConcrete(&ed25519.PubKey{},
ed25519.PubKeyName, nil)
cdc.RegisterConcrete(&secp256k1.PubKey{},
secp256k1.PubKeyName, nil)
cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{},
kmultisig.PubKeyAminoRoute, nil)

cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
cdc.RegisterConcrete(ed25519.PrivKey{},
ed25519.PrivKeyName, nil)
cdc.RegisterConcrete(sr25519.PrivKey{},
sr25519.PrivKeyName, nil)
cdc.RegisterConcrete(tmed25519.PrivKey{},
tmed25519.PrivKeyName, nil)
blushi marked this conversation as resolved.
Show resolved Hide resolved
cdc.RegisterConcrete(&ed25519.PrivKey{},
ed25519.PrivKeyName, nil)
cdc.RegisterConcrete(&secp256k1.PrivKey{},
secp256k1.PrivKeyName, nil)
}
Expand Down
5 changes: 4 additions & 1 deletion crypto/codec/proto.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
tmcrypto "github.com/tendermint/tendermint/crypto"

codectypes "github.com/cosmos/cosmos-sdk/codec/types"
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
"github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
Expand All @@ -13,12 +14,14 @@ import (
func RegisterInterfaces(registry codectypes.InterfaceRegistry) {
// TODO We now register both Tendermint's PubKey and our own PubKey. In the
// long-term, we should move away from Tendermint's PubKey, and delete
// these lines
// these lines.
registry.RegisterInterface("tendermint.crypto.Pubkey", (*tmcrypto.PubKey)(nil))
registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &ed25519.PubKey{})
registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &secp256k1.PubKey{})
registry.RegisterImplementations((*tmcrypto.PubKey)(nil), &multisig.LegacyAminoPubKey{})

registry.RegisterInterface("cosmos.crypto.Pubkey", (*cryptotypes.PubKey)(nil))
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &ed25519.PubKey{})
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &secp256k1.PubKey{})
registry.RegisterImplementations((*cryptotypes.PubKey)(nil), &multisig.LegacyAminoPubKey{})
}
2 changes: 1 addition & 1 deletion crypto/keyring/keyring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
Loading