Is there a way to speed up my Python code?
import scrypt
import binascii
from passlib.utils.pbkdf2 import get_prf, pbkdf2
from coinkit import BitcoinKeypair
def getWallet(phrase, saltPhrase):
s1 = scrypt.hash(password=phrase+'\x01', salt=saltPhrase+'\x01', N=1<<18, r=8, p=1, buflen=32)
s2 = pbkdf2(phrase+'\x02', saltPhrase+'\x02', 1<<16, keylen=32, prf='hmac-sha256')
key = ''.join(chr(ord(a) ^ ord(b)) for a,b in zip(s1,s2))
key_hex = binascii.hexlify(key)
newWallet = BitcoinKeypair(key_hex)
return {"walletAddress":newWallet.address(), "walletWif":newWallet.wif_pk()}
myWallet = getWallet("ER8FT+HFjk0", "[email protected]")
print "Address: "+myWallet["walletAddress"]+"\nWif: "+myWallet["walletWif"]
To try it you need to install these libraries:
pip install scrypt passlib coinkit
This program generates a Bitcoin Address and the Wif from a phrase, but the problem is that it generates the Output in about 1 second, and that's too long. So i'm looking for a way to speed it up, and if there aren't any solutions, perhaps I could use another programming language?
Thank you.