<p>You simply cannot. The HD seed is used to derive the master private key, not the other way around. This derivation uses a hash function so it only works in one direction: HD seed to master private key. Given the master private key, you cannot get the HD seed used to produce it.</p>

<p>BIP 39 mnemonics are used to create a HD seed which is then used to create the master private key. However BIP 39 specifies that the HD seed be created using SHA512 (within PBKDF2) so it will always output a 512 bit seed. But Bitcoin Core cannot take 512 bit seeds, so you cannot use a BIP 39 mnemonic with Bitcoin Core at all.</p>

CC BY-SA 4.0
2019-07-15T03:32:19.627Z
2019-07-15T03:32:19.627Z
Ava Chow
<p>I'm trying to use a mnemonic seed to generate a bitcoin-core wallet. I know core does not support bip39, but it does support bip32 and <a href="https://bitcoincore.org/en/doc/0.18.0/rpc/wallet/sethdseed/" rel="nofollow noreferrer">sethdseed</a> should make it possible to use the seed generated by a given mnemonic.</p>

<p>What I'm trying to do is to generate a seed using <a href="https://github.com/iancoleman/bip39" rel="nofollow noreferrer">https://github.com/iancoleman/bip39</a> and use that xprv to feed sethdseed on an empty wallet created on bitcoin core.</p>

<p>The main problem I'm facing is that the format required by the bitcoin core wallet is not available, and I'm not being able to generate it on any way:</p>

<p>I've just created a new wallet just for testing and make a dump, it reads something like:</p>

<pre><code># extended private masterkey: xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g

L5613pTNa7wks3DVt9HrPYDR1aBpMHn3qpxBLfQyDR4kKgaBrNRS 2019-07-14T21:57:10Z hdseed=1 # addr=32AoHsZ6AvTPxiqkACTMbMcdPhD4Xye1nM
KyAP4Jf5APLei25PbfeohPWaRNmCj2yQjwWtreqM4ixXJR23Dxo7 2019-07-14T21:57:11Z reserve=1 # addr=36DxZaj6JEXgSSdTtsN6yEdULgGrfc5A5W hdkeypath=m/0'/0'/9'
...
</code></pre>

<p>So it says that the masterkey given translate on the given hdseed</p>

<pre><code>xprv = xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g
should translate in some way to:
hdseed = L5613pTNa7wks3DVt9HrPYDR1aBpMHn3qpxBLfQyDR4kKgaBrNRS
</code></pre>

<p>But I could not found any way to get from one to the other.</p>

<p>It seems that <a href="https://github.com/iancoleman/bip39/issues/326" rel="nofollow noreferrer">there is already an isssue</a> on bip39, about this, without results.</p>

<p>I've tested using <code>bitcoinjs-lib</code> with the following code without luck:</p>



<pre><code>const bip32 = require('bip32')
const bitcoin = require('bitcoinjs-lib')
const xpriv = 'xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g'

const node = bip32.fromBase58(xpriv, bitcoin.networks.bitcoin)

console.log(node.toWIF())
</code></pre>

<p>But it does generate 'L1UsWzEdexKrXmNaM8b4dyv4TsMHouVFgKhFANuhomHJjNbniWdx'.</p>

<bip32-hd-wallets><wallet-import-format>
Bip32 bitcoin core wallet `hdseed` format from xprv master key
eloyesp
# Bip32 bitcoin core wallet `hdseed` format from xprv master key

(Asked by: username_0 on 2019-07-15)

I'm trying to use a mnemonic seed to generate a bitcoin-core wallet. I know core does not support bip39, but it does support bip32 and [sethdseed](https://bitcoincore.org/en/doc/0.18.0/rpc/wallet/sethdseed/) should make it possible to use the seed generated by a given mnemonic.

What I'm trying to do is to generate a seed using <https://github.com/iancoleman/bip39> and use that xprv to feed sethdseed on an empty wallet created on bitcoin core.

The main problem I'm facing is that the format required by the bitcoin core wallet is not available, and I'm not being able to generate it on any way:

I've just created a new wallet just for testing and make a dump, it reads something like:

```
# extended private masterkey: xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g

L5613pTNa7wks3DVt9HrPYDR1aBpMHn3qpxBLfQyDR4kKgaBrNRS 2019-07-14T21:57:10Z hdseed=1 # addr=32AoHsZ6AvTPxiqkACTMbMcdPhD4Xye1nM
KyAP4Jf5APLei25PbfeohPWaRNmCj2yQjwWtreqM4ixXJR23Dxo7 2019-07-14T21:57:11Z reserve=1 # addr=36DxZaj6JEXgSSdTtsN6yEdULgGrfc5A5W hdkeypath=m/0'/0'/9'
...

```

So it says that the masterkey given translate on the given hdseed

```
xprv = xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g
should translate in some way to:
hdseed = L5613pTNa7wks3DVt9HrPYDR1aBpMHn3qpxBLfQyDR4kKgaBrNRS

```

But I could not found any way to get from one to the other.

It seems that [there is already an isssue](https://github.com/iancoleman/bip39/issues/326) on bip39, about this, without results.

I've tested using `bitcoinjs-lib` with the following code without luck:

```
const bip32 = require('bip32')
const bitcoin = require('bitcoinjs-lib')
const xpriv = 'xprv9s21ZrQH143K3ndNedb7hus3kpzuUyAafU9zvKxgqgveg4623gViHrSrkiaweK2WfNNbdANyEa6D9GceWtiyWHPtSdyUCpVweg8A6wdqG7g'

const node = bip32.fromBase58(xpriv, bitcoin.networks.bitcoin)

console.log(node.toWIF())

```

But it does generate 'L1UsWzEdexKrXmNaM8b4dyv4TsMHouVFgKhFANuhomHJjNbniWdx'.

**Tags:** bip32-hd-wallets, wallet-import-format


---

## 1 answers

### Answer by username_1 on 2019-07-15. Score: 4

You simply cannot. The HD seed is used to derive the master private key, not the other way around. This derivation uses a hash function so it only works in one direction: HD seed to master private key. Given the master private key, you cannot get the HD seed used to produce it.

BIP 39 mnemonics are used to create a HD seed which is then used to create the master private key. However BIP 39 specifies that the HD seed be created using SHA512 (within PBKDF2) so it will always output a 512 bit seed. But Bitcoin Core cannot take 512 bit seeds, so you cannot use a BIP 39 mnemonic with Bitcoin Core at all.


---

