<p>Generally the private key and chain code (these 2 parts make up the extended private key) are generated at the same time from a seed. The seed can be either a randomly generated number, or derived from a 12 word mnemonic like BIP 39 details. Once you have a seed, <a href="https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki" rel="nofollow noreferrer">BIP 32</a> explains:</p>

<blockquote>
  <p>Calculate I = HMAC-SHA512(Key = "Bitcoin seed", Data = yourSeed)
  Split I into two 32-byte sequences, IL and IR.
  Use parse256(IL) as master secret key, and IR as master chain code.</p>
</blockquote>

<p>So basically you take the 512 bit hash of the seed, and split it into two 256 bit halves, one of which is the private key and the other is the chain code. And from the private key, you can obtain the public key.</p>

CC BY-SA 3.0
2017-08-19T23:31:38.787Z
2017-08-19T23:31:38.787Z
meshcollider
<p>As far as I understand, when I want to create an HD Wallet, do I need a private key that is derived into an extended public key?</p>

<p>So, my question is, if I am coding a portfolio of bitcoin in java, how can I generate this public extended key from a private key (I assume that the private key is like a private password right?)?</p>

<p>Thanks for your help,</p>

CC BY-SA 3.0
2017-08-19T18:33:35.693Z
maybe this helps to get it sorted: http://chimera.labs.oreilly.com/books/1234000001802/ch04.html#hd_wallets and you may want to check https://bitcoin.stackexchange.com/questions/tagged/bip32 and https://bitcoin.stackexchange.com/questions/tagged/bip32+hd-wallet. Let us know, if you are still missing something :-)
pebwindkraft
<private-key><public-key><bip32-hd-wallets><java>
Wallet: how to generate public extended key?
Aleyango
# Wallet: how to generate public extended key?

(Asked by: username_0 on 2017-08-19)

As far as I understand, when I want to create an HD Wallet, do I need a private key that is derived into an extended public key?

So, my question is, if I am coding a portfolio of bitcoin in java, how can I generate this public extended key from a private key (I assume that the private key is like a private password right?)?

Thanks for your help,

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

> **Comments:**
> **username_1**: maybe this helps to get it sorted: http://chimera.labs.oreilly.com/books/1234000001802/ch04.html#hd_wallets and you may want to check https://bitcoin.stackexchange.com/questions/tagged/bip32 and https://bitcoin.stackexchange.com/questions/tagged/bip32+hd-wallet. Let us know, if you are still missing something :-)  

---

## 1 answers

### Answer by username_2 on 2017-08-19. Score: 0 | Accepted answer

Generally the private key and chain code (these 2 parts make up the extended private key) are generated at the same time from a seed. The seed can be either a randomly generated number, or derived from a 12 word mnemonic like BIP 39 details. Once you have a seed, [BIP 32](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki) explains:

> Calculate I = HMAC-SHA512(Key = "Bitcoin seed", Data = yourSeed)
> Split I into two 32-byte sequences, IL and IR.
> Use parse256(IL) as master secret key, and IR as master chain code.

So basically you take the 512 bit hash of the seed, and split it into two 256 bit halves, one of which is the private key and the other is the chain code. And from the private key, you can obtain the public key.


---

