Skip to content

Commit

Permalink
Update snailpub.py
Browse files Browse the repository at this point in the history
  • Loading branch information
pianist-coder authored May 30, 2024
1 parent c703453 commit 15d593c
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions snailpub.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@
"""
import secp256k1 as ice
import time
from datetime import datetime as dt
import os
import sys
import random
import argparse
import numpy as np

#==============================================================================
parser = argparse.ArgumentParser(description='This tool use random number reusability for sequentially searching all unsolved BTC puzzles',
Expand All @@ -24,23 +22,19 @@
args = parser.parse_args()
#==============================================================================

seq = int(args.n) if args.n else 4000000 # 4 Million
seq = int(args.n) if args.n else 1000000 # 1 Million
p_file = args.p if args.p else 'unsolved.pub' # 'unsolved.pub'

if os.path.isfile(p_file) == False:
print('File {} not found'.format(p_file))
sys.exit()

puzz = {int(line.split()[0]):line.split()[1] for line in open(p_file,'r')}
puzz_bits = list(puzz.keys())
puzz_h160 = [ice.pub2upub(line).hex() for line in puzz.values()]
puzz_h160 = [ice.pub2upub(line) for line in puzz.values()]
#==============================================================================

# Very Very Slow. Made only to get a random number completely non pseudo stl.
def randk(bits):
dd = list(str(random.randint(1,2**256)))
random.shuffle(dd); random.shuffle(dd)
rs = int(''.join(dd))
random.seed(rs)
return random.SystemRandom().randint(2**(bits-1), -1+2**bits)

def print_success(my_key):
Expand All @@ -50,6 +44,16 @@ def print_success(my_key):
with open('KEYFOUNDKEYFOUND.txt','a') as fw:
fw.write('Puzzle_FOUND_PrivateKey '+hex(my_key)+'\n')
exit()

def chunks(s):
for start in range(0, 65*seq, 65):
yield s[start : start + 65]

def display_time(seconds):
hours, rem = divmod(seconds, 3600)
minutes, seconds = divmod(rem, 60)
return f"{int(hours):02d}:{int(minutes):02d}:{seconds:05.2f}"

#==============================================================================

print('\n[+] Starting Program.... Please Wait !')
Expand All @@ -67,20 +71,16 @@ def print_success(my_key):
counter += 1
bitkey = int('1'+bin(key_int)[2:][(1+160-cbits):], 2)
P = ice.scalar_multiplication(bitkey)
if P.hex() in puzz_h160:
if P in puzz_h160:
print_success(bitkey)

data = np.frombuffer(ice.point_sequential_increment(seq, P), np.uint8).reshape(seq, 65)
cnt = 0
for t in data:
currpub = (t.tobytes()).hex()
if currpub in puzz_h160:
for t in chunks(ice.point_sequential_increment(seq, P)):
if t in puzz_h160:
print_success(bitkey + cnt + 1)

cnt += 1
elapsed = time.time() - start
speed = ( (loop-1)*(seq+1)*len(puzz_bits) + (seq+1)*counter ) / elapsed
print(' '*120,end='\r')
print(f'[Loop: {loop}] [Puzzle: {cbits} bit] [Speed: {speed:.2f} K/s] [{dt.strftime(dt.utcfromtimestamp(elapsed), "%H:%M:%S")}] [{hex(bitkey)}]', end='\r')
print(f'[Loop: {loop}] [Puzzle: {cbits} bit] [Speed: {speed:.2f} K/s] [{display_time(elapsed)}] [{hex(bitkey)}]', end='\r')
except(KeyboardInterrupt, SystemExit):
exit('\nSIGINT or CTRL-C detected. Exiting gracefully. BYE')

0 comments on commit 15d593c

Please sign in to comment.