I was trying to get strong feedback that I really understood a portion of the Mastering Bitcoin Book concerning HD wallets. The picture below is the reference for the question.

HD Private Child Key Derivation

I checked out the functionality exposed by a Javascript Brain Wallet. By entering "123" (is a very poor secret) into a field for a HD brainwallet and the following extended private key emerged: xprv9s21ZrQH143K2hYgcmBxsUfRw3Kbu3eEGXFJrM8Cqtewuqa6Y6nXbB7tv9HnrBajqjptPsRjL9FmnwLa317jHWJ5dpwTc99C2AiPztPRaxk.

Clicking the button to the right of the private key got me to another page indicating the master private chain code is 40675733fc35303c1c75bc598716f24af225528da686192ceb567c88313f8885 and the master private key is L4h3ZSQ3yfFNbovQjTGumvUGEfB1a7oFAhbkhMMFGsdDKoTSwwU8.

Given these last two pieces of information and an index of 0, is it possible to issue a number a number of bx commands and concatenate their output results to feed a HMAC-SHA512 hash to arrive at private WIF key of KwMsDozFYQG7SZFwfvFRwWDhfuMJjkE669WxP6SqrpDPsCBrPV4p public address 15jbcT7wE81s8n2dbEGRFGf65zp7PHrjxh? If so, how is this accomplished or does bx need to be complemented by some other command that renders HMAC-SHA512 functionality?

  • % echo "L4h3ZSQ3yfFNbovQjTGumvUGEfB1a7oFAhbkhMMFGsdDKoTSwwU8" | bx wif-to-ec deec675df1bc1d395c6098ee63eacb45036fad781717548f4b8cc00709f5d834 – skaht Jul 9 '15 at 13:00
  • % echo "L4h3ZSQ3yfFNbovQjTGumvUGEfB1a7oFAhbkhMMFGsdDKoTSwwU8" | bx wif-to-ec | bx ec-to-public 02430aca0779d7ca52441ee9de2f7b73408ee8229d6c2e42a5c81b65028efc803f – skaht Jul 9 '15 at 13:09

No need for an external program at all:

$ KEY=xprv9s21ZrQH143K2hYgcmBxsUfRw3Kbu3eEGXFJrM8Cqtewuqa6Y6nXbB7tv9HnrBajqjptPsRjL9FmnwLa317jHWJ5dpwTc99C2AiPztPRaxk
$ echo $KEY | bx hd-public -i 0 | bx hd-to-address

Or, because this is non-hardened, you can use the extended public key:

$ KEY=xpub661MyMwAqRbcFBd9iniyEccAV5A6JWN5dkAuejXpQEBvnduF5e6n8ySNmP8uWeqNbwFXLHEQkV1shXbNtBV8YCUJPMSuE7bGCvDaZJfUBuP
$ echo $KEY | bx hd-public -i 0 | bx hd-to-address
  • Most excellent... – skaht Jul 10 '15 at 1:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.