creating the lightweight database, billions keys.
last edit: 12/06/20231-we generate a bin file with the publickeys represented in 1s and 0s.
0=even,
1=odd.
single publickey#@mcdouglasx
import secp256k1 as ice
from bitstring import BitArray
import bitcoin
print("Making Binary Data-Base")
target_public_key = "030d282cf2ff536d2c42f105d0b8588821a915dc3f9a05bd98bb23af67a2e92a5b"
target = ice.pub2upub(target_public_key)
num = 10000 # number of keys.
sustract= 1 #amount to subtract each time, If you modify this, use the same amount to scan.
Low_m= 10
lm= num // Low_m
print(lm)
sustract_pub= ice.scalar_multiplication(sustract)
res= ice.point_loop_subtraction(lm, target, sustract_pub)
binary = ''
for t in range (lm):
h= (res[t*65:t*65+65]).hex()
hc= int(h[2:], 16)
if str(hc).endswith(('0','2','4','6','8')):
A="0"
binary+= ''.join(str(A))
if str(hc).endswith(('1','3','5','7','9')):
A="1"
binary+= ''.join(str(A))
my_str = bytes(BitArray(bin=binary))
binary_file = open('data-base.bin', 'ab')
binary_file.write(my_str)
binary_file.close()
for i in range (1,Low_m):
lm_upub= sustract_pub= ice.scalar_multiplication((lm*i)*sustract)
A1= ice.point_subtraction(target, lm_upub)
sustract_pub= ice.scalar_multiplication(sustract)
res= ice.point_loop_subtraction(lm, A1, sustract_pub)
binary = ''
for t in range (lm):
h= (res[t*65:t*65+65]).hex()
hc= int(h[2:], 16)
if str(hc).endswith(('0','2','4','6','8')):
A="0"
binary+= ''.join(str(A))
if str(hc).endswith(('1','3','5','7','9')):
A="1"
binary+= ''.join(str(A))
my_str = bytes(BitArray(bin=binary))
binary_file = open('data-base.bin', 'ab')
binary_file.write(my_str)
binary_file.close()
If you want to create a longer database than your memory supports
For example, 1000 million keys and your memory limit is 100 million, divide by 10 changing this variable:
Low_m= 10
- You should use numbers like this:
num = 10000000000000
Low_m= 10000
num = 20000000000000
Low_m= 2000
Avoid doing this or you will find private keys with the last numbers changed
num = 14678976447
Low_m= 23
we did it!We have a huge database, with little disk space.
Because there is no sequence between even and odd pubkeys we can set a collision margin of 64, 128, 256....
By this I mean that as you increase the collision margin, the probability of finding an identical binary sequence decreases.
What's the use of this?We just need to randomly generate binary sequences and check if they exist in the
Database.
searching single pubkey#@mcdouglasx
import secp256k1 as ice
import random
from bitstring import BitArray
print("Scanning Binary Sequence")
#Pk: 1033162084
#cPub: 030d282cf2ff536d2c42f105d0b8588821a915dc3f9a05bd98bb23af67a2e92a5b
#range
start= 1033100000
end= 1033200000
while True:
pk= random.randint(start, end)
target = ice.scalar_multiplication(pk)
num = 64 # collision margin.
sustract= 1 # #amount to subtract each time.
sustract_pub= ice.scalar_multiplication(sustract)
res= ice.point_loop_subtraction(num, target, sustract_pub)
binary = ''
for t in range (num):
h= (res[t*65:t*65+65]).hex()
hc= int(h[2:], 16)
if str(hc).endswith(('0','2','4','6','8')):
A="0"
binary+= ''.join(str(A))
if str(hc).endswith(('1','3','5','7','9')):
A="1"
binary+= ''.join(str(A))
my_str = binary
b = bytes(BitArray(bin=my_str))
file = open("data-base.bin", "rb")
dat = bytes(file.read())
if b in dat:
s = b
f = dat
inx = f.find(s)*sustract
inx_0=inx
Pk = (int(pk) + int(inx_0))+int(inx_0)*7
data = open("win.txt","a")
data.write("Pk:"+" "+str(Pk)+"\n")
data.close()
break
for multiple pubkeys- first we create the database by making random subtractions in a range specified by us, you can create your own list at your discretion
#@mcdouglasx
import secp256k1 as ice
import random
print("Making random sustract Data-Base")
target_public_key = "0209c58240e50e3ba3f833c82655e8725c037a2294e14cf5d73a5df8d56159de69"
target = ice.pub2upub(target_public_key)
targets_num= 1000
start= 0
end= 1000000
for i in range(targets_num):
A0 = random.randint(start, end)
A1 = ice.scalar_multiplication(A0)
A2= ice.point_subtraction(target, A1).hex()
A3 = ice.to_cpub(A2)
data = open("rand_subtract.txt","a")
data.write(str(A3)+" "+"#"+str(A0)+"\n")
data.close()
Db multi-pubkeys-we create our database for multiple keys.
#@mcdouglasx
import secp256k1 as ice
from bitstring import BitArray
print("Making Binary Data-Base")
target__multi_public_keys = "rand_subtract.txt"
with open(target__multi_public_keys, 'r') as f:
lines= f.readlines()
X = len(lines)
for line in lines:
mk= ice.pub2upub(str(line.strip()[:66]))
num = 1024 # number of keys for pub.
subtract= 1 #amount to subtract each time.
subtract_pub= ice.scalar_multiplication(subtract)
res= ice.point_loop_subtraction(num, mk, subtract_pub)
binary = ''
for t in range (num):
h= (res[t*65:t*65+65]).hex()
hc= int(h[2:], 16)
if str(hc).endswith(('0','2','4','6','8')):
A="0"
binary+= ''.join(str(A))
if str(hc).endswith(('1','3','5','7','9')):
A="1"
binary+= ''.join(str(A))
my_str = BitArray(bin=binary)
binary_file = open('multi-data-base.bin', 'ab')
my_str.tofile(binary_file)
binary_file.close()
scan multiple publickeys, bit version #@mcdouglasx
import secp256k1 as ice
import random
from bitstring import BitArray
print("Scanning Binary Sequence")
#range
start= 3090000000
end= 3093472814
#total number of pubkeys for targets in database.
X= 1024
while True:
pk= random.randint(start, end)
target = ice.scalar_multiplication(pk)
num = 64 # collision margin.
subtract= 1 #amount to subtract each time.
subtract_pub= ice.scalar_multiplication(subtract)
res= ice.point_loop_subtraction(num, target, subtract_pub)
binary = ''
for t in range (num):
h= (res[t*65:t*65+65]).hex()
hc= int(h[2:], 16)
if str(hc).endswith(('0','2','4','6','8')):
A="0"
binary+= ''.join(str(A))
if str(hc).endswith(('1','3','5','7','9')):
A="1"
binary+= ''.join(str(A))
my_str = binary
b = BitArray(bin=my_str)
c = bytes(b)
file = open("multi-data-base.bin", "rb")
dat= BitArray(file.read())
if b in dat:
s = c
f = dat
inx = f.find(s)
inx_1=str(inx).replace(",", "")
inx_0=str(inx_1).replace("(", "")
inx_2=str(inx_0).replace(")", "")
Pk = (int(pk) + ((int(inx_2) % X)*subtract))
cpub=ice.to_cpub(ice.scalar_multiplication(Pk).hex())
with open("rand_subtract.txt", 'r') as Mk:
lines= Mk.readlines()
for line in lines:
mk_0= str(line.strip())
mk= int(mk_0[68:])
mk2= mk_0[ :66]
if mk2 in cpub:
print("found")
cpub2=ice.to_cpub(ice.scalar_multiplication(Pk+mk).hex())
data = open("win.txt","a")
data.write("Pk:"+" "+str(Pk+mk)+"\n")
data.write("cpub:"+" "+str(cpub2)+"\n")
data.close()
break
break
scan multiple publickeys, version bytes (faster).#@mcdouglasx
import secp256k1 as ice
import random
from bitstring import BitArray
import numpy as np
print("Scanning Binary Sequence")
#range
start= 3000000000
end= 3095000000
X= 1024 #number of sequential pubkeys for each target
while True:
pk= random.randint(start, end)
target = ice.scalar_multiplication(pk)
num = 64 # collision margin.
subtract= 1 #amount to subtract each time.
subtract_pub= ice.scalar_multiplication(subtract)
res= ice.point_loop_subtraction(num, target, subtract_pub)
binary = ''
for t in range (num):
h= (res[t*65:t*65+65]).hex()
hc= int(h[2:], 16)
if str(hc).endswith(('0','2','4','6','8')):
A="0"
binary+= ''.join(str(A))
if str(hc).endswith(('1','3','5','7','9')):
A="1"
binary+= ''.join(str(A))
my_str = binary
b = BitArray(bin=my_str)
c = bytes(b)
file = bytes(np.fromfile("multi-data-base.bin"))
dat= (file)
if c in dat:
s = c
f = BitArray(dat)
inx = f.find(s)
inx_1=str(inx).replace(",", "")
inx_0=str(inx_1).replace("(", "")
inx_2=str(inx_0).replace(")", "")
Pk = (int(pk) + ((int(inx_2) % X)*subtract))
cpub=ice.to_cpub(ice.scalar_multiplication(Pk).hex())
with open("rand_subtract.txt", 'r') as Mk:
lines= Mk.readlines()
for line in lines:
mk_0= str(line.strip())
mk= int(mk_0[68:])
mk2= mk_0[ :66]
if mk2 in cpub:
print("found")
cpub2=ice.to_cpub(ice.scalar_multiplication(Pk+mk).hex())
data = open("win.txt","a")
data.write("Pk:"+" "+str(Pk+mk)+"\n")
data.write("cpub:"+" "+str(cpub2)+"\n")
data.close()
break
break
The difference between bit version and byte version is that with bytes some bits are masked within a byte, and it does not detect some collisions.
This does not happen in the bit version.
--------------------------------------------------------------------------
This code is just a demonstration that may not be optimized correctly, preferably make your own version in C.
Don't forget to say thank you, to motivate me to contribute other ideas.