fixes
This commit is contained in:
parent
dfa6579076
commit
8433194500
@ -4,7 +4,8 @@ find_package(OpenSSL REQUIRED)
|
|||||||
file(GLOB ${PROJECT_NAME}SOURCES *.cpp)
|
file(GLOB ${PROJECT_NAME}SOURCES *.cpp)
|
||||||
file(GLOB ${PROJECT_NAME}HEADERS *.h)
|
file(GLOB ${PROJECT_NAME}HEADERS *.h)
|
||||||
add_executable(${PROJECT_NAME} sources/main.cpp)
|
add_executable(${PROJECT_NAME} sources/main.cpp)
|
||||||
set(CMAKE_CXX_FLAGS_RELEASE "-march=native -O3 -ffast-math -mavx2 -m64 -ftree-vectorize -ftree-slp-vectorize -fdelete-null-pointer-checks -fno-exceptions -fno-rtti -finline-functions -pthread -fomit-frame-pointer -pipe -Wall -Wextra -flto=full")
|
set(CXX_ADDITIONAL_FLAGS "-mavx2 -fomit-frame-pointer -ftree-vectorize -ftree-slp-vectorize -fdelete-null-pointer-checks -fno-exceptions -fno-rtti -pthread -fomit-frame-pointer")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-march=native -O3 -ffast-math -pipe -Wall -Wextra -Wpedantic -Wconversion -Wuninitialized -Wsign-conversion -flto=full")
|
||||||
target_link_libraries(${PROJECT_NAME} pthread)
|
target_link_libraries(${PROJECT_NAME} pthread)
|
||||||
target_link_libraries(${PROJECT_NAME} sodium)
|
target_link_libraries(${PROJECT_NAME} sodium)
|
||||||
target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
#target_link_libraries(${PROJECT_NAME} OpenSSL::SSL OpenSSL::Crypto)
|
@ -22,8 +22,7 @@ static option conf;
|
|||||||
int parameters(option& conf, std::string arg) {
|
int parameters(option& conf, std::string arg) {
|
||||||
if (arg.find(" ") != std::string::npos) {
|
if (arg.find(" ") != std::string::npos) {
|
||||||
const unsigned long npos = std::string::npos;
|
const unsigned long npos = std::string::npos;
|
||||||
int position = arg.find(" ");
|
std::istringstream ss(arg.substr(arg.find(" ") + 1));
|
||||||
std::istringstream ss(arg.substr(position + 1));
|
|
||||||
if (arg.find("--threads") != npos || arg.find("-t") != npos) {
|
if (arg.find("--threads") != npos || arg.find("-t") != npos) {
|
||||||
ss >> conf.proc;
|
ss >> conf.proc;
|
||||||
if (ss.fail()) return 1;
|
if (ss.fail()) return 1;
|
||||||
@ -42,9 +41,9 @@ int parameters(option& conf, std::string arg) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
void displayConfig() {
|
void displayConfig() {
|
||||||
unsigned short processor_count = std::thread::hardware_concurrency();
|
unsigned processor_count = std::thread::hardware_concurrency();
|
||||||
if (conf.proc == 0 || conf.proc > static_cast<unsigned int>(processor_count)) {
|
if (conf.proc == 0 || conf.proc > static_cast<unsigned>(processor_count)) {
|
||||||
conf.proc = static_cast<unsigned int>(processor_count);
|
conf.proc = static_cast<unsigned>(processor_count);
|
||||||
}
|
}
|
||||||
std::cout << " Threads: " << conf.proc << ", " << "high addresses (2" << std::setw(2) << std::setfill('0') << std::hex << conf.high << "+)" << std::dec << std::endl;
|
std::cout << " Threads: " << conf.proc << ", " << "high addresses (2" << std::setw(2) << std::setfill('0') << std::hex << conf.high << "+)" << std::dec << std::endl;
|
||||||
}
|
}
|
||||||
@ -69,36 +68,36 @@ struct KeysBox {
|
|||||||
Key PublicKey;
|
Key PublicKey;
|
||||||
Key PrivateKey;
|
Key PrivateKey;
|
||||||
};
|
};
|
||||||
inline void bitwiseInverse(const unsigned char* key, Key& inverted) noexcept {
|
/*
|
||||||
|
[[gnu::always_inline]] inline void bitwiseInverse(const unsigned char* key, Key& inverted) noexcept {
|
||||||
__m256i chunk = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(key));
|
__m256i chunk = _mm256_loadu_si256(reinterpret_cast<const __m256i*>(key));
|
||||||
chunk = _mm256_xor_si256(chunk, _mm256_set1_epi8(0xFF));
|
chunk = _mm256_xor_si256(chunk, _mm256_set1_epi8(0xFF));
|
||||||
_mm256_storeu_si256(reinterpret_cast<__m256i*>(inverted), chunk);
|
_mm256_storeu_si256(reinterpret_cast<__m256i*>(inverted), chunk);
|
||||||
}
|
}
|
||||||
inline unsigned char getOnes(const Key& value) noexcept {
|
*/
|
||||||
int leadOnes = 0;
|
[[nodiscard]] inline unsigned char getZeros(const Key& value) noexcept {
|
||||||
for (unsigned char i = 0; i < 32; i++) {
|
unsigned char leadZeros = 0;
|
||||||
if (value[0] != 0xFF && value[1] != 0xFF) return leadOnes;
|
#pragma unroll
|
||||||
if (value[i] == 0xFF) {
|
for (unsigned char i = 0; i < 6; i++) {
|
||||||
leadOnes += 8;
|
if (value[i] == 0x00) {
|
||||||
|
leadZeros += 8;
|
||||||
} else {
|
} else {
|
||||||
for (unsigned char j = 7; j < 8; j--) {
|
unsigned char byte = value[i];
|
||||||
if (!(value[i] & (1 << j))) {
|
while (!(byte & 0x80)) {
|
||||||
return leadOnes;
|
leadZeros++;
|
||||||
}
|
byte <<= 1;
|
||||||
leadOnes++;
|
|
||||||
}
|
}
|
||||||
|
return leadZeros;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return leadOnes;
|
return leadZeros;
|
||||||
}
|
}
|
||||||
void miner_thread() noexcept {
|
void miner_thread() noexcept {
|
||||||
Key inv;
|
|
||||||
KeysBox keys;
|
KeysBox keys;
|
||||||
unsigned char ones;
|
unsigned char ones = 0;
|
||||||
while (true) {
|
while (true) {
|
||||||
crypto_sign_ed25519_keypair(keys.PublicKey, keys.PrivateKey);
|
crypto_sign_ed25519_keypair(keys.PublicKey, keys.PrivateKey);
|
||||||
bitwiseInverse(keys.PublicKey, inv);
|
ones = getZeros(keys.PublicKey);
|
||||||
ones = getOnes(inv);
|
|
||||||
if (ones > conf.high) {
|
if (ones > conf.high) {
|
||||||
printf("\nAddr:\t2%x/%d\nPK:\t%s\nSK:\t%s\n", conf.high = ones, ones, keyToString(keys.PublicKey).c_str(), keyToString(keys.PrivateKey).c_str());
|
printf("\nAddr:\t2%x/%d\nPK:\t%s\nSK:\t%s\n", conf.high = ones, ones, keyToString(keys.PublicKey).c_str(), keyToString(keys.PrivateKey).c_str());
|
||||||
}
|
}
|
||||||
@ -135,6 +134,7 @@ int main(int argc, char* argv[]) {
|
|||||||
}
|
}
|
||||||
displayConfig();
|
displayConfig();
|
||||||
startThreads();
|
startThreads();
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
void getRawAddress(int lErase, Key& InvertedPublicKey, Address& rawAddr) {
|
void getRawAddress(int lErase, Key& InvertedPublicKey, Address& rawAddr) {
|
||||||
@ -171,4 +171,4 @@ void logKeys(const Address& raw, const KeysBox& keys) {
|
|||||||
output.close();
|
output.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user