<p>No need for an external program at all:</p>

<pre><code>$ KEY=xprv9s21ZrQH143K2hYgcmBxsUfRw3Kbu3eEGXFJrM8Cqtewuqa6Y6nXbB7tv9HnrBajqjptPsRjL9FmnwLa317jHWJ5dpwTc99C2AiPztPRaxk
$ echo $KEY | bx hd-public -i 0 | bx hd-to-address
15jbcT7wE81s8n2dbEGRFGf65zp7PHrjxh
</code></pre>

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

<pre><code>$ KEY=xpub661MyMwAqRbcFBd9iniyEccAV5A6JWN5dkAuejXpQEBvnduF5e6n8ySNmP8uWeqNbwFXLHEQkV1shXbNtBV8YCUJPMSuE7bGCvDaZJfUBuP
$ echo $KEY | bx hd-public -i 0 | bx hd-to-address
15jbcT7wE81s8n2dbEGRFGf65zp7PHrjxh
</code></pre>

CC BY-SA 3.0
2015-07-10T01:42:32.577Z
Most excellent...
skaht
CC BY-SA 3.0
2015-07-09T23:06:39.257Z
2015-07-09T23:06:39.257Z
Nick ODell
<p>I was trying to get strong feedback that I really understood a <a href="https://github.com/aantonop/bitcoinbook/blob/develop/ch04.asciidoc#CKDpriv" rel="nofollow noreferrer">portion</a> of the Mastering Bitcoin Book concerning HD wallets. The picture below is the reference for the question.</p>

<p><img src="https://i.sstatic.net/HPlYl.png" alt="HD Private Child Key Derivation"></p>

<p>I checked out the functionality exposed by a <a href="https://coinb.in/#newHDaddress" rel="nofollow noreferrer">Javascript Brain Wallet</a>. By entering "123" (is a very poor secret) into a field for a HD brainwallet and the following extended private key emerged: <strong>xprv9s21ZrQH143K2hYgcmBxsUfRw3Kbu3eEGXFJrM8Cqtewuqa6Y6nXbB7tv9HnrBajqjptPsRjL9FmnwLa317jHWJ5dpwTc99C2AiPztPRaxk</strong>.</p>

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

<p>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 <strong>KwMsDozFYQG7SZFwfvFRwWDhfuMJjkE669WxP6SqrpDPsCBrPV4p</strong> public address <strong>15jbcT7wE81s8n2dbEGRFGf65zp7PHrjxh</strong>?  If so, how is this accomplished or does bx need to be complemented by some other command that renders HMAC-SHA512 functionality?</p>

CC BY-SA 3.0
2015-07-09T13:00:50.567Z
% echo "L4h3ZSQ3yfFNbovQjTGumvUGEfB1a7oFAhbkhMMFGsdDKoTSwwU8" | bx wif-to-ec
deec675df1bc1d395c6098ee63eacb45036fad781717548f4b8cc00709f5d834
skaht
CC BY-SA 3.0
2015-07-09T13:09:18.333Z
% echo "L4h3ZSQ3yfFNbovQjTGumvUGEfB1a7oFAhbkhMMFGsdDKoTSwwU8" | bx wif-to-ec | bx ec-to-public 
02430aca0779d7ca52441ee9de2f7b73408ee8229d6c2e42a5c81b65028efc803f
skaht
<wallet><private-key><bip32-hd-wallets>
Getting bx to create a private key from known chain code and a private EC WIF key?
skaht
# Getting bx to create a private key from known chain code and a private EC WIF key?

(Asked by: username_0 on 2015-07-09)

I was trying to get strong feedback that I really understood a [portion](https://github.com/aantonop/bitcoinbook/blob/develop/ch04.asciidoc#CKDpriv) of the Mastering Bitcoin Book concerning HD wallets. The picture below is the reference for the question.

![HD Private Child Key Derivation](https://i.sstatic.net/HPlYl.png)

I checked out the functionality exposed by a [Javascript Brain Wallet](https://coinb.in/#newHDaddress). 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?

**Tags:** wallet, private-key, bip32-hd-wallets

> **Comments:**
> **username_0**: % echo "L4h3ZSQ3yfFNbovQjTGumvUGEfB1a7oFAhbkhMMFGsdDKoTSwwU8" | bx wif-to-ec deec675df1bc1d395c6098ee63eacb45036fad781717548f4b8cc00709f5d834  
> **username_0**: % echo "L4h3ZSQ3yfFNbovQjTGumvUGEfB1a7oFAhbkhMMFGsdDKoTSwwU8" | bx wif-to-ec | bx ec-to-public  02430aca0779d7ca52441ee9de2f7b73408ee8229d6c2e42a5c81b65028efc803f  

---

## 1 answers

### Answer by username_1 on 2015-07-09. Score: 2

No need for an external program at all:

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

```

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
15jbcT7wE81s8n2dbEGRFGf65zp7PHrjxh

```

> **Comments:**
> **username_0**: Most excellent...  

---

