mirror of
https://github.com/albertobsd/keyhunt.git
synced 2025-03-17 13:21:46 +01:00
BSGS Server (Only linux)
This commit is contained in:
parent
ad236ddf66
commit
2edbebf862
1
.gitignore
vendored
1
.gitignore
vendored
@ -2,6 +2,7 @@ bPfile
|
||||
hexcharstoraw
|
||||
*.bin
|
||||
keyhunt
|
||||
bsgsd
|
||||
KEYFOUNDKEYFOUND.txt
|
||||
VANITYKEYFOUND.txt
|
||||
*.dat
|
||||
|
103
BSGSD.md
Normal file
103
BSGSD.md
Normal file
@ -0,0 +1,103 @@
|
||||
# BSGSD
|
||||
|
||||
`BSGS` method but as local `server`, final `D` stand for daemon.
|
||||
|
||||
### Compilation
|
||||
Same as keyhunt we need to do
|
||||
```make bsgsd```
|
||||
|
||||
### Parameters
|
||||
|
||||
- `-6` To skip file checksum
|
||||
- `-t number` Threads Number
|
||||
- `-k factor` Same K factor dor keyhunt
|
||||
- `-n number` Length of the Range to scan each cycle, same as keyhunt
|
||||
|
||||
bsgsd use the same keyhunt files `.blm` and `.tbl`
|
||||
|
||||
### Server
|
||||
This program is an small and custom server without any protocol.
|
||||
By default the server only listen on `localhost` port `8080`
|
||||
```
|
||||
localhost:8080
|
||||
```
|
||||
Tha main advantage of this server is that BSGS blooms and table are always on RAM
|
||||
Clients need to send a single line and wait for reply
|
||||
|
||||
Format of the client request:
|
||||
```
|
||||
<publickey> <range from>:<range to>
|
||||
```
|
||||
example puzzle 63
|
||||
|
||||
```
|
||||
0365ec2994b8cc0a20d40dd69edfe55ca32a54bcbbaa6b0ddcff36049301a54579 4000000000000000:8000000000000000
|
||||
```
|
||||
The search is done Sequentialy Client need to knows more o less the time expect time to solve.
|
||||
|
||||
The server only reply one single line. Client must read that line and proceed according its content, possible replies:
|
||||
|
||||
- `404 Not Found` if the key wasn't in the given range
|
||||
- `400 Bad Request`if there is some error on client request
|
||||
- `value` hexadecimal value with the Private KEY in case of be found
|
||||
|
||||
The server will close the Conection inmediatly after send that line, also in case some other error the server will close the Conection without send any error message. Client need to hadle the Conection status by his own.
|
||||
|
||||
### Example
|
||||
|
||||
Run the server in one terminal:
|
||||
```
|
||||
./bsgsd -k 4096 -t 8 -6
|
||||
[+] Version 0.2.230519 Satoshi Quest, developed by AlbertoBSD
|
||||
[+] K factor 4096
|
||||
[+] Threads : 8
|
||||
[W] Skipping checksums on files
|
||||
[+] Mode BSGS secuential
|
||||
[+] N = 0x100000000000
|
||||
[+] Bloom filter for 17179869184 elements : 58890.60 MB
|
||||
[+] Bloom filter for 536870912 elements : 1840.33 MB
|
||||
[+] Bloom filter for 16777216 elements : 57.51 MB
|
||||
[+] Allocating 256.00 MB for 16777216 bP Points
|
||||
[+] Reading bloom filter from file keyhunt_bsgs_4_17179869184.blm .... Done!
|
||||
[+] Reading bloom filter from file keyhunt_bsgs_6_536870912.blm .... Done!
|
||||
[+] Reading bP Table from file keyhunt_bsgs_2_16777216.tbl .... Done!
|
||||
[+] Reading bloom filter from file keyhunt_bsgs_7_16777216.blm .... Done!
|
||||
[+] Listening in 127.0.0.1:8080
|
||||
```
|
||||
Once that you see `[+] Listening in 127.0.0.1:8080` the server is ready to process client requests
|
||||
|
||||
Now we can connect it in annother terminal with `netcat` as client, this server is `64 GB` ram, expected time for puzzle 63 `~8` Seconds
|
||||
|
||||
command:
|
||||
```
|
||||
time echo "0365ec2994b8cc0a20d40dd69edfe55ca32a54bcbbaa6b0ddcff36049301a54579 4000000000000000:8000000000000000" | nc -v localhost 8080
|
||||
```
|
||||
```
|
||||
time echo "0365ec2994b8cc0a20d40dd69edfe55ca32a54bcbbaa6b0ddcff36049301a54579 4000000000000000:8000000000000000" | nc -v localhost 8080
|
||||
localhost.localdomain [127.0.0.1] 8080 (http-alt) open
|
||||
7cce5efdaccf6808
|
||||
real 0m7.551s
|
||||
user 0m0.002s
|
||||
sys 0m0.001s
|
||||
```
|
||||
If you notice the answer from the server is `7cce5efdaccf6808`
|
||||
|
||||
**Other example `404 Not Found`:**
|
||||
|
||||
```
|
||||
time echo "0233709eb11e0d4439a729f21c2c443dedb727528229713f0065721ba8fa46f00e 4000000000000000:8000000000000000" | nc -v localhost 8080
|
||||
localhost.localdomain [127.0.0.1] 8080 (http-alt) open
|
||||
404 Not Found
|
||||
real 0m7.948s
|
||||
user 0m0.003s
|
||||
sys 0m0.000s
|
||||
```
|
||||
|
||||
### One client at the time
|
||||
To maximize the Speed of BSGS this server only attends one client at the time.
|
||||
I know what are you thinking, but if you are doing 10 ranges of 63 bits, you can send only one range and the time and the program only will take 80 seconds (Based on the speed of the previous example).
|
||||
|
||||
But if i do the program multi-client, and you send the 10 ranges at the same time in 10 different connections, the whole process will also take 80 seconds... so is only question of how your client send the data and manage the ranges..
|
||||
|
||||
### Client
|
||||
**There is public NO client**, i think that this is fair, I already write a lot of code for free, if this server fits your needs write your on client on python or any other langue that you like.
|
51
Makefile
51
Makefile
@ -22,19 +22,40 @@ default:
|
||||
clean:
|
||||
rm keyhunt
|
||||
legacy:
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -flto -c oldbloom/bloom.cpp -o oldbloom.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -flto -c bloom/bloom.cpp -o bloom.o
|
||||
gcc -march=native -mtune=native -Wno-unused-result -Ofast -g -ftree-vectorize -c base58/base58.c -o base58.o
|
||||
gcc -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c xxhash/xxhash.c -o xxhash.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c util.c -o util.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c sha3/sha3.c -o sha3.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c sha3/keccak.c -o keccak.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c hashing.c -o hashing.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c gmp256k1/Int.cpp -o Int.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c gmp256k1/Point.cpp -o Point.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c gmp256k1/GMP256K1.cpp -o GMP256K1.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -c gmp256k1/IntMod.cpp -o IntMod.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -flto -c gmp256k1/Random.cpp -o Random.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -flto -c gmp256k1/IntGroup.cpp -o IntGroup.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -g -ftree-vectorize -o keyhunt keyhunt_legacy.cpp base58.o bloom.o oldbloom.o xxhash.o util.o Int.o Point.o GMP256K1.o IntMod.o IntGroup.o Random.o hashing.o sha3.o keccak.o -lm -lpthread -lcrypto -lgmp
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -flto -c oldbloom/bloom.cpp -o oldbloom.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -flto -c bloom/bloom.cpp -o bloom.o
|
||||
gcc -march=native -mtune=native -Wno-unused-result -Ofast -ftree-vectorize -c base58/base58.c -o base58.o
|
||||
gcc -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c xxhash/xxhash.c -o xxhash.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c util.c -o util.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c sha3/sha3.c -o sha3.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c sha3/keccak.c -o keccak.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c hashing.c -o hashing.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/Int.cpp -o Int.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/Point.cpp -o Point.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/GMP256K1.cpp -o GMP256K1.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/IntMod.cpp -o IntMod.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -flto -c gmp256k1/Random.cpp -o Random.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -flto -c gmp256k1/IntGroup.cpp -o IntGroup.o
|
||||
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -o keyhunt keyhunt_legacy.cpp base58.o bloom.o oldbloom.o xxhash.o util.o Int.o Point.o GMP256K1.o IntMod.o IntGroup.o Random.o hashing.o sha3.o keccak.o -lm -lpthread -lcrypto -lgmp
|
||||
rm -r *.o
|
||||
bsgsd:
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -flto -c oldbloom/bloom.cpp -o oldbloom.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -flto -c bloom/bloom.cpp -o bloom.o
|
||||
gcc -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-unused-parameter -Ofast -ftree-vectorize -c base58/base58.c -o base58.o
|
||||
gcc -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Ofast -ftree-vectorize -c rmd160/rmd160.c -o rmd160.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -c sha3/sha3.c -o sha3.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -c sha3/keccak.c -o keccak.o
|
||||
gcc -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Ofast -ftree-vectorize -c xxhash/xxhash.c -o xxhash.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -c util.c -o util.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -c secp256k1/Int.cpp -o Int.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -c secp256k1/Point.cpp -o Point.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -c secp256k1/SECP256K1.cpp -o SECP256K1.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -c secp256k1/IntMod.cpp -o IntMod.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -flto -c secp256k1/Random.cpp -o Random.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -flto -c secp256k1/IntGroup.cpp -o IntGroup.o
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -o hash/ripemd160.o -ftree-vectorize -flto -c hash/ripemd160.cpp
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -o hash/sha256.o -ftree-vectorize -flto -c hash/sha256.cpp
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -o hash/ripemd160_sse.o -ftree-vectorize -flto -c hash/ripemd160_sse.cpp
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -o hash/sha256_sse.o -ftree-vectorize -flto -c hash/sha256_sse.cpp
|
||||
g++ -m64 -march=native -mtune=native -mssse3 -Wall -Wextra -Wno-deprecated-copy -Ofast -ftree-vectorize -o bsgsd bsgsd.cpp base58.o rmd160.o hash/ripemd160.o hash/ripemd160_sse.o hash/sha256.o hash/sha256_sse.o bloom.o oldbloom.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
|
||||
|
@ -62,7 +62,6 @@ Int::Int(const Int &value) {
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Int::Add(const uint64_t u64) {
|
||||
mpz_t value;
|
||||
char my_str_value[U64STRINGSIZE]; // 30 digits + null terminator
|
||||
@ -81,8 +80,7 @@ void Int::Add(const Int *a) {
|
||||
}
|
||||
|
||||
void Int::Add(const Int *a,const Int *b) {
|
||||
mpz_add(num,num,a->num);
|
||||
mpz_add(num,num,b->num);
|
||||
mpz_add(num,a->num,b->num);
|
||||
}
|
||||
|
||||
void Int::Sub(const uint32_t u32) {
|
||||
@ -103,8 +101,7 @@ void Int::Sub(Int *a) {
|
||||
}
|
||||
|
||||
void Int::Sub(Int *a, Int *b) {
|
||||
mpz_sub(num,num,a->num);
|
||||
mpz_sub(num,num,b->num);
|
||||
mpz_sub(num,a->num,b->num);
|
||||
}
|
||||
|
||||
void Int::Mult(Int *a) {
|
||||
@ -204,10 +201,6 @@ bool Int::IsOdd() {
|
||||
}
|
||||
|
||||
int Int::GetSize() {
|
||||
/*
|
||||
gmp_printf("GetSize of %Zi\n",num);
|
||||
fflush(stdout);
|
||||
*/
|
||||
int r = mpz_sizeinbase(num,2);
|
||||
if(r % 8 == 0)
|
||||
return (int)(r/8);
|
||||
@ -236,6 +229,14 @@ int Int::GetBit(uint32_t n) {
|
||||
return mpz_tstbit(num,n);
|
||||
}
|
||||
|
||||
void Int::SetBit(uint32_t n) {
|
||||
mpz_setbit(num,n);
|
||||
}
|
||||
|
||||
void Int::ClearBit(uint32_t n) {
|
||||
mpz_clrbit(num,n);
|
||||
}
|
||||
|
||||
|
||||
void Int::Get32Bytes(unsigned char *buff) {
|
||||
size_t count, size = this->GetSize();
|
||||
@ -255,24 +256,6 @@ unsigned char Int::GetByte(int n) {
|
||||
return buffer[n];
|
||||
}
|
||||
|
||||
/*
|
||||
void mpz_get_byte(mpz_t num, unsigned char* bytes, size_t index) {
|
||||
size_t num_bytes = (mpz_sizeinbase(num, 2) + 7) / 8; // Calculate the total number of bytes
|
||||
if (index < num_bytes) {
|
||||
mpz_export(bytes, NULL, 1, sizeof(unsigned char), 0, 0, num); // Export the mpz_t variable to bytes
|
||||
} else {
|
||||
// Handle invalid index
|
||||
printf("Error: Index out of range.\n");
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
unsigned char Int::GetByte(unsigned char *buff) {
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
char* Int::GetBase2() {
|
||||
return mpz_get_str(NULL,2,num);
|
||||
}
|
||||
|
@ -102,6 +102,10 @@ public:
|
||||
char* GetBase2();
|
||||
char* GetBase10();
|
||||
char* GetBase16();
|
||||
|
||||
|
||||
void SetBit(uint32_t n);
|
||||
void ClearBit(uint32_t n);
|
||||
/*
|
||||
char* GetBaseN(int n,const char *charset);
|
||||
char* GetBlockStr();
|
||||
@ -141,6 +145,7 @@ public:
|
||||
void ModMulK1(Int *a, Int *b);
|
||||
void ModMulK1(Int *a);
|
||||
void ModMulK1order(Int *a);
|
||||
void ModInvorder(); // this <- this^-1 (mod O)
|
||||
|
||||
void ModSquareK1(Int *a);
|
||||
void ModAddK1order(Int *a,Int *b);
|
||||
|
@ -99,7 +99,7 @@ void Int::ModDouble() {
|
||||
mpz_add(num,num,num);
|
||||
mpz_init_set(p,num);
|
||||
mpz_sub(p,p,_P.num);
|
||||
if(mpz_cmp(p,0) > 0) {
|
||||
if(mpz_cmp_ui(p,0) > 0) {
|
||||
mpz_set(num,p);
|
||||
}
|
||||
mpz_clear(p);
|
||||
@ -142,3 +142,7 @@ void Int::ModAddK1order(Int *a, Int *b) {
|
||||
if (mpz_cmp_ui(num,0) < 0 )
|
||||
mpz_add(num,num,_O->num);
|
||||
}
|
||||
|
||||
void Int::ModInvorder() {
|
||||
mpz_invert(num,num,_O->num);
|
||||
}
|
||||
|
@ -19,31 +19,13 @@
|
||||
#include <stdio.h>
|
||||
|
||||
Point::Point() {
|
||||
mpz_set_ui(x.num,0);
|
||||
mpz_set_ui(y.num,0);
|
||||
mpz_set_ui(z.num,0);
|
||||
|
||||
}
|
||||
|
||||
Point::Point(const Point &p) {
|
||||
|
||||
//char *ptrs[3];
|
||||
|
||||
mpz_set(x.num,p.x.num);
|
||||
mpz_set(y.num,p.y.num);
|
||||
mpz_set(z.num,p.z.num);
|
||||
/*
|
||||
ptrs[0] = x.GetBase16();
|
||||
ptrs[1] = y.GetBase16();
|
||||
ptrs[2] = z.GetBase16();
|
||||
printf("Point\n");
|
||||
printf("X: %s\n",ptrs[0]);
|
||||
printf("Y: %s\n",ptrs[1]);
|
||||
printf("Z: %s\n",ptrs[2]);
|
||||
printf("End Point\n");
|
||||
for(int i = 0; i<3; i++) {
|
||||
free(ptrs[i]);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
Point::Point(Int *cx,Int *cy,Int *cz) {
|
||||
@ -52,13 +34,6 @@ Point::Point(Int *cx,Int *cy,Int *cz) {
|
||||
mpz_set(z.num,cz->num);
|
||||
}
|
||||
|
||||
/*
|
||||
Point::Point(Int *cx, Int *cz) {
|
||||
x.Set(cx);
|
||||
z.Set(cz);
|
||||
}
|
||||
*/
|
||||
|
||||
void Point::Clear() {
|
||||
mpz_set_ui(x.num,0);
|
||||
mpz_set_ui(y.num,0);
|
||||
@ -103,7 +78,6 @@ Point& Point::operator=(const Point& other) {
|
||||
if (this == &other) {
|
||||
return *this;
|
||||
}
|
||||
//char *ptrs[3];
|
||||
// Assign the values from 'other' to the current object
|
||||
mpz_set(x.num,other.x.num);
|
||||
mpz_set(y.num,other.y.num);
|
||||
@ -113,6 +87,7 @@ Point& Point::operator=(const Point& other) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
/*
|
||||
void Point::print(const char *str) {
|
||||
char *ptrs[3];
|
||||
ptrs[0] = x.GetBase16();
|
||||
@ -126,4 +101,5 @@ void Point::print(const char *str) {
|
||||
for(int i = 0; i<3; i++) {
|
||||
free(ptrs[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
Loading…
x
Reference in New Issue
Block a user