Get Master Private Key from BIP39 Seed

0

I have BIP39 Seed:

5b56c417303faa3fcba7e57400e120a0ca83ec5a4fc9ffba757fbe63fbd77a89a1a3be4c67196f57c39a88b76373733891bfaba16ed27a813ceed498804c0570

I want to get Master private Key

Then I Have to use HMAC-SHA512, I can use this site, 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)

monkeyUser

Posted 2019-01-30T15:27:22.063

Reputation: 245

Answers

2

Here are the mechanics for "Mastering Bitcoin" Creating an HD Wallet from the Seed using bitcoin-explorer and this Python HMAC 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

skaht

Posted 2019-01-30T15:27:22.063

Reputation: 2 588

Can I add two secp256k1 keys together with bx ?monkeyUser 2019-01-31T00:56:22.427

1

For cyclic ordinate “Normalization”, you will want to examine bx ec-add-secrets and ec-multiply-secrets

skaht 2019-01-31T01:18:31.760

1

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.

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.

Andrew Chow

Posted 2019-01-30T15:27:22.063

Reputation: 40 910