Title: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: zanza on August 17, 2016, 03:41:03 PM 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? Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: konovalets on August 17, 2016, 07:15:35 PM 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 Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: konovalets on August 17, 2016, 07:28:03 PM 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.
Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: zanza on August 18, 2016, 01:48:02 AM 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 ? Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: achow101 on August 18, 2016, 02:02:10 AM 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.Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: konovalets on August 18, 2016, 02:25:46 PM 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. Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: zanza on August 18, 2016, 03:07:56 PM 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 OK, so if I input the Derived Private Key into Electrum, it generates these addresses Derived Private Key xprv9wHokC2KXdTSpEepFcu53hMDUHYfAtTaLEJEMyxBPAMf78hJg17WhL5FyeDUQH5KWmGjGgEb2j7 4gsZqgupWpPbZgP6uFmP8MYEy5BNbyET Code: 0 1A28RXgCaoNXRynA7rwQSrFiWwBcFCPgE7 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? Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: achow101 on August 18, 2016, 03:11:30 PM 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.Title: Re: [BIP32] Difference between BIP32 Extended Key and Derived Private Key ? Post by: zanza on August 18, 2016, 08:56:30 PM 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. |