|
|
@ -10,9 +10,6 @@ |
|
|
|
* |
|
|
|
* |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
#include <openssl/evp.h> // библиотека OpenSSL |
|
|
|
|
|
|
|
#include <openssl/sha.h> |
|
|
|
|
|
|
|
#include <openssl/bn.h> |
|
|
|
|
|
|
|
#include <iostream> // вывод на экран |
|
|
|
#include <iostream> // вывод на экран |
|
|
|
#include <string> |
|
|
|
#include <string> |
|
|
|
#include <sstream> |
|
|
|
#include <sstream> |
|
|
@ -25,24 +22,36 @@ |
|
|
|
#include <chrono> // для паузы в заставке |
|
|
|
#include <chrono> // для паузы в заставке |
|
|
|
#include <ctime> |
|
|
|
#include <ctime> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// криптография
|
|
|
|
|
|
|
|
#include <sodium/crypto_hash_sha512.h> |
|
|
|
|
|
|
|
#include <sodium/crypto_scalarmult_curve25519.h> |
|
|
|
|
|
|
|
#include <sodium/randombytes.h> |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// преобразование в IPv6
|
|
|
|
|
|
|
|
#ifdef _WIN32 |
|
|
|
|
|
|
|
#include <ws2tcpip.h> |
|
|
|
|
|
|
|
#else |
|
|
|
|
|
|
|
#include <ifaddrs.h> |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
////////////////////////////////////////////////// Заставка
|
|
|
|
////////////////////////////////////////////////// Заставка
|
|
|
|
|
|
|
|
|
|
|
|
void intro() |
|
|
|
void intro() |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::cout << std::endl |
|
|
|
std::cout << std::endl |
|
|
|
<< " +----------------------------------------------------------------------------+" << std::endl |
|
|
|
<< " +--------------------------------------------------------------------------+" << std::endl |
|
|
|
<< " | SimpleYggGen C++ 1.1-train |" << std::endl |
|
|
|
<< " | SimpleYggGen C++ 2.0-outrunning |" << std::endl |
|
|
|
<< " | OpenSSL inside: x25519 -> sha512 |" << std::endl |
|
|
|
<< " | OpenSSL inside: x25519 -> sha512 |" << std::endl |
|
|
|
<< " | notabug.org/acetone/SimpleYggGen-CPP |" << std::endl |
|
|
|
<< " | notabug.org/acetone/SimpleYggGen-CPP |" << std::endl |
|
|
|
<< " | |" << std::endl |
|
|
|
<< " | |" << std::endl |
|
|
|
<< " | developers: acetone, lialh4, orignal, R4SAS |" << std::endl |
|
|
|
<< " | developers: acetone, lialh4, orignal, R4SAS, Vort |" << std::endl |
|
|
|
<< " | GPLv3 (c) 2020 |" << std::endl |
|
|
|
<< " | GPLv3 (c) 2020 |" << std::endl |
|
|
|
<< " +"; |
|
|
|
<< " +"; |
|
|
|
for(int i = 0; i < 76; ++i) |
|
|
|
for(int i = 0; i < 74; ++i) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::cout << "-"; |
|
|
|
std::cout << "-"; |
|
|
|
std::cout.flush(); |
|
|
|
std::cout.flush(); |
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(20)); |
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(10)); |
|
|
|
} |
|
|
|
} |
|
|
|
std::cout << "+" << std::endl; |
|
|
|
std::cout << "+" << std::endl; |
|
|
|
} |
|
|
|
} |
|
|
@ -59,8 +68,9 @@ int conf_high = 0; |
|
|
|
std::string conf_search; |
|
|
|
std::string conf_search; |
|
|
|
std::string log_file; |
|
|
|
std::string log_file; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> startTime; |
|
|
|
uint64_t totalcount = 0; // счетчик основного цикла
|
|
|
|
uint64_t totalcount = 0; // счетчик основного цикла
|
|
|
|
uint64_t totalcountfortune = 0; // счетчик нахождений
|
|
|
|
uint64_t totalcountfortune = 0; // счетчик найденного
|
|
|
|
bool newline = true; // используется для вывода счетчика
|
|
|
|
bool newline = true; // используется для вывода счетчика
|
|
|
|
|
|
|
|
|
|
|
|
int config() |
|
|
|
int config() |
|
|
@ -160,25 +170,15 @@ struct BoxKeys |
|
|
|
BoxKeys getKeyPair() |
|
|
|
BoxKeys getKeyPair() |
|
|
|
{ |
|
|
|
{ |
|
|
|
BoxKeys keys; |
|
|
|
BoxKeys keys; |
|
|
|
size_t len = KEYSIZE; |
|
|
|
randombytes(keys.PrivateKey, KEYSIZE); |
|
|
|
|
|
|
|
keys.PrivateKey[0] &= 248; |
|
|
|
EVP_PKEY_CTX * Ctx; |
|
|
|
keys.PrivateKey[KEYSIZE - 1] &= 127; |
|
|
|
EVP_PKEY * Pkey = nullptr; |
|
|
|
keys.PrivateKey[KEYSIZE - 1] |= 64; |
|
|
|
Ctx = EVP_PKEY_CTX_new_id (NID_X25519, NULL); |
|
|
|
crypto_scalarmult_curve25519_base(keys.PublicKey, keys.PrivateKey); |
|
|
|
|
|
|
|
|
|
|
|
EVP_PKEY_keygen_init (Ctx); |
|
|
|
|
|
|
|
EVP_PKEY_keygen (Ctx, &Pkey); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EVP_PKEY_get_raw_public_key (Pkey, keys.PublicKey, &len); |
|
|
|
|
|
|
|
EVP_PKEY_get_raw_private_key (Pkey, keys.PrivateKey, &len); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EVP_PKEY_CTX_free(Ctx); |
|
|
|
|
|
|
|
EVP_PKEY_free(Pkey); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return keys; |
|
|
|
return keys; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
int getOnes(const unsigned char HashValue[SHA512_DIGEST_LENGTH]) |
|
|
|
int getOnes(const unsigned char HashValue[crypto_hash_sha512_BYTES]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool done = false; |
|
|
|
bool done = false; |
|
|
|
int lOnes = 0; // кол-во лидирующих единиц
|
|
|
|
int lOnes = 0; // кол-во лидирующих единиц
|
|
|
@ -200,7 +200,7 @@ int getOnes(const unsigned char HashValue[SHA512_DIGEST_LENGTH]) |
|
|
|
return lOnes; |
|
|
|
return lOnes; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string getAddress(unsigned char HashValue[SHA512_DIGEST_LENGTH]) |
|
|
|
std::string getAddress(unsigned char HashValue[crypto_hash_sha512_BYTES]) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// функция "портит" массив хэша, т.к. копирование массива не происходит
|
|
|
|
// функция "портит" массив хэша, т.к. копирование массива не происходит
|
|
|
|
int lErase = getOnes(HashValue) + 1; // лидирующие единицы и первый ноль
|
|
|
|
int lErase = getOnes(HashValue) + 1; // лидирующие единицы и первый ноль
|
|
|
@ -228,44 +228,15 @@ std::string getAddress(unsigned char HashValue[SHA512_DIGEST_LENGTH]) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::string address; |
|
|
|
uint8_t ipAddr[16]; |
|
|
|
bool shortadd = false; |
|
|
|
ipAddr[0] = 0x02; |
|
|
|
std::stringstream ss(address); |
|
|
|
ipAddr[1] = lErase - 1; |
|
|
|
ss << 0x02 << std::setw(2) << std::setfill('0') << std::hex << lErase - 1 << ":"; |
|
|
|
for (int i = 0; i < 14; ++i) |
|
|
|
// 2 - константа подсети Yggdrasil, второй байт - кол-во лидирующих единиц в хешэ
|
|
|
|
ipAddr[i + 2] = HashValue[i]; |
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < 14; ++i) |
|
|
|
char ipStrBuf[46]; |
|
|
|
{ |
|
|
|
inet_ntop(AF_INET6, ipAddr, ipStrBuf, 46); |
|
|
|
if(i % 2 == 0) // если работаем с первым байтом секции
|
|
|
|
return std::string(ipStrBuf); |
|
|
|
{ |
|
|
|
|
|
|
|
if(HashValue[i] == 0) // если байт нулевой
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(HashValue[i+1] == 0) // если следующий байт нулевой
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if(HashValue[i+2] == 0 && i+2 < 13 && HashValue[i+3] == 0 && i+3 <= 13 && !shortadd) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ss << ":"; |
|
|
|
|
|
|
|
i += 3; |
|
|
|
|
|
|
|
shortadd = true; |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ss << "0"; |
|
|
|
|
|
|
|
++i; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
ss << std::hex << (int)HashValue[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { // если работаем со вторым байтом секции
|
|
|
|
|
|
|
|
if(HashValue[i-1] == 0) // если предыдущий первый байт был нулевой, нули сокращаем
|
|
|
|
|
|
|
|
ss << std::hex << (int)HashValue[i]; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
ss << std::setw(2) << std::setfill('0') << std::hex << (int)HashValue[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(i != 13 && i % 2 != 0) // не выводим двоеточие в конце адреса и после первого байта секции
|
|
|
|
|
|
|
|
ss << ":"; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return ss.str(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void getConsoleLog() |
|
|
|
void getConsoleLog() |
|
|
@ -281,8 +252,14 @@ void getConsoleLog() |
|
|
|
} |
|
|
|
} |
|
|
|
std::time_t realtime = std::time(NULL); |
|
|
|
std::time_t realtime = std::time(NULL); |
|
|
|
|
|
|
|
|
|
|
|
std::cout << " # count [ " << std::dec << std::setfill('.') << std::setw(19) << totalcount << " ] [ " |
|
|
|
auto stopTime = std::chrono::high_resolution_clock::now(); |
|
|
|
<< std::setw(15) << totalcountfortune << " ] " << std::asctime(std::localtime(&realtime)); |
|
|
|
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stopTime - startTime); |
|
|
|
|
|
|
|
startTime = stopTime; |
|
|
|
|
|
|
|
float khs = 250000000.0 / duration.count(); |
|
|
|
|
|
|
|
std::cout << " [ " << std::setw(7) << std::fixed << std::setprecision(3) << std::setfill('_') << khs << " kH/s ] " |
|
|
|
|
|
|
|
<< "T: [ " << std::setfill('_') << std::left << std::dec << std::setw(16) << totalcount << " ] " |
|
|
|
|
|
|
|
<< "F: [ " << std::right << std::setw(3) << totalcountfortune << " ] " |
|
|
|
|
|
|
|
<< std::asctime(std::localtime(&realtime)); |
|
|
|
std::cout.flush(); |
|
|
|
std::cout.flush(); |
|
|
|
} |
|
|
|
} |
|
|
|
mtx.unlock(); |
|
|
|
mtx.unlock(); |
|
|
@ -290,15 +267,16 @@ void getConsoleLog() |
|
|
|
|
|
|
|
|
|
|
|
void highminer() |
|
|
|
void highminer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned char HashValue[SHA512_DIGEST_LENGTH]; |
|
|
|
unsigned char HashValue[crypto_hash_sha512_BYTES]; |
|
|
|
|
|
|
|
|
|
|
|
uint8_t PublicKeyBest[KEYSIZE]; |
|
|
|
uint8_t PublicKeyBest[KEYSIZE]; |
|
|
|
uint8_t PrivateKeyBest[KEYSIZE]; |
|
|
|
uint8_t PrivateKeyBest[KEYSIZE]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
startTime = std::chrono::high_resolution_clock::now(); |
|
|
|
while(true) |
|
|
|
while(true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BoxKeys myKeys = getKeyPair(); |
|
|
|
BoxKeys myKeys = getKeyPair(); |
|
|
|
SHA512(myKeys.PublicKey, KEYSIZE, HashValue); |
|
|
|
crypto_hash_sha512(HashValue, myKeys.PublicKey, KEYSIZE); |
|
|
|
int newones = getOnes(HashValue); |
|
|
|
int newones = getOnes(HashValue); |
|
|
|
|
|
|
|
|
|
|
|
if(newones > conf_high) // сохранение лучших ключей
|
|
|
|
if(newones > conf_high) // сохранение лучших ключей
|
|
|
@ -356,15 +334,15 @@ void highminer() |
|
|
|
|
|
|
|
|
|
|
|
void nameminer() |
|
|
|
void nameminer() |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned char HashValue[SHA512_DIGEST_LENGTH]; |
|
|
|
unsigned char HashValue[crypto_hash_sha512_BYTES]; |
|
|
|
|
|
|
|
|
|
|
|
uint8_t PublicKeyBest[KEYSIZE]; |
|
|
|
uint8_t PublicKeyBest[KEYSIZE]; |
|
|
|
uint8_t PrivateKeyBest[KEYSIZE]; |
|
|
|
uint8_t PrivateKeyBest[KEYSIZE]; |
|
|
|
|
|
|
|
startTime = std::chrono::high_resolution_clock::now(); |
|
|
|
while(true) |
|
|
|
while(true) |
|
|
|
{ |
|
|
|
{ |
|
|
|
BoxKeys myKeys = getKeyPair(); |
|
|
|
BoxKeys myKeys = getKeyPair(); |
|
|
|
SHA512(myKeys.PublicKey, KEYSIZE, HashValue); |
|
|
|
crypto_hash_sha512(HashValue, myKeys.PublicKey, KEYSIZE); |
|
|
|
std::string tempstr = getAddress(HashValue); |
|
|
|
std::string tempstr = getAddress(HashValue); |
|
|
|
|
|
|
|
|
|
|
|
if(tempstr.find(conf_search.c_str()) != std::string::npos) // сохранение найденных ключей
|
|
|
|
if(tempstr.find(conf_search.c_str()) != std::string::npos) // сохранение найденных ключей
|
|
|
|