From what I understand, the wallet seed is created by inputting into PBKDF2 (using HMAC-SHA512 of which 2048 rounds are applied) a bunch of mnemonic code words and an optional salt (defaulted to "mnemonic"). This generates a 512 bit-seed that is completely impractical to brute-force. This is a picture of the process that I am referring to taken from Mastering Bitcoin. Why, then, is it again hashed using HMAC-SHA512, besides for creating 512 bits of output (in the case where it originally might have been 128 or 256)? Why not just use a SHA512 hash alone (assuming the reason is just to create 512 bits)? What is the point of the HMAC here? Length-extension attacks should have been avoided from the previous iterations during PBKDF2, no?

1 Answer 1


It is because the root seed may not be 512 bits, it could be 128 bits or 256 bits for example as seen in the picture you linked. Thus the final SHA-512 is applied to the seed so that no matter what the seed is, 512 bits will always be generated.

The seed generation described in BIP 39 is independent of the seed -> extended private key step in BIP 32. I expect BIP 32 uses HMAC-SHA-512 instead of just SHA-512 because it makes no assumptions about how the seed was generated, and wants to ensure that the extended private key is uniquely generated for BIP 32 use rather than just using any old SHA-512 hash that could have come from elsewhere.

  • 1
    But why HMAC-SHA-512 as opposed to a regular SHA-512 hash? Was this just arbitrary since it was used before?
    – Leeren
    Commented Oct 19, 2017 at 8:36
  • Ah sorry I misread your question. I've updated my answer :) Commented Oct 19, 2017 at 9:32
  • Can you explain why HMAC-SHA-512 makes no assumptions on how the seed was generated but SHA does?
    – Leeren
    Commented Oct 19, 2017 at 15:53
  • Simply mean we want a key generated from the seed specifically for this purpose, rather than any old SHA-512 hash Commented Oct 19, 2017 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.