<blockquote>
  <p>which secret I have to add ? I don't have any secret, for test I choose "mnemonic", the same constant that I use to generate BIP39seed (is it correct? )</p>
</blockquote>

<p>No, that is incorrect. You use the key <code>mnemonic</code> when converting the BIP 39 mnemonic to a seed. You already have the seed, so you don't use the key <code>mnemonic</code>. You should instead be following the steps described in <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#Master_key_generation" rel="nofollow noreferrer">BIP 32</a>.</p>

<p>So you need to use HMAC-SHA512 with the key <code>Bitcoin seed</code>. Furthermore, the site that you used hashes the input as a string, not as the bytes represented by the hex values. This will result in the wrong hash. You need to use a different site. I used <a href="https://cryptii.com/pipes/hmac" rel="nofollow noreferrer">https://cryptii.com/pipes/hmac</a> and converted the key <code>Bitcoin seed</code> to it's hex representation using <a href="https://www.asciitohex.com/" rel="nofollow noreferrer">https://www.asciitohex.com/</a>. Setting the input to be hexadecimal bytes and setting the key to be the hex form of <code>Bitcoin seed</code> results in the hash:</p>

<pre><code>b2a0d576b828b537688b561f2cfa8dac3602d54c62bde619ad5331e6c235ee26b70d675323c40ec461e0a6af603b1f135fb2af9ae753eeff18922732a73b0f05
</code></pre>

<p>If we look at the master private key we get from your mnemonic (listed as BIP 32 root key on <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a>), we see that its private key and chaincode are the same as the above hash.</p>

CC BY-SA 4.0
2019-01-30T21:43:29.593Z
2019-01-30T21:43:29.593Z
Ava Chow
<p>Here are the mechanics for "Mastering Bitcoin" <a href="https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch05.asciidoc#creating-an-hd-wallet-from-the-seed" rel="nofollow noreferrer"><strong>Creating an HD Wallet from the Seed</strong></a> using  <a href="https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-mnemonic-to-seed" rel="nofollow noreferrer"><strong>bitcoin-explorer</strong></a> and this Python <a href="https://pypi.org/project/hmac_cli/" rel="nofollow noreferrer"><strong>HMAC</strong></a> command.  </p>

<p><strong>Root Seed:</strong></p>

<p><code>% echo "army van defense carry jealous true garbage claim echo media make crunch" | bx mnemonic-to-seed -p ""</code></p>

<p><strong><code>5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570</code></strong></p>

<p><strong>Master Private Key:</strong></p>

<p><code>% echo 5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570 | bx base16-decode | hmac --algorithm sha512 --key "Bitcoin seed" - | cut -c 1-64</code></p>

<p><strong><code>b2a0d576b828b537688b561f2cfa8dac3602d54c62bde619ad5331e6c235ee26</code></strong>   </p>

<p><strong>Master Public Key:</strong></p>

<p><code>% echo 5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570 | bx base16-decode | hmac --algorithm sha512 --key "Bitcoin seed" - | cut -c 1-64 | bx ec-to-public</code></p>

<p><strong><code>03ca72b45eede592f059b7eaf3da13eb7d8d15aa472b6f79f74820bb22ff596186</code></strong></p>

<p><strong>Chain Code:</strong></p>

<p><code>% echo 5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570 | bx base16-decode | hmac --algorithm sha512 --key "Bitcoin seed" - | cut -c 65-128</code></p>

<p><strong><code>b70d675323c40ec461e0a6af603b1f135fb2af9ae753eeff18922732a73b0f05</code></strong></p>

CC BY-SA 4.0
2019-01-31T00:56:22.427Z
Can I  add two secp256k1 keys together with bx ?
monkeyUser
CC BY-SA 4.0
2019-01-31T01:18:31.760Z
For cyclic ordinate “Normalization”, you will want to examine **bx** [**ec-add-secrets**](https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-add-secrets) and [**ec-multiply-secrets**](https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-multiply-secrets)
skaht
CC BY-SA 4.0
2021-05-20T16:13:15.840Z
What is the use of a master public key? Can I see all the the public addresses derived from that HD wallet?
YulePale
CC BY-SA 4.0
2021-05-23T15:48:20.837Z
Instead of all of that decoding, hashing and cutting you can just use the `bx hd-*` commands :). `hd-new`, `hd-private`, `hd-public`, `hd-to-address`, `hd-to-ec`, `hd-to-public`, `hd-to-wif`.
evoskuil
CC BY-SA 4.0
2019-01-31T00:45:37.373Z
2019-01-31T00:54:26.313Z
2019-01-31T00:54:26.313Z
skaht
<p>I have BIP39 Seed:</p>

<pre><code>5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570
</code></pre>

<p>I want to get Master private Key </p>

<p>Then I Have to use HMAC-SHA512, I can use this <a href="https://www.freeformatter.com/hmac-generator.html" rel="nofollow noreferrer">site</a>, which secret I have to add ? I don't have any secret, for test  I choose "mnemonic", the same constant that I use to generate BIP39seed (is it correct? )</p>

<p>the result is: </p>

<blockquote>
  <p>9744d0d7e168f725b6cc36a73c24dfc91bd6d80bf5a6871ad2c6c0b854e4e281b74049c41d25f0b338b3fc9b053b87b95636c3c94c31f37458fe98a09a4a94c9</p>
</blockquote>

<p>and I can get</p>

<pre><code>left 256 bits  =&gt; 9744d0d7e168f725b6cc36a73c24dfc91bd6d80bf5a6871ad2c6c0b854e4e281
right 256 bits  =&gt; b74049c41d25f0b338b3fc9b053b87b95636c3c94c31f37458fe98a09a4a94c9
</code></pre>

<p>And I can Get master private key in this way?</p>

<pre><code>PKM = bx ec-to-wif 9744d0d7e168f725b6cc36a73c24dfc91bd6d80bf5a6871ad2c6c0b854e4e281
</code></pre>

<blockquote>
  <p>result:
  L2Hku6wzwvWnHAct8TmtfvviE4QXBTXtZrae2buXwjq5mRG4doF2</p>
</blockquote>

<p>but this result is not in <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a> If I import my mnemonic phrase </p>

<blockquote>
  <p>(army van defense carry jealous true garbage claim echo media make crunch)</p>
</blockquote>

<wallet><private-key><public-key><bip32-hd-wallets>
Get Master Private Key from BIP39 Seed
monkeyUser
# Get Master Private Key from BIP39 Seed

(Asked by: username_0 on 2019-01-30)

I have BIP39 Seed:

```
5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570

```

I want to get Master private Key

Then I Have to use HMAC-SHA512, I can use this [site](https://www.freeformatter.com/hmac-generator.html), which secret I have to add ? I don't have any secret, for test I choose "mnemonic", the same constant that I use to generate BIP39seed (is it correct? )

the result is:

> 9744d0d7e168f725b6cc36a73c24dfc91bd6d80bf5a6871ad2c6c0b854e4e281b74049c41d25f0b338b3fc9b053b87b95636c3c94c31f37458fe98a09a4a94c9

and I can get

```
left 256 bits  => 9744d0d7e168f725b6cc36a73c24dfc91bd6d80bf5a6871ad2c6c0b854e4e281
right 256 bits  => b74049c41d25f0b338b3fc9b053b87b95636c3c94c31f37458fe98a09a4a94c9

```

And I can Get master private key in this way?

```
PKM = bx ec-to-wif 9744d0d7e168f725b6cc36a73c24dfc91bd6d80bf5a6871ad2c6c0b854e4e281

```

> result:
> L2Hku6wzwvWnHAct8TmtfvviE4QXBTXtZrae2buXwjq5mRG4doF2

but this result is not in <https://iancoleman.io/bip39/> If I import my mnemonic phrase

> (army van defense carry jealous true garbage claim echo media make crunch)

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


---

## 2 answers

### Answer by username_2 on 2019-01-31. Score: 5 | Accepted answer

Here are the mechanics for "Mastering Bitcoin" [**Creating an HD Wallet from the Seed**](https://github.com/bitcoinbook/bitcoinbook/blob/develop/ch05.asciidoc#creating-an-hd-wallet-from-the-seed) using [**bitcoin-explorer**](https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-mnemonic-to-seed) and this Python [**HMAC**](https://pypi.org/project/hmac_cli/) command.

**Root Seed:**

`% echo "army van defense carry jealous true garbage claim echo media make crunch" | bx mnemonic-to-seed -p ""`

**`5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570`**

**Master Private Key:**

`% echo 5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570 | bx base16-decode | hmac --algorithm sha512 --key "Bitcoin seed" - | cut -c 1-64`

**`b2a0d576b828b537688b561f2cfa8dac3602d54c62bde619ad5331e6c235ee26`**

**Master Public Key:**

`% echo 5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570 | bx base16-decode | hmac --algorithm sha512 --key "Bitcoin seed" - | cut -c 1-64 | bx ec-to-public`

**`03ca72b45eede592f059b7eaf3da13eb7d8d15aa472b6f79f74820bb22ff596186`**

**Chain Code:**

`% echo 5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570 | bx base16-decode | hmac --algorithm sha512 --key "Bitcoin seed" - | cut -c 65-128`

**`b70d675323c40ec461e0a6af603b1f135fb2af9ae753eeff18922732a73b0f05`**

> **Comments:**
> **username_0**: Can I  add two secp256k1 keys together with bx ?  
> **username_2**: For cyclic ordinate “Normalization”, you will want to examine **bx** [**ec-add-secrets**](https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-add-secrets) and [**ec-multiply-secrets**](https://github.com/libbitcoin/libbitcoin-explorer/wiki/bx-ec-multiply-secrets)  
> **username_3**: What is the use of a master public key? Can I see all the the public addresses derived from that HD wallet?  
> **username_4**: Instead of all of that decoding, hashing and cutting you can just use the `bx hd-*` commands :). `hd-new`, `hd-private`, `hd-public`, `hd-to-address`, `hd-to-ec`, `hd-to-public`, `hd-to-wif`.  

---

### Answer by username_1 on 2019-01-30. Score: 2

> which secret I have to add ? I don't have any secret, for test I choose "mnemonic", the same constant that I use to generate BIP39seed (is it correct? )

No, that is incorrect. You use the key `mnemonic` when converting the BIP 39 mnemonic to a seed. You already have the seed, so you don't use the key `mnemonic`. You should instead be following the steps described in [BIP 32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#Master_key_generation).

So you need to use HMAC-SHA512 with the key `Bitcoin seed`. Furthermore, the site that you used hashes the input as a string, not as the bytes represented by the hex values. This will result in the wrong hash. You need to use a different site. I used <https://cryptii.com/pipes/hmac> and converted the key `Bitcoin seed` to it's hex representation using <https://www.asciitohex.com/>. Setting the input to be hexadecimal bytes and setting the key to be the hex form of `Bitcoin seed` results in the hash:

```
b2a0d576b828b537688b561f2cfa8dac3602d54c62bde619ad5331e6c235ee26b70d675323c40ec461e0a6af603b1f135fb2af9ae753eeff18922732a73b0f05

```

If we look at the master private key we get from your mnemonic (listed as BIP 32 root key on <https://iancoleman.io/bip39/>), we see that its private key and chaincode are the same as the above hash.


---

