We can use xpub (extended public key) if we want to generate a new public key (and further the address) on some insecure website for each new order without knowing the private key. We'll do this by using the parent's public key and the parent's chain code from the parent's extended public key, and incrementing the index for each new child key. The problem is that by discovering the private key of one child using the formula parentPrivateKey = childPrivateKey - L256bits % n
, we can discover the parent's private key, and thus the private keys for all children in that branch.
So with a non-hardened derivative function, we have:
- (a) the possibility of deriving the public keys of children without knowing the private key of the parent
- (a) risk of theft of all funds by knowing the private key of one child
Hence the need for hardened derivation. It works in such a way that the child keys are derived using the private key instead of the public key. Thus, leaking the private key of one child will make it impossible to discover the private key of the parent and the private key of the other children. But also, this type of implementation makes it impossible to obtain the children's public keys without knowing the parent's private key.
So with the hardened derivative function we have:
- (b) impossibility of deriving children's public keys without the parents private key
- (b) there is no risk of theft of all assets by knowing one child's private key
My question is why do we have a hardened derivation when we can achieve the same effect (1 (b) and 2 (b) above) using an non-hardened derivation with a secret chain code. This will give us:
- impossibility of deriving children's public keys without the parent's private key; since the parent's chain code is required for that, and the chain code will be kept secret along with the parent's private key
- there is no risk of theft of all funds knowing the private key of one child; since the parent's chain code is secret, it will not be possible to make L256 bits from the parent's public key + parent's chain code + index
What's the point of a hardened key derivation when we can achieve the same effects using a non-hardened derivation while keeping the parent's chain code secret?