Post
Topic
Board Development & Technical Discussion
Re: lightweight database, for brute force using publickeys-32Mk =3.81MB(secp256k1)
by
sssergy2705
on 29/11/2023, 16:09:17 UTC
How many keys are you trying to generate?!
For me to make a 2^32 DB, it took over 5 hours. I used the low memory script and wrote to file 2^26 keys, roughly every 5 minutes. 64 (2^32 / 2^26) x 5 minutes = 320 minutes
Also, just for info, a DB with 2^32 values = 524 MB (incredible!)

Can you share your script to create the database file?
I want to create a file of size 2000000000 keys to test on puzzle 65.

I have it prefilled out for you:

Code:
#@mcdouglasx
import secp256k1 as ice
from bitstring import BitArray
import bitcoin


print("Making Binary Data-Base")


target_public_key = "0230210c23b1a047bc9bdbb13448e67deddc108946de6de639bcc75d47c0216b1b"

target = ice.pub2upub(target_public_key)


num = 2000000000 # number of keys.

sustract = 1 #amount to subtract each time.

Low_m= 200

#2^28 / 2^ 26 = 4
#2^29 / 2^26 = 8
#2^30 / 2^26 = 16
#2^32 / 2^26 = 64

lm= num // Low_m
   

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('130Bit.bin', 'wb')
binary_file.write(my_str)
binary_file.close()

for i in range (1,Low_m):
   
    mem= ice.to_cpub(ice.scalar_multiplication(lm).hex())
   
    Apk= bitcoin.multiply(mem, i)
   
    Apk_upu= ice.pub2upub(Apk)

    A1= ice.point_addition(target, Apk_upu)

    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('65Bit.bin', 'ab')
    binary_file.write(my_str)
    binary_file.close()

It will write to file, every 10,000,000 keys.

Let me know if it works for you.

binary_file = open('130Bit.bin', 'wb')
----------------------------------------
binary_file = open('65Bit.bin', 'ab')

I understand the meaning, only the names of the files need to be changed)