Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added candy #283

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
c68e662
Read CHANGELOG.md to see the updates
albertobsd Apr 28, 2023
765f23d
Fixed README.md
albertobsd Apr 28, 2023
63aa8fb
some fixes, check CHANGELOG.md
albertobsd Apr 30, 2023
e5d093f
Update keyhunt.cpp
seega May 4, 2023
65987aa
Update Random.cpp
seega May 4, 2023
f08dff0
Merge pull request #208 from seega/main
albertobsd May 4, 2023
d3d9ef6
cygwin fix v2
seega May 6, 2023
ec56e1f
cygwin fix
seega May 6, 2023
0253114
Revert "cygwin fix"
seega May 6, 2023
6a25033
Update Random.cpp
seega May 6, 2023
1cce3bb
Merge pull request #210 from seega/main
albertobsd May 7, 2023
d29ea17
added option -6 to skip checksums, check CHANGELOG.md
albertobsd May 7, 2023
8d54417
Update keyhunt.cpp
seega May 7, 2023
dfb710b
Merge pull request #212 from seega/main
albertobsd May 7, 2023
8a51838
Added warning for BSGS and Endomorphism, they don't work together
albertobsd May 8, 2023
5a8d6c0
Update README.md
mysterek1337 May 12, 2023
84330e6
Merge pull request #213 from mysterek1337/main
albertobsd May 12, 2023
a278e8c
added keyhunt_legacy.cpp legacy version, check README.md
albertobsd May 16, 2023
98b20ef
removed unused flags in the Makefile
albertobsd May 16, 2023
dddd177
fixed some bugs for legacy version
albertobsd May 17, 2023
3cd3376
Small editions of unused variables
albertobsd May 17, 2023
f92555a
endomorphism for eth
albertobsd May 18, 2023
88934c8
endomorphism for eth in legacy version
albertobsd May 18, 2023
d345a3c
Speed x2 for BSGS mode main
albertobsd May 19, 2023
2b3c218
Double BSGS speed for legacy version
albertobsd May 20, 2023
e3c6762
BSGS Server (Only linux)
albertobsd May 30, 2023
a19a745
Solving some BSGS Server issues
albertobsd Jun 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ bPfile
hexcharstoraw
*.bin
keyhunt
bsgsd
KEYFOUNDKEYFOUND.txt
VANITYKEYFOUND.txt
*.dat
*.tbl
*.blm

Expand Down
164 changes: 164 additions & 0 deletions BSGSD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
# 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
- `-i ip` IP for listening default is `127.0.0.1`
- `-p port` Port for listening default is `8080`

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

Here is a small python example to implent by your self as client.

```
import socket
import time

def send_and_receive_line(host, port, message):
# Create a TCP socket
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

try:
# Connect to the server
sock.connect((host, port))

# Send the message
start_time = time.time()
sock.sendall(message.encode())

# Receive the reply
reply = sock.recv(1024).decode()
end_time = time.time()

# Calculate the elapsed time
elapsed_time = end_time - start_time
sock.close()
return reply, elapsed_time

except ConnectionResetError:
print("Server closed the connection without replying.")
return None, None

except ConnectionRefusedError:
print("Connection refused. Make sure the server is running and the host/port are correct.")
return None, None

except AttributeError:
pass
return None, None


# TCP connection details
host = 'localhost' # Change this to the server's hostname or IP address
port = 8080 # Change this to the server's port number

# Message to send
message = '0365ec2994b8cc0a20d40dd69edfe55ca32a54bcbbaa6b0ddcff36049301a54579 4000000000000000:8000000000000000'

# Number of iterations in the loop
num_iterations = 5

# Loop for sending and receiving messages
for i in range(num_iterations):
reply, elapsed_time = send_and_receive_line(host, port, message)
if reply is not None:
print(f'Received reply: {reply}')
print(f'Elapsed time: {elapsed_time} seconds')
```

The previous client example only repeat 5 times the same target, change it according to your needs.
24 changes: 23 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
# 0.2.211117 SSE Trick or treat ¡Beta!
# Version 0.2.230519 Satoshi Quest
- Speed x2 in BSGS mode for main version

# Version 0.2.230507 Satoshi Quest
- fixed some variables names
- fixed bug in addvanity (realloc problem with dirty memory)
- Added option -6 to skip SHA256 checksum when you read the files (Improved startup process)
- Added warning when you Endomorphism and BSGS, THEY DON'T WORK together!
- Legacy version for ARM processor and other systems
- remove pub2rmd

# Version 0.2.230430 Satoshi Quest
- fixed typos in README
- Speed counter fixed for Compress search without endomorphism check https://github.com/albertobsd/keyhunt/tree/development#Speeds

# Version 0.2.230428 Satoshi Quest
- Merge of address and rmd160 speeds
- Added option for endomorphism
- Added SAVE bloom filter and table option for adddress, rmd160, minikeys and xpoint
- Improved Makefile options
- Updated random function to use the Linux RNG with the function getrandom

# Version 0.2.211117 SSE Trick or treat ¡Beta!
- Minikeys new sequential generator and x2 times more speed
- third bloom filter check for bsgs 20% less memory usage

Expand Down
78 changes: 58 additions & 20 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,23 +1,61 @@
default:
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -flto -c oldbloom/bloom.cpp -o oldbloom.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -flto -c bloom/bloom.cpp -o bloom.o
gcc -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c base58/base58.c -o base58.o
gcc -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c rmd160/rmd160.c -o rmd160.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c sha3/sha3.c -o sha3.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c sha3/keccak.c -o keccak.o
gcc -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c xxhash/xxhash.c -o xxhash.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c util.c -o util.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c secp256k1/Int.cpp -o Int.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c secp256k1/Point.cpp -o Point.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c secp256k1/SECP256K1.cpp -o SECP256K1.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -c secp256k1/IntMod.cpp -o IntMod.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -flto -c secp256k1/Random.cpp -o Random.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -flto -c secp256k1/IntGroup.cpp -o IntGroup.o
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -o hash/ripemd160.o -ftree-vectorize -flto -c hash/ripemd160.cpp
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -o hash/sha256.o -ftree-vectorize -flto -c hash/sha256.cpp
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -o hash/ripemd160_sse.o -ftree-vectorize -flto -c hash/ripemd160_sse.cpp
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -o hash/sha256_sse.o -ftree-vectorize -flto -c hash/sha256_sse.cpp
g++ -m64 -march=native -mtune=native -mssse3 -Wno-unused-result -Wno-write-strings -Ofast -ftree-vectorize -o keyhunt keyhunt.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
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 keyhunt keyhunt.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
clean:
rm keyhunt
rm keyhunt
legacy:
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
Loading