From b48282a24a6c3a65f46c06713cf5fe61ff54fed1 Mon Sep 17 00:00:00 2001 From: PawelGorny Date: Mon, 24 Jan 2022 16:44:55 +0100 Subject: [PATCH] v 0.4.3, build for linux --- README.md | 23 ++++++++++++++++++----- WifSolverCuda/Makefile | 39 +++++++++++++++++++++++++++++++++++++++ WifSolverCuda/main.cu | 4 ++-- 3 files changed, 59 insertions(+), 7 deletions(-) create mode 100644 WifSolverCuda/Makefile diff --git a/README.md b/README.md index afc44a1..3fe77df 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ In my examples I will use WIF _5KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKSmn which produces address _19NzcPZvZMSNQk8sDbSiyjeKpEVpaS1212_ The expected private key is: _c59cb0997ad73f7bf8621b1955caf80b304ded0a48e5b8f28c7b8f9356ec35e5_ -Let's assume we have WIF with 5 missing characters _5KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK-----KKKSmnqY_ +Let's assume we have WIF with 5 missing characters _5KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK?????KKKSmnqY_ We must replace unknown characters by minimal characters from base58 encoding, to produce our starting key. WIF _5KKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKKK11111KKKSmnqY_ could be decoded to: 80c59cb0997ad73f7bf8621b1955caf80b304ded0a48e5b8f28c7b89f466ff5f68e2677283 @@ -57,24 +57,37 @@ Similar test for compressed WIF (target _Kzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz -stride 7479027ea100 -c -rangeStart 8070cfa0d40309798a5bd144a396478b5b5ae3305b7413601b18767654f1108a02787692623a -a 1PzaLTZS3J3HqGfsa8Z2jfkCT1QpSMVunD -For other of examples please see file /docs/examples.txt. +For other of examples please see the file /docs/examples.txt. Build ----- -Program was prepared using CUDA 11.6 - for other version manual change in VS project config files is needed. +Windows: + +Program was prepared using CUDA 11.6 - for any other version manual change in VS project config files is needed. + +Linux: + +Go to WifSolverCuda/ subfolder and execute _make all_. If your device does not support compute capability=86 (error "No kernel image is available for execution on the device"), do the change in _Makefile_ (for example 1080Ti requires COMPUTE_CAP=61). + Performance ----------- One's must modify number of blocks and number of threads in each block to find the ones which are the best for his card. Number of test performed by each thread also could have impact of global performance/latency. -Test card: RTX3060 (eGPU!) with 224 BLOCKS & 640 BLOCK_THREADS checks around 10000 MKey/s for compressed address with missing characters in the middle (collision with checksum) and around 1300-1400 Mkey/s for other cases; + +Test card: RTX3060 (eGPU!) with 224 BLOCKS & 640 BLOCK_THREADS (program default values) checks around 10000 MKey/s for compressed address with missing characters in the middle (collision with checksum) and around 1300-1400 Mkey/s for other cases; other results (using default values of blocks, threads and steps per thread): + +| card | compressed with collision | all other cases | +|---------------|---------------------------|-----------------| +| RTX 3060 eGPU | 10000 | 1300 | +| RTX 3090 | 29500 | 3450 | +| GTX 1080TI | 6000 | 600 | Please consult official Nvidia Occupancy Calculator (https://docs.nvidia.com/cuda/cuda-occupancy-calculator/index.html) to see how to select desired amount of threads (shared memory=0, registers per thread = 48). TODO ---- * code cleaning, review of hash functions -* build configuration for Linux * predefined custom step (using list of possible characters) * reading configuration from file diff --git a/WifSolverCuda/Makefile b/WifSolverCuda/Makefile new file mode 100644 index 0000000..bea181d --- /dev/null +++ b/WifSolverCuda/Makefile @@ -0,0 +1,39 @@ +CXX=g++ +CXXFLAGS=-std=c++11 -m64 -mssse3 -Wno-unused-result -Wno-write-strings -O2 -I. -I$(CUDA)/include + +COMPUTE_CAP=86 +NVCC=nvcc +CUDA_HOME=/usr/local/cuda +CUDA_LIB=${CUDA_HOME}/lib64 +CUDA_INCLUDE=${CUDA_HOME}/include +LFLAGS = -lpthread -L$(CUDA_HOME)/lib64 -lcudart +CXXCUDA = /usr/bin/g++ + +CUSRC:=$(wildcard *.cu) +MKDIR_P = mkdir -p +OBJDIR = obj + +all: + mkdir -p $(OBJDIR) + $(CXX) $(CXXFLAGS) -o $(OBJDIR)/ripemd160.o -c lib/hash/ripemd160.cpp + $(CXX) $(CXXFLAGS) -o $(OBJDIR)/ripemd160_sse.o -c lib/hash/ripemd160_sse.cpp + $(CXX) $(CXXFLAGS) -o $(OBJDIR)/sha256cpp.o -c lib/hash/sha256.cpp + $(CXX) $(CXXFLAGS) -o $(OBJDIR)/sha256_sse.o -c lib/hash/sha256_sse.cpp + gcc -O3 -c lib/base58.c -o $(OBJDIR)/base58.o + $(CXX) -O3 -c lib/util.cpp -o $(OBJDIR)/util.o + $(CXX) $(CXXFLAGS) -c lib/Int.cpp -o $(OBJDIR)/Int.o + $(CXX) $(CXXFLAGS) -c lib/Point.cpp -o $(OBJDIR)/Point.o + $(CXX) $(CXXFLAGS) -c lib/SECP256K1.cpp -o $(OBJDIR)/SECP256K1.o + $(CXX) $(CXXFLAGS) -c lib/IntGroup.cpp -o $(OBJDIR)/IntGroup.o + $(CXX) $(CXXFLAGS) -c lib/IntMod.cpp -o $(OBJDIR)/IntMod.o + + $(NVCC) --ptxas-options=-v -maxrregcount=0 --compile --compiler-options -fPIC -ccbin $(CXXCUDA) -m64 -O2 -I$(CUDA)/include -gencode=arch=compute_$(COMPUTE_CAP),code=sm_$(COMPUTE_CAP) -o $(OBJDIR)/sha256.o -c lib/hash/sha256.cu + $(NVCC) --ptxas-options=-v -maxrregcount=0 --compile --compiler-options -fPIC -ccbin $(CXXCUDA) -m64 -O2 -I$(CUDA)/include -gencode=arch=compute_$(COMPUTE_CAP),code=sm_$(COMPUTE_CAP) -o $(OBJDIR)/Worker1.o -c Worker1.cu + $(NVCC) --ptxas-options=-v -maxrregcount=0 --compile --compiler-options -fPIC -ccbin $(CXXCUDA) -m64 -O2 -I$(CUDA)/include -gencode=arch=compute_$(COMPUTE_CAP),code=sm_$(COMPUTE_CAP) -o $(OBJDIR)/main.o -c main.cu + + @echo Making WifSolver... + $(CXX) $(OBJDIR)/ripemd160.o $(OBJDIR)/ripemd160_sse.o $(OBJDIR)/sha256cpp.o $(OBJDIR)/sha256_sse.o $(OBJDIR)/base58.o $(OBJDIR)/util.o $(OBJDIR)/Int.o $(OBJDIR)/Point.o $(OBJDIR)/SECP256K1.o $(OBJDIR)/IntGroup.o $(OBJDIR)/IntMod.o $(OBJDIR)/sha256.o $(OBJDIR)/Worker1.o $(OBJDIR)/main.o $(LFLAGS) -o wifSolver + +clean: + @echo Cleaning... + @rm -f $(OBJDIR)/*.o \ No newline at end of file diff --git a/WifSolverCuda/main.cu b/WifSolverCuda/main.cu index fb7903a..9cfebec 100644 --- a/WifSolverCuda/main.cu +++ b/WifSolverCuda/main.cu @@ -60,7 +60,7 @@ Secp256K1* secp; int main(int argc, char** argv) { - printf("WifSolver 0.4.2\n\n"); + printf("WifSolver 0.4.3\n\n"); if (readArgs(argc, argv)) { showHelp(); @@ -279,7 +279,7 @@ void processCandidate(Int &toTest) { secp->GetHash160(P2PKH, COMPRESSED, publickey, (unsigned char*)rmdhash); addressToBase58(rmdhash, address); if (!TARGET_ADDRESS.empty()) { - if (TARGET_ADDRESS._Equal(address)) { + if (TARGET_ADDRESS == address) { RESULT = true; printf("\n"); printf("found: %s\n", address);