1

I'm trying to implement a script that uses the Scrypt and PBKDF2 to generate bitcoin addresses according to this formula:

Image link to the formula

For this, I created a script in Python language, which even is generating the addresses, but I believe there is something wrong, since the generated addresses are not expected for the appropriate entries. It is expected to set the passphrase "ER8FT+HFjk0" and the salt "7DpniYifN6c", the output is the address "1J32CmwScqhwnNQ77cKv9q41JGwoZe2JYQ". My script is returning the address "13UYidJ8HbHRZ9hTFgHQxWmq2LNyzeUxKV" to these entries.

 import pyscrypt
 from passlib.utils.pbkdf2 import get_prf, pbkdf2
 from coinkit import BitcoinKeypair

 def getWallet(phrase, saltPhrase):
     s1 = pyscrypt.hash(password=phrase, salt=saltPhrase, N=16, r=8, p=1, dkLen=32)
     s2 = pbkdf2(phrase, saltPhrase, 1, keylen=32, prf='hmac-sha256')

     newWallet = BitcoinKeypair.from_passphrase(s1+s2)
     return {"walletAddress":newWallet.address(), "walletWif":newWallet.wif_pk()}

 myWallet = getWallet("ER8FT+HFjk0", "7DpniYifN6c")
 print "Address: "+myWallet["walletAddress"]+"\nWif: "+myWallet["walletWif"]

Note: For the script to work you need to install some libraries:

 pip install pyscrypt passlib coinkit

I'll be grateful if you can help me. Thank you.

PM 2Ring
  • 54,345
  • 6
  • 82
  • 182
  • You are not implementing the formula correctly. What happened to the `0x1` and `0x2`? I'm pretty sure that `||0x1` means that you need to append a `1` byte to the data, but you should check that (it _could_ mean that you're supposed to append a single `1` bit). The `⊕` symbol is the exclusive-OR operator, which is written in Python as `^`. – PM 2Ring Oct 10 '16 at 05:55

0 Answers0