Search content
Sort by

Showing 5 of 5 results by skedarve
Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
skedarve
on 30/07/2025, 17:06:17 UTC
Looking for real full code that unable to use and it's slow
Instead help me with gpu related private key to hash 160
Entire in one frame code


This code is just a prototype. If you're looking for simple private key → public key → hash160, this is much slower.

My code doesn't follow the full flow from the start, but instead optimizes it with a shortcut:
it uses partial SHA256 on the GPU to pre-filter promising private keys before doing the full flow.

This saves you billions of useless ECC checks, and it's a totally different strategy if you're looking for an exact match like hash160.
Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
skedarve
on 30/07/2025, 15:47:36 UTC
import cupy as cp
import numpy as np
import time
from Crypto.Hash import RIPEMD160, SHA256
from ecdsa import SECP256k1, SigningKey
import concurrent.futures

TARGET_HASH160 = bytes.fromhex("f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8")
TARGET_PREFIX = TARGET_HASH160[:3]
THREADS = 256
BATCH_SIZE = 2**24

sha256_kernel = cp.RawKernel(r'''
extern "C" __global__
void sha256_partial(const unsigned long long* privkeys, unsigned char* out_prefixes, unsigned char* matches, int N) {
    int idx = blockDim.x * blockIdx.x + threadIdx.x;
    if (idx >= N) return;
    unsigned long long key = privkeys[idx];
    unsigned char data[8];
    #pragma unroll
    for (int i = 0; i < 8; ++i)
        data[7 - i] = (key >> (i * Cool) & 0xFF;
    unsigned int h[8] = {
        0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a,
        0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19
    };
    unsigned int k[4] = {
        0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5
    };
    unsigned int w[64] = {0};
    #pragma unroll
    for (int i = 0; i < 8; ++i)
        w = ((unsigned int)data) << 24;
    unsigned int a = h[0], b = h[1], c = h[2], d = h[3];
    unsigned int e = h[4], f = h[5], g = h[6], hh = h[7];
    for (int i = 0; i < 4; ++i) {
        unsigned int S1 = __funnelshift_r(e, e, 6) ^ __funnelshift_r(e, e, 11) ^ __funnelshift_r(e, e, 25);
        unsigned int ch = (e & f) ^ (~e & g);
        unsigned int temp1 = hh + S1 + ch + k + w;
        unsigned int S0 = __funnelshift_r(a, a, 2) ^ __funnelshift_r(a, a, 13) ^ __funnelshift_r(a, a, 22);
        unsigned int maj = (a & b) ^ (a & c) ^ (b & c);
        unsigned int temp2 = S0 + maj;
        hh = g;
        g = f;
        f = e;
        e = d + temp1;
        d = c;
        c = b;
        b = a;
        a = temp1 + temp2;
    }
    h[0] += a;
    unsigned char b0 = (h[0] >> 24) & 0xFF;
    unsigned char b1 = (h[0] >> 16) & 0xFF;
    unsigned char b2 = (h[0] >> Cool & 0xFF;
    out_prefixes[idx * 3 + 0] = b0;
    out_prefixes[idx * 3 + 1] = b1;
    out_prefixes[idx * 3 + 2] = b2;
    if (b0 == 0xf6 && b1 == 0xf5 && b2 == 0x43)
        matches[idx] = 1;
    else
        matches[idx] = 0;
}
''', 'sha256_partial')

def hash160(pubkey_bytes):
    sha = SHA256.new(pubkey_bytes).digest()
    h160 = RIPEMD160.new(sha).digest()
    return h160

def verify_candidate(candidate):
    pubkey = compressed_public_key_from_privkey(candidate)
    h160 = hash160(pubkey)
    if h160 == TARGET_HASH160:
        return candidate, pubkey.hex(), h160.hex()
    return None

def compressed_public_key_from_privkey(privkey_int):
    priv_bytes = int(privkey_int).to_bytes(32, 'big')
    sk = SigningKey.from_string(priv_bytes, curve=SECP256k1)
    vk = sk.get_verifying_key()
    x = vk.pubkey.point.x()
    prefix = b'\x03' if (vk.pubkey.point.y() & 1) else b'\x02'
    return prefix + x.to_bytes(32, 'big')

print("🔁 Starting search with GPU prefilter (3 bytes)...")

try:
    total_keys = 0
    total_candidates = 0
    while True:
        t0 = time.time()
        privkeys = cp.random.randint(0, 2**64, size=BATCH_SIZE, dtype=cp.uint64)
        out = cp.zeros((BATCH_SIZE * 3,), dtype=cp.uint8)
        matches = cp.zeros(BATCH_SIZE, dtype=cp.uint8)
        blocks = (BATCH_SIZE + THREADS - 1) // THREADS
        sha256_kernel((blocks,), (THREADS,), (privkeys, out, matches, BATCH_SIZE))
        matches_cpu = matches.get()
        privkeys_cpu = privkeys.get()
        candidates = [privkeys_cpu for i in range(BATCH_SIZE) if matches_cpu == 1]
        total_keys += BATCH_SIZE
        total_candidates += len(candidates)
        with concurrent.futures.ProcessPoolExecutor(max_workers=8) as executor:
            futures = [executor.submit(verify_candidate, c) for c in candidates]
            for future in concurrent.futures.as_completed(futures):
                result = future.result()
                if result is not None:
                    candidate, pub_hex, h160_hex = result
                    print(f"\n🎯 MATCH found! Private key: {hex(candidate)}")
                    print(f"    PublicKey: {pub_hex}")
                    print(f"    Hash160: {h160_hex}")
                    exit()
        elapsed = time.time() - t0
        print(f"🔹 Processed: {BATCH_SIZE} | Candidates: {len(candidates)} | Speed: {int(BATCH_SIZE / elapsed):,} keys/s")
except KeyboardInterrupt:
    print("⛔ Process interrupted.")
Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
skedarve
on 23/05/2025, 06:17:08 UTC
Accepted all kind of msgs from feel free share the code
With working output

On file save decimal value of keys

U can send private message

just use Numpy and u have your 250 million or more keys/second.

u need a lot of RAM.
Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
skedarve
on 22/05/2025, 22:20:05 UTC
just use Numpy and u have your 250 million or more keys/second.

u need a lot of RAM.

Why stop at 250? Let's get that RAM to speed things up to 100 Gk/s or more. Numpy FTW!

On a single thread. Hell, actually let's dump numpy and do things in CPU machine code directly. I heard we can reach 70 Petakeys/s that way. There's this undocumented "h160" op-code that computes around 262144 hashes for an entire range of private keys, in a single clock instruction! Imagine doing this on 16 cores! It also works with hyper-threading, and turbo boost is enabled automatically for all cores if this secret instruction ends up on the CPU's stack instruction pointer register.


exactly my friend, i have not been working on this and it has had great success results in the simulation, when I finish we could do 30 000 000 000 keys / s this is a small reference it could be done even much more depending on the investment, currently i have little time to continue working on this my work consumes me and a few weeks ago I had my first baby, possibly in a few weeks I will share part of the code with you.

in case anyone wants to support the cause

19yj62wiErnPkocPx4Gq37xt5zDdPMgRat
Post
Topic
Board Bitcoin Discussion
Re: Bitcoin puzzle transaction ~32 BTC prize to who solves it
by
skedarve
on 22/05/2025, 19:53:36 UTC
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

just use Numpy and u have your 250 million or more keys/second.

u need a lot of RAM.