hash – What is the implementation of PBKDF2 in bitcoin?


I’m trying to understand how bitcoin works by writing my own code in C++. Currently I’m struggling to correctly implement PBKDF2 function. I’ve tried so many sources of information, like:

  1. PBKDF2 in Golang
  2. NIST page 7
  3. Ian’s fantastic tool
  4. Another tool
  5. Excellent guide

and many others. Some of them as a source of code, some for checking computational results.

From 5. I understand that SALT parameter of PBKDF2 has to be “mnemonic” string. According to 1. and 2. I have to concatenate SALT with an 4 byte representation of an integer 1 (bitcoin does not require 2, 3, … ). Is it true? Do I have to concatenate SALT with “0001” as a simplest SALT input or “mnemonic” is enough??? What is the correct padding of mnemonic sentence string? Is it required to keep spaces between words or not? From what I already know HMAC-SHA512 message padding starts with SALT (128 bytes block) followed by mnemonic sentence.
I believe that I’ve tried every combination of parameters and computation approaches (desperate :)). And I also believe that there is some kind of trick. So far I’ve seen tricks almost in every part of being said obvious algorithms.

Please help.

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top