import unarmored-hex private key in keychain
See original GitHub issueDescribe the bug
For now there is no supported way to import unarmored-hex private key through cli.
To Reproduce
Steps to reproduce the behavior:
- Create key with
key add
Example
root@agoric:# ag0 keys add testkey Enter keyring passphrase:
- name: testkey type: local address: agoric17v05q6zkms4an52cmqjh66wyua4p3mc5x5x42n pubkey: ‘{“@type”:“/cosmos.crypto.secp256k1.PubKey”,“key”:“ArBppIsQhPrugYbB2E3cBazDeImbSRfT4ersnCpX/PI5”}’ mnemonic: “”
Important write this mnemonic phrase in a safe place. It is the only way to recover your account if you ever forget your password.
donor misery hospital detect hole road sun stock bag sound surge sister young proud unhappy rubber hover limit glide hip element sign fossil blame
- Export created key in unarmored-hex format
Example
root@agoric:# ag0 keys export testkey --unarmored-hex --unsafe WARNING: The private key will be exported as an unarmored hexadecimal string. USE AT YOUR OWN RISK. Continue? [y/N]: y Enter keyring passphrase: b101cfc33ec9f702d2d0540cdbe34855066520d1059c1535f86f08c368a15a6c
- Save key in file
Example
root@agoric:# echo “b101cfc33ec9f702d2d0540cdbe34855066520d1059c1535f86f08c368a15a6c” >> key.txt root@agoric:# cat ./key.txt b101cfc33ec9f702d2d0540cdbe34855066520d1059c1535f86f08c368a15a6c
- Try to import key and get an error
keys import ...
Example
root@agoric:# ag0 keys import testkey2 ./key.txt Enter passphrase to decrypt your key: Error: failed to decrypt private key: EOF Usage: ag0 keys import <name> <keyfile> [flags]
Flags: -h, --help help for import
Global Flags: –home string The application home directory (default “/root/.agoric”) –keyring-backend string Select keyring’s backend (os|file|test) (default “os”) –keyring-dir string The client Keyring directory; if omitted, the default ‘home’ directory will be used –log_format string The logging format (json|plain) (default “plain”) –log_level string The logging level (trace|debug|info|warn|error|fatal|panic) (default “info”) –output string Output format (text|json) (default “text”) –trace print out full stack trace on errors
Expected behavior
Key should be encrypted and imported in keychain
Platform Environment
- Ubuntu 20.04 Go 1.17.2
- ag0 tag agoric-3.1
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)

Top Related StackOverflow Question
keyFmt work-around
Given the raw key above
b101cfc33ec9f702d2d0540cdbe34855066520d1059c1535f86f08c368a15a6c, usingpasswordfor a password:keyFmt.go
@dckc Thank you so much for the workaround. I confirm I am able to import my private key.