Fix CryptoCdc inconsistent (#7987)

* simple fix

* refactor crypto

* just use codec/legacy.Cdc

* revert armor

* add changelog entry

Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
vincent
2020-12-02 14:50:50 +01:00
committed by GitHub
co-authored by Aleksandr Bezobchuk
parent a51eac4f15
commit f57828c091
12 changed files with 39 additions and 51 deletions
-19
View File
@@ -10,13 +10,6 @@ import (
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
)
var amino *codec.LegacyAmino
func init() {
amino = codec.NewLegacyAmino()
RegisterCrypto(amino)
}
// RegisterCrypto registers all crypto dependency types with the provided Amino
// codec.
func RegisterCrypto(cdc *codec.LegacyAmino) {
@@ -38,15 +31,3 @@ func RegisterCrypto(cdc *codec.LegacyAmino) {
cdc.RegisterConcrete(&secp256k1.PrivKey{},
secp256k1.PrivKeyName, nil)
}
// PrivKeyFromBytes unmarshals private key bytes and returns a PrivKey
func PrivKeyFromBytes(privKeyBytes []byte) (privKey cryptotypes.PrivKey, err error) {
err = amino.UnmarshalBinaryBare(privKeyBytes, &privKey)
return
}
// PubKeyFromBytes unmarshals public key bytes and returns a PubKey
func PubKeyFromBytes(pubKeyBytes []byte) (pubKey cryptotypes.PubKey, err error) {
err = amino.UnmarshalBinaryBare(pubKeyBytes, &pubKey)
return
}