Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
nomachine
on 27/10/2023, 21:56:07 UTC
I think mine checks 3,000 key/s on a single core.

Code:
import sys, os, secrets, binascii, base58, time, hashlib, ecdsa
target_h160 = bytes.fromhex("20d45a6a762535700ce9e0b216e31994335db8a5")
def format_hash_rate(hash_rate):
suffixes=['','k','M','G','T','P'];magnitude=0
while hash_rate>=1000 and magnitude<len(suffixes)-1:hash_rate/=1e3;magnitude+=1
return f"{hash_rate:.2f} {suffixes[magnitude]}Hash/s"
with open('found_matches.txt', 'w') as output_file:
    while True:
            dec = secrets.SystemRandom().randrange(36893488147419103231, 73786976294838206463)
            private_key_bytes = (b'\x00' * 32)[:-len(dec.to_bytes((dec.bit_length() + 7) // 8, 'big'))] + dec.to_bytes((dec.bit_length() + 7) // 8, 'big')
            signing_key = ecdsa.SigningKey.from_string(private_key_bytes, curve=ecdsa.SECP256k1)
            h160 = hashlib.new('ripemd160', hashlib.sha256(signing_key.get_verifying_key().to_string("compressed")).digest()).digest()
            hashes_per_second=0;target_hash_count=1000000;start_time=time.time()                     
            while hashes_per_second<target_hash_count:h160.hex();hashes_per_second+=1
            end_time=time.time();elapsed_time=end_time-start_time;hashes_per_second=target_hash_count/elapsed_time         
            formatted_hash_rate=format_hash_rate(hashes_per_second)
            message = "\r[+] Hashes per second: {}".format(formatted_hash_rate);messages = []           
            messages.append(message);output = "\033[01;33m" + ''.join(messages) + "\r"           
            sys.stdout.write(output)
            if h160 in target_h160:
                match_str = f"Found match with hash {h160.hex()}. Decoded value: {dec}\n"
                print(match_str)
                output_file.write(match_str)
                break

  • Hashes per second: 5.23 MHash/s

on a single core  Grin

I have to take a break from this. Just give a false hope Undecided