-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathsnailpub.py
86 lines (73 loc) · 3.24 KB
/
snailpub.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# -*- coding: utf-8 -*-
"""
Usage :
> python snailpub.py
@author: iceland
"""
import secp256k1 as ice
import time
import os
import sys
import random
import argparse
#==============================================================================
parser = argparse.ArgumentParser(description='This tool use random number reusability for sequentially searching all unsolved BTC puzzles',
epilog='Enjoy the program! :) Tips BTC: bc1q39meky2mn5qjq704zz0nnkl0v7kj4uz6r529at')
parser.version = '02052023'
parser.add_argument("-p", help = "Unsolved Puzzles file with pubkey. default=unsolved.pub", action="store")
parser.add_argument("-n", help = "Total sequential search in 1 loop. default=4000000", action='store')
args = parser.parse_args()
#==============================================================================
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) for line in puzz.values()]
#==============================================================================
def randk(bits):
return random.SystemRandom().randint(2**(bits-1), -1+2**bits)
def print_success(my_key):
print('\n============== KEYFOUND ==============')
print(f'Puzzle FOUND PrivateKey: {hex(my_key)} Address: {ice.privatekey_to_address(0, True, my_key)}')
print('======================================')
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 !')
print(f'[+] Search Mode: Sequential Random in each Loop. seq={seq}')
print(f'[+] Total Unsolved: {len(puzz_bits)} Puzzles in the bit range [{min(puzz_bits)}-{max(puzz_bits)}]')
loop = 0
start = time.time()
while True:
try:
key_int = randk(160)
loop += 1
counter = 0
for cbits in puzz_bits:
counter += 1
bitkey = int('1'+bin(key_int)[2:][(1+160-cbits):], 2)
P = ice.scalar_multiplication(bitkey)
if P in puzz_h160:
print_success(bitkey)
cnt = 0
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] [{display_time(elapsed)}] [{hex(bitkey)}]', end='\r')
except(KeyboardInterrupt, SystemExit):
exit('\nSIGINT or CTRL-C detected. Exiting gracefully. BYE')