How to harmonize the set-up of key material to operate all three of them as hd-wallets.
Start with an USB-connected trustanchor to a host computer. Create a mnemonic on the trustanchor and ask for the WIF of the master key. This is necessary as neither bitcoin core nor the Blockstream elementsd client allow import of mnemonic phrases as they don’t directly support BIP-39
Create a new mnemonic phrase
Derive the root or master key in different formats
In elementsd we set-up first a blank wallet
createwallet 'walletname' false true ""Then we import the seed via the WIF encoded masterkey we’ve got from the trustanchor
sethdseed true cMbNCWdLK3eqENuVUcU6oCcdme4fBgNdUEJAb9sTuuMxPRVdCK65Now the hd-wallet inside elementsd (or the same way inside bitcoin core) will transact and sign on top of this key material derived from the newly set seed. to control this we will export the wallet including its Extended Master Private Key.
dumpwallet 'path/filename'Which delivers a wallet dump file of this kind:
Of relevance is the extended master private key which is the serialization of the core of a hd-wallet object. To deserialize this key we can use the following Python3 code
Which results is:
Consequently, we can set up our trustanchor to operate on top of the extended master private key - hd wallet object instead of the seed from the mnemonic phrase.
This also means that all signing with key material done from within in elementsd on raw transactions can now also be done on the trustanchor acting as a real HSM - hardwrae security module
But how exactly are elementsd and bitcoin core handling the sethdseed command to get to this result?
It takes the WIF key: ‘cMbNCWdLK3eqENuVUcU6oCcdme4fBgNdUEJAb9sTuuMxPRVdCK65’ turns it back into the raw private key and calculates it public key by multiplying its raw key with the curve base point.
> bx wif-to-public --config ./bx.cfg cMbNCWdLK3eqENuVUcU6oCcdme4fBgNdUEJAb9sTuuMxPRVdCK65
02aa3dc46791b9f99971551e8162f982867246420f35f3f0a473bc688cd09e2b7fThe public key becomes than the seed for calculating the new extended master private key. That’s all