import SECP256k1
import Point
import sha256
import Int
import ripemd160
import boost.multiprecision.cpp_int as cpp_int
import gmpy2 as mpz
import math
import time
import threading
import os
START_VALUE = 576565752303423488
END_VALUE = 900000000000000000
INCREMENT = 1
# Define a range of factors
MIN_FACTOR = 64.0
MAX_FACTOR = 1028.0
FACTOR_INCREMENT = 1.00
currentValue = mpz.mpz(START_VALUE)
totalKeys = 0
printMutex = threading.Lock()
resultMutex = threading.Lock()
ripemd160Hashes = []
startTime = None
matchFound = False
currentHexPrivateKey = ""
def loadRIPEMD160Hashes():
with open("wallets.txt", "r") as file:
for line in file:
hexHash = line.strip()
if len(hexHash) != 40:
print(f"Invalid RIPEMD160 hash length: {len(hexHash)}")
continue
hash = bytearray.fromhex(hexHash)
ripemd160Hashes.append(hash)
print(f"Loaded {len(ripemd160Hashes)} RIPEMD160 hashes from file.")
def hexBytesToHexString(bytes):
return "".join([format(b, "02x") for b in bytes])
def hasMinimumMatchingCharacters(hash):
for loadedHash in ripemd160Hashes:
isMatch = True
for j in range(19): # Loop through the first 5 bytes (40 bits)
if hash[j] != loadedHash[j]:
isMatch = False
break # If any character doesn't match, stop checking
if isMatch:
return True
return False
def printProgress():
global startTime
startTime = time.time()
while not matchFound:
elapsed = time.time() - startTime
keysPerSecond = totalKeys / elapsed if elapsed != 0 else 0
with resultMutex:
print(f"\rTime: {int(elapsed)}s, Keys: {totalKeys}, Keys/s: {round(keysPerSecond, 5)}, Current: {currentValue}, Priv Key: {currentHexPrivateKey}", end="")
time.sleep(5)
def counterWorker(threadId, secp256k1, numThreads):
global currentHexPrivateKey, matchFound, startTime, totalKeys, currentValue
current = mpz.mpz(START_VALUE + threadId * INCREMENT)
while current <= END_VALUE:
for factor in range(int(MIN_FACTOR), int(MAX_FACTOR) + 1, int(FACTOR_INCREMENT)):
result = current * int(factor)
hexPrivateKey = format(int(result), "x") # Get hex representation directly
currentHexPrivateKey = hexPrivateKey
privateKey = Int.Int(0)
privateKey.SetBase16(hexPrivateKey)
publicKey = secp256k1.ComputePublicKey(privateKey)
compressedPublicKey = bytearray(secp256k1.GetPublicKeyRaw(True, publicKey))
publicKeyHash = sha256.sha256(compressedPublicKey)
ripemd160Hash = ripemd160.ripemd160(publicKeyHash)
if hasMinimumMatchingCharacters(ripemd160Hash):
matchedPrivateKey = hexPrivateKey # Store the private key for printing
matchedRipemd160 = hexBytesToHexString(ripemd160Hash) # Convert RIPEMD160 to hex string
with printMutex:
print(f"\nMatching RIPEMD160 hash found. Private Key: {matchedPrivateKey}, RIPEMD160: {matchedRipemd160}")
with open("found.txt", "a") as foundFile:
foundFile.write(f"Matched Private Key: {matchedPrivateKey}, RIPEMD160: {matchedRipemd160}\n")
matchFound = True
break
totalKeys += 1
# Update the currentValue atomically
with resultMutex:
currentValue = current
current = current + (INCREMENT * numThreads)
# Signal that this thread has completed its work
with resultMutex:
matchFound = True
def main():
global matchFound, totalKeys, currentValue
loadRIPEMD160Hashes()
secp256k1 = SECP256k1.SECP256k1()
secp256k1.Init()
threads = []
numThreads = os.cpu_count()
# Start the progress printing thread
progressThread = threading.Thread(target=printProgress)
progressThread.start()
for i in range(numThreads):
threads.append(threading.Thread(target=counterWorker, args=(i, secp256k1, numThreads)))
for thread in threads:
thread.start()
for thread in threads:
thread.join()
# Wait for the progress thread to complete
progressThread.join()
print()
if __name__ == "__main__":
main()
Script above is the python version of your code written in alien language, I'm on phone so I couldn't test to see if it works, later I will test it on my laptop and fix any issues. Insha'Allah. ( God willing )
Also;
Thanks for the update on the code, appreciate it. My scripts ( small part of them ) don't need much speed because they are not supposed to auto solve a key, they are intended as learning tools, I talked about improving performance to make king of information stop whining so much. 🤣