Spaces:
Runtime error

Gg / app.py
polla1987's picture
Update app.py
576e33f verified
Raw History Blame Contribute Delete
4.67 kB
import hashlib
import ecdsa
import time
import multiprocessing
import os
import sys
from Crypto.Hash import RIPEMD160
# 🎯 เป้าหมายของ Puzzle #71
TARGET_RIPEMD160 = "f6f5431d25bbf7b12e8add9af5e3475c44a0a5b8"
# 📍 พิกัด 18 หลักสุ่มใหม่ล่าสุด (เดินหน้าบวกขึ้นทีละ 1)
BASE_START_HEX = "7c8f9a2b3c4d5e6f10"
def hex_to_ripemd160(hex_string):
"""ฟังก์ชันแปลง Hex เป็น RIPEMD-160"""
priv_key_bytes = bytes.fromhex(hex_string.zfill(64))
sk = ecdsa.SigningKey.from_string(priv_key_bytes, curve=ecdsa.SECP256k1)
vk = sk.get_verifying_key()
pubkey = vk.to_string()
if pubkey[-1] % 2 == 0:
compressed_pubkey = b'\x02' + pubkey[:32]
else:
compressed_pubkey = b'\x03' + pubkey[:32]
sha256_result = hashlib.sha256(compressed_pubkey).digest()
ripemd160 = RIPEMD160.new()
ripemd160.update(sha256_result)
return ripemd160.hexdigest()
def worker_task(worker_id, base_int, shared_offset, shared_counter, jackpot_found):
"""ฟังก์ชันสำหรับแต่ละ CPU Core: เบิกระยะวิ่งแล้วเดินหน้าทีละ 1"""
BATCH_SIZE = 100000
while not jackpot_found.value:
# 📌 1. เบิกระยะก้าว (Offset) จากส่วนกลาง
with shared_offset.get_lock():
my_offset = shared_offset.value
shared_offset.value += BATCH_SIZE
# 📌 2. คำนวณพิกัดจริง (เดินหน้าบวกทีละ 1)
for i in range(BATCH_SIZE):
if jackpot_found.value:
return
# เดินหน้า (+)
current_int = base_int + my_offset + i
current_hex = hex(current_int)[2:]
result_ripemd = hex_to_ripemd160(current_hex)
# 🔍 ตรวจสอบเงื่อนไขแจ้งเตือนเมื่อเจอ f6f543
if result_ripemd.startswith("f6f543") or result_ripemd == TARGET_RIPEMD160:
print(f"\n🔥 [Worker {worker_id}] เจอเป้าหมายย่อย! พิกัด: {current_hex} -> {result_ripemd}", flush=True)
if result_ripemd == TARGET_RIPEMD160:
jackpot_found.value = True
print(f"\n🎉🎉🎉 แจ็กพอตแตกโดย Worker {worker_id}!! Private Key: {current_hex} 🎉🎉🎉", flush=True)
return
# 📌 3. ส่งยอดเข้าบัญชีกลาง
with shared_counter.get_lock():
shared_counter.value += BATCH_SIZE
if __name__ == "__main__":
num_cores = multiprocessing.cpu_count()
print(f"🚀 เริ่มระบบขุดด้วย CPU {num_cores} Cores...")
print(f"📍 จุดสตาร์ทใหม่ (เดินหน้าทีละ 1): {BASE_START_HEX}")
print(f"📊 หน้าจอจะอัปเดตยอดรวมนิ่งๆ อยู่กับที่\n")
# แปลง Hex ตั้งต้นเป็น Integer
base_integer = int(BASE_START_HEX, 16)
shared_offset = multiprocessing.Value('q', 0)
shared_counter = multiprocessing.Value('q', 0)
jackpot_found = multiprocessing.Value('b', False)
global_start_time = time.time()
processes = []
for i in range(num_cores):
p = multiprocessing.Process(
target=worker_task,
args=(i+1, base_integer, shared_offset, shared_counter, jackpot_found)
)
processes.append(p)
p.start()
try:
while any(p.is_alive() for p in processes) and not jackpot_found.value:
time.sleep(1.0)
total = shared_counter.value
elapsed = time.time() - global_start_time
speed = total / elapsed if elapsed > 0 else 0
sys.stdout.write(f"\r⏳ [ยอดรวมสะสม] สแกนเดินหน้าไปแล้ว: {total:,} คีย์ | ความเร็วรวม: {speed:.2f} keys/วิ")
sys.stdout.flush()
for p in processes:
p.join()
except KeyboardInterrupt:
print("\n🛑 ผู้ใช้สั่งหยุดการทำงาน")
for p in processes:
p.terminate()