diff --git a/cmake/randomx.cmake b/cmake/randomx.cmake index 49f9f498a..23f66b297 100644 --- a/cmake/randomx.cmake +++ b/cmake/randomx.cmake @@ -1,5 +1,4 @@ if (WITH_RANDOMX) - include_directories(src/crypto/randomx) add_definitions(/DXMRIG_ALGO_RANDOMX) list(APPEND HEADERS_CRYPTO diff --git a/src/3rdparty/argon2/CMakeLists.txt b/src/3rdparty/argon2/CMakeLists.txt index 2dd9ecd4a..6440a3c05 100644 --- a/src/3rdparty/argon2/CMakeLists.txt +++ b/src/3rdparty/argon2/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required(VERSION 2.6) project(Argon2 C) set(ARGON2_VERSION 1.0) -set(CMAKE_C_STANDARD 90) +set(CMAKE_C_STANDARD 99) set(CMAKE_C_STANDARD_REQUIRED ON) include(CheckCSourceCompiles) diff --git a/src/crypto/randomx/aes_hash.cpp b/src/crypto/randomx/aes_hash.cpp index 5d6cb7438..fe149dfec 100644 --- a/src/crypto/randomx/aes_hash.cpp +++ b/src/crypto/randomx/aes_hash.cpp @@ -26,8 +26,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "soft_aes.h" -#include "randomx.h" +#include "crypto/randomx/soft_aes.h" +#include "crypto/randomx/randomx.h" #define AES_HASH_1R_STATE0 0xd7983aad, 0xcc82db47, 0x9fa856de, 0x92b52c0d #define AES_HASH_1R_STATE1 0xace78057, 0xf59e125a, 0x15c7b798, 0x338d996e diff --git a/src/crypto/randomx/allocator.cpp b/src/crypto/randomx/allocator.cpp index 2ddbed98b..60fb80565 100644 --- a/src/crypto/randomx/allocator.cpp +++ b/src/crypto/randomx/allocator.cpp @@ -27,10 +27,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include "allocator.hpp" -#include "intrin_portable.h" -#include "virtual_memory.hpp" -#include "common.hpp" +#include "crypto/randomx/allocator.hpp" +#include "crypto/randomx/intrin_portable.h" +#include "crypto/randomx/virtual_memory.hpp" +#include "crypto/randomx/common.hpp" namespace randomx { @@ -57,4 +57,4 @@ namespace randomx { freePagedMemory(ptr, count); }; -} \ No newline at end of file +} diff --git a/src/crypto/randomx/argon2_core.c b/src/crypto/randomx/argon2_core.c index 4b8fa43d6..7d87dd350 100644 --- a/src/crypto/randomx/argon2_core.c +++ b/src/crypto/randomx/argon2_core.c @@ -46,9 +46,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "argon2_core.h" -#include "blake2/blake2.h" -#include "blake2/blake2-impl.h" +#include "crypto/randomx/argon2_core.h" +#include "crypto/randomx/blake2/blake2.h" +#include "crypto/randomx/blake2/blake2-impl.h" #ifdef GENKAT #include "genkat.h" diff --git a/src/crypto/randomx/argon2_core.h b/src/crypto/randomx/argon2_core.h index efd56d991..274a01c74 100644 --- a/src/crypto/randomx/argon2_core.h +++ b/src/crypto/randomx/argon2_core.h @@ -36,7 +36,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #define ARGON2_CORE_H #include -#include "argon2.h" +#include "crypto/randomx/argon2.h" #if defined(__cplusplus) extern "C" { diff --git a/src/crypto/randomx/argon2_ref.c b/src/crypto/randomx/argon2_ref.c index 018b985b8..157eda862 100644 --- a/src/crypto/randomx/argon2_ref.c +++ b/src/crypto/randomx/argon2_ref.c @@ -36,12 +36,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "argon2.h" -#include "argon2_core.h" +#include "crypto/randomx/argon2.h" +#include "crypto/randomx/argon2_core.h" -#include "blake2/blamka-round-ref.h" -#include "blake2/blake2-impl.h" -#include "blake2/blake2.h" +#include "crypto/randomx/blake2/blamka-round-ref.h" +#include "crypto/randomx/blake2/blake2-impl.h" +#include "crypto/randomx/blake2/blake2.h" /* * Function fills a new memory block and optionally XORs the old block over the new one. diff --git a/src/crypto/randomx/blake2/blake2-impl.h b/src/crypto/randomx/blake2/blake2-impl.h index 617f7c8a3..28f0e3011 100644 --- a/src/crypto/randomx/blake2/blake2-impl.h +++ b/src/crypto/randomx/blake2/blake2-impl.h @@ -37,7 +37,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include -#include "endian.h" +#include "crypto/randomx/blake2/endian.h" static FORCE_INLINE uint64_t load48(const void *src) { const uint8_t *p = (const uint8_t *)src; diff --git a/src/crypto/randomx/blake2/blake2.h b/src/crypto/randomx/blake2/blake2.h index 7ac301ce4..4d364c36c 100644 --- a/src/crypto/randomx/blake2/blake2.h +++ b/src/crypto/randomx/blake2/blake2.h @@ -85,16 +85,14 @@ extern "C" { }; /* Streaming API */ - int blake2b_init(blake2b_state *S, size_t outlen); - int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, - size_t keylen); - int blake2b_init_param(blake2b_state *S, const blake2b_param *P); - int blake2b_update(blake2b_state *S, const void *in, size_t inlen); - int blake2b_final(blake2b_state *S, void *out, size_t outlen); + int rx_blake2b_init(blake2b_state *S, size_t outlen); + int rx_blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, size_t keylen); + int rx_blake2b_init_param(blake2b_state *S, const blake2b_param *P); + int rx_blake2b_update(blake2b_state *S, const void *in, size_t inlen); + int rx_blake2b_final(blake2b_state *S, void *out, size_t outlen); /* Simple API */ - int blake2b(void *out, size_t outlen, const void *in, size_t inlen, - const void *key, size_t keylen); + int rx_blake2b(void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen); /* Argon2 Team - Begin Code */ int rxa2_blake2b_long(void *out, size_t outlen, const void *in, size_t inlen); diff --git a/src/crypto/randomx/blake2/blake2b.c b/src/crypto/randomx/blake2/blake2b.c index 5931ee5c2..d2e028878 100644 --- a/src/crypto/randomx/blake2/blake2b.c +++ b/src/crypto/randomx/blake2/blake2b.c @@ -36,8 +36,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "blake2.h" -#include "blake2-impl.h" +#include "crypto/randomx/blake2/blake2.h" +#include "crypto/randomx/blake2/blake2-impl.h" static const uint64_t blake2b_IV[8] = { UINT64_C(0x6a09e667f3bcc908), UINT64_C(0xbb67ae8584caa73b), @@ -105,7 +105,7 @@ int blake2b_init_param(blake2b_state *S, const blake2b_param *P) { } /* Sequential blake2b initialization */ -int blake2b_init(blake2b_state *S, size_t outlen) { +int rx_blake2b_init(blake2b_state *S, size_t outlen) { blake2b_param P; if (S == NULL) { @@ -133,7 +133,7 @@ int blake2b_init(blake2b_state *S, size_t outlen) { return blake2b_init_param(S, &P); } -int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, size_t keylen) { +int rx_blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, size_t keylen) { blake2b_param P; if (S == NULL) { @@ -172,14 +172,14 @@ int blake2b_init_key(blake2b_state *S, size_t outlen, const void *key, size_t ke uint8_t block[BLAKE2B_BLOCKBYTES]; memset(block, 0, BLAKE2B_BLOCKBYTES); memcpy(block, key, keylen); - blake2b_update(S, block, BLAKE2B_BLOCKBYTES); + rx_blake2b_update(S, block, BLAKE2B_BLOCKBYTES); /* Burn the key from stack */ //clear_internal_memory(block, BLAKE2B_BLOCKBYTES); } return 0; } -static void blake2b_compress(blake2b_state *S, const uint8_t *block) { +static void rx_blake2b_compress(blake2b_state *S, const uint8_t *block) { uint64_t m[16]; uint64_t v[16]; unsigned int i, r; @@ -237,7 +237,7 @@ static void blake2b_compress(blake2b_state *S, const uint8_t *block) { #undef ROUND } -int blake2b_update(blake2b_state *S, const void *in, size_t inlen) { +int rx_blake2b_update(blake2b_state *S, const void *in, size_t inlen) { const uint8_t *pin = (const uint8_t *)in; if (inlen == 0) { @@ -260,14 +260,14 @@ int blake2b_update(blake2b_state *S, const void *in, size_t inlen) { size_t fill = BLAKE2B_BLOCKBYTES - left; memcpy(&S->buf[left], pin, fill); blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); - blake2b_compress(S, S->buf); + rx_blake2b_compress(S, S->buf); S->buflen = 0; inlen -= fill; pin += fill; /* Avoid buffer copies when possible */ while (inlen > BLAKE2B_BLOCKBYTES) { blake2b_increment_counter(S, BLAKE2B_BLOCKBYTES); - blake2b_compress(S, pin); + rx_blake2b_compress(S, pin); inlen -= BLAKE2B_BLOCKBYTES; pin += BLAKE2B_BLOCKBYTES; } @@ -277,7 +277,7 @@ int blake2b_update(blake2b_state *S, const void *in, size_t inlen) { return 0; } -int blake2b_final(blake2b_state *S, void *out, size_t outlen) { +int rx_blake2b_final(blake2b_state *S, void *out, size_t outlen) { uint8_t buffer[BLAKE2B_OUTBYTES] = { 0 }; unsigned int i; @@ -294,7 +294,7 @@ int blake2b_final(blake2b_state *S, void *out, size_t outlen) { blake2b_increment_counter(S, S->buflen); blake2b_set_lastblock(S); memset(&S->buf[S->buflen], 0, BLAKE2B_BLOCKBYTES - S->buflen); /* Padding */ - blake2b_compress(S, S->buf); + rx_blake2b_compress(S, S->buf); for (i = 0; i < 8; ++i) { /* Output full hash to temp buffer */ store64(buffer + sizeof(S->h[i]) * i, S->h[i]); @@ -307,7 +307,7 @@ int blake2b_final(blake2b_state *S, void *out, size_t outlen) { return 0; } -int blake2b(void *out, size_t outlen, const void *in, size_t inlen, +int rx_blake2b(void *out, size_t outlen, const void *in, size_t inlen, const void *key, size_t keylen) { blake2b_state S; int ret = -1; @@ -326,20 +326,20 @@ int blake2b(void *out, size_t outlen, const void *in, size_t inlen, } if (keylen > 0) { - if (blake2b_init_key(&S, outlen, key, keylen) < 0) { + if (rx_blake2b_init_key(&S, outlen, key, keylen) < 0) { goto fail; } } else { - if (blake2b_init(&S, outlen) < 0) { + if (rx_blake2b_init(&S, outlen) < 0) { goto fail; } } - if (blake2b_update(&S, in, inlen) < 0) { + if (rx_blake2b_update(&S, in, inlen) < 0) { goto fail; } - ret = blake2b_final(&S, out, outlen); + ret = rx_blake2b_final(&S, out, outlen); fail: //clear_internal_memory(&S, sizeof(S)); @@ -369,26 +369,26 @@ int rxa2_blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) { } while ((void)0, 0) if (outlen <= BLAKE2B_OUTBYTES) { - TRY(blake2b_init(&blake_state, outlen)); - TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); - TRY(blake2b_update(&blake_state, in, inlen)); - TRY(blake2b_final(&blake_state, out, outlen)); + TRY(rx_blake2b_init(&blake_state, outlen)); + TRY(rx_blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); + TRY(rx_blake2b_update(&blake_state, in, inlen)); + TRY(rx_blake2b_final(&blake_state, out, outlen)); } else { uint32_t toproduce; uint8_t out_buffer[BLAKE2B_OUTBYTES]; uint8_t in_buffer[BLAKE2B_OUTBYTES]; - TRY(blake2b_init(&blake_state, BLAKE2B_OUTBYTES)); - TRY(blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); - TRY(blake2b_update(&blake_state, in, inlen)); - TRY(blake2b_final(&blake_state, out_buffer, BLAKE2B_OUTBYTES)); + TRY(rx_blake2b_init(&blake_state, BLAKE2B_OUTBYTES)); + TRY(rx_blake2b_update(&blake_state, outlen_bytes, sizeof(outlen_bytes))); + TRY(rx_blake2b_update(&blake_state, in, inlen)); + TRY(rx_blake2b_final(&blake_state, out_buffer, BLAKE2B_OUTBYTES)); memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); out += BLAKE2B_OUTBYTES / 2; toproduce = (uint32_t)outlen - BLAKE2B_OUTBYTES / 2; while (toproduce > BLAKE2B_OUTBYTES) { memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); - TRY(blake2b(out_buffer, BLAKE2B_OUTBYTES, in_buffer, + TRY(rx_blake2b(out_buffer, BLAKE2B_OUTBYTES, in_buffer, BLAKE2B_OUTBYTES, NULL, 0)); memcpy(out, out_buffer, BLAKE2B_OUTBYTES / 2); out += BLAKE2B_OUTBYTES / 2; @@ -396,7 +396,7 @@ int rxa2_blake2b_long(void *pout, size_t outlen, const void *in, size_t inlen) { } memcpy(in_buffer, out_buffer, BLAKE2B_OUTBYTES); - TRY(blake2b(out_buffer, toproduce, in_buffer, BLAKE2B_OUTBYTES, NULL, + TRY(rx_blake2b(out_buffer, toproduce, in_buffer, BLAKE2B_OUTBYTES, NULL, 0)); memcpy(out, out_buffer, toproduce); } diff --git a/src/crypto/randomx/blake2/blamka-round-ref.h b/src/crypto/randomx/blake2/blamka-round-ref.h index f1fb50bf8..45606b8f8 100644 --- a/src/crypto/randomx/blake2/blamka-round-ref.h +++ b/src/crypto/randomx/blake2/blamka-round-ref.h @@ -35,8 +35,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #ifndef BLAKE_ROUND_MKA_H #define BLAKE_ROUND_MKA_H -#include "blake2.h" -#include "blake2-impl.h" +#include "crypto/randomx/blake2/blake2.h" +#include "crypto/randomx/blake2/blake2-impl.h" /* designed by the Lyra PHC team */ static FORCE_INLINE uint64_t fBlaMka(uint64_t x, uint64_t y) { diff --git a/src/crypto/randomx/blake2_generator.cpp b/src/crypto/randomx/blake2_generator.cpp index dcf51cecc..83789129e 100644 --- a/src/crypto/randomx/blake2_generator.cpp +++ b/src/crypto/randomx/blake2_generator.cpp @@ -27,9 +27,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include "blake2/blake2.h" -#include "blake2/endian.h" -#include "blake2_generator.hpp" +#include "crypto/randomx/blake2/blake2.h" +#include "crypto/randomx/blake2/endian.h" +#include "crypto/randomx/blake2_generator.hpp" namespace randomx { @@ -55,8 +55,8 @@ namespace randomx { void Blake2Generator::checkData(const size_t bytesNeeded) { if (dataIndex + bytesNeeded > sizeof(data)) { - blake2b(data, sizeof(data), data, sizeof(data), nullptr, 0); + rx_blake2b(data, sizeof(data), data, sizeof(data), nullptr, 0); dataIndex = 0; } } -} \ No newline at end of file +} diff --git a/src/crypto/randomx/bytecode_machine.cpp b/src/crypto/randomx/bytecode_machine.cpp index 8447318e7..6c51b86c3 100644 --- a/src/crypto/randomx/bytecode_machine.cpp +++ b/src/crypto/randomx/bytecode_machine.cpp @@ -26,8 +26,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "bytecode_machine.hpp" -#include "reciprocal.h" +#include "crypto/randomx/bytecode_machine.hpp" +#include "crypto/randomx/reciprocal.h" namespace randomx { diff --git a/src/crypto/randomx/bytecode_machine.hpp b/src/crypto/randomx/bytecode_machine.hpp index 810f854aa..8aee78d89 100644 --- a/src/crypto/randomx/bytecode_machine.hpp +++ b/src/crypto/randomx/bytecode_machine.hpp @@ -28,10 +28,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once -#include "common.hpp" -#include "intrin_portable.h" -#include "instruction.hpp" -#include "program.hpp" +#include "crypto/randomx/common.hpp" +#include "crypto/randomx/intrin_portable.h" +#include "crypto/randomx/instruction.hpp" +#include "crypto/randomx/program.hpp" namespace randomx { diff --git a/src/crypto/randomx/common.hpp b/src/crypto/randomx/common.hpp index 7f7ea0edb..31b18ce42 100644 --- a/src/crypto/randomx/common.hpp +++ b/src/crypto/randomx/common.hpp @@ -31,9 +31,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "blake2/endian.h" -#include "configuration.h" -#include "randomx.h" +#include "crypto/randomx/blake2/endian.h" +#include "crypto/randomx/configuration.h" +#include "crypto/randomx/randomx.h" namespace randomx { diff --git a/src/crypto/randomx/dataset.cpp b/src/crypto/randomx/dataset.cpp index b094b1cb4..8aeafffd8 100644 --- a/src/crypto/randomx/dataset.cpp +++ b/src/crypto/randomx/dataset.cpp @@ -39,17 +39,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "common.hpp" -#include "dataset.hpp" -#include "virtual_memory.hpp" -#include "superscalar.hpp" -#include "blake2_generator.hpp" -#include "reciprocal.h" -#include "blake2/endian.h" -#include "argon2.h" -#include "argon2_core.h" -#include "jit_compiler.hpp" -#include "intrin_portable.h" +#include "crypto/randomx/common.hpp" +#include "crypto/randomx/dataset.hpp" +#include "crypto/randomx/virtual_memory.hpp" +#include "crypto/randomx/superscalar.hpp" +#include "crypto/randomx/blake2_generator.hpp" +#include "crypto/randomx/reciprocal.h" +#include "crypto/randomx/blake2/endian.h" +#include "crypto/randomx/argon2.h" +#include "crypto/randomx/argon2_core.h" +#include "crypto/randomx/jit_compiler.hpp" +#include "crypto/randomx/intrin_portable.h" //static_assert(RANDOMX_ARGON_MEMORY % (RANDOMX_ARGON_LANES * ARGON2_SYNC_POINTS) == 0, "RANDOMX_ARGON_MEMORY - invalid value"); static_assert(ARGON2_BLOCK_SIZE == randomx::ArgonBlockSize, "Unpexpected value of ARGON2_BLOCK_SIZE"); diff --git a/src/crypto/randomx/dataset.hpp b/src/crypto/randomx/dataset.hpp index 42d4f05eb..6c179b5d1 100644 --- a/src/crypto/randomx/dataset.hpp +++ b/src/crypto/randomx/dataset.hpp @@ -31,9 +31,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "common.hpp" -#include "superscalar_program.hpp" -#include "allocator.hpp" +#include "crypto/randomx/common.hpp" +#include "crypto/randomx/superscalar_program.hpp" +#include "crypto/randomx/allocator.hpp" /* Global scope for C binding */ struct randomx_dataset { diff --git a/src/crypto/randomx/instruction.hpp b/src/crypto/randomx/instruction.hpp index 1904afc0c..a3ad6b7a6 100644 --- a/src/crypto/randomx/instruction.hpp +++ b/src/crypto/randomx/instruction.hpp @@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "blake2/endian.h" +#include "crypto/randomx/blake2/endian.h" namespace randomx { diff --git a/src/crypto/randomx/instructions_portable.cpp b/src/crypto/randomx/instructions_portable.cpp index 8f0592dda..b28203a9c 100644 --- a/src/crypto/randomx/instructions_portable.cpp +++ b/src/crypto/randomx/instructions_portable.cpp @@ -28,9 +28,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "common.hpp" -#include "intrin_portable.h" -#include "blake2/endian.h" +#include "crypto/randomx/common.hpp" +#include "crypto/randomx/intrin_portable.h" +#include "crypto/randomx/blake2/endian.h" #if defined(__SIZEOF_INT128__) typedef unsigned __int128 uint128_t; diff --git a/src/crypto/randomx/intrin_portable.h b/src/crypto/randomx/intrin_portable.h index 83acbe65d..e49160967 100644 --- a/src/crypto/randomx/intrin_portable.h +++ b/src/crypto/randomx/intrin_portable.h @@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include "blake2/endian.h" +#include "crypto/randomx/blake2/endian.h" constexpr int32_t unsigned32ToSigned2sCompl(uint32_t x) { return (-1 == ~0) ? (int32_t)x : (x > INT32_MAX ? (-(int32_t)(UINT32_MAX - x) - 1) : (int32_t)x); diff --git a/src/crypto/randomx/jit_compiler.hpp b/src/crypto/randomx/jit_compiler.hpp index bd9c2b0e4..03b605085 100644 --- a/src/crypto/randomx/jit_compiler.hpp +++ b/src/crypto/randomx/jit_compiler.hpp @@ -29,9 +29,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #if defined(_M_X64) || defined(__x86_64__) -#include "jit_compiler_x86.hpp" +#include "crypto/randomx/jit_compiler_x86.hpp" #elif defined(__aarch64__) -#include "jit_compiler_a64.hpp" +#include "crypto/randomx/jit_compiler_a64.hpp" #else -#include "jit_compiler_fallback.hpp" +#include "crypto/randomx/jit_compiler_fallback.hpp" #endif diff --git a/src/crypto/randomx/jit_compiler_a64.hpp b/src/crypto/randomx/jit_compiler_a64.hpp index 58aa25c4d..4b0bed665 100644 --- a/src/crypto/randomx/jit_compiler_a64.hpp +++ b/src/crypto/randomx/jit_compiler_a64.hpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "common.hpp" +#include "crypto/randomx/common.hpp" namespace randomx { @@ -70,4 +70,4 @@ namespace randomx { return 0; } }; -} \ No newline at end of file +} diff --git a/src/crypto/randomx/jit_compiler_fallback.hpp b/src/crypto/randomx/jit_compiler_fallback.hpp index 8103a6321..bc3638589 100644 --- a/src/crypto/randomx/jit_compiler_fallback.hpp +++ b/src/crypto/randomx/jit_compiler_fallback.hpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "common.hpp" +#include "crypto/randomx/common.hpp" namespace randomx { @@ -70,4 +70,4 @@ namespace randomx { return 0; } }; -} \ No newline at end of file +} diff --git a/src/crypto/randomx/jit_compiler_x86.cpp b/src/crypto/randomx/jit_compiler_x86.cpp index 6f04e28a1..dd579c696 100644 --- a/src/crypto/randomx/jit_compiler_x86.cpp +++ b/src/crypto/randomx/jit_compiler_x86.cpp @@ -29,12 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "jit_compiler_x86.hpp" -#include "jit_compiler_x86_static.hpp" -#include "superscalar.hpp" -#include "program.hpp" -#include "reciprocal.h" -#include "virtual_memory.hpp" +#include "crypto/randomx/jit_compiler_x86.hpp" +#include "crypto/randomx/jit_compiler_x86_static.hpp" +#include "crypto/randomx/superscalar.hpp" +#include "crypto/randomx/program.hpp" +#include "crypto/randomx/reciprocal.h" +#include "crypto/randomx/virtual_memory.hpp" namespace randomx { /* diff --git a/src/crypto/randomx/jit_compiler_x86.hpp b/src/crypto/randomx/jit_compiler_x86.hpp index a81c8f4e6..497e66cb0 100644 --- a/src/crypto/randomx/jit_compiler_x86.hpp +++ b/src/crypto/randomx/jit_compiler_x86.hpp @@ -31,7 +31,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "common.hpp" +#include "crypto/randomx/common.hpp" namespace randomx { @@ -138,4 +138,4 @@ namespace randomx { void h_NOP(Instruction&, int); }; -} \ No newline at end of file +} diff --git a/src/crypto/randomx/program.hpp b/src/crypto/randomx/program.hpp index ef8ac748a..404607589 100644 --- a/src/crypto/randomx/program.hpp +++ b/src/crypto/randomx/program.hpp @@ -29,9 +29,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include "common.hpp" -#include "instruction.hpp" -#include "blake2/endian.h" +#include "crypto/randomx/common.hpp" +#include "crypto/randomx/instruction.hpp" +#include "crypto/randomx/blake2/endian.h" namespace randomx { diff --git a/src/crypto/randomx/randomx.cpp b/src/crypto/randomx/randomx.cpp index 9e88bc6db..ffd9e2c54 100644 --- a/src/crypto/randomx/randomx.cpp +++ b/src/crypto/randomx/randomx.cpp @@ -26,14 +26,14 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "randomx.h" -#include "dataset.hpp" -#include "vm_interpreted.hpp" -#include "vm_interpreted_light.hpp" -#include "vm_compiled.hpp" -#include "vm_compiled_light.hpp" -#include "blake2/blake2.h" -#include "jit_compiler_x86_static.hpp" +#include "crypto/randomx/randomx.h" +#include "crypto/randomx/dataset.hpp" +#include "crypto/randomx/vm_interpreted.hpp" +#include "crypto/randomx/vm_interpreted_light.hpp" +#include "crypto/randomx/vm_compiled.hpp" +#include "crypto/randomx/vm_compiled_light.hpp" +#include "crypto/randomx/blake2/blake2.h" +#include "crypto/randomx/jit_compiler_x86_static.hpp" #include RandomX_ConfigurationWownero::RandomX_ConfigurationWownero() @@ -430,12 +430,12 @@ extern "C" { assert(inputSize == 0 || input != nullptr); assert(output != nullptr); alignas(16) uint64_t tempHash[8]; - blake2b(tempHash, sizeof(tempHash), input, inputSize, nullptr, 0); + rx_blake2b(tempHash, sizeof(tempHash), input, inputSize, nullptr, 0); machine->initScratchpad(&tempHash); machine->resetRoundingMode(); for (uint32_t chain = 0; chain < RandomX_CurrentConfig.ProgramCount - 1; ++chain) { machine->run(&tempHash); - blake2b(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0); + rx_blake2b(tempHash, sizeof(tempHash), machine->getRegisterFile(), sizeof(randomx::RegisterFile), nullptr, 0); } machine->run(&tempHash); machine->getFinalResult(output, RANDOMX_HASH_SIZE); diff --git a/src/crypto/randomx/randomx.h b/src/crypto/randomx/randomx.h index d688189fe..137edc507 100644 --- a/src/crypto/randomx/randomx.h +++ b/src/crypto/randomx/randomx.h @@ -32,7 +32,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "intrin_portable.h" +#include "crypto/randomx/intrin_portable.h" #define RANDOMX_HASH_SIZE 32 #define RANDOMX_DATASET_ITEM_SIZE 64 diff --git a/src/crypto/randomx/reciprocal.c b/src/crypto/randomx/reciprocal.c index 22620f53a..87cda2677 100644 --- a/src/crypto/randomx/reciprocal.c +++ b/src/crypto/randomx/reciprocal.c @@ -27,7 +27,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include -#include "reciprocal.h" +#include "crypto/randomx/reciprocal.h" /* Calculates rcp = 2**x / divisor for highest integer x such that rcp < 2**64. diff --git a/src/crypto/randomx/soft_aes.cpp b/src/crypto/randomx/soft_aes.cpp index 3e82fa2ef..a8e592c33 100644 --- a/src/crypto/randomx/soft_aes.cpp +++ b/src/crypto/randomx/soft_aes.cpp @@ -26,7 +26,7 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "soft_aes.h" +#include "crypto/randomx/soft_aes.h" alignas(16) const uint8_t sbox[256] = { 0x63, 0x7c, 0x77, 0x7b, 0xf2, 0x6b, 0x6f, 0xc5, 0x30, 0x01, 0x67, 0x2b, 0xfe, 0xd7, 0xab, 0x76, diff --git a/src/crypto/randomx/soft_aes.h b/src/crypto/randomx/soft_aes.h index 254f8d630..650a81946 100644 --- a/src/crypto/randomx/soft_aes.h +++ b/src/crypto/randomx/soft_aes.h @@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include "intrin_portable.h" +#include "crypto/randomx/intrin_portable.h" rx_vec_i128 soft_aesenc(rx_vec_i128 in, rx_vec_i128 key); @@ -43,4 +43,4 @@ inline rx_vec_i128 aesenc(rx_vec_i128 in, rx_vec_i128 key) { template inline rx_vec_i128 aesdec(rx_vec_i128 in, rx_vec_i128 key) { return soft ? soft_aesdec(in, key) : rx_aesdec_vec_i128(in, key); -} \ No newline at end of file +} diff --git a/src/crypto/randomx/superscalar.cpp b/src/crypto/randomx/superscalar.cpp index 0ca1fe693..4ed993f4e 100644 --- a/src/crypto/randomx/superscalar.cpp +++ b/src/crypto/randomx/superscalar.cpp @@ -26,12 +26,12 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "configuration.h" -#include "program.hpp" -#include "blake2/endian.h" -#include "superscalar.hpp" -#include "intrin_portable.h" -#include "reciprocal.h" +#include "crypto/randomx/configuration.h" +#include "crypto/randomx/program.hpp" +#include "crypto/randomx/blake2/endian.h" +#include "crypto/randomx/superscalar.hpp" +#include "crypto/randomx/intrin_portable.h" +#include "crypto/randomx/reciprocal.h" namespace randomx { diff --git a/src/crypto/randomx/superscalar.hpp b/src/crypto/randomx/superscalar.hpp index bc101c453..fd2a593b4 100644 --- a/src/crypto/randomx/superscalar.hpp +++ b/src/crypto/randomx/superscalar.hpp @@ -30,8 +30,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "superscalar_program.hpp" -#include "blake2_generator.hpp" +#include "crypto/randomx/superscalar_program.hpp" +#include "crypto/randomx/blake2_generator.hpp" namespace randomx { // Intel Ivy Bridge reference @@ -57,4 +57,4 @@ namespace randomx { void generateSuperscalar(SuperscalarProgram& prog, Blake2Generator& gen); void executeSuperscalar(uint64_t(&r)[8], SuperscalarProgram& prog, std::vector *reciprocals = nullptr); -} \ No newline at end of file +} diff --git a/src/crypto/randomx/superscalar_program.hpp b/src/crypto/randomx/superscalar_program.hpp index dbb0b1635..dc173591b 100644 --- a/src/crypto/randomx/superscalar_program.hpp +++ b/src/crypto/randomx/superscalar_program.hpp @@ -29,8 +29,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include "instruction.hpp" -#include "common.hpp" +#include "crypto/randomx/instruction.hpp" +#include "crypto/randomx/common.hpp" namespace randomx { @@ -70,4 +70,4 @@ namespace randomx { int asicLatencies[8]; }; -} \ No newline at end of file +} diff --git a/src/crypto/randomx/virtual_machine.cpp b/src/crypto/randomx/virtual_machine.cpp index c216de697..2913c7e5e 100644 --- a/src/crypto/randomx/virtual_machine.cpp +++ b/src/crypto/randomx/virtual_machine.cpp @@ -29,12 +29,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include -#include "virtual_machine.hpp" -#include "common.hpp" -#include "aes_hash.hpp" -#include "blake2/blake2.h" -#include "intrin_portable.h" -#include "allocator.hpp" +#include "crypto/randomx/virtual_machine.hpp" +#include "crypto/randomx/common.hpp" +#include "crypto/randomx/aes_hash.hpp" +#include "crypto/randomx/blake2/blake2.h" +#include "crypto/randomx/intrin_portable.h" +#include "crypto/randomx/allocator.hpp" randomx_vm::~randomx_vm() { @@ -111,7 +111,7 @@ namespace randomx { template void VmBase::getFinalResult(void* out, size_t outSize) { hashAes1Rx4(scratchpad, ScratchpadSize, ®.a); - blake2b(out, outSize, ®, sizeof(RegisterFile), nullptr, 0); + rx_blake2b(out, outSize, ®, sizeof(RegisterFile), nullptr, 0); } template diff --git a/src/crypto/randomx/virtual_machine.hpp b/src/crypto/randomx/virtual_machine.hpp index cba79d724..2dc89bb57 100644 --- a/src/crypto/randomx/virtual_machine.hpp +++ b/src/crypto/randomx/virtual_machine.hpp @@ -29,8 +29,8 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include "common.hpp" -#include "program.hpp" +#include "crypto/randomx/common.hpp" +#include "crypto/randomx/program.hpp" /* Global namespace for C binding */ class randomx_vm diff --git a/src/crypto/randomx/virtual_memory.cpp b/src/crypto/randomx/virtual_memory.cpp index 661740fc9..06165ffb6 100644 --- a/src/crypto/randomx/virtual_memory.cpp +++ b/src/crypto/randomx/virtual_memory.cpp @@ -30,7 +30,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "crypto/common/VirtualMemory.h" -#include "virtual_memory.hpp" +#include "crypto/randomx/virtual_memory.hpp" void* allocExecutableMemory(std::size_t bytes) { diff --git a/src/crypto/randomx/vm_compiled.cpp b/src/crypto/randomx/vm_compiled.cpp index 4d14c7931..f3b9758c4 100644 --- a/src/crypto/randomx/vm_compiled.cpp +++ b/src/crypto/randomx/vm_compiled.cpp @@ -26,8 +26,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "vm_compiled.hpp" -#include "common.hpp" +#include "crypto/randomx/vm_compiled.hpp" +#include "crypto/randomx/common.hpp" namespace randomx { diff --git a/src/crypto/randomx/vm_compiled.hpp b/src/crypto/randomx/vm_compiled.hpp index 05b34b9c7..6fa824155 100644 --- a/src/crypto/randomx/vm_compiled.hpp +++ b/src/crypto/randomx/vm_compiled.hpp @@ -30,10 +30,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include -#include "virtual_machine.hpp" -#include "jit_compiler.hpp" -#include "allocator.hpp" -#include "dataset.hpp" +#include "crypto/randomx/virtual_machine.hpp" +#include "crypto/randomx/jit_compiler.hpp" +#include "crypto/randomx/allocator.hpp" +#include "crypto/randomx/dataset.hpp" namespace randomx { diff --git a/src/crypto/randomx/vm_compiled_light.cpp b/src/crypto/randomx/vm_compiled_light.cpp index 6009216b3..02115cefd 100644 --- a/src/crypto/randomx/vm_compiled_light.cpp +++ b/src/crypto/randomx/vm_compiled_light.cpp @@ -26,8 +26,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "vm_compiled_light.hpp" -#include "common.hpp" +#include "crypto/randomx/vm_compiled_light.hpp" +#include "crypto/randomx/common.hpp" #include namespace randomx { diff --git a/src/crypto/randomx/vm_compiled_light.hpp b/src/crypto/randomx/vm_compiled_light.hpp index 6cd3cb203..4d8638a82 100644 --- a/src/crypto/randomx/vm_compiled_light.hpp +++ b/src/crypto/randomx/vm_compiled_light.hpp @@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include "vm_compiled.hpp" +#include "crypto/randomx/vm_compiled.hpp" namespace randomx { diff --git a/src/crypto/randomx/vm_interpreted.cpp b/src/crypto/randomx/vm_interpreted.cpp index f4c1e05c9..e21ecfe69 100644 --- a/src/crypto/randomx/vm_interpreted.cpp +++ b/src/crypto/randomx/vm_interpreted.cpp @@ -26,10 +26,10 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "vm_interpreted.hpp" -#include "dataset.hpp" -#include "intrin_portable.h" -#include "reciprocal.h" +#include "crypto/randomx/vm_interpreted.hpp" +#include "crypto/randomx/dataset.hpp" +#include "crypto/randomx/intrin_portable.h" +#include "crypto/randomx/reciprocal.h" namespace randomx { diff --git a/src/crypto/randomx/vm_interpreted.hpp b/src/crypto/randomx/vm_interpreted.hpp index 1dc9ab6dc..b369ab110 100644 --- a/src/crypto/randomx/vm_interpreted.hpp +++ b/src/crypto/randomx/vm_interpreted.hpp @@ -31,10 +31,10 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include #include #include "common.hpp" -#include "virtual_machine.hpp" -#include "bytecode_machine.hpp" -#include "intrin_portable.h" -#include "allocator.hpp" +#include "crypto/randomx/virtual_machine.hpp" +#include "crypto/randomx/bytecode_machine.hpp" +#include "crypto/randomx/intrin_portable.h" +#include "crypto/randomx/allocator.hpp" namespace randomx { diff --git a/src/crypto/randomx/vm_interpreted_light.cpp b/src/crypto/randomx/vm_interpreted_light.cpp index 9c97187b2..bed6f35bc 100644 --- a/src/crypto/randomx/vm_interpreted_light.cpp +++ b/src/crypto/randomx/vm_interpreted_light.cpp @@ -26,8 +26,8 @@ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#include "vm_interpreted_light.hpp" -#include "dataset.hpp" +#include "crypto/randomx/vm_interpreted_light.hpp" +#include "crypto/randomx/dataset.hpp" namespace randomx { diff --git a/src/crypto/randomx/vm_interpreted_light.hpp b/src/crypto/randomx/vm_interpreted_light.hpp index 1a35c5801..c8abba2cf 100644 --- a/src/crypto/randomx/vm_interpreted_light.hpp +++ b/src/crypto/randomx/vm_interpreted_light.hpp @@ -29,7 +29,7 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #pragma once #include -#include "vm_interpreted.hpp" +#include "crypto/randomx/vm_interpreted.hpp" namespace randomx {