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

fix(crypto): update secp256k1 key names to match with CometBFT changes #34

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
58 changes: 29 additions & 29 deletions api/cosmos/crypto/secp256k1/keys.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions client/keys/output_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func TestBech32KeysOutput(t *testing.T) {
out, err := MkAccKeyOutput(k)
require.NoError(t, err)
require.Equal(t, expectedOutput, out)
require.Equal(t, "{Name:multisig Type:multi Address:0x16a035adce9fe233cec9cd50699922c90618bc7a PubKey:{\"@type\":\"/cosmos.crypto.multisig.LegacyAminoPubKey\",\"threshold\":1,\"public_keys\":[{\"@type\":\"/cosmos.crypto.secp256k1.PubKey\",\"key\":\"BOrroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJRBvMr2v1o7/Tt5MFOm9RcJhxfM8axlq8SseN3Dl07xg=\"}]} Mnemonic:}", fmt.Sprintf("%+v", out))
require.Equal(t, "{Name:multisig Type:multi Address:0xe7e1add937d6cd091d6a0db2ea44eef5c1613c72 PubKey:{\"@type\":\"/cosmos.crypto.multisig.LegacyAminoPubKey\",\"threshold\":1,\"public_keys\":[{\"@type\":\"/cosmos.crypto.secp256k1.PubKey\",\"key\":\"BOrroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJRBvMr2v1o7/Tt5MFOm9RcJhxfM8axlq8SseN3Dl07xg=\"}]} Mnemonic:}", fmt.Sprintf("%+v", out))
}

// TestBech32KeysOutputNestedMsig tests that the output of a nested multisig key is correct
Expand All @@ -65,7 +65,7 @@ func TestBech32KeysOutputNestedMsig(t *testing.T) {
require.NoError(t, err)

require.Equal(t, expectedOutput, out)
require.Equal(t, "{Name:multisig Type:multi Address:0xf03f3dfbd4f8973f5c48ef53297d746e141983c2 PubKey:{\"@type\":\"/cosmos.crypto.multisig.LegacyAminoPubKey\",\"threshold\":2,\"public_keys\":[{\"@type\":\"/cosmos.crypto.secp256k1.PubKey\",\"key\":\"BOrroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJRBvMr2v1o7/Tt5MFOm9RcJhxfM8axlq8SseN3Dl07xg=\"},{\"@type\":\"/cosmos.crypto.multisig.LegacyAminoPubKey\",\"threshold\":1,\"public_keys\":[{\"@type\":\"/cosmos.crypto.secp256k1.PubKey\",\"key\":\"BOrroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJRBvMr2v1o7/Tt5MFOm9RcJhxfM8axlq8SseN3Dl07xg=\"}]}]} Mnemonic:}", fmt.Sprintf("%+v", out))
require.Equal(t, "{Name:multisig Type:multi Address:0x7d1c3ef842dcc796df25d46a0716005d30de5a9a PubKey:{\"@type\":\"/cosmos.crypto.multisig.LegacyAminoPubKey\",\"threshold\":2,\"public_keys\":[{\"@type\":\"/cosmos.crypto.secp256k1.PubKey\",\"key\":\"BOrroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJRBvMr2v1o7/Tt5MFOm9RcJhxfM8axlq8SseN3Dl07xg=\"},{\"@type\":\"/cosmos.crypto.multisig.LegacyAminoPubKey\",\"threshold\":1,\"public_keys\":[{\"@type\":\"/cosmos.crypto.secp256k1.PubKey\",\"key\":\"BOrroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJRBvMr2v1o7/Tt5MFOm9RcJhxfM8axlq8SseN3Dl07xg=\"}]}]} Mnemonic:}", fmt.Sprintf("%+v", out))
}

func TestProtoMarshalJSON(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions client/keys/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ func Test_multiSigKey_Properties(t *testing.T) {

pub, err := k.GetPubKey()
require.NoError(t, err)
require.Equal(t, "D2B8E5992CF6A3F5904E537F65F27B8FE85DDD38", pub.Address().String())
require.Equal(t, "8F86E3DB26D754696569401A2933FD740C1389EA", pub.Address().String())

addr, err := k.GetAddress()
require.NoError(t, err)
require.Equal(t, "0xd2b8e5992cf6a3f5904e537f65f27b8fe85ddd38", sdk.MustHexifyAddressBytes(addr))
require.Equal(t, "0x8f86e3db26d754696569401a2933fd740c1389ea", sdk.MustHexifyAddressBytes(addr))
}

func Test_showKeysCmd(t *testing.T) {
Expand Down
22 changes: 11 additions & 11 deletions crypto/keys/secp256k1/keys.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions crypto/keys/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ const (
keyType = "secp256k1"
PrivKeyNameOld = "tendermint/PrivKeySecp256k1"
PubKeyNameOld = "tendermint/PubKeySecp256k1"
PrivKeyName = "comet/PrivKeySecp256k1Uncompressed"
PubKeyName = "comet/PubKeySecp256k1Uncompressed"
PrivKeyName = "cometbft/PrivKeySecp256k1eth"
PubKeyName = "cometbft/PubKeySecp256k1eth"
)

func (privKey *PrivKeyOld) Bytes() []byte {
Expand Down
2 changes: 1 addition & 1 deletion crypto/ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ func TestPublicKeyUnsafe(t *testing.T) {
func checkDefaultPubKey(t *testing.T, priv types.LedgerPrivKey) {
require.NotNil(t, priv)
expectedPkStr := "PubKeySecp256k1{034FEF9CD7C4C63588D3B03FEB5281B9D232CBA34D6F3D71AEE59211FFBFE1FE870000000000000000000000000000000000000000000000000000000000000000}"
require.Equal(t, "7277b5e741034fef9cd7c4c63588d3b03feb5281b9d232cba34d6f3d71aee59211ffbfe1fe870000000000000000000000000000000000000000000000000000000000000000",
require.Equal(t, "6ca3b68f41034fef9cd7c4c63588d3b03feb5281b9d232cba34d6f3d71aee59211ffbfe1fe870000000000000000000000000000000000000000000000000000000000000000",
fmt.Sprintf("%x", cdc.Amino.MustMarshalBinaryBare(priv.PubKey())),
"Is your device using test mnemonic: %s ?", testdata.TestMnemonic)
require.Equal(t, expectedPkStr, priv.PubKey().String())
Expand Down
4 changes: 2 additions & 2 deletions proto/cosmos/crypto/secp256k1/keys.proto
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ message PubKeyOld {
// PubKey defines a comet uncompressed secp256k1 public key
// Key is the uncompressed form of the pubkey.
message PubKey {
option (amino.name) = "comet/PubKeySecp256k1Uncompressed";
option (amino.name) = "cometbft/PubKeySecp256k1eth";
// The Amino encoding is simply the inner bytes field, and not the Amino
// encoding of the whole PubKey struct.
//
Expand All @@ -56,7 +56,7 @@ message PrivKeyOld {

// PrivKey defines a comet secp256k1 private key.
message PrivKey {
option (amino.name) = "comet/PrivKeySecp256k1Uncompressed";
option (amino.name) = "cometbft/PrivKeySecp256k1eth";
option (amino.message_encoding) = "key_field";

bytes key = 1;
Expand Down
Loading