From 1e8fc76f22ab421f96dd8afd23fba5dd585fc886 Mon Sep 17 00:00:00 2001 From: rcxpony Date: Sat, 15 Mar 2025 05:33:26 +0500 Subject: [PATCH] fixed --- sources/main.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/sources/main.cpp b/sources/main.cpp index 9df4c17..af523e3 100644 --- a/sources/main.cpp +++ b/sources/main.cpp @@ -109,9 +109,9 @@ inline void invertKey(const unsigned char* __restrict key, Key& inverted) noexce state ^= state << 4; return static_cast(state * 2685821657736338717); } -inline void rmbytes(unsigned char* __restrict buf, unsigned char size, unsigned long& state) noexcept { - for (unsigned char x = 0; x < 32; x++) { - _mm256_store_si256((__m256i*) & buf[x * 32], _mm256_set_epi64x(xorshift64(state), xorshift64(state), xorshift64(state), xorshift64(state))); +inline void rmbytes(unsigned char* __restrict buf, unsigned long& state) noexcept { + for (unsigned char x = 0; x < 1; x++) { + _mm256_storeu_si256((__m256i*) & buf[x * 32], _mm256_set_epi64x(xorshift64(state), xorshift64(state), xorshift64(state), xorshift64(state))); } } inline void sign_keypair(unsigned char* __restrict pk, unsigned char* __restrict sk, const unsigned char* __restrict seed) noexcept { @@ -119,21 +119,25 @@ inline void sign_keypair(unsigned char* __restrict pk, unsigned char* __restrict crypto_hash_sha512(h, seed, 32); h[31] = (h[31] & 0xF8) | (0x40 | (h[31] & 0x7F)); crypto_scalarmult_ed25519_base(pk, h); - _mm256_store_si256(reinterpret_cast<__m256i*>(sk), _mm256_load_si256(reinterpret_cast(seed))); - _mm256_store_si256(reinterpret_cast<__m256i*>(sk + 32), _mm256_load_si256(reinterpret_cast(pk))); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(sk), _mm256_loadu_si256(reinterpret_cast(seed))); + _mm256_storeu_si256(reinterpret_cast<__m256i*>(sk + 32), _mm256_loadu_si256(reinterpret_cast(pk))); } + void miner_thread() noexcept { alignas(32) Key inv; alignas(32) Key seed; KeysBox keys; Address rawAddr; + unsigned char ones = 0; std::random_device rd; unsigned long state = static_cast(rd()); printf("Using seed: %lu\n", state); while (true) { - rmbytes(seed, sizeof(seed), state); + rmbytes(seed, state); + //sign_keypair(keys.PublicKey, keys.PrivateKey, seed); crypto_sign_ed25519_seed_keypair(keys.PublicKey, keys.PrivateKey, seed); - if (unsigned char ones = getZeros(keys.PublicKey); ones > conf.high.load()) { + ones = getZeros(keys.PublicKey); + if (ones > conf.high.load()) { conf.high.store(ones); invertKey(keys.PublicKey, inv); getRawAddress(ones, inv, rawAddr); @@ -141,6 +145,7 @@ void miner_thread() noexcept { } } } + void startThreads() noexcept { std::vector threads; threads.reserve(conf.proc);