<p>The mnemonic represents a BIP32 extended private key: <code>xprv9s21ZrQH143K4BbpSvRBDykoXLhwtznbp7qAfKVLw1QdJtJsmgS5rZJfSgZNtgk7e39uRNiYHbcRQnYvruqfftfG6WFmuiCspehEz1VS3YM</code></p>

<p>The function you are calling accepts a regular private key.</p>

<p>You can derive child private keys from the extended private key and use these to generate addresses.</p>

<p>It it be possible to derive the corresponding private key of either the children of this extended private key or the corresponding private key itself using the <code>toWIF</code> method in the bip32 JS library. See <a href="https://github.com/bitcoinjs/bip32/blob/master/index.js" rel="nofollow noreferrer">https://github.com/bitcoinjs/bip32/blob/master/index.js</a></p>

<p>You can see some examples of the use of BIP32 here:
<a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/a6f2cc2924df170537f0b588254178f5445d7dc8/test/integration/bip32.js" rel="nofollow noreferrer">https://github.com/bitcoinjs/bitcoinjs-lib/blob/a6f2cc2924df170537f0b588254178f5445d7dc8/test/integration/bip32.js</a></p>

CC BY-SA 4.0
2019-01-08T12:01:36.957Z
Thanks so much @Thorkil, just one last question: which line in the file you added shows a derivation to a regular private key?
timothyylim
CC BY-SA 4.0
2019-01-08T13:43:08.187Z
Can you call this?

const seed = bip39.mnemonicToSeed(mnemonic);
const node = bip32.fromSeed(seed);
const privateKey = node.toWIF();
Thorkil Værge
CC BY-SA 4.0
2019-01-09T16:12:26.263Z
that worked! Just for future reference, I used the wif node module to decode it to hex.
timothyylim
CC BY-SA 4.0
2019-01-08T11:56:21.113Z
2019-01-08T13:32:02.437Z
2019-01-08T13:32:02.437Z
Thorkil Værge
<p>I have the following test Mnemonic:</p>

<pre><code>stable primary already collect buffalo bike into robust fury cement proof agree neither blouse course
</code></pre>

<p>From this I can generate a BIP39 Wallet:
<a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a></p>

<p>From this I can get all the private keys of the derived addresses (if you scroll down to the bottom).</p>

<p>But I'm not sure what format they're in. </p>

<p>The library, bitconjs-lib does the following:</p>

<pre><code>const ONE = Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
keyPair = ECPair.fromPrivateKey(ONE)
</code></pre>

<p><a href="https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/ecpair.js#L29" rel="nofollow noreferrer">https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/ecpair.js#L29</a></p>

<p>But the private keys generated by <a href="https://iancoleman.io/bip39/" rel="nofollow noreferrer">https://iancoleman.io/bip39/</a> do not match the length required by bitcoinjs-lib</p>

<private-key><bip32-hd-wallets>
Deriving hex private key from a HD wallet
timothyylim
# Deriving hex private key from a HD wallet

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

I have the following test Mnemonic:

```
stable primary already collect buffalo bike into robust fury cement proof agree neither blouse course

```

From this I can generate a BIP39 Wallet:
<https://iancoleman.io/bip39/>

From this I can get all the private keys of the derived addresses (if you scroll down to the bottom).

But I'm not sure what format they're in.

The library, bitconjs-lib does the following:

```
const ONE = Buffer.from('0000000000000000000000000000000000000000000000000000000000000001', 'hex')
keyPair = ECPair.fromPrivateKey(ONE)

```

<https://github.com/bitcoinjs/bitcoinjs-lib/blob/master/test/ecpair.js#L29>

But the private keys generated by <https://iancoleman.io/bip39/> do not match the length required by bitcoinjs-lib

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


---

## 1 answers

### Answer by username_1 on 2019-01-08. Score: 2 | Accepted answer

The mnemonic represents a BIP32 extended private key: `xprv9s21ZrQH143K4BbpSvRBDykoXLhwtznbp7qAfKVLw1QdJtJsmgS5rZJfSgZNtgk7e39uRNiYHbcRQnYvruqfftfG6WFmuiCspehEz1VS3YM`

The function you are calling accepts a regular private key.

You can derive child private keys from the extended private key and use these to generate addresses.

It it be possible to derive the corresponding private key of either the children of this extended private key or the corresponding private key itself using the `toWIF` method in the bip32 JS library. See <https://github.com/bitcoinjs/bip32/blob/master/index.js>

You can see some examples of the use of BIP32 here:
<https://github.com/bitcoinjs/bitcoinjs-lib/blob/a6f2cc2924df170537f0b588254178f5445d7dc8/test/integration/bip32.js>

> **Comments:**
> **username_0**: Thanks so much @username_1, just one last question: which line in the file you added shows a derivation to a regular private key?  
> **username_1**: Can you call this?  const seed = bip39.mnemonicToSeed(mnemonic); const node = bip32.fromSeed(seed); const privateKey = node.toWIF();  
> **username_0**: that worked! Just for future reference, I used the wif node module to decode it to hex.  

---

