Score:1

Question about Harden and Normal Key derivation

vn flag

I am reading about Hardened and Normal child key in chapter 5 of the book "Mastering Bitcoin" by Andreas, along with this detailed thread and BIP-32. Here are some of my understanding about these two procedures:

k: private key // K: public key // i index // c chain code // H HMAC hashing result // Hleft the first 32 bits of the hash result. // n order of Elliptic Curve. // G starting point of Elliptic Curve

Normal Key Derivation

Case 1: parPrivkey -> childPrivkey (and from that, childPubkey)

H = HMAC(cpar, Kpar || ichild) 
=> kchild = (kpar + Hleft) mod n
=> Kchild = G*kchild = G*[ (kpar + Hleft) mod n)]

Case 2: parPubkey -> childPubkey

H = HMAC(cpar, Kpar || ichild)
=> Kchild = G*Hleft + Kpar

Hardened Key Derivation`

Case 3: parPrivkey -> childPrivkey (and from that childPubkey)

H = HMAC(cpar, kpar || ichild)
=> kchild = (kpar + Hleft) mod n
=> Kchild = G*kchild = G*[ (kpar + Hleft) mod n]

Given these 3 methods, I am somewhat confused:

  1. the difference in the generation equation between cases 1 and 2 is quite subtle, such that we only need to multiply kchild = (kpar + Hleft) mod n by G to get that in case 2. Nevertheless, since there is a factor mod n at the end, I couldn't tell whether Kchild of Case 1 will relate to that of Case 2. If it does not, then what's the point of generating just public key without being able to spend the funds sent to to it?
  1. This is not related to the above question, but rather about the generation of the master private key: I have read that after getting the Root seed, the seed was put into HMAC-SHA512 function to get a 512-bit hash, the first 32 bytes of which serves as master private key. So my question is since HMAC function takes in 2 input which are key and text, what is the "key" in this case? If there is no "key", then why not using just SHA-512 hashing function?

Thank you very much in advance.

Score:1
gb flag

Nevertheless, since there is a factor mod n at the end, I couldn't tell wether Kchild of Case 1 will relate to that of Case 2.

Yes, the child private key from case 1 is the secret key for the public key derived in case 2. $n$ is the order of the generator point $G$ so it doesn't affect the correctness of the secret key.

since HMAC function takes in 2 input which are key and text, what is the "key" in this case? If there is no "key", then why not using just SHA-512 hashing function?

In the specific case of the seed, the key is "Bitcoin seed", and is used as a kind of domain separation - a unique string just for this purpose.

In the other uses of HMAC in BIP 32, the key is the "chain code", while the text/data is as you wrote above in your question. This chain code ensures child keys are not solely derived from the parent keys, but rather also use some extra entropy which must be known in order to derive the children. So you can choose to give out the chain code if you want people to be able to derive child keys, or keep it secret so they cannot.

John Pham avatar
vn flag
For your second question's answer, isn't the *bitcoin seed* is used as the "text" paramater for the HMAC function? Or the format of the hash function for master private key is HMAC(seed, seed) ?
meshcollider avatar
gb flag
@JohnPham the key is literally the string "Bitcoin seed", not the seed itself. It is that fixed string.
John Pham avatar
vn flag
Oh okey I got it now, did not expect to be that simple :)) Thank you very much. Btw I'm gladly surprised to see you again from one of my [previous question threads](https://crypto.stackexchange.com/questions/98362/elliptic-curve-how-to-calculate-y-value)
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.