import time
import hashlib
from coincurve import PrivateKey
from Crypto.Hash import RIPEMD160
import psutil
import os
import signal
import sys
import multiprocessing as mp
from bloom_filter2 import BloomFilter
from google.colab import drive
# Mount Google Drive
drive.mount('/content/drive')
# Config
File_NAME = "Puzzle 71.013.000.csv"
DRIVE_FOLDER = "/content/drive/MyDrive/Puzzle71"
file_path = f"{DRIVE_FOLDER}/{File_NAME}"
SCAN_RANGE = 100_000
TARGET_PREFIX = "f6f543"
BLOOM_CAPACITY = 1_000_000
BLOOM_ERROR_RATE = 0.001
# Load known H160 hashes into Bloom filter
KNOWN_H160S = [
"f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8",
]
bloom = BloomFilter(max_elements=BLOOM_CAPACITY, error_rate=BLOOM_ERROR_RATE)
for h in KNOWN_H160S:
bloom.add(h)
# Read decimal numbers from CSV
with open(file_path, 'r') as f:
lines = [line.strip() for line in f if line.strip()]
if lines[0].lower().startswith('value'):
lines = lines[1:]
Decimal_numbers = [int(line) for line in lines]
def privatekey_to_h160(priv_key_int):
try:
priv = PrivateKey.from_int(priv_key_int)
pubkey = priv.public_key.format(compressed=True)
sha256 = hashlib.sha256(pubkey).digest()
ripemd160 = RIPEMD160.new(sha256).digest()
return ripemd160.hex()
except Exception:
return None
def optimize_performance():
try:
p = psutil.Process()
if hasattr(p, "cpu_affinity"):
p.cpu_affinity(list(range(os.cpu_count())))
if hasattr(psutil, "REALTIME_PRIORITY_CLASS"):
p.nice(psutil.REALTIME_PRIORITY_CLASS)
else:
p.nice(-20)
except Exception as e:
print(f"[!] Optimization warning: {e}")
def signal_handler(sig, frame):
print("\n[!] Interrupted. Exiting.")
sys.exit(0)
def check_key(k):
h160 = privatekey_to_h160(k)
if h160 and (h160.startswith(TARGET_PREFIX) or h160 in bloom):
return ('match', k, h160)
return ('progress', k, h160)
def process_decimal(decimal):
start = max(1, decimal - SCAN_RANGE)
end = decimal + SCAN_RANGE
keys = list(range(start, end + 1))
processed = 0
start_time = time.time()
last_key = None
last_h160 = None
ctx = mp.get_context("fork")
with ctx.Pool(processes=os.cpu_count()) as pool:
result_iter = pool.imap_unordered(check_key, keys, chunksize=1000)
for result in result_iter:
if result[0] == 'match':
_, key, h160 = result
print(f"\n**PREFIX MATCH FOUND!** Private key {hex(key)} produces Hash160: {h160}\n")
elif result[0] == 'progress':
_, key, h160 = result
processed += 1
last_key = key
last_h160 = h160
elapsed = time.time() - start_time
speed = processed / elapsed if elapsed > 0 else 0
print(f"\nHash160 of the last processed key {hex(last_key)} -> {last_h160}")
print(f"[✓] Completed Decimal: {Decimal} - Processed {processed} keys in {elapsed:.2f}s (Speed: {speed:.2f} keys/sec)")
def main():
signal.signal(signal.SIGINT, signal_handler)
optimize_performance()
print(f"\nLoaded {len(Decimal_numbers)} Decimal numbers.")
print(f"Scanning ±{SCAN_RANGE} around each.\nTarget prefix: {TARGET_PREFIX}")
print(f"Bloom filter contains {len(KNOWN_H160S)} known H160 hashes.\n")
for decimal in decimal_numbers:
process_decimal(decimal)
if __name__ == '__main__':
main()
Help me out to use rotor cuda gpu modules able run on colab
Private key to hash 160
Who ever help me with this code able to run on gpu
I definitely give u 1 BTC
NEED ACHIEVE ATLEAST 250M Keys/sec
Here optimized for Google collab code
# ──────────────────────────────────────────────────────────────────────────────
# 1) Install system deps & build oclvanitygen (GPU‐accelerated secp256k1 + H160)
# ──────────────────────────────────────────────────────────────────────────────
!apt-get update && apt-get install -y \
libgmp3-dev build-essential ocl-icd-libopencl1 opencl-headers git
# Clone and compile the OpenCL vanity-gen fork
!git clone
https://github.com/samr7/oclvanitygen.git /content/oclvanitygen
%cd /content/oclvanitygen
!make
# Return to working directory
%cd /content
#!/usr/bin/env python3
import subprocess
import csv
from google.colab import drive
# ──────────────────────────────────────────────────────────────────────────────
# CONFIGURATION (edit as needed)
# ──────────────────────────────────────────────────────────────────────────────
# 1) Mount your Google Drive so we can read/write files
drive.mount('/content/drive', force_remount=True)
# 2) Path to your CSV (one decimal per line, optional header 'Value')
CSV_PATH = "/content/drive/MyDrive/Puzzle71/Puzzle 71.013.000.csv"
SCAN_RANGE = 100_000 # ±range around each decimal
TARGET_PREFIX = "f6f543" # hex-string prefix on RIPEMD-160(pubkey)
OCL_PATH = "/content/oclvanitygen/oclvanitygen"
# ──────────────────────────────────────────────────────────────────────────────
# HELPER: sanitize & load decimals
# ──────────────────────────────────────────────────────────────────────────────
def load_decimals(path):
"""Read one integer per line, skip header if present."""
nums = []
with open(path, newline='') as f:
rdr = csv.reader(f)
for row in rdr:
if not row: continue
val = row[0].strip()
# skip header
if val.lower().startswith("value"):
continue
try:
nums.append(int(val))
except ValueError:
continue
return nums
# ──────────────────────────────────────────────────────────────────────────────
# MAIN LOOP: for each decimal, spawn a GPU search over [n-SCAN, n+SCAN]
# ──────────────────────────────────────────────────────────────────────────────
def run_gpu_search(center):
"""
Invoke oclvanitygen with:
-P prefix match on raw HASH160 (not base58)
-s starting private key
-r range size (number of keys to try)
"""
start = max(1, center - SCAN_RANGE)
# oclvanitygen -P expects hex-string, -s decimal start, -r count
cmd = [
OCL_PATH,
"-P", TARGET_PREFIX, # match H160 prefix f6f543…
"-s", str(start), # starting privkey
"-r", str(2*SCAN_RANGE), # total keys to scan
]
print(f"→ Scanning around {center:,} [{start:,} … {start+2*SCAN_RANGE:,}]")
# run and stream output
subprocess.run(cmd, check=True)
def main():
decimals = load_decimals(CSV_PATH)
print(f"
- Loaded {len(decimals)} center values from CSV.")
print(f"
- Target prefix: {TARGET_PREFIX}")
print(f"
- Scan range: ±{SCAN_RANGE:,}\n")
for n in decimals:
run_gpu_search(n)
if __name__ == "__main__":
main()
Speed 200 mh/s