Browse Source

Generate a new full keypair instead just RAND_bytes (will fix bug with bad key format)

Also not rewrite exists .dat file if exists before
delete much commentaries
Do a full new search instead new keypair
fix a bug with double increment in multiple search mode
pull/91/head
wipedlifepotato 10 months ago
parent
commit
a16075f22a
  1. 55
      vain.cpp
  2. 1
      vanity.hpp

55
vain.cpp

@ -188,14 +188,11 @@ Orignal is sensei of crypto ;)
//bool result = options.reg ? !NotThat(addr, &options.regex) : !NotThat(addr,prefix); //bool result = options.reg ? !NotThat(addr, &options.regex) : !NotThat(addr,prefix);
if( ( options.reg ? !NotThat(addr, options.regex) : !NotThat(addr,prefix) ) ) if( ( options.reg ? !NotThat(addr, options.regex) : !NotThat(addr,prefix) ) )
// if(result)
{ {
ByteStreamToBase32 ((uint8_t*)hash, 32, addr, 52); ByteStreamToBase32 ((uint8_t*)hash, 32, addr, 52);
std::cout << "Address found " << addr << " in " << id_thread << std::endl; std::cout << "Address found " << addr << " in " << id_thread << std::endl;
found=true; found=true;
FoundNonce=*nonce; FoundNonce=*nonce;
// free(hash);
// free(b);
// From there place we get a nonce, for some one a byte. // From there place we get a nonce, for some one a byte.
return true; return true;
} }
@ -203,10 +200,8 @@ Orignal is sensei of crypto ;)
(*nonce)++; (*nonce)++;
hashescounter++; hashescounter++;
if (found) // for another threads if (found) // for another threads (?)
{ {
// free(hash);
// free(b);
break; break;
} }
}//while }//while
@ -224,8 +219,6 @@ void usage(void){
"--threads -t (default count of system)\n" "--threads -t (default count of system)\n"
//"--signature -s (signature type)\n" //"--signature -s (signature type)\n"
"-o --output output file(default " DEF_OUT_FILE ")\n" "-o --output output file(default " DEF_OUT_FILE ")\n"
//"--usage usage\n"
//"--prefix -p\n"
"--multiplymode -m - multiple addresses search" "--multiplymode -m - multiple addresses search"
""; "";
puts(help); puts(help);
@ -241,18 +234,12 @@ void parsing(int argc, char ** args){
{"signature", required_argument,0,'s'}, {"signature", required_argument,0,'s'},
{"output", required_argument,0,'o'}, {"output", required_argument,0,'o'},
{"multiplymode", no_argument, 0, 'm'}, {"multiplymode", no_argument, 0, 'm'},
//{"usage", no_argument,0,0},
{0,0,0,0} {0,0,0,0}
}; };
int c; int c;
while( (c=getopt_long(argc,args, "hrt:s:o:m", long_options, &option_index))!=-1){ while( (c=getopt_long(argc,args, "hrt:s:o:m", long_options, &option_index))!=-1){
switch(c){ switch(c){
//case 0:
// if ( std::string(long_options[option_index].name) == std::string("usage") ){
// usage();
// exit(1);
// }
case 'm': case 'm':
multipleSearchMode=true; multipleSearchMode=true;
break; break;
@ -296,23 +283,17 @@ int main (int argc, char * argv[])
parsing( argc > 2 ? argc-1 : argc, argc > 2 ? argv+1 : argv); // parsing is was there. parsing( argc > 2 ? argc-1 : argc, argc > 2 ? argv+1 : argv); // parsing is was there.
// if argc size more than 2. nameprogram is 1. and 2 is prefix. if not there is will be flags like regex // if argc size more than 2. nameprogram is 1. and 2 is prefix. if not there is will be flags like regex
// TODO: ? // TODO: ?
//
if(!options.reg && !check_prefix( argv[1] )) if(!options.reg && !check_prefix( argv[1] ))
{ {
std::cout << "Not correct prefix(just string)" << std::endl; std::cout << "Not correct prefix(just string)" << std::endl;
return 1; return 1;
}else{ }else{
options.regex=std::regex(argv[1]); options.regex=std::regex(argv[1]);
// int ret = regcomp( &options.regex, argv[1], REG_EXTENDED );
// if( ret != 0 ){
// std::cerr << "Can't create regexp pattern from " << argv[1] << std::endl;
// return 1;
// }
} }
// https://github.com/PurpleI2P/i2pd/blob/ae5239de435e1dcdff342961af9b506f60a494d4/libi2pd/Crypto.h#L310 // https://github.com/PurpleI2P/i2pd/blob/ae5239de435e1dcdff342961af9b506f60a494d4/libi2pd/Crypto.h#L310
//// init and terminate //// init and terminate
// void InitCrypto (bool precomputation, bool aesni, bool avx, bool force); // void InitCrypto (bool precomputation, bool aesni, bool avx, bool force);
// By default false to all. // By default false to all. But on much proccessors some things will be enabled. SO, TODO
i2p::crypto::InitCrypto (PRECOMPUTATION_CRYPTO, AESNI_CRYPTO, AVX_CRYPTO, FORCE_CRYPTO); i2p::crypto::InitCrypto (PRECOMPUTATION_CRYPTO, AESNI_CRYPTO, AVX_CRYPTO, FORCE_CRYPTO);
options.signature = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519; options.signature = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519;
/////////////// ///////////////
@ -327,20 +308,6 @@ int main (int argc, char * argv[])
if(options.threads <= 0) if(options.threads <= 0)
{ {
options.threads = std::thread::hardware_concurrency(); // thx for acetone. lol options.threads = std::thread::hardware_concurrency(); // thx for acetone. lol
//
//#if defined(WIN32)
// SYSTEM_INFO siSysInfo;
// GetSystemInfo(&siSysInfo);
// options.threads = siSysInfo.dwNumberOfProcessors;
//#elif defined(_SC_NPROCESSORS_CONF)
// options.threads = sysconf(_SC_NPROCESSORS_CONF);
//#elif defined(HW_NCPU)
// int req[] = { CTL_HW, HW_NCPU };
// size_t len = sizeof(options.threads);
// v = sysctl(req, 2, &options.threads, &len, NULL, 0);
//#else
// options.threads = 1;
//#endif
} }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@ -352,6 +319,7 @@ int main (int argc, char * argv[])
if ( options . outputpath . empty () ) options . outputpath . assign ( DEF_OUT_FILE ) ; if ( options . outputpath . empty () ) options . outputpath . assign ( DEF_OUT_FILE ) ;
static std::string outPutFileName = options.outputpath; static std::string outPutFileName = options.outputpath;
auto doSearch = [argc,argv] () { auto doSearch = [argc,argv] () {
found = false;
auto keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature); auto keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature);
// TODO: create libi2pd_tools // TODO: create libi2pd_tools
// If file not exists we create a dump file. (a bug was found in issues) // If file not exists we create a dump file. (a bug was found in issues)
@ -423,12 +391,12 @@ int main (int argc, char * argv[])
// So I put it ^^^ // So I put it ^^^
for(unsigned int j = 0; j < (unsigned int)options.threads;j++) for(unsigned int j = 0; j < (unsigned int)options.threads;j++)
threads[j].join(); threads[j].join();
if(FoundNonce == 0) if(FoundNonce == 0)
{ {
keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature); //keys = i2p::data::PrivateKeys::CreateRandomKeys (options.signature);
//RAND_bytes( KeyBuf+MutateByte , 90 ); // FoundNonce is //RAND_bytes( KeyBuf+MutateByte , 90 ); // FoundNonce is
std::cout << "Attempts #" << ++attempts << std::endl; std::cout << "(Generate a new keypair) Attempts #" << ++attempts << std::endl;
return 1;
} }
}//stack }//stack
@ -447,7 +415,9 @@ int main (int argc, char * argv[])
options.outputpath.assign(outPutFileName); options.outputpath.assign(outPutFileName);
options.outputpath = options.outputpath + std::to_string(foundKeys) + std::string(".dat"); options.outputpath = options.outputpath + std::to_string(foundKeys) + std::string(".dat");
foundKeys++; foundKeys++;
//printf("foundKeys = %d\n", foundKeys);
}while( boost::filesystem::exists(options.outputpath) ); }while( boost::filesystem::exists(options.outputpath) );
//puts("do while cycle break");
//if ( ! boost::algorithm::ends_with(options.outputpath, ".dat") ) //if ( ! boost::algorithm::ends_with(options.outputpath, ".dat") )
// options.outputpath = options.outputpath + ".dat"; // options.outputpath = options.outputpath + ".dat";
@ -469,11 +439,14 @@ int main (int argc, char * argv[])
do { do {
doSearch(); doSearch();
foundKeys++; if(found)
{
//TODO: an another variable for file count and found keys as found keys by one runs
//foundKeys++;
}
options.outputpath.assign(outPutFileName); options.outputpath.assign(outPutFileName);
found = false;
FoundNonce = 0; FoundNonce = 0;
} while(multipleSearchMode); } while(multipleSearchMode || !found);
i2p::crypto::TerminateCrypto (); i2p::crypto::TerminateCrypto ();
return 0; return 0;

1
vanity.hpp

@ -61,6 +61,7 @@
// Global vars // Global vars
static bool found=false; static bool found=false;
static bool multipleSearchMode = false; static bool multipleSearchMode = false;
//TODO: an another variable for file count and found keys as found keys by one runs
static unsigned int foundKeys = 0; static unsigned int foundKeys = 0;
static size_t MutateByte; static size_t MutateByte;

Loading…
Cancel
Save