Skip to content

With help from ChatGPT succeed to compile it on Mac M1  #268

Open
@bane77111

Description

If someone interested to run it on Mac m1 chip maybe it will work on m2 too, this is the changed Make file:

make legacy

CC = clang
CXX = clang++
CFLAGS = -Ofast -target arm64-apple-macos -arch arm64 -ftree-vectorize -flto
CXXFLAGS = -Ofast -target arm64-apple-macos -arch arm64 -ftree-vectorize -flto
LDFLAGS = -lm -lpthread -lcrypto -lgmp
RM = rm -f

# Specify the include path for OpenSSL
OPENSSL_INCLUDE = -I/opt/homebrew/Cellar/openssl@3/3.1.4/include
OPENSSL_LIB = -L/opt/homebrew/Cellar/openssl@3/3.1.4/lib -lssl -lcrypto

# Specify the include and library paths for GMP
GMP_INCLUDE := -I/opt/homebrew/include
GMP_LIB := -L/opt/homebrew/lib -lgmp

CFLAGS += $(OPENSSL_INCLUDE) $(GMP_INCLUDE)
CXXFLAGS += $(OPENSSL_INCLUDE) $(GMP_INCLUDE)
LDFLAGS += $(OPENSSL_LIB) $(GMP_LIB)

# Define the separator
SEPARATOR = ;

# List of GMP256K1 source files
GMP256K1_SRCS = gmp256k1/GMP256K1.cpp gmp256k1/Int.cpp gmp256k1/IntGroup.cpp gmp256k1/IntMod.cpp gmp256k1/Point.cpp gmp256k1/Random.cpp

legacy: ; \
    $(CXX) $(CXXFLAGS) -c oldbloom/bloom.cpp -o oldbloom.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c bloom/bloom.cpp -o bloom.o $(SEPARATOR) \
    $(CC) $(CFLAGS) -c base58/base58.c -o base58.o $(SEPARATOR) \
    $(CC) $(CFLAGS) -c xxhash/xxhash.c -o xxhash.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c util.c -o util.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c sha3/sha3.c -o sha3.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c sha3/keccak.c -o keccak.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c hashing.c -o hashing.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c gmp256k1/Int.cpp -o Int.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c gmp256k1/Point.cpp -o Point.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c gmp256k1/GMP256K1.cpp -o GMP256K1.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c gmp256k1/IntMod.cpp -o IntMod.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c gmp256k1/Random.cpp -o Random.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c gmp256k1/IntGroup.cpp -o IntGroup.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -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 $(LDFLAGS) $(SEPARATOR) \
    $(RM) *.o

bsgsd: ; \
    $(CXX) $(CXXFLAGS) -c oldbloom/bloom.cpp -o oldbloom.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c bloom/bloom.cpp -o bloom.o $(SEPARATOR) \
    $(CC) $(CFLAGS) -c base58/base58.c -o base58.o $(SEPARATOR) \
    $(CC) $(CFLAGS) -c rmd160/rmd160.c -o rmd160.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c sha3/sha3.c -o sha3.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c sha3/keccak.c -o keccak.o $(SEPARATOR) \
    $(CC) $(CFLAGS) -c xxhash/xxhash.c -o xxhash.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c util.c -o util.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c secp256k1/Int.cpp -o Int.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c secp256k1/Point.cpp -o Point.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c secp256k1/SECP256K1.cpp -o SECP256K1.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c secp256k1/IntMod.cpp -o IntMod.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c secp256k1/Random.cpp -o Random.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -c secp256k1/IntGroup.cpp -o IntGroup.o $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -o hash/ripemd160.o -c hash/ripemd160.cpp $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -o hash/sha256.o -c hash/sha256.cpp $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -o hash/ripemd160_sse.o -c hash/ripemd160_sse.cpp $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -o hash/sha256_sse.o -c hash/sha256_sse.cpp $(SEPARATOR) \
    $(CXX) $(CXXFLAGS) -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 $(LDFLAGS) $(SEPARATOR) \
    $(RM) *.o    

Before compale make sure to have all paths setup and you'll have to delete in file: gmp256k1/Random.cpp ; the line #include <linux/random.h>

I try it to run:

bane@Luse keyhunt % ./keyhunt -m bsgs -f tests/125.txt -R -b 125 -q -S -s 10

[+] Version 0.2.230519 Satoshi Quest (legacy), developed by AlbertoBSD

[+] Random mode

[+] Quiet thread output

[+] Stats output every 10 seconds

[+] Mode BSGS random

[+] Opening file tests/125.txt

[+] Added 1 points from file

[+] Bit Range 125

[+] -- from : 0x10000000000000000000000000000000

[+] -- to   : 0x20000000000000000000000000000000

[+] N = 0x100000000000

[+] Bloom filter for 4194304 elements : 14.38 MB

[+] Bloom filter for 131072 elements : 0.88 MB

[+] Bloom filter for 4096 elements : 0.88 MB

[+] Allocating 0.00 MB for 4096 bP Points

[+] processing 4194304/4194304 bP points : 100%     

[+] Making checkums .. ... done

[+] Sorting 4096 elements... Done!

[+] Writing bloom filter to file keyhunt_bsgs_4_4194304.blm .... Done!

[+] Writing bloom filter to file keyhunt_bsgs_6_131072.blm .... Done!

[+] Writing bP Table to file keyhunt_bsgs_2_4096.tbl .. Done!

[+] Writing bloom filter to file keyhunt_bsgs_7_4096.blm .... Done!

[+] Total 105553116266496 keys in 10 seconds: ~10 Tkeys/s (10555311626649 keys/s[+] Total 246290604621824 keys in 20 seconds: ~12 Tkeys/s (12314530231091 keys/s[+] Total 351843720888320 keys in 30 seconds: ~11 Tkeys/s (11728124029610 keys/s

And on my Mac works OK.
ps.
There is also an issue with legacy reading pub. keys, if you have uncompressed you'll get an error so you need to change it to compressed pub.key.

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions