Bitcoin Forum
September 28, 2021, 02:38:09 AM *
News: Latest Bitcoin Core release: 22.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ?  (Read 3135 times)
zanza
Newbie
*
Offline Offline

Activity: 40
Merit: 0


View Profile
August 17, 2016, 03:41:03 PM
 #1

I have been trying to study up on BIP32, read the relevant documentation, but still confused on a point

http://bip32.org/

Playing around with codes on this site, I get 2 different xprv keys (the example given is just for the default password "crazy horse battery staple")

BIP32 Extended Key
xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8im bZKLYVBxFPND1pniTZ81vKfd45EHKX73

Derived Private Key
xprv9wHokC2KXdTSpEepFcu53hMDUHYfAtTaLEJEMyxBPAMf78hJg17WhL5FyeDUQH5KWmGjGgEb2j7 4gsZqgupWpPbZgP6uFmP8MYEy5BNbyET


So I am a bit confused now what the difference is between these 2 xprv keys?  I tried to input both into Electrum recovery wallet, and they both accepted, but gave different address tree structures. 

Can anyone help clear this up for me?

1632796689
Hero Member
*
Offline Offline

Posts: 1632796689

View Profile Personal Message (Offline)

Ignore
1632796689
Reply with quote  #2

1632796689
Report to moderator
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction. Advertise here.
konovalets
Sr. Member
****
Offline Offline

Activity: 248
Merit: 250


View Profile
August 17, 2016, 07:15:35 PM
 #2

Extended keys

In what follows, we will define a function that derives a number of child keys from a parent key. In order to prevent these from depending solely on the key itself, we extend both private and public keys first with an extra 256 bits of entropy. This extension, called the chain code, is identical for corresponding private and public keys, and consists of 32 bytes.

We represent an extended private key as (k, c), with k the normal private key, and c the chain code. An extended public key is represented as (K, c), with K = point(k) and c the chain code.

Each extended key has 2^31 normal child keys, and 2^31 hardened child keys. Each of these child keys has an index. The normal child keys use indices 0 through 2^31-1. The hardened child keys use indices 2^31 through 2^32-1. To ease notation for hardened key indices, a number iH represents i+2^31.

https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#Extended_keys
konovalets
Sr. Member
****
Offline Offline

Activity: 248
Merit: 250


View Profile
August 17, 2016, 07:28:03 PM
 #3

You have one master key (extended key) and can produce a lot of derived keys from it. But each derived key can be master key as well, so there is extended form for it.
zanza
Newbie
*
Offline Offline

Activity: 40
Merit: 0


View Profile
August 18, 2016, 01:48:02 AM
 #4

You have one master key (extended key) and can produce a lot of derived keys from it. But each derived key can be master key as well, so there is extended form for it.

Hello konovalets, thank you for the reply.  So, let me see if I understand correctly?  I have been studying the BIP32 page


BIP Extended Key -> many different Derived Private Key

Derived Private Key + chain code = Extended key


So, which key do I use to import into Electrum or something?

So does generation go like

Private Key -> BIP Extended key -> Child Key ?


achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 2604
Merit: 4248


Just writing some code


View Profile WWW
August 18, 2016, 02:02:10 AM
 #5

An extended private key is a format.

A derived private key is any private key that is deterministically generated from another private key.

Any private key can use the extended private key format to give wallets information about how to derive that key given the master private key that it was derived from.

So, which key do I use to import into Electrum or something?
To import a deterministic wallet into Electrum, you would use a private key in the extended private key format encoded with the base58 check encoding.

konovalets
Sr. Member
****
Offline Offline

Activity: 248
Merit: 250


View Profile
August 18, 2016, 02:25:46 PM
 #6

To import a deterministic wallet into Electrum, you would use a private key in the extended private key format encoded with the base58 check encoding.

Yep, pretty clear explanation.
zanza
Newbie
*
Offline Offline

Activity: 40
Merit: 0


View Profile
August 18, 2016, 03:07:56 PM
 #7

OK, thanks guys for all the helps.  I guess I mostly understand how BIP32 works.  One final question

Using this site as an example

http://bip32.org/


I am using "crazy horse battery staple" passphrase to generate an example BIP32

BIP32 Extended Key
xprv9s21ZrQH143K2JF8RafpqtKiTbsbaxEeUaMnNHsm5o6wCW3z8ySyH4UxFVSfZ8n7ESu7fgir8im bZKLYVBxFPND1pniTZ81vKfd45EHKX73

Inputting this into Electrum, this generates these child address
Code:
0 1LpNMg5bpLfStunETxq6BQecf5Jc5kUvf1
1 1QJ47NXJ1cf9iDK6yAEkL3wGRNbRn89VNp
0 1LpNMg5bpLfStunETxq6BQecf5Jc5kUvf1
2 13BhQDyuZv4zac8YPKpcycTPZyiRdJbYXb
1 1QJ47NXJ1cf9iDK6yAEkL3wGRNbRn89VNp
0 1LpNMg5bpLfStunETxq6BQecf5Jc5kUvf1
...

OK, so if I input the Derived Private Key into Electrum, it generates these addresses
Derived Private Key
xprv9wHokC2KXdTSpEepFcu53hMDUHYfAtTaLEJEMyxBPAMf78hJg17WhL5FyeDUQH5KWmGjGgEb2j7 4gsZqgupWpPbZgP6uFmP8MYEy5BNbyET
Code:
0 1A28RXgCaoNXRynA7rwQSrFiWwBcFCPgE7
1 12pc2Qp4U4sFnu9q6HsK8msR2GTqgkgTm7
2 1AsuEsy6AqbFkA7n8Yjb2q7zfgSwMeq8MN
0 1A28RXgCaoNXRynA7rwQSrFiWwBcFCPgE7
3 1H8UaFibaK4TzRDKR7dbYnM3vzKDim6aH9
1 12pc2Qp4U4sFnu9q6HsK8msR2GTqgkgTm7
...



So, these address are show 2 different HD address structure child tree generated. 



So, for what you guys tell me here, the BIP32 Extended Key is the true address structure to generate from (the first address list).  So what does the second Derived Private Key represent, since it seems to generate a valid address child chain?
achow101
Moderator
Legendary
*
expert
Offline Offline

Activity: 2604
Merit: 4248


Just writing some code


View Profile WWW
August 18, 2016, 03:11:30 PM
 #8

So, for what you guys tell me here, the BIP32 Extended Key is the true address structure to generate from (the first address list).  So what does the second Derived Private Key represent, since it seems to generate a valid address child chain?
The derived key is an extended key that is derived from the first extended key.

zanza
Newbie
*
Offline Offline

Activity: 40
Merit: 0


View Profile
August 18, 2016, 08:56:30 PM
 #9

So, for what you guys tell me here, the BIP32 Extended Key is the true address structure to generate from (the first address list).  So what does the second Derived Private Key represent, since it seems to generate a valid address child chain?
The derived key is an extended key that is derived from the first extended key.

OK, thanks.  I think I understand it now.  There is lots of derivation paths than can give you many different HD wallets, all from a single Extended Master Key.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!