A robust way to do that is to use cardano-wallet CLI.
First of all, run cardano-wallet serve and cardano-node.
Root Key
The command that helps us writing a root private key into a file should look like this:
cardano-wallet recovery-phrase generate --size 18 \
| cardano-wallet key from-recovery-phrase Shelley > secretKey.prv
It results in private key creation that might look like this:
root_xsk1vrv54w0rpg6j9qz54ed48hjf99k0qt7p4wu5l3y55tlpk8684dphx6a8xw82u3vsgwcv6n8mdxwczhfhusy22eknmdpjn9lnyram0alqaa7mwjx4rg0eyh3ckv0el34j5vswquzhvrpaze6ju6s623fs4ylx346v
Derivation Path
m / purpose' / coin_type' / account_index' / role / address_index
If you tap a 20th receiving address in Daedalus wallet you'll see the following path:
m / 1852H / 1815H / 0H / 0 / 19
where 1852
is a hardened Shelley-era address type, and 1815
is hardened ADA's index.
Account Keys
According to this scheme let's create account private key and account public key:
cat secretKey.prv \
| cardano-wallet key child 1852H/1815H/0H \
| tee account.prv \
| cardano-wallet key public --with-chain-code > account.pub
These results are:
acct_xsk10ra048lvz7le0y5pkmqmceuf492u64nv8edk9qsh3036jtz84dp3xqns35edmhag0nke3xmhm87368v8mtr5d2ryd3ucjgg6e5vjf7r8eu4ejhpyax2us59c73pt7sduvddy934k8p925xxsqvc2hh8nnug24fq6
...
acct_xvk1fpqtkwf8yy5rn3f79a4vr4fpd9rxxfheursjzqw8kgj0qf3q98ux0netn9wzf6v4epgt3azzhaqmcc66gtrtvwz24gvdqqes40w088c36lqsu
Create a wallet
cardano-wallet wallet create from-public-key < 128-bit hash of acct pub key >
Additional reading
If you need more details on Cardano CLI, please read my Medium stories: