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

PubKey proto types #7147

Merged
merged 58 commits into from
Sep 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
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
bc5af8b
Move crypto types.go and register new proto pubkeys
blushi Sep 4, 2020
f4a1fd5
Add missing pointer ref
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
3103c29
Merge branch 'master' into marie/protobuf-pubkeys
blushi Sep 7, 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
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
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
d9294ee
Merge branch 'master' into marie/protobuf-pubkeys
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
c5d5c81
Simplify proto names
amaury1093 Sep 15, 2020
2dcfaed
Merge branch 'master' into marie/protobuf-pubkeys
amaury1093 Sep 15, 2020
f45f339
Add comment about multisig codec
amaury1093 Sep 15, 2020
bfa3077
Merge branch 'master' into marie/protobuf-pubkeys
amaury1093 Sep 16, 2020
8ea5a3e
Merge branch 'master' into marie/protobuf-pubkeys
mergify[bot] Sep 16, 2020
d5c484a
Merge branch 'master' into marie/protobuf-pubkeys
mergify[bot] Sep 16, 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
9 changes: 9 additions & 0 deletions codec/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,13 @@ type (
Size() int
Unmarshal(data []byte) error
}

// AminoMarshaler defines an interface where Amino marshalling can be
// overridden by custom marshalling.
AminoMarshaler interface {
MarshalAmino() ([]byte, error)
UnmarshalAmino([]byte) error
MarshalAminoJSON() ([]byte, error)
UnmarshalAminoJSON([]byte) error
}
)
10 changes: 8 additions & 2 deletions crypto/codec/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"github.com/tendermint/tendermint/crypto/sr25519"

"github.com/cosmos/cosmos-sdk/codec"
kmultisig "github.com/cosmos/cosmos-sdk/crypto/keys/multisig"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
"github.com/cosmos/cosmos-sdk/crypto/types/multisig"
)
Expand All @@ -25,17 +26,22 @@ func RegisterCrypto(cdc *codec.LegacyAmino) {
ed25519.PubKeyName, nil)
cdc.RegisterConcrete(sr25519.PubKey{},
sr25519.PubKeyName, nil)
cdc.RegisterConcrete(secp256k1.PubKey{},
cdc.RegisterConcrete(&secp256k1.PubKey{},
secp256k1.PubKeyName, nil)
// TODO Follow-up in https://github.com/cosmos/cosmos-sdk/pull/7284
// Remove `multisig.PubKeyMultisigThreshold{}`, and register instead
// kmultisig.LegacyAminoPubKey{} on `PubKeyAminoRoute`.
cdc.RegisterConcrete(multisig.PubKeyMultisigThreshold{},
multisig.PubKeyAminoRoute, nil)
cdc.RegisterConcrete(&kmultisig.LegacyAminoPubKey{},
"cosmos-sdk/LegacyAminoPubKey", nil)

cdc.RegisterInterface((*crypto.PrivKey)(nil), nil)
cdc.RegisterConcrete(ed25519.PrivKey{},
ed25519.PrivKeyName, nil)
cdc.RegisterConcrete(sr25519.PrivKey{},
sr25519.PrivKeyName, nil)
cdc.RegisterConcrete(secp256k1.PrivKey{},
cdc.RegisterConcrete(&secp256k1.PrivKey{},
secp256k1.PrivKeyName, nil)
}

Expand Down
2 changes: 1 addition & 1 deletion crypto/hd/algo.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,6 @@ func (s secp256k1Algo) Generate() GenerateFn {
var bzArr = make([]byte, secp256k1.PrivKeySize)
copy(bzArr, bz)

return secp256k1.PrivKey(bzArr)
return &secp256k1.PrivKey{Key: bzArr}
}
}
5 changes: 3 additions & 2 deletions crypto/hd/fundraiser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ func TestFundraiserCompatibility(t *testing.T) {
master, ch := hd.ComputeMastersFromSeed(seed)
priv, err := hd.DerivePrivateKeyForPath(master, ch, "44'/118'/0'/0/0")
require.NoError(t, err)
pub := secp256k1.PrivKey(priv).PubKey()
privKey := &secp256k1.PrivKey{Key: priv}
pub := privKey.PubKey()

t.Log("\tNODEJS GOLANG\n")
t.Logf("SEED \t%X %X\n", seedB, seed)
Expand All @@ -78,7 +79,7 @@ func TestFundraiserCompatibility(t *testing.T) {
require.Equal(t, priv[:], privB, "Expected priv keys to match")
pubBFixed := make([]byte, secp256k1.PubKeySize)
copy(pubBFixed, pubB)
require.Equal(t, pub, secp256k1.PubKey(pubBFixed), fmt.Sprintf("Expected pub keys to match for %d", i))
require.Equal(t, pub, &secp256k1.PubKey{Key: pubBFixed}, fmt.Sprintf("Expected pub keys to match for %d", i))

addr := pub.Address()
t.Logf("ADDR \t%X %X\n", addrB, addr)
Expand Down
4 changes: 2 additions & 2 deletions crypto/keyring/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ import (
)

func Test_writeReadLedgerInfo(t *testing.T) {
tmpKey := make(secp256k1.PubKey, secp256k1.PubKeySize)
tmpKey := make([]byte, secp256k1.PubKeySize)
bz, _ := hex.DecodeString("035AD6810A47F073553FF30D2FCC7E0D3B1C0B74B61A1AAA2582344037151E143A")
copy(tmpKey[:], bz)

lInfo := newLedgerInfo("some_name", tmpKey, *hd.NewFundraiserParams(5, sdk.CoinType, 1), hd.Secp256k1Type)
lInfo := newLedgerInfo("some_name", &secp256k1.PubKey{Key: tmpKey}, *hd.NewFundraiserParams(5, sdk.CoinType, 1), hd.Secp256k1Type)
assert.Equal(t, TypeLedger, lInfo.GetType())

path, err := lInfo.GetPath()
Expand Down
Loading