Using Cardano-CLI to generate keys offline

I am trying to use the Cardano-wallet to generate an English recovery phrase, use that to generate a set of keys, then use that to get a wallet address all offline on an air-gapped Linux laptop.

in reading the documentation it looks like there are two ways i could go about doing this and I’m not sure which way it should be done?

$ cardano-wallet recovery-phrase generate --size 15
| cardano-wallet key from-recovery-phrase Shelley > root.prv

$ cat root.prv
| cardano-wallet key child 1852H/1815H/0H
| tee acct.prv
| cardano-wallet key public > acct.pub

cardano-wallet key inspect <<< (cat acct.prv)
{
“key_type”: “private”,
“chain_code”: “67bef6f80df02c7452e20e76ffb4bb57cae8aac2adf042b21a6b19e4f7b1f511”,
“extended_key”: “90ead3efad7aacac242705ede323665387f49ed847bed025eb333708ccf6aa54403482a867daeb18f38c57d6cddd7e6fd6aed4a3209f7425a3d1c5d9987a9c5f”
}

cardano-wallet key inspect <<< (cat acct.pub)
{
“key_type”: “public”,
“chain_code”: “67bef6f80df02c7452e20e76ffb4bb57cae8aac2adf042b21a6b19e4f7b1f511”,
“extended_key”: “d306350ee88f51fb710252e27f0c40006c58e994761b383e02d400e2be59b3cc”
}

Or:

$ cardano-address recovery-phrase generate --size 15
| cardano-address key from-recovery-phrase Shelley > root.prv

$ cat root.prv
| cardano-address key child 1852H/1815H/0H
| tee acct.prv
| cardano-address key public > acct.pub

cardano-address key inspect <<< (cat acct.prv)
{
“key_type”: “private”,
“chain_code”: “67bef6f80df02c7452e20e76ffb4bb57cae8aac2adf042b21a6b19e4f7b1f511”,
“extended_key”: “90ead3efad7aacac242705ede323665387f49ed847bed025eb333708ccf6aa54403482a867daeb18f38c57d6cddd7e6fd6aed4a3209f7425a3d1c5d9987a9c5f”
}

cardano-address key inspect <<< (cat acct.pub)
{
“key_type”: “public”,
“chain_code”: “67bef6f80df02c7452e20e76ffb4bb57cae8aac2adf042b21a6b19e4f7b1f511”,
“extended_key”: “d306350ee88f51fb710252e27f0c40006c58e994761b383e02d400e2be59b3cc”
}

One is making a wallet key and one is making an address key but both are using root.prv, acct.prv, and acct.pub.

If anyone is willing to explain this to me I would greatly appreciate it, or if you can point out what I need to learn to help me get a better understanding of the CLI.

What will this allow us to do? Recover from files?

@Jaime - This is about creating new keys, completely unrelated to your Daedalus key (for which you lost the recovery phrase and you cannot remember spending password) which is encrypted using your spending password.

1 Like

To clarify my question, I went ahead and created a address recovery phrase, made a pkey, made a child key, made a public key, and a payment address using :

$./cardano-address recovery-phrase generate > rec.txt \ cat rec.txt | ./cardano-address key from-recovery-phrase Shelley > root.prv

$ cat root.prv \ | ./cardano-address key child 1852H/1815H/0H/0/0 > addr.prv

$ cat addr.prv \ | ./cardano-address key public --with-chain-code \ | ./cardano-address address payment --network-tag mainnet

This all worked fine however, what would be different if I had used:

$ ./cardano-wallet recovery-phrase generate

instead of:

$ ./cardano-address recovery-phrase generate

any help would be great!

Nothing really, generating a recovery phrase is kinda independent of actual wallet/address derivation, it is simply a way to generate a private key that is derived from the words.

1 Like

Okay Thanks! just to be clear when referring to this:

+--------------------------------------------------------------------------------+
|         BIP-39 Encoded 128 bits Seed with CRC a.k.a 12 Mnemonic Words          |
|                                                                                |
|    squirrel material silly twice direct ... razor become junk kingdom flee     |
|                                                                                |
+--------------------------------------------------------------------------------+
              |                                                     
              |                                                    
              v                                                     
+--------------------------+    +-----------------------+
|    Wallet Private Key    |--->|   Wallet Public Key   |    m
+--------------------------+    +-----------------------+
              |                                           
              | account ix
              v                                           
+--------------------------+    +-----------------------+
|   Account Private Key    |--->|   Account Public Key  |    m/account_ix'
+--------------------------+    +-----------------------+
              |                                           
              | address ix
              v                                           
+--------------------------+    +-----------------------+
|   Address Private Key    |--->|   Address Public Key  |    m/account_ix'/address_ix'
+--------------------------+    +-----------------------+

Generating any of these pkeys would be the same?

Generating root/pub keys from recovery phrase will be the same for both.
Now depending on the path (coin type, account and address index) you derive the key for, the keys generated could be different, but the example you use above is for deriving root keys, which will be the same.

The part where you are doing a drill down specifying 1852H/1815H/0H is currently the same as what HD Wallet uses, thus - it is the indeed same in this case.

1 Like

Much aprecated!

For anyone searching this I was referencing the documentation on GitHub:

I just found this and found it helpful:
https://docs.cardano.org/projects/cardano-node/en/latest/reference/cardano-node-cli-reference.html