fixed some bugs for legacy version

This commit is contained in:
Alberto 2023-05-16 21:42:06 -06:00
parent f25e13be4a
commit d33bbe8795
8 changed files with 251 additions and 208 deletions

View File

@ -27,12 +27,14 @@ legacy:
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 hashing.c -o hashing.o -lcrypto
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/Int.cpp -o Int.o -lgmp
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/Point.cpp -o Point.o -lgmp
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/GMP256K1.cpp -o GMP256K1.o -lgmp
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -c gmp256k1/IntMod.cpp -o IntMod.o -lgmp
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -flto -c gmp256k1/Random.cpp -o Random.o -lgmp
g++ -march=native -mtune=native -Wall -Wextra -Ofast -ftree-vectorize -flto -c gmp256k1/IntGroup.cpp -o IntGroup.o -lgmp
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 -lm -lpthread -lcrypto -lgmp
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

View File

@ -44,7 +44,7 @@ Secp256K1::~Secp256K1() {
Point Secp256K1::Negation(Point &p) {
Point Q;
Q.Clear();
//Q.Clear();
Q.x.Set(&p.x);
Q.y.Set(&this->P);
Q.y.Sub(&p.y);
@ -562,10 +562,57 @@ void Secp256K1::GetHash160(int type, bool compressed, Point &pubKey, unsigned ch
void Secp256K1::GetHash160(int type,bool compressed,
Point &k0,Point &k1,Point &k2,Point &k3,
uint8_t *h0,uint8_t *h1,uint8_t *h2,uint8_t *h3) {
GetHash160(type,compressed,k0,h0);
GetHash160(type,compressed,k1,h1);
GetHash160(type,compressed,k2,h2);
GetHash160(type,compressed,k3,h3);
switch (type) {
case P2PKH:
case BECH32:
unsigned char digests[4][65];
if (!compressed) {
// Full public key
digests[0][0] = 0x4;
digests[1][0] = 0x4;
digests[2][0] = 0x4;
digests[3][0] = 0x4;
k0.x.Get32Bytes(digests[0] + 1);
k0.y.Get32Bytes(digests[0] + 33);
k1.x.Get32Bytes(digests[1] + 1);
k1.y.Get32Bytes(digests[1] + 33);
k2.x.Get32Bytes(digests[2] + 1);
k2.y.Get32Bytes(digests[2] + 33);
k3.x.Get32Bytes(digests[3] + 1);
k3.y.Get32Bytes(digests[3] + 33);
sha256_4(65, digests[0], digests[1],digests[2],digests[3],digests[0], digests[1],digests[2],digests[3]);
} else {
// Compressed public key
digests[0][0] = (unsigned char) k0.y.IsEven() ? 0x2 : 0x3;
digests[1][0] = (unsigned char) k1.y.IsEven() ? 0x2 : 0x3;
digests[2][0] = (unsigned char) k2.y.IsEven() ? 0x2 : 0x3;
digests[3][0] = (unsigned char) k3.y.IsEven() ? 0x2 : 0x3;
k0.x.Get32Bytes(digests[0] + 1);
k1.x.Get32Bytes(digests[1] + 1);
k2.x.Get32Bytes(digests[2] + 1);
k3.x.Get32Bytes(digests[3] + 1);
sha256_4(33, digests[0], digests[1],digests[2],digests[3],digests[0], digests[1],digests[2],digests[3]);
}
rmd160_4(32, digests[0], digests[1],digests[2],digests[3],h0,h1,h2,h3);
break;
case P2SH:
printf("Unsoported P2SH\n");
exit(0);
/*
// Redeem Script (1 to 1 P2SH)
unsigned char script[64];
script[0] = 0x00; // OP_0
script[1] = 0x14; // PUSH 20 bytes
GetHash160(P2PKH, compressed, pubKey, script + 2);
sha256(script, 22, shapk);
rmd160(shapk,32,hash);
*/
break;
}
}
@ -573,7 +620,7 @@ void Secp256K1::GetHash160_fromX(int type,unsigned char prefix,
Int *k0,Int *k1,Int *k2,Int *k3,
uint8_t *h0,uint8_t *h1,uint8_t *h2,uint8_t *h3) {
unsigned char digests[4][33];
int i;
//int i;
switch (type) {
case P2PKH:
@ -581,14 +628,14 @@ void Secp256K1::GetHash160_fromX(int type,unsigned char prefix,
k1->Get32Bytes((unsigned char*)(digests[1] + 1));
k2->Get32Bytes((unsigned char*)(digests[2] + 1));
k3->Get32Bytes((unsigned char*)(digests[3] + 1));
for(i = 0; i < 4; i++) {
digests[i][0] = prefix;
sha256(digests[i],33,digests[i]);
}
rmd160(digests[0],32,h0);
rmd160(digests[1],32,h1);
rmd160(digests[2],32,h2);
rmd160(digests[3],32,h3);
digests[0][0] = prefix;
digests[1][0] = prefix;
digests[2][0] = prefix;
digests[3][0] = prefix;
sha256_4(33, digests[0], digests[1],digests[2],digests[3],digests[0], digests[1],digests[2],digests[3]);
rmd160_4(32, digests[0], digests[1],digests[2],digests[3],h0,h1,h2,h3);
break;
case P2SH:

View File

@ -204,6 +204,10 @@ 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);
@ -281,13 +285,6 @@ char* Int::GetBase16() {
return mpz_get_str(NULL,16,num);
}
/*
char* Int::GetBaseN(int n,const char *charset);
char* Int::GetBlockStr();
char* Int::GetC64Str(int nbDigit);
*/
void Int::SetInt64(uint64_t value) {
char my_str_value[U64STRINGSIZE]; // 30 digits + null terminator
snprintf(my_str_value, U64STRINGSIZE, "%lu", value);

View File

@ -19,6 +19,9 @@
#include <stdio.h>
Point::Point() {
mpz_set_ui(x.num,0);
mpz_set_ui(y.num,0);
mpz_set_ui(z.num,0);
}
@ -87,22 +90,7 @@ void Point::Reduce() {
i.ModInv();
x.ModMul(&x,&i);
y.ModMul(&y,&i);
z.SetInt32(1);
/*
Yes, exactly. The Reduce function you mentioned converts the point from projective coordinates back to affine coordinates.
In elliptic curve computations, it's often more efficient to work with projective coordinates because they allow addition and doubling operations to be performed without needing to do division operations, which are computationally expensive.
However, at the end of your computation, or at certain intermediate stages, you might need to convert the point back to affine coordinates. That's what this Reduce function is doing.
Here's what each line in Reduce is doing:
Int i(&z); creates an integer i from the z coordinate of the point.
i.ModInv(); computes the modular inverse of i, effectively performing a division operation. Note that this operation is only valid if i is not zero.
x.ModMul(&x,&i); and y.ModMul(&y,&i); multiply the x and y coordinates by the modular inverse of z, effectively dividing them by z. This converts the x and y coordinates from projective back to affine coordinates.
z.SetInt32(1); sets the z coordinate to 1, completing the conversion to affine coordinates.
In the end, Reduce leaves the point in the form (X/Z, Y/Z, 1), which is equivalent to (X, Y) in affine coordinates.
*/
z.SetInt32(1);
}
bool Point::equals(Point &p) {
@ -120,19 +108,7 @@ Point& Point::operator=(const Point& other) {
mpz_set(x.num,other.x.num);
mpz_set(y.num,other.y.num);
mpz_set(z.num,other.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]);
}
*/
// Return the current object
return *this;
}

235
hashing.c
View File

@ -1,106 +1,116 @@
#include <openssl/evp.h>
#include <openssl/sha.h>
#include <openssl/ripemd.h>
#include <string.h>
#include <stdio.h>
#include "hashing.h"
#include "sha3/sha3.h"
int sha256(const unsigned char *data, size_t length, unsigned char *digest) {
EVP_MD_CTX *mdctx;
const EVP_MD *md;
md = EVP_sha256();
if(!md) {
printf("Unknown message digest sha256\n");
SHA256_CTX ctx;
if (SHA256_Init(&ctx) != 1) {
printf("Failed to initialize SHA256 context\n");
return 1;
}
mdctx = EVP_MD_CTX_new();
if(!mdctx) {
printf("Failed to create new EVP_MD_CTX\n");
}
if (SHA256_Update(&ctx, data, length) != 1) {
printf("Failed to update digest\n");
return 1;
}
if(EVP_DigestInit_ex(mdctx, md, NULL) != 1) {
printf("Failed to initialize EVP_Digest with sha256\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
if(EVP_DigestUpdate(mdctx, data, length) != 1) {
printf("Failed to update digest\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
unsigned int digest_len;
if(EVP_DigestFinal_ex(mdctx, digest, &digest_len) != 1) {
printf("Failed to finalize digest\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
EVP_MD_CTX_free(mdctx);
return 0; // Success
}
if (SHA256_Final(digest, &ctx) != 1) {
printf("Failed to finalize digest\n");
return 1;
}
return 0; // Success
}
int sha256_4(size_t length, const unsigned char *data0, const unsigned char *data1,
const unsigned char *data2, const unsigned char *data3,
unsigned char *digest0, unsigned char *digest1,
unsigned char *digest2, unsigned char *digest3) {
SHA256_CTX ctx[4];
if (SHA256_Init(&ctx[0]) != 1 || SHA256_Init(&ctx[1]) != 1 ||
SHA256_Init(&ctx[2]) != 1 || SHA256_Init(&ctx[3]) != 1) {
printf("Failed to initialize SHA256 contexts\n");
return 1;
}
if (SHA256_Update(&ctx[0], data0, length) != 1 ||
SHA256_Update(&ctx[1], data1, length) != 1 ||
SHA256_Update(&ctx[2], data2, length) != 1 ||
SHA256_Update(&ctx[3], data3, length) != 1) {
printf("Failed to update digests\n");
return 1;
}
if (SHA256_Final(digest0, &ctx[0]) != 1 ||
SHA256_Final(digest1, &ctx[1]) != 1 ||
SHA256_Final(digest2, &ctx[2]) != 1 ||
SHA256_Final(digest3, &ctx[3]) != 1) {
printf("Failed to finalize digests\n");
return 1;
}
return 0; // Success
}
// Function for hashing
int keccak(const unsigned char *data, size_t length, unsigned char *digest) {
EVP_MD_CTX *mdctx;
const EVP_MD *md;
md = EVP_get_digestbyname("keccak256");
if(!md) {
printf("Unknown message digest keccak256\n");
return 1;
}
mdctx = EVP_MD_CTX_new();
if(!mdctx) {
printf("Failed to create new EVP_MD_CTX\n");
return 1;
}
if(EVP_DigestInit_ex(mdctx, md, NULL) != 1) {
printf("Failed to initialize EVP_Digest with keccak256\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
if(EVP_DigestUpdate(mdctx, data, length) != 1) {
printf("Failed to update digest\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
unsigned int digest_len;
if(EVP_DigestFinal_ex(mdctx, digest, &digest_len) != 1) {
printf("Failed to finalize digest\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
EVP_MD_CTX_free(mdctx);
SHA3_256_CTX ctx;
SHA3_256_Init(&ctx);
SHA3_256_Update(&ctx,data,length);
KECCAK_256_Final(digest,&ctx);
return 0; // Success
}
int rmd160(const unsigned char *data, size_t length, unsigned char *digest) {
EVP_MD_CTX *mdctx;
const EVP_MD *md;
md = EVP_get_digestbyname("rmd160");
if(!md) {
printf("Unknown message digest rmd160\n");
RIPEMD160_CTX ctx;
if (RIPEMD160_Init(&ctx) != 1) {
printf("Failed to initialize RIPEMD-160 context\n");
return 1;
}
mdctx = EVP_MD_CTX_new();
if(!mdctx) {
printf("Failed to create new EVP_MD_CTX\n");
}
if (RIPEMD160_Update(&ctx, data, length) != 1) {
printf("Failed to update digest\n");
return 1;
}
if(EVP_DigestInit_ex(mdctx, md, NULL) != 1) {
printf("Failed to initialize EVP_Digest with rmd160\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
if(EVP_DigestUpdate(mdctx, data, length) != 1) {
printf("Failed to update digest\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
unsigned int digest_len;
if(EVP_DigestFinal_ex(mdctx, digest, &digest_len) != 1) {
printf("Failed to finalize digest\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
EVP_MD_CTX_free(mdctx);
return 0; // Success
}
if (RIPEMD160_Final(digest, &ctx) != 1) {
printf("Failed to finalize digest\n");
return 1;
}
return 0; // Success
}
int rmd160_4(size_t length, const unsigned char *data0, const unsigned char *data1,
const unsigned char *data2, const unsigned char *data3,
unsigned char *digest0, unsigned char *digest1,
unsigned char *digest2, unsigned char *digest3) {
RIPEMD160_CTX ctx[4];
if (RIPEMD160_Init(&ctx[0]) != 1 || RIPEMD160_Init(&ctx[1]) != 1 ||
RIPEMD160_Init(&ctx[2]) != 1 || RIPEMD160_Init(&ctx[3]) != 1) {
printf("Failed to initialize RIPEMD-160 contexts\n");
return 1;
}
if (RIPEMD160_Update(&ctx[0], data0, length) != 1 ||
RIPEMD160_Update(&ctx[1], data1, length) != 1 ||
RIPEMD160_Update(&ctx[2], data2, length) != 1 ||
RIPEMD160_Update(&ctx[3], data3, length) != 1) {
printf("Failed to update digests\n");
return 1;
}
if (RIPEMD160_Final(digest0, &ctx[0]) != 1 ||
RIPEMD160_Final(digest1, &ctx[1]) != 1 ||
RIPEMD160_Final(digest2, &ctx[2]) != 1 ||
RIPEMD160_Final(digest3, &ctx[3]) != 1) {
printf("Failed to finalize digests\n");
return 1;
}
return 0; // Success
}
bool sha256_file(const char* file_name, uint8_t* digest) {
@ -109,40 +119,31 @@ bool sha256_file(const char* file_name, uint8_t* digest) {
printf("Failed to open file: %s\n", file_name);
return false;
}
uint8_t buffer[8192]; // Buffer to read file contents
size_t bytes_read;
EVP_MD_CTX *mdctx;
const EVP_MD *md;
md = EVP_sha256();
if(!md) {
printf("Unknown message digest sha256\n");
SHA256_CTX ctx;
if (SHA256_Init(&ctx) != 1) {
printf("Failed to initialize SHA256 context\n");
fclose(file);
return false;
}
mdctx = EVP_MD_CTX_new();
if(!mdctx) {
printf("Failed to create new EVP_MD_CTX\n");
}
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file)) > 0) {
if (SHA256_Update(&ctx, buffer, bytes_read) != 1) {
printf("Failed to update digest\n");
fclose(file);
return false;
}
}
if (SHA256_Final(digest, &ctx) != 1) {
printf("Failed to finalize digest\n");
fclose(file);
return false;
}
if(EVP_DigestInit_ex(mdctx, md, NULL) != 1) {
printf("Failed to initialize EVP_Digest with sha256\n");
EVP_MD_CTX_free(mdctx);
return false;
}
// Read file contents and update SHA256 context
while ((bytes_read = fread(buffer, 1, sizeof(buffer), file)) > 0) {
if(EVP_DigestUpdate(mdctx, buffer, bytes_read) != 1) {
printf("Failed to update digest\n");
EVP_MD_CTX_free(mdctx);
return false;
}
}
unsigned int digest_len;
if(EVP_DigestFinal_ex(mdctx, digest, &digest_len) != 1) {
printf("Failed to finalize digest\n");
EVP_MD_CTX_free(mdctx);
return 1;
}
EVP_MD_CTX_free(mdctx);
fclose(file);
return true;
}
fclose(file);
return true;
}

View File

@ -1,12 +1,19 @@
#ifndef HASHSING
#define HASHSING
#include <openssl/evp.h>
#include <string.h>
int sha256(const unsigned char *data, size_t length, unsigned char *digest);
int rmd160(const unsigned char *data, size_t length, unsigned char *digest);
int keccak(const unsigned char *data, size_t length, unsigned char *digest);
bool sha256_file(const char* file_name, unsigned char * checksum);
int rmd160_4(size_t length, const unsigned char *data0, const unsigned char *data1,
const unsigned char *data2, const unsigned char *data3,
unsigned char *digest0, unsigned char *digest1,
unsigned char *digest2, unsigned char *digest3);
int sha256_4(size_t length, const unsigned char *data0, const unsigned char *data1,
const unsigned char *data2, const unsigned char *data3,
unsigned char *digest0, unsigned char *digest1,
unsigned char *digest2, unsigned char *digest3);
#endif // HASHSING

View File

@ -2115,6 +2115,7 @@ int main(int argc, char **argv) {
checkpointer((void *)tt,__FILE__,"malloc","tt" ,__LINE__ -1 );
tt->nt = i;
steps[i] = 0;
s = 0;
switch(FLAGMODE) {
#if defined(_WIN64) && !defined(__CYGWIN__)
case MODE_ADDRESS:
@ -2404,15 +2405,7 @@ void *thread_process_minikeys(void *vargp) {
do {
if(FLAGRANDOM) {
#if defined(_WIN64) && !defined(__CYGWIN__)
WaitForSingleObject(write_random, INFINITE);
counter.Rand(256);
ReleaseMutex(write_random);
#else
pthread_mutex_lock(&write_random);
counter.Rand(256);
pthread_mutex_unlock(&write_random);
#endif
for(k = 0; k < 21; k++) {
buffer_b58[k] =(uint8_t)((uint8_t) rawbuffer[k] % 58);
}
@ -2823,18 +2816,18 @@ void *thread_process(void *vargp) {
endomorphism_negeted_point[l] = secp->Negation(pts[(j*4)+l]);
}
secp->GetHash160(P2PKH,false, pts[(j*4)], pts[(j*4)+1], pts[(j*4)+2], pts[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[6][0],(uint8_t*)publickeyhashrmd160_endomorphism[6][1],(uint8_t*)publickeyhashrmd160_endomorphism[6][2],(uint8_t*)publickeyhashrmd160_endomorphism[6][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)] ,endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0] ,endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta[(j*4)+l]);
}
secp->GetHash160(P2PKH,false,endomorphism_beta[(j*4)], endomorphism_beta[(j*4)+1], endomorphism_beta[(j*4)+2], endomorphism_beta[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[8][0],(uint8_t*)publickeyhashrmd160_endomorphism[8][1],(uint8_t*)publickeyhashrmd160_endomorphism[8][2],(uint8_t*)publickeyhashrmd160_endomorphism[8][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)],endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0],endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta2[(j*4)+l]);
}
secp->GetHash160(P2PKH,false, endomorphism_beta2[(j*4)], endomorphism_beta2[(j*4)+1] , endomorphism_beta2[(j*4)+2] , endomorphism_beta2[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[10][0],(uint8_t*)publickeyhashrmd160_endomorphism[10][1],(uint8_t*)publickeyhashrmd160_endomorphism[10][2],(uint8_t*)publickeyhashrmd160_endomorphism[10][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[(j*4)], endomorphism_negeted_point[(j*4)+1], endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[0], endomorphism_negeted_point[1], endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
}
else {
@ -3436,18 +3429,18 @@ void *thread_process_vanity(void *vargp) {
endomorphism_negeted_point[l] = secp->Negation(pts[(j*4)+l]);
}
secp->GetHash160(P2PKH,false, pts[(j*4)], pts[(j*4)+1], pts[(j*4)+2], pts[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[6][0],(uint8_t*)publickeyhashrmd160_endomorphism[6][1],(uint8_t*)publickeyhashrmd160_endomorphism[6][2],(uint8_t*)publickeyhashrmd160_endomorphism[6][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)] ,endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0] ,endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta[(j*4)+l]);
}
secp->GetHash160(P2PKH,false,endomorphism_beta[(j*4)], endomorphism_beta[(j*4)+1], endomorphism_beta[(j*4)+2], endomorphism_beta[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[8][0],(uint8_t*)publickeyhashrmd160_endomorphism[8][1],(uint8_t*)publickeyhashrmd160_endomorphism[8][2],(uint8_t*)publickeyhashrmd160_endomorphism[8][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)],endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0],endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta2[(j*4)+l]);
}
secp->GetHash160(P2PKH,false, endomorphism_beta2[(j*4)], endomorphism_beta2[(j*4)+1] , endomorphism_beta2[(j*4)+2] , endomorphism_beta2[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[10][0],(uint8_t*)publickeyhashrmd160_endomorphism[10][1],(uint8_t*)publickeyhashrmd160_endomorphism[10][2],(uint8_t*)publickeyhashrmd160_endomorphism[10][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[(j*4)], endomorphism_negeted_point[(j*4)+1], endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[0], endomorphism_negeted_point[1], endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
}
else {
secp->GetHash160(P2PKH,false,pts[(j*4)],pts[(j*4)+1],pts[(j*4)+2],pts[(j*4)+3],(uint8_t*)publickeyhashrmd160_uncompress[0],(uint8_t*)publickeyhashrmd160_uncompress[1],(uint8_t*)publickeyhashrmd160_uncompress[2],(uint8_t*)publickeyhashrmd160_uncompress[3]);
@ -6935,7 +6928,7 @@ bool forceReadFileAddress(char *fileName) {
if(!initBloomFilter(&bloom,numberItems))
return false;
i = 0;
while(i < numberItems) {
validAddress = false;
memset(aux,0,100);
@ -7010,7 +7003,7 @@ bool forceReadFileAddressEth(char *fileName) {
if(!initBloomFilter(&bloom,N))
return false;
i = 0;
while(i < numberItems) {
validAddress = false;
memset(aux,0,100);

View File

@ -839,7 +839,7 @@ int main(int argc, char **argv) {
FLAGRANGE = 0;
}
}
if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
//if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
if(FLAGMODE != MODE_BSGS && FLAGMODE != MODE_MINIKEYS) {
BSGS_N.SetInt32(DEBUGCOUNT);
if(FLAGRANGE == 0 && FLAGBITRANGE == 0) {
@ -863,7 +863,7 @@ int main(int argc, char **argv) {
}
}
N = 0;
if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
//if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
if(FLAGMODE != MODE_BSGS ) {
if(FLAG_N){
if(str_N[0] == '0' && str_N[1] == 'x') {
@ -951,7 +951,7 @@ int main(int argc, char **argv) {
}
break;
}
if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
//if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
if(FLAGMODE != MODE_VANITY && !FLAGREADEDFILE1) {
printf("[+] Sorting data ...");
_sort(addressTable,N);
@ -959,7 +959,7 @@ int main(int argc, char **argv) {
writeFileIfNeeded(fileName);
}
}
if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
//if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
if(FLAGMODE == MODE_BSGS ) {
printf("[+] Opening file %s\n",fileName);
fd = fopen(fileName,"rb");
@ -2111,7 +2111,7 @@ int main(int argc, char **argv) {
free(aux);
}
if(FLAGMODE != MODE_BSGS) {
if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
//if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
steps = (uint64_t *) calloc(NTHREADS,sizeof(uint64_t));
checkpointer((void *)steps,__FILE__,"calloc","steps" ,__LINE__ -1 );
ends = (unsigned int *) calloc(NTHREADS,sizeof(int));
@ -2122,7 +2122,7 @@ int main(int argc, char **argv) {
tid = (pthread_t *) calloc(NTHREADS,sizeof(pthread_t));
#endif
checkpointer((void *)tid,__FILE__,"calloc","tid" ,__LINE__ -1 );
if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
//if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
for(i= 0;i < NTHREADS; i++) {
tt = (tothread*) malloc(sizeof(struct tothread));
checkpointer((void *)tt,__FILE__,"malloc","tt" ,__LINE__ -1 );
@ -2134,7 +2134,7 @@ int main(int argc, char **argv) {
case MODE_ADDRESS:
case MODE_XPOINT:
case MODE_RMD160:
if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
//if(FLAGDEBUG) { printf("[D] File: %s Line %i\n",__FILE__,__LINE__); fflush(stdout); }
tid[i] = CreateThread(NULL, 0, thread_process, (void*)tt, 0, &s);
break;
case MODE_PUB2RMD:
@ -2569,10 +2569,12 @@ DWORD WINAPI thread_process(LPVOID vargp) {
void *thread_process(void *vargp) {
#endif
struct tothread *tt;
Point pts[CPU_GRP_SIZE];
Point endomorphism_beta[CPU_GRP_SIZE];
Point endomorphism_beta2[CPU_GRP_SIZE];
Point endomorphism_negeted_point[4];
Int dx[CPU_GRP_SIZE / 2 + 1];
IntGroup *grp = new IntGroup(CPU_GRP_SIZE / 2 + 1);
@ -2603,7 +2605,11 @@ void *thread_process(void *vargp) {
thread_number = tt->nt;
free(tt);
grp->Set(dx);
//printf("[D] Thread %i calculate_y = %s \n",thread_number,calculate_y ? "true": "false");
//sleep_ms(1000);
do {
if(FLAGRANDOM){
key_mpz.Rand(&n_range_start,&n_range_end);
@ -2797,21 +2803,35 @@ void *thread_process(void *vargp) {
if(FLAGSEARCH == SEARCH_UNCOMPRESS || FLAGSEARCH == SEARCH_BOTH){
if(FLAGENDOMORPHISM) {
for(l = 0; l < 4; l++) {
/*
pthread_mutex_lock(&write_keys);
printf("Valores thread, %i ,l = %i, j = %li\n",thread_number,l,j);
hextemp = secp->GetPublicKeyHex(false,pts[(j*4)+l]);
printf("Negating %s\n",hextemp);
free(hextemp);
*/
endomorphism_negeted_point[l] = secp->Negation(pts[(j*4)+l]);
/*
hextemp = secp->GetPublicKeyHex(false,endomorphism_negeted_point[l]);
printf("Result %s\n",hextemp);
free(hextemp);
fflush(stdout);
pthread_mutex_unlock(&write_keys);
*/
}
secp->GetHash160(P2PKH,false, pts[(j*4)], pts[(j*4)+1], pts[(j*4)+2], pts[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[6][0],(uint8_t*)publickeyhashrmd160_endomorphism[6][1],(uint8_t*)publickeyhashrmd160_endomorphism[6][2],(uint8_t*)publickeyhashrmd160_endomorphism[6][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)] ,endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0] ,endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta[(j*4)+l]);
}
secp->GetHash160(P2PKH,false,endomorphism_beta[(j*4)], endomorphism_beta[(j*4)+1], endomorphism_beta[(j*4)+2], endomorphism_beta[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[8][0],(uint8_t*)publickeyhashrmd160_endomorphism[8][1],(uint8_t*)publickeyhashrmd160_endomorphism[8][2],(uint8_t*)publickeyhashrmd160_endomorphism[8][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)],endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0],endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta2[(j*4)+l]);
}
secp->GetHash160(P2PKH,false, endomorphism_beta2[(j*4)], endomorphism_beta2[(j*4)+1] , endomorphism_beta2[(j*4)+2] , endomorphism_beta2[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[10][0],(uint8_t*)publickeyhashrmd160_endomorphism[10][1],(uint8_t*)publickeyhashrmd160_endomorphism[10][2],(uint8_t*)publickeyhashrmd160_endomorphism[10][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[(j*4)], endomorphism_negeted_point[(j*4)+1], endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[0], endomorphism_negeted_point[1], endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
}
else {
@ -3396,18 +3416,18 @@ void *thread_process_vanity(void *vargp) {
endomorphism_negeted_point[l] = secp->Negation(pts[(j*4)+l]);
}
secp->GetHash160(P2PKH,false, pts[(j*4)], pts[(j*4)+1], pts[(j*4)+2], pts[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[6][0],(uint8_t*)publickeyhashrmd160_endomorphism[6][1],(uint8_t*)publickeyhashrmd160_endomorphism[6][2],(uint8_t*)publickeyhashrmd160_endomorphism[6][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)] ,endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0] ,endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[7][0],(uint8_t*)publickeyhashrmd160_endomorphism[7][1],(uint8_t*)publickeyhashrmd160_endomorphism[7][2],(uint8_t*)publickeyhashrmd160_endomorphism[7][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta[(j*4)+l]);
}
secp->GetHash160(P2PKH,false,endomorphism_beta[(j*4)], endomorphism_beta[(j*4)+1], endomorphism_beta[(j*4)+2], endomorphism_beta[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[8][0],(uint8_t*)publickeyhashrmd160_endomorphism[8][1],(uint8_t*)publickeyhashrmd160_endomorphism[8][2],(uint8_t*)publickeyhashrmd160_endomorphism[8][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[(j*4)],endomorphism_negeted_point[(j*4)+1],endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
secp->GetHash160(P2PKH,false,endomorphism_negeted_point[0],endomorphism_negeted_point[1],endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[9][0],(uint8_t*)publickeyhashrmd160_endomorphism[9][1],(uint8_t*)publickeyhashrmd160_endomorphism[9][2],(uint8_t*)publickeyhashrmd160_endomorphism[9][3]);
for(l = 0; l < 4; l++) {
endomorphism_negeted_point[l] = secp->Negation(endomorphism_beta2[(j*4)+l]);
}
secp->GetHash160(P2PKH,false, endomorphism_beta2[(j*4)], endomorphism_beta2[(j*4)+1] , endomorphism_beta2[(j*4)+2] , endomorphism_beta2[(j*4)+3] ,(uint8_t*)publickeyhashrmd160_endomorphism[10][0],(uint8_t*)publickeyhashrmd160_endomorphism[10][1],(uint8_t*)publickeyhashrmd160_endomorphism[10][2],(uint8_t*)publickeyhashrmd160_endomorphism[10][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[(j*4)], endomorphism_negeted_point[(j*4)+1], endomorphism_negeted_point[(j*4)+2],endomorphism_negeted_point[(j*4)+3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
secp->GetHash160(P2PKH,false, endomorphism_negeted_point[0], endomorphism_negeted_point[1], endomorphism_negeted_point[2],endomorphism_negeted_point[3],(uint8_t*)publickeyhashrmd160_endomorphism[11][0],(uint8_t*)publickeyhashrmd160_endomorphism[11][1],(uint8_t*)publickeyhashrmd160_endomorphism[11][2],(uint8_t*)publickeyhashrmd160_endomorphism[11][3]);
}
else {
secp->GetHash160(P2PKH,false,pts[(j*4)],pts[(j*4)+1],pts[(j*4)+2],pts[(j*4)+3],(uint8_t*)publickeyhashrmd160_uncompress[0],(uint8_t*)publickeyhashrmd160_uncompress[1],(uint8_t*)publickeyhashrmd160_uncompress[2],(uint8_t*)publickeyhashrmd160_uncompress[3]);