From 00225100a89608a01d82e9fc207c7ecc68d4c842 Mon Sep 17 00:00:00 2001 From: Jeff Date: Mon, 14 Aug 2017 13:59:28 -0400 Subject: [PATCH] Revert "Vanity stuff" --- Makefile | 2 +- vanity.hpp | 5 ++++- vanitygen.cpp | 53 +++++++++++++++++---------------------------------- 3 files changed, 23 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index df89e2c..9a108bd 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ regaddr: $(OBJECTS) $(CXX) -o regaddr regaddr.o $(LDFLAGS) $(LIBS) vain: $(OBJECTS) - $(CXX) -o vain vanitygen.o $(LDFLAGS) -mavx $(LIBS) + $(CXX) -o vain vanitygen.o $(LDFLAGS) $(LIBS) $(OBJECTS): libi2pd.a diff --git a/vanity.hpp b/vanity.hpp index 09910c2..34d1e6e 100644 --- a/vanity.hpp +++ b/vanity.hpp @@ -24,5 +24,8 @@ static uint8_t * KeyBuf; //static uint8_t * PaddingBuf; static unsigned long long hashescounter; -unsigned short count_cpu __attribute__((__mode__(QI))); // 1 byte + + +//Functions visible and don't need. + diff --git a/vanitygen.cpp b/vanitygen.cpp index bb60d6b..98e1827 100644 --- a/vanitygen.cpp +++ b/vanitygen.cpp @@ -1,6 +1,9 @@ #include "vanity.hpp" #define CPU_ONLY + + + static bool check_prefix(const char * buf){ unsigned short size_str=0; while(*buf) @@ -68,7 +71,7 @@ Orignal is sensei of crypto ;) */ std::cout << "Thread " << id_thread << " binded" << std::endl; - uint8_t b[391]; __attribute__((__mode__(SI))); // 4 byte == 32 bits, not usefull. i think. + uint8_t b[391] __attribute__((aligned(4))); memcpy (b, buf, 391); int len = strlen (prefix); @@ -111,7 +114,7 @@ int main (int argc, char * argv[]) { if ( argc < 3 ) { - std::cout << "Usage: " << argv[0] << " filename generatestring " << std::endl; + std::cout << "Usage: " << argv[0] << " filename generatestring " << std::endl; return 0; } if(!check_prefix(argv[2])){ @@ -119,17 +122,9 @@ int main (int argc, char * argv[]) return 0; } i2p::crypto::InitCrypto (false); - type = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519; - if ( argc > 3 ){ - unsigned int tmp = atoi(argv[3]); - if(tmp > 255) { - std::cout << "Really more than 255 threads?:D Nope, sorry" << std::endl; - return 0; - } - count_cpu=atoi(argv[3]); - }if ( argc > 4 ) { - type = NameToSigType(std::string(argv[4])); - } + type = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519; + if ( argc > 3 ) + type = NameToSigType(std::string(argv[3])); /////////////// //For while @@ -153,7 +148,6 @@ if(type != i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519){ return 0; break; } -//TODO: for other types. switch(type){ case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA256_P256: @@ -162,7 +156,7 @@ if(type != i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519){ break; case i2p::data::SIGNING_KEY_TYPE_ECDSA_SHA512_P521: - + break; case i2p::data::SIGNING_KEY_TYPE_RSA_SHA256_2048: @@ -186,36 +180,25 @@ if(type != i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519){ KeyBuf = new uint8_t[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(!finded) + unsigned int count_cpu = sysconf(_SC_NPROCESSORS_ONLN); + std::vector threads(count_cpu); -{//while -{//stack(for destructors(vector/thread)) + std::cout << "Start vanity generator in " << count_cpu << " threads" << std::endl; - std::vector threads(count_cpu); - unsigned long long thoughtput = 0x4F4B5A37; +unsigned long long thoughtput = 0x4F4B5A37; for ( unsigned int j = count_cpu;j--;){ threads[j] = std::thread(thread_find,KeyBuf,argv[2],j,thoughtput); thoughtput+=1000; - }//for + } for(unsigned int j = 0; j < count_cpu;j++) threads[j].join(); - - if(FindedNonce == 0){ - RAND_bytes( KeyBuf+256 , 90 ); - std::cout << "Attempts #" << ++attempts << std::endl; - } -}//stack -}//while + if(FindedNonce == 0){ + std::cout << "Don't finded " << std::endl; + return 0; + } memcpy (KeyBuf + MutateByte, &FindedNonce, 4); std::cout << "Hashes: " << hashescounter << std::endl;