Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/355.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 使用Scrypt和PBKDF2生成比特币钱包_Python_Cryptography_Bitcoin_Pbkdf2_Scrypt - Fatal编程技术网

Python 使用Scrypt和PBKDF2生成比特币钱包

Python 使用Scrypt和PBKDF2生成比特币钱包,python,cryptography,bitcoin,pbkdf2,scrypt,Python,Cryptography,Bitcoin,Pbkdf2,Scrypt,我正在尝试实现一个脚本,它使用Scrypt和PBKDF2根据以下公式生成比特币地址: 为此,我用Python语言创建了一个脚本,该脚本甚至正在生成地址,但我认为有问题,因为生成的地址不适用于适当的条目。预计将设置密码短语“ER8FT+HFjk0”和salt“7DpniYifN6c”,输出地址为“1J32CmwScqhwnNQ77cKv9q41JGwoZe2JYQ”。我的脚本将地址“13UYidJ8HbHRZ9hTFgHQxWmq2LNyzeUxKV”返回给这些条目 import pyscry

我正在尝试实现一个脚本,它使用Scrypt和PBKDF2根据以下公式生成比特币地址:

为此,我用Python语言创建了一个脚本,该脚本甚至正在生成地址,但我认为有问题,因为生成的地址不适用于适当的条目。预计将设置密码短语“ER8FT+HFjk0”和salt“7DpniYifN6c”,输出地址为“1J32CmwScqhwnNQ77cKv9q41JGwoZe2JYQ”。我的脚本将地址“13UYidJ8HbHRZ9hTFgHQxWmq2LNyzeUxKV”返回给这些条目

 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"]
注意:要使脚本正常工作,您需要安装一些库:

 pip install pyscrypt passlib coinkit

如果你能帮助我,我将不胜感激。谢谢。

您没有正确执行公式。
0x1
0x2
发生了什么?我很确定
|0x1
意味着需要在数据中附加一个
1
字节,但您应该对此进行检查(这可能意味着应该附加一个
1
位)。
symbol是异或运算符,用Python编写为
^
。您没有正确实现该公式。
0x1
0x2
发生了什么?我很确定
|0x1
意味着需要在数据中附加一个
1
字节,但您应该对此进行检查(这可能意味着应该附加一个
1
位)。
symbol是异或运算符,用Python编写为
^