Skip to content

Commit

Permalink
feat: apply change of prefix of key name in ostracon (#610)
Browse files Browse the repository at this point in the history
* feat: apply the changes to change the prefixs of key name in ostracon.

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: update ostracon version

Signed-off-by: zemyblue <zemyblue@gmail.com>

* chore: update changelog

Signed-off-by: zemyblue <zemyblue@gmail.com>
  • Loading branch information
zemyblue committed Jul 27, 2022
1 parent 99ebca8 commit 97baddf
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 65 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (amino) [\#600](https://github.com/line/lbm-sdk/pull/600) change amino codec path from `lbm-sdk/` to `cosmos-sdk/`
* (store) [\#605](https://github.com/line/lbm-sdk/pull/605) replace line/iavl and line/tm-db with cosmos/iavl and tendermint/tm-db.
* (server/grpc) [\#607](https://github.com/line/lbm-sdk/pull/607) revert gRPC block height header.
* (ostracon) [\#610](https://github.com/line/lbm-sdk/pull/610) apply change of prefix of key name in ostracon

### Improvements

Expand Down
11 changes: 5 additions & 6 deletions client/keys/import_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ func Test_runImportCmd(t *testing.T) {

armoredKey := `-----BEGIN OSTRACON PRIVATE KEY-----
kdf: bcrypt
salt: A278E4F0DC466EF58CC9FC3149688593
salt: A53F628182B827E07DD11A96EAB9D526
type: secp256k1
mSB5rEfN4VCi1EnEca5PigV/WphYtrBFft+QyZ2ISztMeQmuhFNFWwjLBsJm5zXv
KNXMn0ZEeCZtbyNzPPdQUQBwcbueq9vx5NDqQCg=
=wp9z
-----END OSTRACON PRIVATE KEY-----
`
Ax9IQsSq+jOWkPRDJQ69a5/uUm4XliPim/CbYDVoXO6D3fts5IEXcUTmIa60ynC/
8hzYAawzYMO95Kwi0NI8WW9wUv3TseSWFv6/RpU=
=umYd
-----END OSTRACON PRIVATE KEY-----`

for _, tc := range testCases {
t.Run(tc.name, func(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 @@ -29,8 +29,8 @@ func Test_multiSigKey_Properties(t *testing.T) {
require.NoError(t, err)
require.Equal(t, "myMultisig", tmp.GetName())
require.Equal(t, keyring.TypeMulti, tmp.GetType())
require.Equal(t, "BDF0C827D34CA39919C7688EB5A95383C60B3471", tmp.GetPubKey().Address().String())
require.Equal(t, "link1hhcvsf7nfj3ejxw8dz8tt22ns0rqkdr3rrh7xy", sdk.MustBech32ifyAddressBytes("link", tmp.GetAddress()))
require.Equal(t, "D3923267FA8A3DD367BB768FA8BDC8FF7F89DA3F", tmp.GetPubKey().Address().String())
require.Equal(t, "link16wfryel63g7axeamw68630wglalcnk3l6vulks", sdk.MustBech32ifyAddressBytes("link", tmp.GetAddress()))
}

func Test_showKeysCmd(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion codec/amino_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ func TestAminoCodecUnpackAnyFails(t *testing.T) {

func TestAminoCodecFullDecodeAndEncode(t *testing.T) {
// This tx comes from https://github.com/cosmos/cosmos-sdk/issues/8117.
txSigned := `{"type":"cosmos-sdk/StdTx","value":{"msg":[{"type":"cosmos-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"link14pt0q5cwf38zt08uu0n6yrstf3rndzr5057jys","validator_address":"linkvaloper14pt0q5cwf38zt08uu0n6yrstf3rndzr52q28gr","pubkey":{"type":"ostracon/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"ostracon/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"memo":"","timeout_height":"0"}}`
txSigned := `{"type":"cosmos-sdk/StdTx","value":{"msg":[{"type":"cosmos-sdk/MsgCreateValidator","value":{"description":{"moniker":"fulltest","identity":"satoshi","website":"example.com","details":"example inc"},"commission":{"rate":"0.500000000000000000","max_rate":"1.000000000000000000","max_change_rate":"0.200000000000000000"},"min_self_delegation":"1000000","delegator_address":"link14pt0q5cwf38zt08uu0n6yrstf3rndzr5057jys","validator_address":"linkvaloper14pt0q5cwf38zt08uu0n6yrstf3rndzr52q28gr","pubkey":{"type":"tendermint/PubKeyEd25519","value":"CYrOiM3HtS7uv1B1OAkknZnFYSRpQYSYII8AtMMtev0="},"value":{"denom":"umuon","amount":"700000000"}}}],"fee":{"amount":[{"denom":"umuon","amount":"6000"}],"gas":"160000"},"signatures":[{"pub_key":{"type":"tendermint/PubKeySecp256k1","value":"AwAOXeWgNf1FjMaayrSnrOOKz+Fivr6DiI/i0x0sZCHw"},"signature":"RcnfS/u2yl7uIShTrSUlDWvsXo2p2dYu6WJC8VDVHMBLEQZWc8bsINSCjOnlsIVkUNNe1q/WCA9n3Gy1+0zhYA=="}],"memo":"","timeout_height":"0"}}`
var legacyCdc = simapp.MakeTestEncodingConfig().Amino
var tx legacytx.StdTx
err := legacyCdc.UnmarshalJSON([]byte(txSigned), &tx)
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 @@ -26,5 +26,5 @@ func TestBech32KeysOutput(t *testing.T) {
out, err := MkAccKeyOutput(info)
require.NoError(t, err)
require.Equal(t, expectedOutput, out)
require.Equal(t, `{Name:multisig Type:multi Address:link1azx3qquuvjfvs7khudad7e3jnrsqrtlpkhsfeg PubKey:{"@type":"/cosmos.crypto.multisig.LegacyAminoPubKey","threshold":1,"public_keys":[{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJ"}]} Mnemonic:}`, fmt.Sprintf("%+v", out))
require.Equal(t, `{Name:multisig Type:multi Address:link1nf8lf6n4wa43rzmdzwe6hkrnw5guekhq769krx PubKey:{"@type":"/cosmos.crypto.multisig.LegacyAminoPubKey","threshold":1,"public_keys":[{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"AurroA7jvfPd1AadmmOvWM2rJSwipXfRf8yD6pLbA2DJ"}]} Mnemonic:}`, fmt.Sprintf("%+v", out))
}
4 changes: 2 additions & 2 deletions crypto/keys/ed25519/ed25519.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import (
//-------------------------------------

const (
PrivKeyName = "ostracon/PrivKeyEd25519"
PubKeyName = "ostracon/PubKeyEd25519"
PrivKeyName = "tendermint/PrivKeyEd25519"
PubKeyName = "tendermint/PubKeyEd25519"
// PubKeySize is is the size, in bytes, of public keys as used in this package.
PubKeySize = 32
// PrivKeySize is the size, in bytes, of private keys as used in this package.
Expand Down
2 changes: 1 addition & 1 deletion crypto/keys/multisig/codec.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
// TODO: Figure out API for others to either add their own pubkey types, or
// to make verify / marshal accept a AminoCdc.
const (
PubKeyAminoRoute = "ostracon/PubKeyMultisigThreshold"
PubKeyAminoRoute = "tendermint/PubKeyMultisigThreshold"
)

//nolint
Expand Down
12 changes: 6 additions & 6 deletions crypto/keys/multisig/multisig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,27 +392,27 @@ func TestAminoUnmarshalJSON(t *testing.T) {
// with amino, there's no error.
// ref: https://github.com/cosmos/cosmos-sdk/issues/8776
pkJSON := `{
"type": "ostracon/PubKeyMultisigThreshold",
"type": "tendermint/PubKeyMultisigThreshold",
"value": {
"pubkeys": [
{
"type": "ostracon/PubKeySecp256k1",
"type": "tendermint/PubKeySecp256k1",
"value": "AzYxq2VNeD10TyABwOgV36OVWDIMn8AtI4OFA0uQX2MK"
},
{
"type": "ostracon/PubKeySecp256k1",
"type": "tendermint/PubKeySecp256k1",
"value": "A39cdsrm00bTeQ3RVZVqjkH8MvIViO9o99c8iLiNO35h"
},
{
"type": "ostracon/PubKeySecp256k1",
"type": "tendermint/PubKeySecp256k1",
"value": "A/uLLCZph8MkFg2tCxqSMGwFfPHdt1kkObmmrqy9aiYD"
},
{
"type": "ostracon/PubKeySecp256k1",
"type": "tendermint/PubKeySecp256k1",
"value": "A4mOMhM5gPDtBAkAophjRs6uDGZm4tD4Dbok3ai4qJi8"
},
{
"type": "ostracon/PubKeySecp256k1",
"type": "tendermint/PubKeySecp256k1",
"value": "A90icFucrjNNz2SAdJWMApfSQcARIqt+M2x++t6w5fFs"
}
],
Expand Down
4 changes: 2 additions & 2 deletions crypto/keys/secp256k1/secp256k1.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ var _ codec.AminoMarshaler = &PrivKey{}
const (
PrivKeySize = 32
keyType = "secp256k1"
PrivKeyName = "ostracon/PrivKeySecp256k1"
PubKeyName = "ostracon/PubKeySecp256k1"
PrivKeyName = "tendermint/PrivKeySecp256k1"
PubKeyName = "tendermint/PubKeySecp256k1"
)

// Bytes returns the byte representation of the Private Key.
Expand Down
2 changes: 1 addition & 1 deletion crypto/ledger/amino.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func init() {
// RegisterAmino registers all go-crypto related types in the given (amino) codec.
func RegisterAmino(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(PrivKeyLedgerSecp256k1{},
"ostracon/PrivKeyLedgerSecp256k1", nil)
"tendermint/PrivKeyLedgerSecp256k1", nil)
}
16 changes: 8 additions & 8 deletions crypto/ledger/encode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ func ExamplePrintRegisteredTypes() {
cdc.PrintTypes(os.Stdout)
//| Type | Name | Prefix | Length | Notes |
//| ---- | ---- | ------ | ----- | ------ |
//| PrivKeyLedgerSecp256k1 | ostracon/PrivKeyLedgerSecp256k1 | 0x5421414C | variable | |
//| PubKey | ostracon/PubKeySr25519 | 0x09EF29BD | variable | |
//| PubKey | ostracon/PubKeyEd25519 | 0xCA5F2BB0 | variable | |
//| PubKey | ostracon/PubKeySecp256k1 | 0xC03701B7 | variable | |
//| LegacyAminoPubKey | ostracon/PubKeyMultisigThreshold | 0x77A72198 | variable | |
//| PrivKey | ostracon/PrivKeySr25519 | 0x2C3D3053 | variable | |
//| PrivKey | ostracon/PrivKeyEd25519 | 0xF53C89CD | variable | |
//| PrivKey | ostracon/PrivKeySecp256k1 | 0x423EB2BA | variable | |
//| PrivKeyLedgerSecp256k1 | tendermint/PrivKeyLedgerSecp256k1 | 0x10CAB393 | variable | |
//| PubKey | tendermint/PubKeySr25519 | 0x0DFB1005 | variable | |
//| PubKey | tendermint/PubKeyEd25519 | 0x1624DE64 | variable | |
//| PubKey | tendermint/PubKeySecp256k1 | 0xEB5AE987 | variable | |
//| LegacyAminoPubKey | tendermint/PubKeyMultisigThreshold | 0x22C1F7E2 | variable | |
//| PrivKey | tendermint/PrivKeySr25519 | 0x2F82D78B | variable | |
//| PrivKey | tendermint/PrivKeyEd25519 | 0xA3288910 | variable | |
//| PrivKey | tendermint/PrivKeySecp256k1 | 0xE1B0F79B | variable | |
}

func TestNilEncodings(t *testing.T) {
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 @@ -31,7 +31,7 @@ func TestPublicKeyUnsafe(t *testing.T) {
func checkDefaultPubKey(t *testing.T, priv types.LedgerPrivKey) {
require.NotNil(t, priv)
expectedPkStr := "PubKeySecp256k1{02BCD96CAB102304AC10E90C5A0F29358E3A4A6FB1217B83E5DB657918EA28BEC1}"
require.Equal(t, "c03701b72102bcd96cab102304ac10e90c5a0f29358e3a4a6fb1217b83e5db657918ea28bec1",
require.Equal(t, "eb5ae9872102bcd96cab102304ac10e90c5a0f29358e3a4a6fb1217b83e5db657918ea28bec1",
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
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ require (
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/iavl v0.17.3
github.com/cosmos/ledger-cosmos-go v0.11.1
github.com/dgraph-io/ristretto v0.1.0
github.com/dgraph-io/ristretto v0.1.0 // indirect
github.com/dvsekhvalnov/jose2go v0.0.0-20200901110807-248326c1351b
github.com/go-kit/kit v0.12.0
github.com/gogo/gateway v1.1.0
Expand All @@ -30,7 +30,7 @@ require (
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3
github.com/improbable-eng/grpc-web v0.15.0
github.com/jhump/protoreflect v1.10.3
github.com/line/ostracon v1.0.6
github.com/line/ostracon v1.0.7-0.20220727044439-81b4fb7095a8
github.com/line/wasmvm v1.0.0-0.10.0
github.com/magiconair/properties v1.8.6
github.com/mailru/easyjson v0.7.7
Expand All @@ -55,7 +55,7 @@ require (
github.com/tendermint/tm-db v0.6.6
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
google.golang.org/genproto v0.0.0-20220519153652-3a47de7e79bd
google.golang.org/grpc v1.47.0
google.golang.org/grpc v1.48.0
google.golang.org/protobuf v1.28.0
gopkg.in/yaml.v2 v2.4.0
)
Expand Down
Loading

0 comments on commit 97baddf

Please sign in to comment.