crypto: updates from reviews (#535)

This commit is contained in:
Federico Kunze Küllmer
2021-09-07 17:29:24 +00:00
committed by GitHub
parent c3f70aeaf7
commit 2e45a0665e
12 changed files with 71 additions and 70 deletions
+7 -2
View File
@@ -74,14 +74,19 @@ func UnsafeExportEthKeyCommand() *cobra.Command {
return fmt.Errorf("invalid key algorithm, got %s, expected %s", algo, ethsecp256k1.KeyType)
}
// Converts key to Ethermint secp256 implementation
// Converts key to Ethermint secp256k1 implementation
ethPrivKey, ok := privKey.(*ethsecp256k1.PrivKey)
if !ok {
return fmt.Errorf("invalid private key type %T, expected %T", privKey, &ethsecp256k1.PrivKey{})
}
key, err := ethPrivKey.ToECDSA()
if err != nil {
return err
}
// Formats key for output
privB := ethcrypto.FromECDSA(ethPrivKey.ToECDSA())
privB := ethcrypto.FromECDSA(key)
keyS := strings.ToUpper(hexutil.Encode(privB)[2:])
fmt.Println(keyS)