# HD wallets with an exposed child private key

HD wallets as described here are built based on a master seed and a master public key as follows:

``````PK.b = PK.a + sG
SK.b = SK.a + s
``````
1. I just got a little confused about this. Is `s` the mnemonic seed that user knows? which generates the private keys.
2. Secondly a service provider only needs to know `sG` to calculate the user's next address. Am I right?
3. And lastly more importantly I am just wondering whether it is possible to calculate the master private key (seed) if an attacker or service provider gets one child's private key address?
• The link you give doesn't define the notation PK.a and so on. Mar 9, 2015 at 15:14
• @NateEldredge precisely you can look at this link Mar 11, 2015 at 3:57
• @abeikverdi I don't see that notation on the first page of the thread you link, and I don't see it in a search of the forums. Mar 14, 2015 at 4:15
• @NickODell PK.a refers to the public key of a and SK.a refers to the private key of a. G is the generator point and s I suppose is the secret that is used to generate next keys. In HD wallets as you know we can generate new key pairs by adding the private key with a secret s. Anyone without knowing your private key by knowing a "master public key" can generate your next public key. Does this "master public key" refer to sG here? Mar 24, 2015 at 8:34
• @abeikverdi What you're saying doesn't describe BIP32. Are you asking about BIP32, or some other HD wallet system? Mar 24, 2015 at 9:15

I don't know where you found this formula, here is the code to derivate a childkey, the BIP is here, it does not look like your formula, but I'll try to respond to some of your questions.

``````I just got a little confused about this. Is s the mnemonic seed that user knows? which generates the private keys.
``````

A mnemonic seed is just a sentence that permit you to get the master key with (optionally) a password. A master key is the real important piece of information, a mnemonic is only a way to generate one that can be write it down in words.

``````Secondly a service provider only needs to know sG to calculate the user's next address. Am I right?
``````

Your formula does not look like what is in the BIP, so I can't really comment on that.

``````And lastly more importantly I am just wondering whether it is possible to calculate the master private key (seed) if an attacker or service provider gets one child's private key address?
``````

Yes, if all the children in the path to the leaked private are non-hardened keys AND the root HD PubKey leaked. I explain that P 35 of my book.

``````A non-hardened key can “climb” the hierarchy.
Non-hardened key should only be used for categorizing accounts that belongs to a single control.
``````
• Thanks for your answer. I know what a mnemonic seed is. I'm not referring to the exact implementation of BIP32. Whats important for me here is that how we can generate the next public key without knowing the private key of the next public key. I am referring to this post"bitcointalk.org/index.php?topic=19137.msg239768#msg239768" by gmaxwell who proposed the idea of HD wallets. Thats what the formula says which I mentioned. Is that incorrect? Apr 9, 2015 at 5:41
• I've never heard about hardened keys. How can you harden it to stop people from climbing back to the root? I definitely love to read your book, but can you explain that to me in summary? Apr 9, 2015 at 5:45
• You can take a look at the implementation. The condition "(nChild >> 31) == 0" means "is non hardened". You can see that when it is non hardened, the child key is derived from the public key, while if it hardened, it is derived from private key. This means that if it is not hardened, you can go back in the hierarchy if you know the parent public key. As I am doing here The post on bitcointalk is outdated compared to the bip. Apr 9, 2015 at 14:42
• @NicolasDorier Actually, you didn't explain it in the book. You just stated the fact without any explanation. :-)
– woky
Apr 20, 2017 at 12:42