Bitcoin Forum
May 21, 2024, 12:48:53 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: « 1 2 3 4 5 6 7 8 9 10 [11]  All
  Print  
Author Topic: lightweight database, for brute force using publickeys-32Mk =3.81MB(secp256k1)  (Read 2297 times)
arulbero
Legendary
*
Offline Offline

Activity: 1915
Merit: 2074


View Profile
December 12, 2023, 10:16:41 PM
Last edit: December 19, 2023, 07:46:51 PM by arulbero
 #201

After more script tweaking, I can generate a 20,000,000 key database in less than 10 seconds. Search time less than 2 seconds.

36 Bit Result:

Code:
This is the public key: 02b3e772216695845fa9dda419fb5daca28154d8aa59ea302f05e916635e47b9f6

 Building the Binary Database

 Targeting PubKey:      02b3e772216695845fa9dda419fb5daca28154d8aa59ea302f05e916635e47b9f6
 Number of PubKeys:     20,000,000
 Writing to file every: 20,000,000 keys
 Subtract Value:        1
 Space Covered:        20,000,000 / 0x1312d00

DB Generation Time:  0:00:09.604563


 Scanning Randomly

 Current Random Key:  0x9dd926219   Jumps Made:  291
PK Found: 42387769980
PK Found: 0x9de820a7c


Search Time:  0:00:01.815859

Total Time:  0:00:11.420422

EDIT:  If I use the BitArray option, as in original code, 20,000,000 keys generated into DB takes right at 4 seconds.

Are you using multithreading?  It works only for consecutive keys?

With multithreading and 16 cores, I get 2**24 (16.77M) keys in 4.35 seconds. Non consecutive keys.

EDIT:

multithread (16 cores), 2^25 keys (33.5M) with distance = 16 (using ice.point_loop_subtraction): 5.15 seconds

multithread (16 cores), 2^25 consecutive keys (using ice.point_sequential_decrement): 1.39 seconds

EDIT2:

multithread (16 cores), 2^25 keys (33.5M) with distance = 16 (using ice.point_loop_subtraction): 4.8 seconds

multithread (16 cores), 2^25 consecutive keys (using ice.point_sequential_decrement): 1.06 seconds


EDIT3:

multithread (16 cores), 2^25 keys (33.5M) with distance = 16 (using ice.point_loop_subtraction): 4.67 seconds

multithread (16 cores), 2^25 consecutive keys (using ice.point_sequential_decrement): 0.89 seconds
mcdouglasx (OP)
Member
**
Offline Offline

Activity: 239
Merit: 53

New ideas will be criticized and then admired.


View Profile WWW
December 13, 2023, 02:48:55 PM
 #202

Be careful with those who use multithreading to create the db, if you do something wrong and write the bits where they don't belong, they could obtain partially correct keys, such as:


private key = 32685509
private key = 33435509

when you should really get:

target = 33185509

Test your codes first, before believing that it is a false positive when it is really a human error.

I'm not dead, long story... BTC bc1qxs47ttydl8tmdv8vtygp7dy76lvayz3r6rdahu
WanderingPhilospher
Full Member
***
Offline Offline

Activity: 1064
Merit: 219

Shooters Shoot...


View Profile
December 14, 2023, 04:55:08 PM
 #203

Quote
EDIT2:

multithread (16 cores), 2^25 keys (33.5M) with distance = 16 (using ice.point_loop_subtraction): 4.8 seconds

multithread (16 cores), 2^25 consecutive keys (using ice.point_sequential_decrement): 1.06 seconds

Wow, impressive!

My results have all been single core. I have not attempted to do anything with multi-core yet.
arulbero
Legendary
*
Offline Offline

Activity: 1915
Merit: 2074


View Profile
December 14, 2023, 05:29:00 PM
 #204

Quote
EDIT2:

multithread (16 cores), 2^25 keys (33.5M) with distance = 16 (using ice.point_loop_subtraction): 4.8 seconds

multithread (16 cores), 2^25 consecutive keys (using ice.point_sequential_decrement): 1.06 seconds

Wow, impressive!

My results have all been single core. I have not attempted to do anything with multi-core yet.

Then your results are better than mine.

With only 1 cpu in 4 seconds I get around 16.5 M consecutive keys, not 20 M.
WanderingPhilospher
Full Member
***
Offline Offline

Activity: 1064
Merit: 219

Shooters Shoot...


View Profile
December 14, 2023, 06:50:55 PM
 #205

Quote
EDIT2:

multithread (16 cores), 2^25 keys (33.5M) with distance = 16 (using ice.point_loop_subtraction): 4.8 seconds

multithread (16 cores), 2^25 consecutive keys (using ice.point_sequential_decrement): 1.06 seconds

Wow, impressive!

My results have all been single core. I have not attempted to do anything with multi-core yet.

Then your results are better than mine.

With only 1 cpu in 4 seconds I get around 16.5 M consecutive keys, not 20 M.

That’s probably just because of the different CPUs.

ElDalmatino
Jr. Member
*
Offline Offline

Activity: 53
Merit: 11


View Profile
December 14, 2023, 07:47:14 PM
 #206

Hi new to this topic, asking if there is a newer single core script that we can try, than the one in the first post.
ElonMusk_ia
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
April 08, 2024, 03:23:13 PM
 #207

Does anyone have C or C++ code to create databases faster?
whanau
Member
**
Offline Offline

Activity: 118
Merit: 30


View Profile
April 10, 2024, 03:08:06 AM
 #208

what is the highest scalar (private key) you have found with this method?
What were your settings?.
Thanks
studyroom1
Jr. Member
*
Offline Offline

Activity: 40
Merit: 7


View Profile
April 10, 2024, 09:17:49 AM
 #209

lol tried to even find where is working codes but all seems like chit chat and no solid code are available not even on github

please provide all working codes or update it in github
ElonMusk_ia
Newbie
*
Offline Offline

Activity: 4
Merit: 0


View Profile
April 10, 2024, 12:43:39 PM
 #210

lol tried to even find where is working codes but all seems like chit chat and no solid code are available not even on github

please provide all working codes or update it in github

I wrote to the OP, but I think he died according to his last post, or maybe he's a troll, I don't know.
whanau
Member
**
Offline Offline

Activity: 118
Merit: 30


View Profile
April 10, 2024, 06:10:36 PM
 #211

I wrote the both scripts:

create_database_arulbero.py
search_key_arulbero.py


parameters:

private key interval: from 1 to 2^32
keys stored: 2^32 / 2^7 = 2^25 (1 each 128)
bits for each key = 64
size of database: 257 MB

time to create the database: 3 min 55 s

time to find the private key of a single random public key in the db: 0.1 - 0.3 s




create_database_arulbero.py

Code:
#!/usr/bin/env python3
# 2023/Dec/03, create_database_arulbero.py
import secp256k1 as ice
import sys

#############################################################################
# Set the number of public keys to generate
#############################################################################
start_key = 1
num_public_keys = 2**32 #(about 4 billions of keys)
bits_to_store = 64
bytes_to_store = bits_to_store//8
rate_of_key_to_generate = 2**20
rate_of_key_to_store = rate_of_key_to_generate

interval_to_generate = range(start_key, start_key + num_public_keys, rate_of_key_to_store)
interval_to_store = range(start_key,start_key + num_public_keys,rate_of_key_to_store)

binary_mode = 1

#############################################################################


if (binary_mode == 1):

f = open("public_keys_database.bin", "wb") #binary mode

########################################generation#############################################
public_keys=[]


public_keys_complete=list(map(ice.scalar_multiplication,interval_to_generate)) #generates the public keys complete
public_keys=list(map(lambda w: int(w[33-bytes_to_store:33].hex(),16),public_keys_complete)) #extract only the last bytes_to_store



########################################writing the db##########################################
for i in range(0,len(interval_to_store)):
f.write(public_keys[i].to_bytes(bytes_to_store,sys.byteorder))  #writes each key

f.close()

else:

f = open("public_keys_database.txt", "w")

#generation
public_keys=[]

for i in interval_to_generate:
P4 = ice.scalar_multiplication(i)
public_keys.append(P4[33-bytes_to_store:33].hex())

#writing the db
for i in range(0,len(interval_to_store)):
f.write(public_keys[i])

f.close()

search_key_arulbero.py
Code:
# 2023/Dec/03, arulbero_search_key.py
import secp256k1 as ice
import random
import sys

#############################################################################
# Set the number of public keys to generate
#############################################################################

start_key = 1
num_public_keys = 2**32
bits_to_store = 64
bytes_to_store = bits_to_store//8
rate_of_key_to_generate = 2**20
rate_of_key_to_store = rate_of_key_to_generate

split_database = 256 #read only a fraction of the database to speedup the finding of the string

interval_to_generate = range(start_key,start_key + num_public_keys, rate_of_key_to_store)

interval_to_store = range(start_key,start_key + num_public_keys,rate_of_key_to_store)

binary_mode = 1

#########################################################################################

#pk = 0x3243 = 12867
#P = ice.scalar_multiplication(12867)
#P="0x6800b#b8a9dffe1709ceac95d7d06646188c2cb656c09cd2e717ec67487ce1be3"


#############generates random private key and public key#################################
pk= random.randint(start_key, start_key + num_public_keys)
#pk=start_key + num_public_keys-1
P = ice.scalar_multiplication(pk)
print()
print("This is the public key: " + P[1:33].hex())
print("I need to find this private key: "+str(pk))


###################subtraction of : P - 1G,  P - 2G, ..., P - rate_of_key*G################
substract_pub = ice.scalar_multiplication(1)
complete_pub= ice.point_loop_subtraction(rate_of_key_to_generate, P, substract_pub)


partial_pub=[] #need only the last bytes_to_store
P2=int(P[33-bytes_to_store:33].hex(),16).to_bytes(bytes_to_store,sys.byteorder)
partial_pub.append(P2)

for i in range(1,rate_of_key_to_store+1):
partial_pub.append(int(complete_pub[(i-1)*65+33-bytes_to_store:(i-1)*65+33].hex(),16).to_bytes(bytes_to_store,sys.byteorder))




################search in database##########################################################
num_bytes = num_public_keys*bytes_to_store//rate_of_key_to_store
size = num_bytes//split_database
s_partial_pub = set(partial_pub)


with open("public_keys_database.bin", 'r+b') as f:

#s=f.read()

for k in range(0, num_bytes, num_bytes//split_database):

f.seek(0,1)
partial_db = f.read(num_bytes//split_database)

l_partial_db = [partial_db[i:i + bytes_to_store] for i in range(0, size, bytes_to_store)]
s_partial_db = set(l_partial_db)

a = list(s_partial_db & s_partial_pub)
if (len(a)>0):

n = partial_db.find(a[0])

if n > -1:
print()
print("Private key found!!!")
private_key = (n+k)//bytes_to_store*rate_of_key_to_generate + partial_pub.index(a[0])+1
if(pk == private_key):
print("It is correct!!!")
else:
print("Collision!")
print(private_key)
P3 = ice.scalar_multiplication(private_key)
pub_key=P3[1:33].hex()
print((pub_key)[:])
f.close()
sys.exit(0)


print("string not found")
 



This code works very well as does the code on the OP's Github page.
Pages: « 1 2 3 4 5 6 7 8 9 10 [11]  All
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!