WanderingPhilospher
Sr. Member
  
Offline
Activity: 1386
Merit: 269
Shooters Shoot...
|
 |
October 27, 2023, 05:04:54 PM |
|
import subprocess import time import os from decimal import Decimal import base58 import hashlib import ecdsa
# Function to clear the terminal screen def clear_terminal(): subprocess.call('clear', shell=True)
# Function to calculate the Hash 160 of a public key def calculate_public_key_hash(public_key): sha256_hash = hashlib.sha256(public_key).digest() ripemd160_hash = hashlib.new('ripemd160') ripemd160_hash.update(sha256_hash) return ripemd160_hash.digest()
# Function to convert a decimal number to a private key in hexadecimal format def decimal_to_private_key_hex(decimal_number): private_key_bytes = int(decimal_number).to_bytes(32, byteorder='big') private_key_hex = private_key_bytes.hex() private_key_hex_flipped = private_key_hex.replace('2', '3', 2) return private_key_hex, private_key_hex_flipped
# Function to check if a target Hash 160 is found def check_target_hash(public_key_hash, decimal_number, private_key_hex): if public_key_hash in target_public_key_hashes: target_hashes_found.append(public_key_hash) print(f"Target Hash 160 found: {public_key_hash.hex()}") print(f"Decimal Number: {decimal_number}") print(f"Private Key Hex: {private_key_hex}")
# Write the found Hash 160 to the file found_addresses.txt with open("found_addresses.txt", "a") as found_file: found_file.write(f"Target Hash 160 found: {public_key_hash.hex()}\n") found_file.write(f"Decimal Number: {decimal_number}\n") found_file.write(f"Private Key Hex: {private_key_hex}\n\n") found_file.flush() # Flush the buffer to ensure data is written immediately
return True return False
# List of target Hash 160 values to search for target_public_key_hashes = [ bytes.fromhex('20d45a6a762535700ce9e0b216e31994335db8a5'), bytes.fromhex('739437bb3dd6d1983e66629c5f08c70e52769371'), bytes.fromhex('e0b8a2baee1b77fc703455f39d51477451fc8cfc'), bytes.fromhex('61eb8a50c86b0584bb727dd65bed8d2400d6d5aa'), bytes.fromhex('f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8'),
]
target_hashes_found = []
# Define the lower and upper bounds for the decimal number search range lower_bound = Decimal('37000000000000000000') upper_bound = Decimal('55340232221128654832')
# List of additional hex numbers to modify the decimal number additional_hex_numbers = ['3','4','5','6','7','8', '9', 'a', 'b', 'c', 'd', 'e', 'f','10','11','12','13','14','15','16','17','18','19','1a', '1b', '1c','1d', '1e', '1f' ,'40','41','42','43','44','45','46','47','48','49','4a', '4b', '4c','4d', '4e', '4f' ,'50','51','52','53','54','55','56','57','58','59','5a', '5b', '5c','5d', '5e', '5f' ,'60','61','62','63','64','65','66','67','68','69','6a', '6b', '6c','6d', '6e', '6f' ,'70','71','72','73','74','75','76','77','78','79','7a', '7b', '7c','7d', '7e', '7f' ]
# Initialize time and iteration tracking variables start_time = time.time() total_iterations = 0
# Function to search for target Hash 160 values within a specified range def search_decimal_range(decimal_number, upper_bound): global total_iterations # Use the global variable iterations = 0 update_interval = 1 step_size = 10000000000000000 # Initial step size
while decimal_number <= upper_bound: private_key_hex, flipped_private_key_hex = decimal_to_private_key_hex(decimal_number) private_key = int(decimal_number).to_bytes(32, byteorder='big') signing_key = ecdsa.SigningKey.from_string(private_key, curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256) verifying_key = signing_key.verifying_key public_key = verifying_key.to_string("compressed") public_key_hash = calculate_public_key_hash(public_key)
if check_target_hash(public_key_hash, decimal_number, private_key_hex): return True # Stop the loop if a match is found
found_match = False
additional_hashes = [] for hex_number in additional_hex_numbers: modified_decimal_number = int(hex(int(decimal_number))[2:].replace('2', hex_number, 1), 16) modified_private_key_hex, _ = decimal_to_private_key_hex(modified_decimal_number) modified_private_key = int(modified_decimal_number).to_bytes(32, byteorder='big') modified_signing_key = ecdsa.SigningKey.from_string(modified_private_key, curve=ecdsa.SECP256k1, hashfunc=hashlib.sha256) modified_verifying_key = modified_signing_key.verifying_key modified_public_key = modified_verifying_key.to_string("compressed") modified_hash = calculate_public_key_hash(modified_public_key) additional_hashes.append(modified_hash)
if check_target_hash(modified_hash, modified_decimal_number, modified_private_key_hex): found_match = True break
if found_match: return True
if len(target_hashes_found) == len(target_public_key_hashes): return True
if iterations % update_interval == 0: elapsed_time = time.time() - start_time iterations_per_second = iterations elapsed_time print(f"Reached {iterations} iterations.") print(f"Elapsed Time: {elapsed_time:.2f} seconds") print(f"Iterations per Second: {iterations_per_second:.2f}") print(f"Decimal Number: {decimal_number}") print(f"Private Key Hex: {private_key_hex}") print(f"Target Hash 160: {public_key_hash.hex()}") print(f"Target Decimal Number: {decimal_number}") if target_hashes_found: print_hashes_side_by_side(target_hashes_found[-1], decimal_number, private_key_hex, additional_hashes) print("\n")
decimal_number += step_size # Increase the decimal number by the current step size iterations += 1
# Adjust the step size dynamically based on the search space if iterations % 1000 == 0: step_size *= 2 # Double the step size every 1 million iterations
# Function to print the target Hash 160 and additional Hash 160 values side by side def print_hashes_side_by_side(target_hash, decimal_number, private_key_hex, additional_hashes): print(f"Decimal Number: {decimal_number}") print(f"Target Hash 160: {target_hash.hex()}") print(f"Private Key Hex: {private_key_hex}") print(f"Target Decimal Number: {decimal_number}") for i, hash in enumerate(additional_hashes): print(f" ({additional_hex_numbers[i]}): {hash.hex()}") print("\n")
# Function to continuously search for target Hash 160 values in the specified range def continuous_search(lower_bound, upper_bound): global total_iterations, start_time # Use the global variables current_decimal = lower_bound
while True: elapsed_time = time.time() - start_time total_iterations += 1
if search_decimal_range(current_decimal, upper_bound): print("All target Hash 160 values found. Restarting search...") time.sleep(0) # Optional: Add a delay before restarting the search current_decimal = lower_bound # Reset the current_decimal to the lower_bound else: current_decimal += 1484585542367 # Increment by 1
# Start the continuous search while True: continuous_search(lower_bound, upper_bound)
# Add sound notification when the script completes print("Glass sound (indicating script completion)") subprocess.run(["afplay", "/System/Library/Sounds/glass.aiff"])
hows this one? ready for some fun?  THIS ONE SCRIPT IS SEARCHING FOR PUZZLES 66 -71 from a single hex which is 20000000000000000...2ffffffffffffffff. I can also adjust the step size. MoreForUs, what speed are you showing with your program? When I ran it a few times, it seems very slow, and the text is somewhat confusing. What is considered an iteration, one key checked? Also: Reached 12 iterations. Elapsed Time: 0.53 seconds Iterations per Second: 22.43 Decimal Number: 37120000000000000000 Private Key Hex: 0000000000000000000000000000000000000000000000020324bb546e800000 Target Hash 160: 09d19b3025828bca263e80cf2b5da1e08e938ca3 Target Decimal Number: 37120000000000000000
Reached 170 iterations. Elapsed Time: 14.13 seconds Iterations per Second: 12.03 Decimal Number: 38700000000000000000 Private Key Hex: 000000000000000000000000000000000000000000000002191204f5679e0000 Target Hash 160: 846874d169173600744fe5c1cdf9f2915cdb25ae Target Decimal Number: 38700000000000000000
The Target Hash 160 verbiage is misleading, as it's not the target 160, it's the actual 160 of the current Private Key Hex being checked. Same for Target Dec Num, if we knew the target, we wouldn't be talking lol. Anywho, I am trying to compare it's speed to my old slow python script; I think mine checks 3,000 key/s on a single core.
|