0.2.211007 Chocolate ¡Beta!

This commit is contained in:
AlbertoBSD 2021-10-11 07:09:41 +02:00
parent 42938fdc9b
commit 6086ddd5e9
15 changed files with 2818 additions and 1341 deletions

View File

@ -1,3 +1,11 @@
# Version 0.2.211007 Chocolate ¡Beta!
- BSGS improvements:
-- 10x more Speed
-- new submodes for BSGS, secuential (default), backward, both, random and dance
-- automatic file generation for bloom filter file and bPtable file.
-- Good bye to bPfile.
- Memory check periodically for bloom filters and bP Table
# Version 0.1.20210420 secp256k1
- Solved Issues 49, 50 51
See:

View File

@ -3,7 +3,8 @@ default:
g++ -O3 -c sha256/sha256.c -o sha256.o
gcc -O3 -c base58/base58.c -o base58.o
gcc -O3 -c rmd160/rmd160.c -o rmd160.o
gcc -O3 -c sha3/sha3.c -o sha3.o
g++ -O3 -c sha3/sha3.c -o sha3.o
g++ -O3 -c sha3/keccak.c -o keccak.o
gcc -O3 -c xxhash/xxhash.c -o xxhash.o
g++ -O3 -c util.c -o util.o
g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/Int.cpp -o Int.o
@ -12,8 +13,9 @@ default:
g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/IntMod.cpp -o IntMod.o
g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/Random.cpp -o Random.o
g++ -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -c secp256k1/IntGroup.cpp -o IntGroup.o
g++ -o keyhunt keyhunt.c base58.o rmd160.o sha256.o bloom.o xxhash.o util.o Int.o Point.o SECP256K1.o IntMod.o Random.o IntGroup.o -lgmp -lm -lpthread
#gcc -O3 hexcharstoraw.c -o hexcharstoraw util.o -lm
g++ -o bPfile bPfile.c util.o -lgmp -lm
clean:
g++ -o keyhunt keyhunt.c base58.o rmd160.o sha256.o bloom.o xxhash.o util.o Int.o Point.o SECP256K1.o IntMod.o Random.o IntGroup.o sha3.o keccak.o -lm -lpthread
rm -r *.o
clean:
rm keyhunt
rm bPfile

745
README.md
View File

@ -11,7 +11,9 @@ Ethereum addresses is a work in develop
To clone the repository:
`git clone https://github.com/albertobsd/keyhunt.git`
```
git clone https://github.com/albertobsd/keyhunt.git
```
don't forget change to the keyhunt directory
@ -22,9 +24,13 @@ First compile:
`make`
and then execute:
and then execute with `-h` to see the help
`./keyhunt -h`
```./keyhunt -h```
## ¡Beta!
This version is still a beta version, there are a lot of things that can be fail. And absoluly there are some bugs
# Modes
@ -35,6 +41,8 @@ The current availables modes are:
- xpoint
- bsgs
you can select them with `-m`
## address mode
This is the most basic approach to work, in this mode your text file need to have a list of the publicaddress to be search.
@ -82,65 +90,58 @@ To target that file we need to execute keyhunt with this line
output:
```
[+] Version 0.1.20210328
[+] Setting mode address
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode address
[+] Matrix screen
[+] Opening file tests/1to32.txt
[+] Setting search for btc adddress
[+] Allocating memory for 32 elements: 0.00 MB
[+] Initializing bloom filter for 32 elements.
[+] Loading data to the bloomfilter
[+] Bloom filter for 32 elements.
[+] Loading data to the bloomfilter total: 0.00 MB
[+] Bloomfilter completed
[+] Sorting data
[+] 32 values were loaded and sorted
Thread 0 : Setting up base key: 0000000000000000000000000000000000000000000000000000000000000001
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000001
[+] Sorting data ... done! 32 values were loaded and sorted
Base key: 1
HIT!! PrivKey: 1
pubkey: 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
address: 1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000003
HIT!! PrivKey: 3
pubkey: 02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9
address: 1CUNEBjYrCn2y1SdiUMohaKUi4wpP326Lb
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000007
HIT!! PrivKey: 7
pubkey: 025cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc
address: 19ZewH8Kk1PDbSNdJ97FP4EiCjTRaZMZQA
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000008
HIT!! PrivKey: 8
pubkey: 022f01e5e15cca351daff3843fb70f3c2f0a1bdd05e5af888a67784ef3e10a2a01
address: 1EhqbyUMvvs7BfL8goY6qcPbD6YKfPqb7e
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000015
pubkey: 02352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5
address: 1E6NuFjCi27W5zoXg8TRdcSRq84zJeBW3k
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000031
pubkey: 03f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530
address: 1PitScNLyp2HCygzadCh7FveTnfmpPbfp8
(Output omitted)
```
In this mode you can specify to seach only address compressed or uncompressed with `-l compress` o `-l compress`
In this mode you can specify to seach only address compressed or uncompressed with `-l compress` or `-l uncompress`
Test your look with the random parameter `-R` againts the puzzle #64
`./keyhunt -m address -f tests/64.txt -b 64 -l compress -R`
```
./keyhunt -m address -f tests/64.txt -b 64 -l compress -R -q -s 10
```
Please note the change from `-r 1:FFFFFFFF` to `-b 64`, with -b you can specify the bit range
output:
```
[+] Version 0.1.20210328
[+] Setting mode address
[+] Min range: 8000000000000000
[+] Max range: ffffffffffffffff
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode address
[+] Search compress only
[+] Setting random mode.
[+] Random mode
[+] Quiet thread output
[+] Stats output every 10 seconds
[+] Opening file tests/64.txt
[+] Setting search for btc adddress
[+] Allocating memory for 1 elements: 0.00 MB
[+] Initializing bloom filter for 1 elements.
[+] Loading data to the bloomfilter
[+] Bloom filter for 1 elements.
[+] Loading data to the bloomfilter total: 0.00 MB
[+] Bloomfilter completed
[+] Sorting data
[+] 1 values were loaded and sorted
Thread 0 : Setting up base key: 000000000000000000000000000000000000000000000000adf754734f7cf61a
Total 26214400 keys in 150 seconds: 174762 keys/s
(Output omitted)
[+] Sorting data ... done! 1 values were loaded and sorted
[+] Total 6291456 keys in 20 seconds: 314572 keys/s
```
## rmd160 mode
@ -190,58 +191,58 @@ d805f6f251f7479ebd853b3d0f4b9b2656d92f1d
to target that file you need to execute the next line:
`./keyhunt -m rmd160 -f tests/1to32.rmd -r 1:FFFFFFFF -l compress`
```
./keyhunt -m rmd160 -f tests/1to32.rmd -r 1:FFFFFFFF -l compress
```
output:
```
[+] Version 0.1.20210328
[+] Setting mode rmd160
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode rmd160
[+] Search compress only
[+] Opening file tests/1to32.rmd
[+] Allocating memory for 32 elements: 0.00 MB
[+] Initializing bloom filter for 32 elements.
[+] Loading data to the bloomfilter
[+] Bloom filter for 32 elements.
[+] Loading data to the bloomfilter total: 0.00 MB
[+] Bloomfilter completed
[+] Sorting data
[+] 32 values were loaded and sorted
Thread 0 : Setting up base key: 0000000000000000000000000000000000000000000000000000000000000001HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000001
[+] Sorting data ... done! 32 values were loaded and sorted
HIT!! PrivKey: 1
pubkey: 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000003
HIT!! PrivKey: 3
pubkey: 02f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000007
HIT!! PrivKey: 7
pubkey: 025cbdf0646e5db4eaa398f365f2ea7a0e3d419b7e0330e39ce92bddedcac4f9bc
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000008
HIT!! PrivKey: 8
pubkey: 022f01e5e15cca351daff3843fb70f3c2f0a1bdd05e5af888a67784ef3e10a2a01
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000015
HIT!! PrivKey: 15
pubkey: 02352bbf4a4cdd12564f93fa332ce333301d9ad40271f8107181340aef25be59d5
HIT!! PrivKey: 0000000000000000000000000000000000000000000000000000000000000031
(Output omited)
HIT!! PrivKey: 31
pubkey: 03f2dac991cc4ce4b9ea44887e5c7c0bce58c80074ab9d4dbaeb28531b7739f530
```
test your luck with the next file for th puzzle #64
`./keyhunt -m rmd160 -f tests/64.rmd -b 64 -l compress -R`
```
./keyhunt -m rmd160 -f tests/64.rmd -b 64 -l compress -R -q
```
Output:
```
[+] Version 0.1.20210328
[+] Setting mode rmd160
[+] Min range: 8000000000000000
[+] Max range: ffffffffffffffff
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode rmd160
[+] Search compress only
[+] Setting random mode.
[+] Random mode
[+] Quiet thread output
[+] Opening file tests/64.rmd
[+] Allocating memory for 1 elements: 0.00 MB
[+] Initializing bloom filter for 1 elements.
[+] Loading data to the bloomfilter
[+] Bloom filter for 1 elements.
[+] Loading data to the bloomfilter total: 0.00 MB
[+] Bloomfilter completed
[+] Sorting data
[+] 1 values were loaded and sorted
Thread 0 : Setting up base key: 000000000000000000000000000000000000000000000000f7d1beda50ed79d4
Total 27262976 keys in 120 seconds: 227191 keys/s
(Output omited)
[+] Sorting data ... done! 1 values were loaded and sorted
[+] Total 34603008 keys in 30 seconds: ~1 Mkeys/s (1153433 keys/s)
```
BTW this rmd160 mode doesn't allow search by vanity address
@ -276,28 +277,26 @@ A few substracted values from puzzle *40*
Now you can use keyhunt against some thousand values of the puzzle 40:
`./keyhunt -m xpoint -f tests/substracted40.txt -n 65536 -t 4 -b 40`
```./keyhunt -m xpoint -f tests/substracted40.txt -n 65536 -t 4 -b 40```
Output:
```
[+] Version 0.1.20210330a
[+] Setting mode xpoint
[+] Setting 4 threads
[+] Min range: 8000000000
[+] Max range: ffffffffff
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode xpoint
[+] Threads : 4
[+] Quiet thread output
[+] Opening file tests/substracted40.txt
[+] Allocating memory for 6003 elements: 0.11 MB
[+] Initializing bloom filter for 6003 elements.
[+] Loading data to the bloomfilter
[+] Bloom filter for 6003 elements.
[+] Loading data to the bloomfilter total: 0.02 MB
[+] Bloomfilter completed
[+] Sorting data
[+] 6003 values were loaded and sorted
Thread 3 : Setting up base key: 0000000000000000000000000000000000000000000000000000008001d00000
Thread 0 : Setting up base key: 00000000000000000000000000000000000000000000000000000080025b0000
HIT!! PrivKey: 000000000000000000000000000000000000000000000000000000800258a2ce
[+] Sorting data ... done! 6003 values were loaded and sorted
HIT!! PrivKey: 800258a2ce
pubkey: 0274241b684e7c31e7933510b510aa14de9ac88ec3635bdd35a3bcf1d16da210be
Thread 1 : Setting up base key: 0000000000000000000000000000000000000000000000000000008002910000^C
HIT!! PrivKey: 8009c16fb9
pubkey: 027c3463c3d4e034f328749e2ac17b47a24b42ad47aaab0ec09d4d0abeee3ab46d
```
After the hit we need to search the substracted index and make a simple math operation to get the real privatek:
@ -309,6 +308,27 @@ The Operation is `800258a2ce` hex (+/-) in this case + `453856235784` decimal eq
This is an easy example, I been trying the puzzle 120 with more than 500 millions of substracted keys and no luck.
Test you luck with the puzzle 120 with xpoint:
```./keyhunt -m xpoint -f tests/120.txt -t 4 -b 120 -R -q```
Output:
```
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode xpoint
[+] Threads : 4
[+] Random mode
[+] Quiet thread output
[+] Opening file tests/120.txt
[+] Allocating memory for 1 elements: 0.00 MB
[+] Bloom filter for 1 elements.
[+] Loading data to the bloomfilter total: 0.00 MB
[+] Bloomfilter completed
[+] Total 544210944 keys in 30 seconds: ~18 Mkeys/s (18140364 keys/s)
```
## pub2rmd mode
This method is made to try to get the puzzles publickey key it works a little more faster because it skip the EC Operations
@ -348,22 +368,22 @@ c01bf430a97cbcdaedddba87ef4ea21c456cebdb
To target that file you need to do:
`./keyhunt -m pub2rmd -f tests/puzzleswopublickey.txt -q`
```./keyhunt -m pub2rmd -f tests/puzzleswopublickey.txt -t 6 -q```
Output:
```
[+] Version 0.1.20210331
[+] Setting mode pub2rmd
[+] Set quiet thread output
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode pub2rmd
[+] Threads : 6
[+] Quiet thread output
[+] Opening file tests/puzzleswopublickey.txt
[+] Allocating memory for 29 elements: 0.00 MB
[+] Initializing bloom filter for 29 elements.
[+] Bloom filter for 29 elements.
[+] Loading data to the bloomfilter total: 0.00 MB
[+] Bloomfilter completed
[+] Sorting data
[+] 29 values were loaded and sorted
Total 76546048 keys in 90 seconds: 850511 keys/s
[+] Sorting data ... done! 29 values were loaded and sorted
[+] Total 207618048 keys in 60 seconds: ~3 Mkeys/s (3460300 keys/s)
```
You can let it run for a while together with others scripts, if you get one of those publickeys now you can target it with a better method like bsgs or another tools like kangaroo
@ -389,36 +409,103 @@ btw any word followed by and space after the publickey is ignored the file can b
046534b9e9d56624f5850198f6ac462f482fec8a60262728ee79a91cac1d60f8d6a92d5131a20f78e26726a63d212158b20b14c3025ebb9968c890c4bab90bfc69
```
### File creation
the bsgs mode `-m bsgs` now can create automatically the files needed to speed up the initial load process of keyhunt this is the bloom filters creation and the bp table creation.
To request to keyhunt to create those files automatically use `-S` Capital S for SAVE and READ files.
The 3 files needed for keyhunt can vary from size depending of your values of `-n` and `-k` , so make your test and stick to one combination of (n,k) values or you can end with hundreds of unnesesary files.
The 3 Files size are the same amount of memory used in runtime.
The files are created if they don't exist when you run the program the first time.
example of file creation:
```
./keyhunt -m bsgs -f tests/120.txt -R -b 120 -q -S
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Random mode
[+] Quiet thread output
[+] Mode BSGS random
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] -- from : 0x800000000000000000000000000000
[+] -- to : 0x1000000000000000000000000000000
[+] N = 0x100000000000
[+] Bloom filter for 4194304 elements : 14.00 MB
[+] Bloom filter for 209716 elements : 0.72 MB
[+] Allocating 3.00 MB for 209716 bP Points
[+] processing 4194304/4194304 bP points : 100%
[+] Sorting 209716 elements... Done!
[+] Writing bloom filter to file keyhunt_bsgs_0_4194304.blm .. Done!
[+] Writing bloom filter to file keyhunt_bsgs_1_209716.blm .. Done!
[+] Writing bP Table to file keyhunt_bsgs_2_209716.tbl .. Done!
[+] Total 439804651110400 keys in 30 seconds: ~14 Tkeys/s (14660155037013 keys/s)
[+] Total 897201488265216 keys in 60 seconds: ~14 Tkeys/s (14953358137753 keys/s)
```
when we run the program for second time the files are now readed and the bP Points processing is omited:
```
./keyhunt -m bsgs -f tests/120.txt -b 120 -q -S
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Quiet thread output
[+] Turn off stats output
[+] Mode BSGS secuential
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] -- from : 0x800000000000000000000000000000
[+] -- to : 0x1000000000000000000000000000000
[+] N = 0x100000000000
[+] Bloom filter for 4194304 elements : 14.00 MB
[+] Bloom filter for 209716 elements : 0.72 MB
[+] Allocating 3.00 MB for 209716 bP Points
[+] Reading bloom filter from file keyhunt_bsgs_0_4194304.blm .. Done!
[+] Reading bloom filter from file keyhunt_bsgs_1_209716.blm .. Done!
[+] Reading bP Table from file keyhunt_bsgs_2_209716.tbl ..Done!
^C
```
All the next examples were made with the `-S` option I just ommit that part of the output to avoid confutions use `-S` if you want, but remember with a great `-n` there must also come great files
### Examples
To try to find those privatekey this is the line of execution:
``./keyhunt -m bsgs -f tests/test120.txt -b 120``
```
time ./keyhunt -m bsgs -f tests/test120.txt -b 120 -S
```
Output:
```
[+] Version 0.1.20210328
[+] Setting mode BSGS
[+] Min range: 800000000000000000000000000000
[+] Max range: ffffffffffffffffffffffffffffff
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Mode BSGS secuential
[+] Opening file tests/test120.txt
[+] Added 2 points from file
[+] Bit Range 120
[+] Setting N up to 17592186044416.
[+] Init 1st bloom filter for 4194304 elements : 14.00 MB
[+] Init 2nd bloom filter for 209716 elements : 0.00 MB
[+] Allocating 128.0 MB for 4194304 aMP Points
[+] Precalculating 4194304 aMP points
[+] -- from : 0x800000000000000000000000000000
[+] -- to : 0x1000000000000000000000000000000
[+] N = 0x100000000000
[+] Bloom filter for 4194304 elements : 14.00 MB
[+] Bloom filter for 209716 elements : 0.72 MB
[+] Allocating 3.00 MB for 209716 bP Points
[+] processing 4194304/4194304 bP points : 100 %
[+] Sorting 209716 elements
[+] Thread 0: 0000000000000000000000000000000000800000000000000000000000000000
[+] Thread 0 Key found privkey 0000000000000000000000000000000000800000000000000000100000000000
[+] Reading bloom filter from file keyhunt_bsgs_0_4194304.blm .. Done!
[+] Reading bloom filter from file keyhunt_bsgs_1_209716.blm .. Done!
[+] Reading bP Table from file keyhunt_bsgs_2_209716.tbl ..Done!
[+] Thread Key found privkey 800000000000000000100000000000
[+] Publickey 043ffa1cc011a8d23dec502c7656fb3f93dbe4c61f91fd443ba444b4ec2dd8e6f0406c36edf3d8a0dfaa7b8f309b8f1276a5c04131762c23594f130a023742bdde
[+] Thread 0: 0000000000000000000000000000000000800000000000000000100000000000
Total 17592186044416 keys in 30 seconds: 586406201480 keys/s
[+] Thread 0 Key found privkey 0000000000000000000000000000000000800000000000000000200000000000
[+] Thread Key found privkey 800000000000000000200000000000
[+] Publickey 046534b9e9d56624f5850198f6ac462f482fec8a60262728ee79a91cac1d60f8d6a92d5131a20f78e26726a63d212158b20b14c3025ebb9968c890c4bab90bfc69
All points were found
real 0m3.642s
user 0m3.637s
sys 0m0.005s
```
Test the puzzle 120 with the next publickey:
@ -427,132 +514,372 @@ Test the puzzle 120 with the next publickey:
02CEB6CBBCDBDF5EF7150682150F4CE2C6F4807B349827DCDBDD1F2EFA885A2630
```
Line of execution in random mode **-R**
Line of execution in random mode `-R` or -B random
`./keyhunt -m bsgs -f tests/120.txt -b 120 -R`
```./keyhunt -m bsgs -f tests/120.txt -b 120 -q -s 10 -R```
```./keyhunt -m bsgs -f tests/120.txt -b 120 -q -s 10 -B random```
Example Output:
```
[+] Version 0.1.20210328
[+] Setting mode BSGS
[+] Min range: 800000000000000000000000000000
[+] Max range: ffffffffffffffffffffffffffffff
[+] Setting random mode.
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Quiet thread output
[+] Stats output every 10 seconds
[+] Mode BSGS random
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] Setting N up to 17592186044416.
[+] Init 1st bloom filter for 4194304 elements : 14.00 MB
[+] Init 2nd bloom filter for 209716 elements : 0.00 MB
[+] Allocating 128.0 MB for 4194304 aMP Points
[+] Precalculating 4194304 aMP points
[+] -- from : 0x800000000000000000000000000000
[+] -- to : 0x1000000000000000000000000000000
[+] N = 0x100000000000
[+] Bloom filter for 4194304 elements : 14.00 MB
[+] Bloom filter for 209716 elements : 0.72 MB
[+] Allocating 3.00 MB for 209716 bP Points
[+] processing 4194304/4194304 bP points : 100 %
[+] Sorting 209716 elements
[+] Thread 0: 0000000000000000000000000000000000d79219eeaef3d014d3effc55327b00
Total 35184372088832 keys in 30 seconds: 1172812402961 keys/s
[+] processing 4194304/4194304 bP points : 100%
[+] Sorting 209716 elements... Done!
^C] Total 439804651110400 keys in 30 seconds: ~14 Tkeys/s (14660155037013 keys/s)
```
Good speed no? 1.1 Terakeys/s for one single thread
Good speed no? 14.6 Terakeys/s for one single thread
**Total 70368744177664 keys in 60 seconds: 1172812402961 keys/s**
**[+] Total 439804651110400 keys in 30 seconds: ~14 Tkeys/s (14660155037013 keys/s)**
We can speed up our process selecting a bigger K value `-k value` btw the n value is the total length of item tested in the radom range, a bigger k value means more ram to be use:
Example:
`$ ./keyhunt -m bsgs -f tests/120.txt -b 120 -R -k 20`
Example output:
```
[+] Version 0.1.20210328
[+] Setting mode BSGS
[+] Min range: 800000000000000000000000000000
[+] Max range: ffffffffffffffffffffffffffffff
[+] Setting random mode.
[+] Setting k factor to 20
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] Setting N up to 17592253153280.
[+] Init 1st bloom filter for 83886080 elements : 287.00 MB
[+] Init 2nd bloom filter for 4194304 elements : 14.00 MB
[+] Allocating 6.0 MB for 209716 aMP Points
[+] Precalculating 209716 aMP points
[+] Allocating 64.00 MB for 4194304 bP Points
[+] processing 83886080/83886080 bP points : 100 %
[+] Sorting 83886080 elements
[+] Thread 0: 0000000000000000000000000000000000e6389dbe5f63a094d7fcc748e2ccba
Total 703690126131200 keys in 30 seconds: 23456337537706 keys/s
(Thread output omited....)
./keyhunt -m bsgs -f tests/120.txt -b 120 -R -k 20
```
**23 Terakeys/s for one single thread**
Want to more Speed use a bigger -k value like 128, it will use some 2.5 GB of RAM
```
[+] Version 0.1.20210328
[+] Setting mode BSGS
[+] Min range: 800000000000000000000000000000
[+] Max range: ffffffffffffffffffffffffffffff
[+] Setting random mode.
[+] Setting k factor to 128
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] Setting N up to 17592186044416.
[+] Init 1st bloom filter for 536870912 elements : 1840.00 MB
[+] Init 2nd bloom filter for 26843546 elements : 92.00 MB
[+] Allocating 1.0 MB for 32768 aMP Points
[+] Precalculating 32768 aMP points
[+] Allocating 409.00 MB for 26843546 bP Points
[+] processing 536870912/536870912 bP points : 100 %
[+] Sorting 26843546 elements
[+] Thread 0: 000000000000000000000000000000000086a2afb9eac0a5ea30e7a554a88aec
(Thread output omited....)
Total 4679521487814656 keys in 30 seconds: 155984049593821 keys/s
```
**~155 Terakeys/s for one single thread**
OK at this point maybe you want to use ALL your RAM memory to solve the puzzle 120, just a bigger -k value
I already tested it with some **24 GB **used with `-k 1024` and I get **1.16 Petakeys/s per thread.**
with 6 threads
`./keyhunt -m bsgs -f tests/120.txt -b 120 -R -k 1024 -q -p ./bPfile.bin -t 6`
Output:
```
[+] Version 0.1.20210328
[+] Setting mode BSGS
[+] Min range: 800000000000000000000000000000
[+] Max range: ffffffffffffffffffffffffffffff
[+] Setting random mode.
[+] Setting k factor to 1024
[+] Set quiet thread output
[+] Setting 6 threads
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Random mode
[+] K factor 20
[+] Mode BSGS random
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] Setting N up to 17592186044416.
[+] Init 1st bloom filter for 4294967296 elements : 14722.00 MB
[+] Init 2nd bloom filter for 214748365 elements : 736.00 MB
[+] Allocating 0.0 MB for 4096 aMP Points
[+] Precalculating 4096 aMP points
[+] Allocating 3276.00 MB for 214748365 bP Points
[+] Reading 4294967296 bP points from file ./bPfile.bin
[+] processing 4294967296/4294967296 bP points : 100 %
[+] Sorting 214748365 elements
Total 157238958864990208 keys in 30 seconds: 5241298628833006 keys/s
[+] -- from : 0x800000000000000000000000000000
[+] -- to : 0x1000000000000000000000000000000
[+] N = 0xfffff000000
[+] Bloom filter for 83886080 elements : 287.00 MB
[+] Bloom filter for 4194304 elements : 14.38 MB
[+] Allocating 64.00 MB for 4194304 bP Points
[+] processing 83886080/83886080 bP points : 100%
^C] Thread 0xc769b6007dccced55c48c28db483f3 : ~252 Tkeys/s (252740831805440 keys/s)
```
I get 5.2 Petakeys/s total
**~252 Terakeys/s for one single thread**
Note the value of N `0xfffff000000` with k = 20 this mean that the N value is less than the default value `0x100000000000` that is because k is not a 2^X number
if you want to more Speed use a bigger -k value like 128, it will use some 2.5 GB of RAM
```
./keyhunt -m bsgs -f tests/120.txt -b 120 -R -k 128
```
Output
```
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Random mode
[+] K factor 128
[+] Mode BSGS random
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] -- from : 0x800000000000000000000000000000
[+] -- to : 0x1000000000000000000000000000000
[+] N = 0x100000000000
[+] Bloom filter for 536870912 elements : 1840.00 MB
[+] Bloom filter for 26843546 elements : 92.02 MB
[+] processing 536870912/536870912 bP points : 100%
^C] Thread 0xa6be81c8ac15f65047f322862e37c4 s: ~1 Pkeys/s (1600302523840375 keys/s
```
**~1.6 Pkeys/s for one single thread**
OK at this point maybe you want to use ALL your RAM memory to solve the puzzle 120, just a bigger -k value
I already tested it with some **18 GB ** used with `-k 1024` and I get **~46 Petakeys/s per thread.**
with 6 threads
`./keyhunt -m bsgs -f tests/120.txt -b 120 -R -k 1024 -q -t 6`
Output:
```
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Random mode
[+] K factor 1024
[+] Quiet thread output
[+] Threads : 6
[+] Mode BSGS random
[+] Opening file tests/120.txt
[+] Added 1 points from file
[+] Bit Range 120
[+] -- from : 0x800000000000000000000000000000
[+] -- to : 0x1000000000000000000000000000000
[+] N = 0x100000000000
[+] Bloom filter for 4294967296 elements : 14722.00 MB
[+] Bloom filter for 214748365 elements : 736.13 MB
[+] Allocating 3276.00 MB for 214748365 bP Points
[+] Sorting 214748365 elements
[+] Total 5607544486029688832 keys in 120 seconds: ~46 Pkeys/s (46729537383580740 keys/s)
```
I get ~46 Petakeys/s total
Warning: the default n value have a maximun K of `4096` if that value is exceed the program can have an unknow behavior or suboptimal speed.
If you want to use a bigger K I recomend use a bigger N value `-n 0x400000000000` and half your K value.
Just as comparation with the BSGS program of JLP
Same publickeys and ranged used by his sample:
publickeys:
```
0459A3BFDAD718C9D3FAC7C187F1139F0815AC5D923910D516E186AFDA28B221DC994327554CED887AAE5D211A2407CDD025CFC3779ECB9C9D7F2F1A1DDF3E9FF8
04A50FBBB20757CC0E9C41C49DD9DF261646EE7936272F3F68C740C9DA50D42BCD3E48440249D6BC78BC928AA52B1921E9690EBA823CBC7F3AF54B3707E6A73F34
0404A49211C0FE07C9F7C94695996F8826E09545375A3CF9677F2D780A3EB70DE3BD05357CAF8340CB041B1D46C5BB6B88CD9859A083B0804EF63D498B29D31DD1
040B39E3F26AF294502A5BE708BB87AEDD9F895868011E60C1D2ABFCA202CD7A4D1D18283AF49556CF33E1EA71A16B2D0E31EE7179D88BE7F6AA0A7C5498E5D97F
04837A31977A73A630C436E680915934A58B8C76EB9B57A42C3C717689BE8C0493E46726DE04352832790FD1C99D9DDC2EE8A96E50CAD4DCC3AF1BFB82D51F2494
040ECDB6359D41D2FD37628C718DDA9BE30E65801A88A00C3C5BDF36E7EE6ADBBAD71A2A535FCB54D56913E7F37D8103BA33ED6441D019D0922AC363FCC792C29A
0422DD52FCFA3A4384F0AFF199D019E481D335923D8C00BADAD42FFFC80AF8FCF038F139D652842243FC841E7C5B3E477D901F88C5AB0B88EE13D80080E413F2ED
04DB4F1B249406B8BD662F78CBA46F5E90E20FE27FC69D0FBAA2F06E6E50E536695DF83B68FD0F396BB9BFCF6D4FE312F32A43CF3FA1FE0F81DF70C877593B64E0
043BD0330D7381917F8860F1949ACBCCFDC7863422EEE2B6DB7EDD551850196687528B6D2BC0AA7A5855D168B26C6BAF9DDCD04B585D42C7B9913F60421716D37A
04332A02CA42C481EAADB7ADB97DF89033B23EA291FDA809BEA3CE5C3B73B20C49C410D1AD42A9247EB8FF217935C9E28411A08B325FBF28CC2AF8182CE2B5CE38
04513981849DE1A1327DEF34B51F5011C5070603CA22E6D868263CB7C908525F0C19EBA6BD2A8DCF651E4342512EDEACB6EA22DA323A194E25C6A1614ABD259BC0
04D4E6FA664BD75A508C0FF0ED6F2C52DA2ADD7C3F954D9C346D24318DBD2ECFC6805511F46262E10A25F252FD525AF1CBCC46016B6CD0A7705037364309198DA1
0456B468963752924DBF56112633DC57F07C512E3671A16CD7375C58469164599D1E04011D3E9004466C814B144A9BCB7E47D5BACA1B90DA0C4752603781BF5873
04D5BE7C653773CEE06A238020E953CFCD0F22BE2D045C6E5B4388A3F11B4586CBB4B177DFFD111F6A15A453009B568E95798B0227B60D8BEAC98AF671F31B0E2B
04B1985389D8AB680DEDD67BBA7CA781D1A9E6E5974AAD2E70518125BAD5783EB5355F46E927A030DB14CF8D3940C1BED7FB80624B32B349AB5A05226AF15A2228
0455B95BEF84A6045A505D015EF15E136E0A31CC2AA00FA4BCA62E5DF215EE981B3B4D6BCE33718DC6CF59F28B550648D7E8B2796AC36F25FF0C01F8BC42A16FD9
```
set range
```
-r 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e0000000000000000:49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5effffffffffffffff
```
the n value to get the same baby step table:
```
-n 1152921504606846976
```
number of threads
```
-t 6
```
Hidding the speed:
```
-s 0
```
command:
```
time ./keyhunt -m bsgs -t 6 -f tests/in.txt -r 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e0000000000000000:49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5effffffffffffffff -n 0x1000000000000000 -M -s 0
```
Output:
```
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Threads : 6
[+] Matrix screen
[+] Turn off stats output
[+] Mode BSGS secuential
[+] Opening file tests/in.txt
[+] Added 16 points from file
[+] Range
[+] -- from : 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e0000000000000000
[+] -- to : 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5effffffffffffffff
[+] N = 0x1000000000000000
[+] Bloom filter for 1073741824 elements : 3680.00 MB
[+] Bloom filter for 53687092 elements : 184.03 MB
[+] Allocating 819.00 MB for 53687092 bP Points
[+] processing 1073741824/1073741824 bP points : 100%
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e0000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e2000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e1000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e3000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e4000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e5000000000000000
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e5698aaab6cac52b3
[+] Publickey 0404a49211c0fe07c9f7c94695996f8826e09545375a3cf9677f2d780a3eb70de3bd05357caf8340cb041b1d46c5bb6b88cd9859a083b0804ef63d498b29d31dd1
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e59c839258c2ad7a0
[+] Publickey 040b39e3f26af294502a5be708bb87aedd9f895868011e60c1d2abfca202cd7a4d1d18283af49556cf33e1ea71a16b2d0e31ee7179d88be7f6aa0a7c5498e5d97f
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e38160da9ebeaecd7
[+] Publickey 04db4f1b249406b8bd662f78cba46f5e90e20fe27fc69d0fbaa2f06e6e50e536695df83b68fd0f396bb9bfcf6d4fe312f32a43cf3fa1fe0f81df70c877593b64e0
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e54cad3cfbc2a9c2b
[+] Publickey 04332a02ca42c481eaadb7adb97df89033b23ea291fda809bea3ce5c3b73b20c49c410d1ad42a9247eb8ff217935c9e28411a08b325fbf28cc2af8182ce2b5ce38
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e0d5eccc38d0230e6
[+] Publickey 04513981849de1a1327def34b51f5011c5070603ca22e6d868263cb7c908525f0c19eba6bd2a8dcf651e4342512edeacb6ea22da323a194e25c6a1614abd259bc0
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e2452dd26bc983cd5
[+] Publickey 04b1985389d8ab680dedd67bba7ca781d1a9e6e5974aad2e70518125bad5783eb5355f46e927a030db14cf8d3940c1bed7fb80624b32b349ab5a05226af15a2228
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e6000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e7000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e8000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e9000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ea000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5eb000000000000000
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ebb3ef3883c1866d4
[+] Publickey 0459a3bfdad718c9d3fac7c187f1139f0815ac5d923910d516e186afda28b221dc994327554ced887aae5d211a2407cdd025cfc3779ecb9c9d7f2f1a1ddf3e9ff8
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5eb5abc43bebad3207
[+] Publickey 04a50fbbb20757cc0e9c41c49dd9df261646ee7936272f3f68c740c9da50d42bcd3e48440249d6bc78bc928aa52b1921e9690eba823cbc7f3af54b3707e6a73f34
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e765fb411e63b92b9
[+] Publickey 04837a31977a73a630c436e680915934a58b8c76eb9b57a42c3c717689be8c0493e46726de04352832790fd1c99d9ddc2ee8a96e50cad4dcc3af1bfb82d51f2494
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e7d0e6081c7e0e865
[+] Publickey 040ecdb6359d41d2fd37628c718dda9be30e65801a88a00c3c5bdf36e7ee6adbbad71a2a535fcb54d56913e7f37d8103ba33ed6441d019d0922ac363fcc792c29a
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e79d808cab1decf8d
[+] Publickey 043bd0330d7381917f8860f1949acbccfdc7863422eee2b6db7edd551850196687528b6d2bc0aa7a5855d168b26c6baf9ddcd04b585d42c7b9913f60421716d37a
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e7c43b8e079ae7278
[+] Publickey 0456b468963752924dbf56112633dc57f07c512e3671a16cd7375c58469164599d1e04011d3e9004466c814b144a9bcb7e47d5baca1b90da0c4752603781bf5873
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e8d63ef128ef66b42
[+] Publickey 04d5be7c653773cee06a238020e953cfcd0f22be2d045c6e5b4388a3f11b4586cbb4b177dffd111f6a15a453009b568e95798b0227b60d8beac98af671f31b0e2b
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5e7ad38337c7f173c7
[+] Publickey 0455b95bef84a6045a505d015ef15e136e0a31cc2aa00fa4bca62e5df215ee981b3b4d6bce33718dc6cf59f28b550648d7e8b2796ac36f25ff0c01f8bc42a16fd9
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ec000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ed000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ee000000000000000
[+] Thread 0x49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ef000000000000000
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ec737344ca673ce28
[+] Publickey 0422dd52fcfa3a4384f0aff199d019e481d335923d8c00badad42fffc80af8fcf038f139d652842243fc841e7c5b3e477d901f88c5ab0b88ee13d80080e413f2ed
[+] Thread Key found privkey 49dccfd96dc5df56487436f5a1b18c4f5d34f65ddb48cb5ee3579364de939b0c
[+] Publickey 04d4e6fa664bd75a508c0ff0ed6f2c52da2add7c3f954d9c346d24318dbd2ecfc6805511f46262e10a25f252fd525af1cbcc46016b6cd0a7705037364309198da1
All points were found
real 164m32.904s
user 973m8.387s
sys 0m26.803s
```
Amount of RAM used ~4.5 GB, time to solve the sixteen publickeys in the range of 64 bits key-space: 164 min (~2.7 hrs) using 6 threads
if we run the same command with `-n 0x1000000000000000 -k 4 -t 6` it use ~18 GB or RAM and solve the same keys in 60 minutes
```
All points were found
real 59m50.533s
user 329m29.836s
sys 0m22.752s
```
There are several variations to play with the values `-n` and `-k` but there are some minimal values required, n can not be less than 1048576 (2^20)
To get optimal performance the k values need to be base 2^x values, this is 1,2,4,8,16,32 ...
### Valid n and k values
+---------------------------+-------------+---------------------------+
| bits | n in hexadecimal | k max value | Amount of RAM with k = 1 |
+---------------------------+-------------+---------------------------+
| 20 | 0x100000 | 1 (default) | |
| 22 | 0x400000 | 2 | |
| 24 | 0x1000000 | 4 | |
| 26 | 0x4000000 | 8 | |
| 28 | 0x10000000 | 16 | |
| 30 | 0x40000000 | 32 | |
| 32 | 0x100000000 | 64 | |
| 34 | 0x400000000 | 128 | |
| 36 | 0x1000000000 | 256 | |
| 38 | 0x4000000000 | 512 | |
| 40 | 0x10000000000 | 1024 | |
| 42 | 0x40000000000 | 2048 | |
| 44 | 0x100000000000 | 4096 | ~17 MB |
| 46 | 0x400000000000 | 8192 | ~34 MB |
| 48 | 0x1000000000000 | 16384 | |
| 50 | 0x4000000000000 | 32768 | |
| 52 | 0x10000000000000 | 65536 | |
| 54 | 0x40000000000000 | 131072 | |
| 56 | 0x100000000000000 | 262144 | |
| 58 | 0x400000000000000 | 524288 | |
| 60 | 0x1000000000000000 | 1048576 | ~4.5 GB |
| 62 | 0x4000000000000000 | 2097152 | ~9 GB |
+---------------------------+-------------+---------------------------+
if you exceed the Max value of K the program can have a unknow behavior, the program can have a suboptimal performance, or in the wrong case you can missing some hits.
Of course you can use a bigger number N like 2^64 or 2^70 if you have enough memory for it.
Note for user that want use it with SWAP memory. IT DON'T WORK swap memory was made to small chucks of memory also is slowly.
### Testing puzzle 63 bits
Publickey:
```
0365ec2994b8cc0a20d40dd69edfe55ca32a54bcbbaa6b0ddcff36049301a54579
```
Command
```
time ./keyhunt -m bsgs -t 6 -f tests/63.pub -n 0x1000000000000000 -M -s 0 -S -k 4 -b 63
```
output:
```
[+] Version 0.2.211007 Chocolate ¡Beta!
[+] Threads : 6
[+] Matrix screen
[+] Turn off stats output
[+] K factor 4
[+] Mode BSGS secuential
[+] Opening file tests/63.pub
[+] Added 1 points from file
[+] Bit Range 63
[+] -- from : 0x4000000000000000
[+] -- to : 0x8000000000000000
[+] N = 0x1000000000000000
[+] Bloom filter for 4294967296 elements : 14722.00 MB
[+] Bloom filter for 214748365 elements : 736.13 MB
[+] Allocating 3276.00 MB for 214748365 bP Points
[+] Reading bloom filter from file keyhunt_bsgs_0_4294967296.blm .. Done!
[+] Reading bloom filter from file keyhunt_bsgs_1_214748365.blm .. Done!
[+] Reading bP Table from file keyhunt_bsgs_2_214748365.tbl ..Done!
[+] Thread 0x6000000000000000
[+] Thread 0x5000000000000000
[+] Thread 0x4000000000000000
[+] Thread 0x7000000000000000
[+] Thread Key found privkey 7cce5efdaccf6808
[+] Publickey 0365ec2994b8cc0a20d40dd69edfe55ca32a54bcbbaa6b0ddcff36049301a54579
All points were found
real 4m58.644s
user 7m52.332s
sys 0m11.803s
```
Please note that number of threads was setting to 6 but only 4 threads were used, this is because the range 63 bits is small for BSGS and we only need four times the current N value to fill it, to avoid this we can use a smaller N value but with some multiplier K in that way w we can achieve the same speed and also be able to launch more threads. Repeat only in case that the range was small like this.
The next command also solve the Puzzle 63 with more threads
```
time ./keyhunt -m bsgs -t 6 -f tests/63.pub -n 0x400000000000000 -M -s 0 -S -k 16 -b 63 -B both
```
```
real 4m4.719s
user 2m15.706s
sys 0m13.009s
```
## FAQ
@ -561,13 +888,31 @@ R: In a file called `KEYFOUNDKEYFOUND.txt`
- Is available for Windows?
R: It can be compiled with mingw, It can be executed in the Ubuntu shell for windows 10
Updated: Yes, thanks to @WanderingPhilosopher
Available in: https://github.com/WanderingPhilosopher/keyhunt/releases/tag/v1.0
- Why i need the bPfile.bin ?
R: Usually you don't need it, but if you are going to run and stop the program several times is faster load the data from a file.
NOTE: bPfile.bin will discontinued in some future version, the current versios have the `-S` to SAVE the FILES or READ from IT if they already exist
- The bPfile gives me extra speed?
R: No, is just to help to speed up a little the load process and no more, but the final speed of keys per second is going to be the same without this file.
## Dependencies
- pthread
Tested under Debian, Termux, Ubuntu Shell for windows 10
## Donation
## Thanks
This program was possible thanks to
- IceLand
- kanhavishva
- All the group of CryptoHunters that made this program possible
- All the users that tested it, report bugs, requested improvements and shared his knowledge.
## Donations
- BTC: 1Coffee1jV4gB5gaXfHgSHDz9xx9QSECVW
- ETH: 0x6222978c984C22d21b11b5b6b0Dd839C75821069

260
bPfile.c
View File

@ -1,260 +0,0 @@
/*
Develop by Luis Alberto
email: alberto.bsd@gmail.com
gcc -o bPfile bPfile.c -lgmp -lm
Hint: compile in the keyhunt directory
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <gmp.h>
#include <string.h>
#include <unistd.h>
#include <pthread.h>
#include <math.h>
#include "util.h"
uint64_t BSGS_BUFFERXPOINTLENGTH = 32;
uint64_t BSGS_BUFFERREGISTERLENGTH = 36;
struct Point {
mpz_t x;
mpz_t y;
};
struct Elliptic_Curve {
mpz_t p;
mpz_t n;
};
const char *EC_constant_N = "FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141";
const char *EC_constant_P = "fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f";
const char *EC_constant_Gx = "79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798";
const char *EC_constant_Gy = "483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8";
struct Point DoublingG[256];
void Point_Doubling(struct Point *P, struct Point *R);
void Point_Addition(struct Point *P, struct Point *Q, struct Point *R);
void Scalar_Multiplication(struct Point P, struct Point *R, mpz_t m);
void Point_Negation(struct Point *A, struct Point *S);
void init_doublingG(struct Point *P);
struct Elliptic_Curve EC;
struct Point G;
int main(int argc, char **argv) {
mpz_t temp;
FILE *p_file;
char temporal[512],rawvalue[BSGS_BUFFERXPOINTLENGTH];
long int i,m,sz;
mpz_t M;
struct Point point_t,P;
if(argc < 3) {
printf("Create bP File usage\n");
printf("%s <bP items> <output filename>\n\n",argv[0]);
printf("Example to create a File with 1 Billion items:\n%s 1000000000 Pfile.bin\n",argv[0]);
printf("If the file exists, only the missing bP items will be added○\n");
exit(0);
}
mpz_init_set_str(M,argv[1],10);
mpz_init_set_str(EC.p, EC_constant_P, 16);
mpz_init_set_str(EC.n, EC_constant_N, 16);
mpz_init_set_str(G.x , EC_constant_Gx, 16);
mpz_init_set_str(G.y , EC_constant_Gy, 16);
init_doublingG(&G);
mpz_init(point_t.x);
mpz_init(point_t.y);
mpz_init(temp);
m = mpz_get_ui(M);
mpz_init_set(P.x,G.x);
mpz_init_set(P.y,G.y);
p_file = fopen(argv[2],"wb");
if(p_file == NULL) {
printf("Can't create file %s\n",argv[2]);
exit(0);
}
/*
fseek(p_file, 0L, SEEK_END);
sz = ftell(p_file);
if(sz % 32 != 0) {
printf("Invalid filesize\n");
exit(0);
}
printf("Current numeber of items %li\n",(long int)(sz/32));
if(m <= sz/32 ) {
printf("The current file have %li items\n",m);
}
else {
i = m-(sz/32);
printf("OK, items missing %li\n",i);
}
mpz_set_ui(temp,i)
*/
i = 0;
printf("[+] precalculating %li bP elements in file %s\n",m,argv[2]);
do {
mpz_set(point_t.x,P.x);
mpz_set(point_t.y,P.y);
gmp_sprintf(temporal,"%0.64Zx",P.x);
hexs2bin(temporal,(unsigned char *)rawvalue);
fwrite(rawvalue,1,32,p_file);
Point_Addition(&G,&point_t,&P);
i++;
} while(i < m);
}
void Point_Doubling(struct Point *P, struct Point *R) {
mpz_t slope, temp;
mpz_init(temp);
mpz_init(slope);
if(mpz_cmp_ui(P->y, 0) != 0) {
mpz_mul_ui(temp, P->y, 2);
mpz_invert(temp, temp, EC.p);
mpz_mul(slope, P->x, P->x);
mpz_mul_ui(slope, slope, 3);
mpz_mul(slope, slope, temp);
mpz_mod(slope, slope, EC.p);
mpz_mul(R->x, slope, slope);
mpz_sub(R->x, R->x, P->x);
mpz_sub(R->x, R->x, P->x);
mpz_mod(R->x, R->x, EC.p);
mpz_sub(temp, P->x, R->x);
mpz_mul(R->y, slope, temp);
mpz_sub(R->y, R->y, P->y);
mpz_mod(R->y, R->y, EC.p);
} else {
mpz_set_ui(R->x, 0);
mpz_set_ui(R->y, 0);
}
mpz_clear(temp);
mpz_clear(slope);
}
void Point_Addition(struct Point *P, struct Point *Q, struct Point *R) {
mpz_t PA_temp,PA_slope;
mpz_init(PA_temp);
mpz_init(PA_slope);
mpz_mod(Q->x, Q->x, EC.p);
mpz_mod(Q->y, Q->y, EC.p);
mpz_mod(P->x, P->x, EC.p);
mpz_mod(P->y, P->y, EC.p);
if(mpz_cmp_ui(P->x, 0) == 0 && mpz_cmp_ui(P->y, 0) == 0) {
mpz_set(R->x, Q->x);
mpz_set(R->y, Q->y);
}
else {
/* This is commented because Q never 0,0, always is kG point*/
/*
if(mpz_cmp_ui(Q->x, 0) == 0 && mpz_cmp_ui(Q->y, 0) == 0) {
mpz_set(R->x, P->x);
mpz_set(R->y, P->y);
}
else {
*/
if(mpz_cmp_ui(Q->y, 0) != 0) {
mpz_sub(PA_temp, EC.p, Q->y);
mpz_mod(PA_temp, PA_temp, EC.p);
}
else {
mpz_set_ui(PA_temp, 0);
}
if(mpz_cmp(P->y, PA_temp) == 0 && mpz_cmp(P->x, Q->x) == 0) {
mpz_set_ui(R->x, 0);
mpz_set_ui(R->y, 0);
}
else {
if(mpz_cmp(P->x, Q->x) == 0 && mpz_cmp(P->y, Q->y) == 0) {
Point_Doubling(P, R);
}
else {
mpz_set_ui(PA_slope, 0);
mpz_sub(PA_temp, P->x, Q->x);
mpz_mod(PA_temp, PA_temp, EC.p);
mpz_invert(PA_temp, PA_temp, EC.p);
mpz_sub(PA_slope, P->y, Q->y);
mpz_mul(PA_slope, PA_slope, PA_temp);
mpz_mod(PA_slope, PA_slope, EC.p);
mpz_mul(R->x, PA_slope, PA_slope);
mpz_sub(R->x, R->x, P->x);
mpz_sub(R->x, R->x, Q->x);
mpz_mod(R->x, R->x, EC.p);
mpz_sub(PA_temp, P->x, R->x);
mpz_mul(R->y, PA_slope, PA_temp);
mpz_sub(R->y, R->y, P->y);
mpz_mod(R->y, R->y, EC.p);
}
}
//}
}
mpz_clear(PA_temp);
mpz_clear(PA_slope);
}
void Scalar_Multiplication(struct Point P, struct Point *R, mpz_t m) {
char strtemp[65];
struct Point SM_T,SM_Q;
long no_of_bits, i;
no_of_bits = mpz_sizeinbase(m, 2);
mpz_init_set_ui(SM_Q.x,0);
mpz_init_set_ui(SM_Q.y,0);
mpz_init_set_ui(SM_T.x,0);
mpz_init_set_ui(SM_T.y,0);
mpz_set_ui(R->x, 0);
mpz_set_ui(R->y, 0);
if(mpz_cmp_ui(m, 0) != 0) {
mpz_set(SM_Q.x, P.x);
mpz_set(SM_Q.y, P.y);
for(i = 0; i < no_of_bits; i++) {
if(mpz_tstbit(m, i)) {
mpz_set(SM_T.x, R->x);
mpz_set(SM_T.y, R->y);
mpz_set(SM_Q.x,DoublingG[i].x);
mpz_set(SM_Q.y,DoublingG[i].y);
Point_Addition(&SM_T, &SM_Q, R);
}
}
}
mpz_clear(SM_T.x);
mpz_clear(SM_T.y);
mpz_clear(SM_Q.x);
mpz_clear(SM_Q.y);
}
void Point_Negation(struct Point *A, struct Point *S) {
mpz_sub(S->y, EC.p, A->y);
mpz_set(S->x, A->x);
}
void init_doublingG(struct Point *P) {
int i = 0;
mpz_init(DoublingG[i].x);
mpz_init(DoublingG[i].y);
mpz_set(DoublingG[i].x,P->x);
mpz_set(DoublingG[i].y,P->y);
i = 1;
while(i < 256){
mpz_init(DoublingG[i].x);
mpz_init(DoublingG[i].y);
Point_Doubling(&DoublingG[i-1] ,&DoublingG[i]);
mpz_mod(DoublingG[i].x, DoublingG[i].x, EC.p);
mpz_mod(DoublingG[i].y, DoublingG[i].y, EC.p);
i++;
}
}

View File

@ -29,7 +29,7 @@
#define STRING(n) #n
#define BLOOM_MAGIC "libbloom2"
#define BLOOM_VERSION_MAJOR 2
#define BLOOM_VERSION_MINOR 1
#define BLOOM_VERSION_MINOR 200
inline static int test_bit_set_bit(unsigned char * buf, uint64_t bit, int set_bit)
{
@ -105,7 +105,12 @@ int bloom_init2(struct bloom * bloom, uint64_t entries, long double error)
}
bloom->hashes = (uint8_t)ceil(0.693147180559945 * bloom->bpe); // ln(2)
/*
printf("\nBPE: %lu\n",bloom->bpe);
printf("BITS: %lu\n",bloom->bits);
printf("BYTES: %lu\n",bloom->bytes);
*/
bloom->bf = (uint8_t *)calloc(bloom->bytes, sizeof(uint8_t));
if (bloom->bf == NULL) { // LCOV_EXCL_START
return 1;

View File

@ -37,6 +37,8 @@ struct bloom
uint8_t major;
uint8_t minor;
double bpe;
uint8_t checksum[32];
uint8_t checksum_backup[32];
uint8_t *bf;
pthread_mutex_t mutex;
};

3043
keyhunt.c

File diff suppressed because it is too large Load Diff

View File

@ -231,6 +231,7 @@ Point Secp256K1::AddDirect(Point &p1,Point &p2) {
return r;
}
Point Secp256K1::Add2(Point &p1, Point &p2) {
// P2.z = 1
Int u;

Binary file not shown.

View File

@ -1,42 +0,0 @@
/*
gcc -o test test.c
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#include <cstring>
#include "SECP256k1.h"
#include "Point.h"
#include "Int.h"
#include "util.h"
Secp256K1 *secp;
int main() {
char dst[32];
Int key;
char *test;
secp = new Secp256K1();
key = new Int();
secp->Init();
Point punto;
bool parity;
if(secp->ParsePublicKeyHex((char*)"04ceb6cbbcdbdf5ef7150682150f4ce2c6f4807b349827dcdbdd1f2efa885a26302b195386bea3f5f002dc033b92cfc2c9e71b586302b09cfe535e1ff290b1b5ac",punto,parity)) {
test = punto.x.GetBase16();
printf("%s\n",test);
free(test);
test = punto.y.GetBase16();
printf("%s\n",test);
free(test);
}
else {
printf("Is not a valid point");
}
printf("%i\n",sizeof(Point));
punto.x.Get32Bytes((unsigned char*)dst);
test = tohex(dst,32);
printf("%s\n",test);
free(test);
}

View File

@ -52,7 +52,7 @@ explicit_memset(void *buf, int c, size_t n)
static inline uint64_t
le64dec(const void *buf)
{
const uint8_t *p = buf;
const uint8_t *p = (const uint8_t *)buf;
return (((uint64_t)p[0]) |
((uint64_t)p[1] << 8) |
@ -67,7 +67,7 @@ le64dec(const void *buf)
static inline void
le64enc(void *buf, uint64_t v)
{
uint8_t *p = buf;
uint8_t *p = (uint8_t *)buf;
*p++ = v; v >>= 8;
*p++ = v; v >>= 8;
@ -437,7 +437,7 @@ KECCAK_512_Final(uint8_t h[SHA3_512_DIGEST_LENGTH], SHA3_512_CTX *C)
static void
sha3_selftest_prng(void *buf, size_t len, uint32_t seed)
{
uint8_t *p = buf;
uint8_t *p = (uint8_t *)buf;
size_t n = len;
uint32_t t, a, b;

2
tests/63.pub Normal file
View File

@ -0,0 +1,2 @@
0365ec2994b8cc0a20d40dd69edfe55ca32a54bcbbaa6b0ddcff36049301a54579

17
tests/in.txt Normal file
View File

@ -0,0 +1,17 @@
0459A3BFDAD718C9D3FAC7C187F1139F0815AC5D923910D516E186AFDA28B221DC994327554CED887AAE5D211A2407CDD025CFC3779ECB9C9D7F2F1A1DDF3E9FF8
04A50FBBB20757CC0E9C41C49DD9DF261646EE7936272F3F68C740C9DA50D42BCD3E48440249D6BC78BC928AA52B1921E9690EBA823CBC7F3AF54B3707E6A73F34
0404A49211C0FE07C9F7C94695996F8826E09545375A3CF9677F2D780A3EB70DE3BD05357CAF8340CB041B1D46C5BB6B88CD9859A083B0804EF63D498B29D31DD1
040B39E3F26AF294502A5BE708BB87AEDD9F895868011E60C1D2ABFCA202CD7A4D1D18283AF49556CF33E1EA71A16B2D0E31EE7179D88BE7F6AA0A7C5498E5D97F
04837A31977A73A630C436E680915934A58B8C76EB9B57A42C3C717689BE8C0493E46726DE04352832790FD1C99D9DDC2EE8A96E50CAD4DCC3AF1BFB82D51F2494
040ECDB6359D41D2FD37628C718DDA9BE30E65801A88A00C3C5BDF36E7EE6ADBBAD71A2A535FCB54D56913E7F37D8103BA33ED6441D019D0922AC363FCC792C29A
0422DD52FCFA3A4384F0AFF199D019E481D335923D8C00BADAD42FFFC80AF8FCF038F139D652842243FC841E7C5B3E477D901F88C5AB0B88EE13D80080E413F2ED
04DB4F1B249406B8BD662F78CBA46F5E90E20FE27FC69D0FBAA2F06E6E50E536695DF83B68FD0F396BB9BFCF6D4FE312F32A43CF3FA1FE0F81DF70C877593B64E0
043BD0330D7381917F8860F1949ACBCCFDC7863422EEE2B6DB7EDD551850196687528B6D2BC0AA7A5855D168B26C6BAF9DDCD04B585D42C7B9913F60421716D37A
04332A02CA42C481EAADB7ADB97DF89033B23EA291FDA809BEA3CE5C3B73B20C49C410D1AD42A9247EB8FF217935C9E28411A08B325FBF28CC2AF8182CE2B5CE38
04513981849DE1A1327DEF34B51F5011C5070603CA22E6D868263CB7C908525F0C19EBA6BD2A8DCF651E4342512EDEACB6EA22DA323A194E25C6A1614ABD259BC0
04D4E6FA664BD75A508C0FF0ED6F2C52DA2ADD7C3F954D9C346D24318DBD2ECFC6805511F46262E10A25F252FD525AF1CBCC46016B6CD0A7705037364309198DA1
0456B468963752924DBF56112633DC57F07C512E3671A16CD7375C58469164599D1E04011D3E9004466C814B144A9BCB7E47D5BACA1B90DA0C4752603781BF5873
04D5BE7C653773CEE06A238020E953CFCD0F22BE2D045C6E5B4388A3F11B4586CBB4B177DFFD111F6A15A453009B568E95798B0227B60D8BEAC98AF671F31B0E2B
04B1985389D8AB680DEDD67BBA7CA781D1A9E6E5974AAD2E70518125BAD5783EB5355F46E927A030DB14CF8D3940C1BED7FB80624B32B349AB5A05226AF15A2228
0455B95BEF84A6045A505D015EF15E136E0A31CC2AA00FA4BCA62E5DF215EE981B3B4D6BCE33718DC6CF59F28B550648D7E8B2796AC36F25FF0C01F8BC42A16FD9

11
util.c
View File

@ -108,6 +108,17 @@ char *tohex(char *ptr,int length){
return buffer;
}
void tohex_dst(char *ptr,int length,char *dst) {
int offset = 0;
unsigned char c;
for (int i = 0; i <length; i++) {
c = ptr[i];
sprintf((char*) (dst + offset),"%.2x",c);
offset+=2;
}
dst[length*2] = 0;
}
int hexs2bin(char *hex, unsigned char *out) {
int len;
char b1;

1
util.h
View File

@ -21,6 +21,7 @@ int indexOf(char *s,const char **array,int length_array);
int hexchr2bin(char hex, char *out);
int hexs2bin(char *hex, unsigned char *out);
char *tohex(char *ptr,int length);
void tohex_dst(char *ptr,int length,char *dst);
int hasMoreTokens(Tokenizer *t);
char *nextToken(Tokenizer *t);