Post
Topic
Board Development & Technical Discussion
Re: PBKDF2 questions
by
webtricks
on 31/03/2021, 14:35:42 UTC
~~

Didn't know this website thank for sharing. Do you know what format are MESSAGE and SALT? I thought parameters must be in binary but inside github :

Code:
export function Pbkdf2HmacSha512(password: Uint8Array, salt: Uint8Array, count: number, length: number): Uint8Array {
  const hmac = new HmacSha512(password);

  return pbkdf2core(hmac, salt, length, count);
}

As you can see that the function has defined the type of `password` and `salt` parameters as Uint8Array. Uint8Array is a handy way to store and work with bytes in JS (and TS).

In Bitcoin, message and salt are provided as ASCII characters which are then converted in Binary during PBKDF2 function. These values are then used as parameters in pseudorandom function which is iterated c number of times.

The above library is first converting ASCII characters into hexadecimal and then storing each byte as 8-bit unsigned integer in Uint8Array.