However it think the easiest is if python generates the pontential passphrases, which you then run through
sha256sum and recode to bitcoin base58. sha256sum is from coreutils.
It is not quite that easy. After sha256 you have to do an elliptic curve multiply of the bitcoin curve's generator point by the private key to derive the public key. Then DER-encode that point, sha256 and then ripemd160 it. Then base58check-encode.
refer_2_me, I would do it all in one script and not involve OpenCL. If you're actually "close" to the passphrase, it seems like a relatively naive CPU implementation will find it quicker than the time it would take you to develop and test the OpenCL code (unless you're really interested in learning OpenCL and want to do it for fun.)
I am surprised your Python script got such poor performance. If you can post it (omitting passphrase generation) maybe somebody can optimize it.
Thanks for your reply.
What i'm doing is (roughly) the following:
import sys
import os
import hashlib, binascii
import ecdsa
secp256k1curve=ecdsa.ellipticcurve.CurveFp(115792089237316195423570985008687907853269984665640564039457584007908834671663,0,7)
secp256k1point=ecdsa.ellipticcurve.Point(secp256k1curve,0x79BE667EF9DCBBAC55A06295CE870B07029BFCDB2DCE28D959F2815B16F81798,0x483ADA7726A3C4655DA4FBFC0E1108A8FD17B448A68554199C47D08FFB10D4B8,0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141)
secp256k1=ecdsa.curves.Curve('secp256k1',secp256k1curve,secp256k1point,(1,3,132,0,10))
def gen_keys(string):
'''
Generate the private key and address for the given input string using ecdsa
Arguments:
string -- input string
Return:
private_key, addr -- private key and BTC address
'''
pk_hex = hashlib.sha256(string).hexdigest()
pk = int(pk_hex,16)
pko=ecdsa.SigningKey.from_secret_exponent(pk,secp256k1)
pubkey=binascii.hexlify(pko.get_verifying_key().to_string())
pubkey2=hashlib.sha256(binascii.unhexlify('04'+pubkey)).hexdigest()
pubkey3=hashlib.new('ripemd160',binascii.unhexlify(pubkey2)).hexdigest()
pubkey4=hashlib.sha256(binascii.unhexlify('00'+pubkey3)).hexdigest()
pubkey5=hashlib.sha256(binascii.unhexlify(pubkey4)).hexdigest()
pubkey6=pubkey3+pubkey5[:8]
pubnum=int(pubkey6,16)
pubnumlist=[]
while pubnum!=0: pubnumlist.append(pubnum%58); pubnum/=58
address=''
for l in ['123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'[x] for x in pubnumlist]:
address=l+address
return pk_hex, '1'+address
if __name__ == '__main__':
#my passphrases to try, generated in another script
wordlist = ( word.strip() for word in open(sys.argv[1]).readlines() )
for word in wordlist:
priv_key, addr = gen_keys(word)
if addr == '1...........': #my bitcoin addresss
print 'Found it!\nPrivate Key:', priv_key, '\nAddress:',addr
sys.exit()
So on a single CPU, it takes about 0.25 seconds for each pass phrase that I check (4 per second). I figure that I have a few million to test (this may be way off), so it seems like it should be worth some time.
I've profiled the code using cProfile and I found that 0.23 seconds of the execution comes from a single line:
pko=ecdsa.SigningKey.from_secret_exponent(pk,secp256k1)
The above code is heavily based on this post:
https://bt.irlbtc.com/view/84238