mirror of
https://github.com/PurpleI2P/i2pd-tools.git
synced 2025-04-24 09:56:36 +02:00
Merge 9376c13eb0
into 85ea3ff293
This commit is contained in:
commit
60e0221d10
2 changed files with 47 additions and 7 deletions
16
vanity.hpp
16
vanity.hpp
|
@ -11,21 +11,33 @@
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#define MODES
|
||||||
|
|
||||||
static std::mutex thread_mutex;
|
static std::mutex thread_mutex;
|
||||||
static i2p::data::SigningKeyType type;
|
static i2p::data::SigningKeyType type;
|
||||||
//static i2p::data::PrivateKeys keys;
|
//static i2p::data::PrivateKeys keys;
|
||||||
static bool finded=false;
|
static bool found=false;
|
||||||
|
|
||||||
static size_t MutateByte;
|
static size_t MutateByte;
|
||||||
|
|
||||||
static uint32_t FindedNonce=0;
|
static uint32_t FoundNonce=0;
|
||||||
|
|
||||||
static uint8_t * KeyBuf;
|
static uint8_t * KeyBuf;
|
||||||
|
|
||||||
//static uint8_t * PaddingBuf;
|
//static uint8_t * PaddingBuf;
|
||||||
static unsigned long long hashescounter;
|
static unsigned long long hashescounter;
|
||||||
|
|
||||||
|
#ifdef MODES
|
||||||
|
unsigned short count_cpu __attribute__((__mode__(QI))); // 1 byte i think don't usefful
|
||||||
|
#else
|
||||||
|
unsigned short count_cpu;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//Functions visible and don't need.
|
//Functions visible and don't need.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -71,7 +71,15 @@ Orignal is sensei of crypto ;)
|
||||||
*/
|
*/
|
||||||
std::cout << "Thread " << id_thread << " binded" << std::endl;
|
std::cout << "Thread " << id_thread << " binded" << std::endl;
|
||||||
|
|
||||||
|
#ifdef MODES
|
||||||
|
uint8_t b[391] __attribute__((__mode__(SI))); // 4 byte == 32 bits, not usefull. i think.
|
||||||
|
#else
|
||||||
|
uint8_t b[391];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
uint8_t b[391] __attribute__((aligned(4)));
|
uint8_t b[391] __attribute__((aligned(4)));
|
||||||
|
|
||||||
memcpy (b, buf, 391);
|
memcpy (b, buf, 391);
|
||||||
|
|
||||||
int len = strlen (prefix);
|
int len = strlen (prefix);
|
||||||
|
@ -86,7 +94,7 @@ Orignal is sensei of crypto ;)
|
||||||
uint8_t hash[32];
|
uint8_t hash[32];
|
||||||
char addr[53];
|
char addr[53];
|
||||||
|
|
||||||
while(throughput-- and !finded){
|
while(throughput-- and !found){
|
||||||
|
|
||||||
memcpy (&ctx1, &ctx, sizeof (SHA256_CTX));
|
memcpy (&ctx1, &ctx, sizeof (SHA256_CTX));
|
||||||
SHA256_Update(&ctx1, b + MutateByte, 71);
|
SHA256_Update(&ctx1, b + MutateByte, 71);
|
||||||
|
@ -96,14 +104,14 @@ Orignal is sensei of crypto ;)
|
||||||
if( !NotThat(addr,prefix) ){
|
if( !NotThat(addr,prefix) ){
|
||||||
ByteStreamToBase32 (hash, 32, addr, 52);
|
ByteStreamToBase32 (hash, 32, addr, 52);
|
||||||
std::cout << "Address found " << addr << " in " << id_thread << std::endl;
|
std::cout << "Address found " << addr << " in " << id_thread << std::endl;
|
||||||
finded=true;
|
found=true;
|
||||||
FindedNonce=*nonce;
|
FoundNonce=*nonce;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
(*nonce)++;
|
(*nonce)++;
|
||||||
hashescounter++;
|
hashescounter++;
|
||||||
if (finded) break;
|
if (found) break;
|
||||||
}//while
|
}//while
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -180,9 +188,20 @@ if(type != i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519){
|
||||||
KeyBuf = new uint8_t[keys.GetFullLen()];
|
KeyBuf = new uint8_t[keys.GetFullLen()];
|
||||||
keys.ToBuffer (KeyBuf, keys.GetFullLen ());
|
keys.ToBuffer (KeyBuf, keys.GetFullLen ());
|
||||||
|
|
||||||
|
|
||||||
|
if(!count_cpu)
|
||||||
|
count_cpu = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
|
|
||||||
|
std::cout << "Start vanity generator in " << (int)count_cpu << " threads" << std::endl;
|
||||||
|
|
||||||
|
|
||||||
|
unsigned short attempts = 0;
|
||||||
|
while(!found)
|
||||||
|
|
||||||
unsigned int count_cpu = sysconf(_SC_NPROCESSORS_ONLN);
|
unsigned int count_cpu = sysconf(_SC_NPROCESSORS_ONLN);
|
||||||
std::vector<std::thread> threads(count_cpu);
|
std::vector<std::thread> threads(count_cpu);
|
||||||
|
|
||||||
|
|
||||||
std::cout << "Start vanity generator in " << count_cpu << " threads" << std::endl;
|
std::cout << "Start vanity generator in " << count_cpu << " threads" << std::endl;
|
||||||
|
|
||||||
unsigned long long thoughtput = 0x4F4B5A37;
|
unsigned long long thoughtput = 0x4F4B5A37;
|
||||||
|
@ -195,12 +214,19 @@ unsigned long long thoughtput = 0x4F4B5A37;
|
||||||
for(unsigned int j = 0; j < count_cpu;j++)
|
for(unsigned int j = 0; j < count_cpu;j++)
|
||||||
threads[j].join();
|
threads[j].join();
|
||||||
|
|
||||||
|
|
||||||
|
if(FoundNonce == 0){
|
||||||
|
RAND_bytes( KeyBuf+MutateByte , 90 );
|
||||||
|
std::cout << "Attempts #" << ++attempts << std::endl;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if(FindedNonce == 0){
|
if(FindedNonce == 0){
|
||||||
std::cout << "Don't finded " << std::endl;
|
std::cout << "Don't finded " << std::endl;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy (KeyBuf + MutateByte, &FindedNonce, 4);
|
memcpy (KeyBuf + MutateByte, &FoundNonce, 4);
|
||||||
std::cout << "Hashes: " << hashescounter << std::endl;
|
std::cout << "Hashes: " << hashescounter << std::endl;
|
||||||
|
|
||||||
std::ofstream f (argv[1], std::ofstream::binary | std::ofstream::out);
|
std::ofstream f (argv[1], std::ofstream::binary | std::ofstream::out);
|
||||||
|
@ -217,3 +243,5 @@ unsigned long long thoughtput = 0x4F4B5A37;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#undef MODES
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue