routman / brainwallet.io

Deterministic Bitcoin and Litecoin Address Generator
https://brainwallet.io
MIT License
92 stars 34 forks source link

is brainwallet.io not scrypt hash standard ? #2

Closed aknik closed 8 years ago

aknik commented 8 years ago

I just check and the result from brainwallet.io is different from http://kclnn.github.io/js-scrypt-async/test_scrypt_browser.html I check it in python and nodejs with a standard scrypt implementation and the result is different from brainwallet , too

The process is as follows (pseudocode): key = scrypt(passphrase, salt, N=218, r=8, p=1, dkLen=32) keypair = generate_bitcoin_keypair(sha256(key))

So, is brainwallet.io not scrypt hash standard ?

routman commented 8 years ago

Brainwallet.io uses the scrypt standard. I just double-checked myself, and got matching results.

I used the link you provided above, entered "hello" as the passphrase, "world" as the salt, N=262144, r=8, p=1, and # bytes = 32. The result was: 1752aa0001d505168a308bac976ee2c0e94e7ca8235c6de404e6428eba946796

I did the same thing in brainwallet.io, and the result was identical. If you want to see for yourself, download the HTML, then insert the following directly below line 1414:

alert(result);

You should see the same scrypt result generated by the github link above.

aknik commented 8 years ago

You are right. The 'problem' is that brainwallet.io uses the result as passphrase (sha256)for generating the private key not as the private key itself (or secret exponent). My fault. I'm sorry.

Thanks for your fast reply. Best regards.

routman commented 8 years ago

No worries!

There's actually a very good reason why I am also feeding it through a round of SHA256. If brainwallet.io were to ever disappear, and you don't have a copy of the website, you could still recover your keys using the following method:

  1. Go to http://kclnn.github.io/js-scrypt-async/test_scrypt_browser.html to generate a scrypt key.
  2. Go to https://bitaddress.org and paste that key into the brainwallet generator.

You will arrive at the same keys.