crypto: add keyring supported algorithms (#439)

* add keyring supported algorithms

* lint

* minor updates

* use eth_secp256k1 as the default signing algo

* add flag

* derivation func

* refactor

* rename keys amino registration

* fix keys

* address comments from review
This commit is contained in:
Federico Kunze
2020-08-11 11:01:15 -04:00
committed by GitHub
parent defcad2bcd
commit a243f43fe2
17 changed files with 239 additions and 52 deletions
+3 -2
View File
@@ -16,7 +16,7 @@ import (
"github.com/cosmos/cosmos-sdk/crypto/keyring"
sdk "github.com/cosmos/cosmos-sdk/types"
emintcrypto "github.com/cosmos/ethermint/crypto"
"github.com/cosmos/ethermint/crypto"
)
// UnsafeExportEthKeyCommand exports a key with the given name as a private key in hex format.
@@ -34,6 +34,7 @@ func UnsafeExportEthKeyCommand() *cobra.Command {
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
inBuf,
crypto.EthSecp256k1Options()...,
)
if err != nil {
return err
@@ -63,7 +64,7 @@ func UnsafeExportEthKeyCommand() *cobra.Command {
}
// Converts key to Ethermint secp256 implementation
emintKey, ok := privKey.(emintcrypto.PrivKeySecp256k1)
emintKey, ok := privKey.(crypto.PrivKeySecp256k1)
if !ok {
return fmt.Errorf("invalid private key type, must be Ethereum key: %T", privKey)
}
+5 -2
View File
@@ -65,7 +65,9 @@ func runAddCmd(cmd *cobra.Command, args []string) error {
func getKeybase(transient bool, buf io.Reader) (keyring.Keybase, error) {
if transient {
return keyring.NewInMemory(keyring.WithKeygenFunc(crypto.EthermintKeygenFunc)), nil
return keyring.NewInMemory(
crypto.EthSecp256k1Options()...,
), nil
}
return keyring.NewKeyring(
@@ -73,5 +75,6 @@ func getKeybase(transient bool, buf io.Reader) (keyring.Keybase, error) {
viper.GetString(flags.FlagKeyringBackend),
viper.GetString(flags.FlagHome),
buf,
keyring.WithKeygenFunc(crypto.EthermintKeygenFunc))
crypto.EthSecp256k1Options()...,
)
}
+1 -1
View File
@@ -165,7 +165,7 @@ func InitTestnet(
keyringBackend,
clientDir,
inBuf,
keyring.WithKeygenFunc(crypto.EthermintKeygenFunc),
crypto.EthSecp256k1Options()...,
)
if err != nil {
return err