diff --git a/CHANGELOG.md b/CHANGELOG.md index 100ce1d3..2acd802b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# 1.6.3 +- Added shift+click function for multi row selection to Dashboard +- Added -DBUILD_STATIC=ON/OFF option to CMake configuration to create fully static builds +- Added current algo and list of supported_varaints to login message for future usage on proxy +- Added support for latest Stellite (XTL) and Alloy (XAO) variants +- Simplification of configuration, "force-pow-variant" and "cryptonight-lite-ipbc" parameters are now deprecated see [Coin Configuration](https://github.com/Bendr0id/xmrigCC/wiki/Coin-configurations) for guidance +- Fixed leaks in transport shutdown # 1.6.2 - Implementation of CN-Lite-IPBC algo - Fixed Windows 32bit build / crashes diff --git a/CMakeLists.txt b/CMakeLists.txt index 69c2e5b0..ffcbc8f4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ option(WITH_HTTPD "HTTP REST API" OFF) option(WITH_CC_CLIENT "CC Client" ON) option(WITH_CC_SERVER "CC Server" ON) option(WITH_TLS "TLS support" ON) +option(BUILD_STATIC "Build static binary" OFF) set(MINER_EXECUTABLE_NAME "xmrigMiner" CACHE STRING "Miner executable file name") set(DAEMON_EXECUTABLE_NAME "xmrigDaemon" CACHE STRING "Daemon executable file name") @@ -209,6 +210,10 @@ else() add_definitions(/DXMRIG_NO_CC) endif() +if (BUILD_STATIC) + set(CMAKE_EXE_LINKER_FLAGS " -static") +endif() + include_directories(src) include_directories(src/3rdparty) include_directories(${UV_INCLUDE_DIR}) diff --git a/README.md b/README.md index b3bda660..25533065 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # XMRigCC -:warning: **To be prepared for the upcoming PoW changes you need to update your miners to at least release (1.5.5).** +:warning: **Confused by all the forks? Check the [Coin Configuration](https://github.com/Bendr0id/xmrigCC/wiki/Coin-configurations) guide.** [![Windows Build status](https://ci.appveyor.com/api/projects/status/l8v7cuuy320a4tpd?svg=true)](https://ci.appveyor.com/project/Bendr0id/xmrigcc) @@ -21,10 +21,15 @@ The modified version can also handle commands like "update config", "start/stop Full Windows/Linux compatible, and you can mix Linux and Windows miner on one XMRigCCServer. ## Additional features of XMRigCC (on top of XMRig) -* **NEW: Support of Crytptonight-Lite-IPBC** + +Check the [Coin Configuration](https://github.com/Bendr0id/xmrigCC/wiki/Coin-configurations) guide + +* **NEW: Support of Crytptonight Stellite (XTL) v4 variant** +* **NEW: Support of Crytptonight Alloy (XAO) variant** +* **NEW: Support of Crytptonight-Lite IPBC/TUBE variant** * **NEW: Support of Crytptonight-Heavy (Sumokoin, Haven, ...)** -* **NEW: Ready for Monero v7 PoW changes on April 6 2018** -* **NEW: Ready for Aeon v7 PoW changes on April 7? 2018** +* **Support of Crytptonight v7 PoW changes** +* **Support of Crytptonight-Lite v7 PoW changes** * Full SSL/TLS support for the whole communication: [Howto](https://github.com/Bendr0id/xmrigCC/wiki/tls) - XMRigCCServer Dashboard <-> Browser - XMRigCCServer <-> XMRigMiner diff --git a/index.html b/index.html index 277566ea..5a999dfb 100644 --- a/index.html +++ b/index.html @@ -7,7 +7,7 @@ - + @@ -127,7 +127,7 @@ ], rowId: 'client_status.client_id', select: { - style: "multi" + style: "multi+shift" }, order: [1, 'asc'], lengthChange: false, diff --git a/src/Cpu.cpp b/src/Cpu.cpp index ddc568e7..ddd4642d 100644 --- a/src/Cpu.cpp +++ b/src/Cpu.cpp @@ -67,7 +67,6 @@ void CpuImpl::optimizeParameters(size_t& threadsCount, size_t& hashFactor, size_t algoBlockSize; switch (algo) { case Options::ALGO_CRYPTONIGHT_LITE: - case Options::ALGO_CRYPTONIGHT_LITE_IPBC: algoBlockSize = 1024; break; case Options::ALGO_CRYPTONIGHT_HEAVY: diff --git a/src/Mem.cpp b/src/Mem.cpp index 871ee20a..522deab4 100644 --- a/src/Mem.cpp +++ b/src/Mem.cpp @@ -44,7 +44,6 @@ cryptonight_ctx *Mem::create(int threadId) switch (m_algo) { case Options::ALGO_CRYPTONIGHT_LITE: - case Options::ALGO_CRYPTONIGHT_LITE_IPBC: scratchPadSize = MEMORY_LITE; break; case Options::ALGO_CRYPTONIGHT_HEAVY: diff --git a/src/Mem_unix.cpp b/src/Mem_unix.cpp index 6cae3a63..b52c449b 100644 --- a/src/Mem_unix.cpp +++ b/src/Mem_unix.cpp @@ -50,7 +50,6 @@ bool Mem::allocate(const Options* options) switch (m_algo) { case Options::ALGO_CRYPTONIGHT_LITE: - case Options::ALGO_CRYPTONIGHT_LITE_IPBC: scratchPadSize = MEMORY_LITE; break; case Options::ALGO_CRYPTONIGHT_HEAVY: diff --git a/src/Mem_win.cpp b/src/Mem_win.cpp index 658d0ceb..a52cc5b5 100644 --- a/src/Mem_win.cpp +++ b/src/Mem_win.cpp @@ -156,7 +156,6 @@ bool Mem::allocate(const Options* options) switch (m_algo) { case Options::ALGO_CRYPTONIGHT_LITE: - case Options::ALGO_CRYPTONIGHT_LITE_IPBC: scratchPadSize = MEMORY_LITE; break; case Options::ALGO_CRYPTONIGHT_HEAVY: diff --git a/src/Options.cpp b/src/Options.cpp index 0e395f87..93b9980e 100644 --- a/src/Options.cpp +++ b/src/Options.cpp @@ -58,13 +58,12 @@ Options *Options::m_self = nullptr; - static char const usage[] = "\ Usage: " APP_ID " [OPTIONS]\n\ Options:\n" # ifndef XMRIG_CC_SERVER "\ - -a, --algo=ALGO cryptonight (default), cryptonight-lite, cryptonight-lite-ipbc or cryptonight-heavy\n\ + -a, --algo=ALGO cryptonight (default), cryptonight-lite or cryptonight-heavy\n\ -o, --url=URL URL of mining server\n\ -O, --userpass=U:P username:password pair for mining server\n\ -u, --user=USERNAME username for mining server\n\ @@ -75,7 +74,7 @@ Options:\n" -k, --keepalive send keepalived for prevent timeout (need pool support)\n\ -r, --retries=N number of times to retry before switch to backup server (default: 5)\n\ -R, --retry-pause=N time to pause between retries (default: 5)\n\ - --force-pow-version=N force to use specific PoW variation (default: 0 POW_AUTODETECT, 1 POW_V1, 2 POW_V2)\n\ + --force-pow-version=N force to use specific PoW variation (default: 0 POW_AUTODETECT, 1 POW_V0, 2 POW_MONERO_V7)\n\ --multihash-factor=N number of hash blocks to process at a time (not set or 0 enables automatic selection of optimal number of hash blocks)\n\ --multihash-thread-mask for av=2/4 only, limits multihash to given threads (mask), (default: all threads)\n\ --cpu-affinity set process affinity to CPU core(s), mask 0x3 for cores 0 and 1\n\ @@ -165,6 +164,7 @@ static struct option const options[] = { { "version", 0, nullptr, 'V' }, { "use-tls", 0, nullptr, 1015 }, { "force-pow-version",1, nullptr, 1016 }, + { "pow-variant" ,1, nullptr, 1017 }, { "api-port", 1, nullptr, 4000 }, { "api-access-token", 1, nullptr, 4001 }, { "api-worker-id", 1, nullptr, 4002 }, @@ -208,6 +208,7 @@ static struct option const config_options[] = { { "threads", 1, nullptr, 't' }, { "user-agent", 1, nullptr, 1008 }, { "force-pow-version", 1, nullptr, 1016 }, + { "pow-variant", 1, nullptr, 1017 }, { "doublehash-thread-mask", 1, nullptr, 4013 }, { "multihash-thread-mask", 1, nullptr, 4013 }, { nullptr, 0, nullptr, 0 } @@ -259,10 +260,23 @@ static struct option const cc_server_options[] = { static const char *algo_names[] = { "cryptonight", "cryptonight-lite", - "cryptonight-lite-ipbc", "cryptonight-heavy" }; +static const char *algo_short_names[] = { + "cn", + "cn-lite", + "cn-heavy" +}; + +constexpr static const char *pow_variant_names[] = { + "auto", + "0", + "1", + "ipbc", + "alloy", + "xtl" +}; Options *Options::parse(int argc, char **argv) { @@ -282,6 +296,10 @@ const char *Options::algoName() const return algo_names[m_algo]; } +const char *Options::algoShortName() const +{ + return algo_short_names[m_algo]; +} Options::Options(int argc, char **argv) : m_background(false), @@ -309,7 +327,7 @@ Options::Options(int argc, char **argv) : m_algo(ALGO_CRYPTONIGHT), m_algoVariant(AV0_AUTO), m_aesni(AESNI_AUTO), - m_forcePowVersion(POW_AUTODETECT), + m_powVariant(POW_AUTODETECT), m_hashFactor(0), m_apiPort(0), m_donateLevel(kDonateLevel), @@ -548,6 +566,9 @@ bool Options::parseArg(int key, const char *arg) case 1015: /* --use-tls */ return parseBoolean(key, true); + case 1017: /* --pow-variant */ + return parsePowVariant(arg); + case 4016: /* --cc-use-tls */ return parseBoolean(key, true); @@ -626,6 +647,7 @@ bool Options::parseArg(int key, uint64_t arg) break; case 'v': /* --av */ + showDeprecateWarning("av", "aesni"); if (arg > 1000) { showUsage(1); return false; @@ -677,12 +699,13 @@ bool Options::parseArg(int key, uint64_t arg) break; case 1016: /* --force-pow-version */ - if (arg < POW_AUTODETECT || arg > POW_V2) { + showDeprecateWarning("force-pow-version", "pow-variant"); + if (arg != POW_AUTODETECT && arg != POW_V0 && arg != POW_V1) { showUsage(1); return false; } - m_forcePowVersion = static_cast(arg); + m_powVariant = static_cast(arg); break; case 1020: /* --cpu-affinity */ @@ -875,6 +898,10 @@ void Options::showUsage(int status) const } } +void Options::showDeprecateWarning(const char* deprecated, const char* newParam) const +{ + fprintf(stderr, "Parameter \"%s\" is deprecated, please used \"%s\" instead.\n", deprecated, newParam); +} void Options::showVersion() { @@ -920,17 +947,19 @@ bool Options::setAlgo(const char *algo) break; } - if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-light")) { + if (i == ARRAY_SIZE(algo_names) - 1 && (!strcmp(algo, "cn-lite") || !strcmp(algo, "cryptonight-light"))) { m_algo = ALGO_CRYPTONIGHT_LITE; break; } - if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-light-ipbc")) { - m_algo = ALGO_CRYPTONIGHT_LITE_IPBC; + if (i == ARRAY_SIZE(algo_names) - 1 && (!strcmp(algo, "cryptonight-lite-ipbc") || !strcmp(algo, "cryptonight-light-ipbc") || !strcmp(algo, "cn-lite-ipbc"))) { + showDeprecateWarning("cryptonight-light-ipbc", "cryptonight-light (with variant \"ipbc\")"); + m_algo = ALGO_CRYPTONIGHT_LITE; + m_powVariant = POW_IPBC; break; } - if (i == ARRAY_SIZE(algo_names) - 1 && !strcmp(algo, "cryptonight-heavy")) { + if (i == ARRAY_SIZE(algo_names) - 1 && (!strcmp(algo, "cryptonight-heavy") || !strcmp(algo, "cn-heavy"))) { m_algo = ALGO_CRYPTONIGHT_HEAVY; break; } @@ -944,6 +973,38 @@ bool Options::setAlgo(const char *algo) return true; } +bool Options::parsePowVariant(const char *powVariant) +{ + for (size_t i = 0; i < ARRAY_SIZE(pow_variant_names); i++) { + if (pow_variant_names[i] && !strcmp(powVariant, pow_variant_names[i])) { + m_powVariant = static_cast(i); + break; + } + + if (i == ARRAY_SIZE(pow_variant_names) - 1 && !strcmp(powVariant, "auto")) { + m_powVariant = POW_AUTODETECT; + break; + } + + if (i == ARRAY_SIZE(pow_variant_names) - 1 && (!strcmp(powVariant, "monerov7") || !strcmp(powVariant, "aeonv7") || !strcmp(powVariant, "v7"))) { + m_powVariant = POW_V1; + break; + } + + if (i == ARRAY_SIZE(pow_variant_names) - 1 && !strcmp(powVariant, "stellite")) { + m_powVariant = POW_XTL; + break; + } + + if (i == ARRAY_SIZE(pow_variant_names) - 1) { + showUsage(1); + return false; + } + } + + return true; +} + void Options::optimizeAlgorithmConfiguration() { // backwards compatibility for configs still setting algo variant (av) diff --git a/src/Options.h b/src/Options.h index bc1d7474..b2434f02 100644 --- a/src/Options.h +++ b/src/Options.h @@ -33,6 +33,7 @@ #include #include "rapidjson/fwd.h" +#include "PowVariant.h" class Url; struct option; @@ -42,10 +43,9 @@ class Options { public: enum Algo { - ALGO_CRYPTONIGHT, /* CryptoNight (Monero) */ - ALGO_CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ - ALGO_CRYPTONIGHT_LITE_IPBC, /* CryptoNight-Lite-IPBC (IPBC) */ - ALGO_CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (SUMO) */ + ALGO_CRYPTONIGHT, /* CryptoNight (2MB ScratchPad) */ + ALGO_CRYPTONIGHT_LITE, /* CryptoNight-Lite (1MB ScratchPad) */ + ALGO_CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (4MB ScratchPad) */ }; enum AlgoVariant { @@ -63,12 +63,6 @@ public: AESNI_OFF }; - enum PowVersion { - POW_AUTODETECT, /* Default, automatic detect by block version */ - POW_V1, /* Force to use PoW algo before 28.03.2018 */ - POW_V2, /* Force to use PoW algo used by Monero V7 (after 28.03.2018) and AEON */ - }; - static inline Options* i() { return m_self; } static Options *parse(int argc, char **argv); @@ -94,7 +88,7 @@ public: inline const char *ccCertFile() const { return m_ccCertFile == nullptr ? "server.pem" : m_ccCertFile; } inline const std::vector &pools() const { return m_pools; } inline Algo algo() const { return m_algo; } - inline PowVersion forcePowVersion() const { return m_forcePowVersion; } + inline PowVariant powVariant() const { return m_powVariant; } inline bool aesni() const { return m_aesni == AESNI_ON; } inline size_t hashFactor() const { return m_hashFactor; } inline int apiPort() const { return m_apiPort; } @@ -110,9 +104,10 @@ public: inline int64_t multiHashThreadMask() const { return m_multiHashThreadMask; } inline void setColors(bool colors) { m_colors = colors; } - inline static void release() { delete m_self; } + inline static void release() { delete m_self; } const char *algoName() const; + const char *algoShortName() const; private: constexpr static uint16_t kDefaultCCPort = 3344; @@ -133,9 +128,11 @@ private: void parseConfig(const char *fileName); void parseJSON(const struct option *option, const rapidjson::Value &object); void showUsage(int status) const; + void showDeprecateWarning(const char* deprecated, const char* newParam) const; void showVersion(void); bool setAlgo(const char *algo); + bool parsePowVariant(const char *powVariant); void optimizeAlgorithmConfiguration(); @@ -164,7 +161,7 @@ private: Algo m_algo; AlgoVariant m_algoVariant; AesNi m_aesni; - PowVersion m_forcePowVersion; + PowVariant m_powVariant; size_t m_hashFactor; int m_apiPort; int m_donateLevel; diff --git a/src/PowVariant.h b/src/PowVariant.h new file mode 100644 index 00000000..73d5583d --- /dev/null +++ b/src/PowVariant.h @@ -0,0 +1,110 @@ +/* XMRigCC + * Copyright 2018- BenDr0id + * + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#ifndef __POW_VARIANT_H__ +#define __POW_VARIANT_H__ + +#include +#include + +enum PowVariant +{ + POW_AUTODETECT, + POW_V0, + POW_V1, + POW_IPBC, + POW_ALLOY, + POW_XTL, + LAST_ITEM +}; + +inline std::string getPowVariantName(PowVariant powVariant) +{ + switch (powVariant) + { + case POW_V0: + return "0"; + case POW_V1: + return "1"; + case POW_IPBC: + return "ipbc"; + case POW_ALLOY: + return "alloy"; + case POW_XTL: + return "xtl"; + case POW_AUTODETECT: + default: + return "-1"; + } +} + +inline std::list getSupportedPowVariants() +{ + std::list supportedPowVariants; + + for (int variant = 0; variant != LAST_ITEM; variant++) + { + supportedPowVariants.push_back(getPowVariantName(static_cast(variant))); + } + + return supportedPowVariants; +} + +inline PowVariant parseVariant(int variant) +{ + PowVariant powVariant = PowVariant::POW_AUTODETECT; + + switch (variant) { + case -1: + powVariant = PowVariant::POW_AUTODETECT; + break; + case 0: + powVariant = PowVariant::POW_V0; + break; + case 1: + powVariant = PowVariant::POW_V1; + break; + default: + break; + } + + return powVariant; +} + + +inline PowVariant parseVariant(const std::string variant) +{ + PowVariant powVariant = PowVariant::POW_AUTODETECT; + + if (variant == "0") { + powVariant = PowVariant::POW_V0; + } else if (variant == "1") { + powVariant = PowVariant::POW_V1; + } else if (variant == "ipbc") { + powVariant = PowVariant::POW_IPBC; + } else if (variant == "alloy") { + powVariant = PowVariant::POW_ALLOY; + } else if (variant == "xtl") { + powVariant = PowVariant::POW_XTL; + } + + return powVariant; +} + + +#endif /* __POW_VARIANT_H__ */ diff --git a/src/crypto/CryptoNight.cpp b/src/crypto/CryptoNight.cpp index 0362ec91..0f9feac3 100644 --- a/src/crypto/CryptoNight.cpp +++ b/src/crypto/CryptoNight.cpp @@ -34,74 +34,70 @@ #include "crypto/CryptoNight_test.h" template -static void cryptonight_aesni(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { +static void cryptonight_aesni(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { # if !defined(XMRIG_ARMv7) - if ((reinterpret_cast(input)[0] > 6 && powVersion == Options::PowVersion::POW_AUTODETECT) || - powVersion == Options::PowVersion::POW_V2) { - CryptoNightMultiHash<0x80000, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); + if (powVersion == PowVariant::POW_V1) { + CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); + } else if (powVersion == PowVariant::POW_ALLOY) { + CryptoNightMultiHash<0x100000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); + } else if (powVersion == PowVariant::POW_XTL) { + CryptoNightMultiHash<0x80000, POW_XLT_V4_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); } else { - CryptoNightMultiHash<0x80000, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); + CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); } # endif } template -static void cryptonight_softaes(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { - if ((reinterpret_cast(input)[0] > 6 && powVersion == Options::PowVersion::POW_AUTODETECT) || - powVersion == Options::PowVersion::POW_V2) { - CryptoNightMultiHash<0x80000, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); +static void cryptonight_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { + if (powVersion == PowVariant::POW_V1) { + CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); + } else if (powVersion == PowVariant::POW_ALLOY) { + CryptoNightMultiHash<0x100000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); + } else if (powVersion == PowVariant::POW_XTL) { + CryptoNightMultiHash<0x80000, POW_XLT_V4_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); } else { - CryptoNightMultiHash<0x80000, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); + CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); } } template -static void cryptonight_lite_aesni(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { +static void cryptonight_lite_aesni(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { # if !defined(XMRIG_ARMv7) - if ((reinterpret_cast(input)[0] > 1 && powVersion == Options::PowVersion::POW_AUTODETECT) || - powVersion == Options::PowVersion::POW_V2) { - CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); + if (powVersion == PowVariant::POW_V1) { + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); + } else if (powVersion == PowVariant::POW_IPBC) { + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hashLiteIpbc(input, size, output, ctx); } else { - CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); } # endif } template -static void cryptonight_lite_softaes(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { - if ((reinterpret_cast(input)[0] > 1 && powVersion == Options::PowVersion::POW_AUTODETECT) || - powVersion == Options::PowVersion::POW_V2) { - CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); +static void cryptonight_lite_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { + if (powVersion == PowVariant::POW_V1) { + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx); + } else if (powVersion == PowVariant::POW_IPBC) { + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashLiteIpbc(input, size, output, ctx); } else { - CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, ctx); } } template -static void cryptonight_lite_ipbc_aesni(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { +static void cryptonight_heavy_aesni(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { # if !defined(XMRIG_ARMv7) - CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hashLiteIpbc(input, size, output, ctx); + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx); # endif } template -static void cryptonight_lite_ipbc_softaes(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { - CryptoNightMultiHash<0x40000, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashLiteIpbc(input, size, output, ctx); +static void cryptonight_heavy_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { + CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx); } -template -static void cryptonight_heavy_aesni(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { -# if !defined(XMRIG_ARMv7) - CryptoNightMultiHash<0x40000, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx); -# endif -} - -template -static void cryptonight_heavy_softaes(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) { - CryptoNightMultiHash<0x40000, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx); -} - -void (*cryptonight_hash_ctx[MAX_NUM_HASH_BLOCKS])(Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx); +void (*cryptonight_hash_ctx[MAX_NUM_HASH_BLOCKS])(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx); template void setCryptoNightHashMethods(Options::Algo algo, bool aesni) @@ -123,14 +119,6 @@ void setCryptoNightHashMethods(Options::Algo algo, bool aesni) } break; - case Options::ALGO_CRYPTONIGHT_LITE_IPBC: - if (aesni) { - cryptonight_hash_ctx[HASH_FACTOR - 1] = cryptonight_lite_ipbc_aesni; - } else { - cryptonight_hash_ctx[HASH_FACTOR - 1] = cryptonight_lite_ipbc_softaes; - } - break; - case Options::ALGO_CRYPTONIGHT_HEAVY: if (aesni) { cryptonight_hash_ctx[HASH_FACTOR - 1] = cryptonight_heavy_aesni; @@ -155,7 +143,7 @@ bool CryptoNight::init(int algo, bool aesni) return selfTest(algo); } -void CryptoNight::hash(size_t factor, Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx* ctx) +void CryptoNight::hash(size_t factor, PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx* ctx) { cryptonight_hash_ctx[factor-1](powVersion, input, size, output, ctx); } @@ -184,113 +172,180 @@ bool CryptoNight::selfTest(int algo) auto ctx = (struct cryptonight_ctx*) _mm_malloc(sizeof(struct cryptonight_ctx), 16); ctx->memory = (uint8_t *) _mm_malloc(MEMORY * 6, 16); - bool resultV1Pow = true; - bool resultV2Pow = true; - bool resultLiteIpbc = true; + bool result = true; + bool resultLite = true; bool resultHeavy = true; if (algo == Options::ALGO_CRYPTONIGHT_HEAVY) { - // cn-heavy tests + // cn-heavy - cryptonight_hash_ctx[0](Options::PowVersion::POW_AUTODETECT, test_input, 76, output, ctx); + cryptonight_hash_ctx[0](PowVariant::POW_V0, test_input, 76, output, ctx); resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 32) == 0; #if MAX_NUM_HASH_BLOCKS > 1 - cryptonight_hash_ctx[1](Options::PowVersion::POW_AUTODETECT, test_input, 76, output, ctx); + cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, ctx); resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 64) == 0; #endif #if MAX_NUM_HASH_BLOCKS > 2 - cryptonight_hash_ctx[2](Options::PowVersion::POW_AUTODETECT, test_input, 76, output, ctx); + cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, ctx); resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 96) == 0; #endif - } else if (algo == Options::ALGO_CRYPTONIGHT_LITE_IPBC) { - // cn-lite-ipbc tests + } else if (algo == Options::ALGO_CRYPTONIGHT_LITE) { + // cn-lite v0 - cryptonight_hash_ctx[0](Options::PowVersion::POW_AUTODETECT, test_input_lite_ipbc, 43, output, ctx); - resultLiteIpbc = resultLiteIpbc && memcmp(output, test_output_lite_ipbc, 32) == 0; + cryptonight_hash_ctx[0](PowVariant::POW_V0, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v0_lite, 32) == 0; #if MAX_NUM_HASH_BLOCKS > 1 - cryptonight_hash_ctx[1](Options::PowVersion::POW_AUTODETECT, test_input_lite_ipbc, 43, output, ctx); - resultLiteIpbc = resultLiteIpbc && memcmp(output, test_output_lite_ipbc, 64) == 0; + cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v0_lite, 64) == 0; #endif #if MAX_NUM_HASH_BLOCKS > 2 - cryptonight_hash_ctx[2](Options::PowVersion::POW_AUTODETECT, test_input_lite_ipbc, 43, output, ctx); - resultLiteIpbc = resultLiteIpbc && memcmp(output, test_output_lite_ipbc, 96) == 0; + cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v0_lite, 96) == 0; #endif #if MAX_NUM_HASH_BLOCKS > 3 - cryptonight_hash_ctx[3](Options::PowVersion::POW_AUTODETECT, test_input_lite_ipbc, 43, output, ctx); - resultLiteIpbc = resultLiteIpbc && memcmp(output, test_output_lite_ipbc, 128) == 0; + cryptonight_hash_ctx[3](PowVariant::POW_V0, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v0_lite, 128) == 0; #endif #if MAX_NUM_HASH_BLOCKS > 4 - cryptonight_hash_ctx[4](Options::PowVersion::POW_AUTODETECT, test_input_lite_ipbc, 43, output, ctx); - resultLiteIpbc = resultLiteIpbc && memcmp(output, test_output_lite_ipbc, 160) == 0; + cryptonight_hash_ctx[4](PowVariant::POW_V0, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v0_lite, 160) == 0; #endif + + // cn-lite v7 tests + + cryptonight_hash_ctx[0](PowVariant::POW_V1, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v1_lite, 32) == 0; + + #if MAX_NUM_HASH_BLOCKS > 1 + cryptonight_hash_ctx[1](PowVariant::POW_V1, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v1_lite, 64) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 2 + cryptonight_hash_ctx[2](PowVariant::POW_V1, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v1_lite, 96) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 3 + cryptonight_hash_ctx[3](PowVariant::POW_V1, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v1_lite, 128) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 4 + cryptonight_hash_ctx[4](PowVariant::POW_V1, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_v1_lite, 160) == 0; + #endif + + + // cn-lite ibpc tests + + cryptonight_hash_ctx[0](PowVariant::POW_IPBC, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_ipbc_lite, 32) == 0; + + #if MAX_NUM_HASH_BLOCKS > 1 + cryptonight_hash_ctx[1](PowVariant::POW_IPBC, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_ipbc_lite, 64) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 2 + cryptonight_hash_ctx[2](PowVariant::POW_IPBC, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_ipbc_lite, 96) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 3 + cryptonight_hash_ctx[3](PowVariant::POW_IPBC, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_ipbc_lite, 128) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 4 + cryptonight_hash_ctx[4](PowVariant::POW_IPBC, test_input, 76, output, ctx); + resultLite = resultLite && memcmp(output, test_output_ipbc_lite, 160) == 0; + #endif + } else { - // < v7 tests autodetect - cryptonight_hash_ctx[0](Options::PowVersion::POW_AUTODETECT,test_input, 76, output, ctx); - resultV1Pow = resultV1Pow && - memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, - 32) == 0; + // cn v0 + + cryptonight_hash_ctx[0](PowVariant::POW_V0,test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v0, 32) == 0; #if MAX_NUM_HASH_BLOCKS > 1 - cryptonight_hash_ctx[1](Options::PowVersion::POW_AUTODETECT, test_input, 76, output, ctx); - resultV1Pow = resultV1Pow && - memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, - 64) == 0; + cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v0, 64) == 0; #endif #if MAX_NUM_HASH_BLOCKS > 2 - cryptonight_hash_ctx[2](Options::PowVersion::POW_AUTODETECT, test_input, 76, output, ctx); - resultV1Pow = resultV1Pow && - memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, - 96) == 0; + cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v0, 96) == 0; #endif - // < v7 tests force pow #if MAX_NUM_HASH_BLOCKS > 3 - cryptonight_hash_ctx[3](Options::PowVersion::POW_V1, test_input, 76, output, ctx); - resultV1Pow = resultV1Pow && - memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, - 128) == 0; + cryptonight_hash_ctx[3](PowVariant::POW_V0, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v0, 128) == 0; #endif #if MAX_NUM_HASH_BLOCKS > 4 - cryptonight_hash_ctx[4](Options::PowVersion::POW_V1, test_input, 76, output, ctx); - resultV1Pow = resultV1Pow && - memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output_light : test_output, - 160) == 0; + cryptonight_hash_ctx[4](PowVariant::POW_V0, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v0, 160) == 0; #endif - // v7 tests autodetect - cryptonight_hash_ctx[0](Options::PowVersion::POW_AUTODETECT, test_input_monero_v2_pow_0, - sizeof(test_input_monero_v2_pow_0), output, ctx); - resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE - ? test_output_monero_v2_pow_light[0] - : test_output_monero_v2_pow[0], 32) == 0; + // cn v7 + + cryptonight_hash_ctx[0](PowVariant::POW_V1, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v1, 32) == 0; #if MAX_NUM_HASH_BLOCKS > 1 - cryptonight_hash_ctx[1](Options::PowVersion::POW_AUTODETECT, test_input_monero_v2_pow_1, - sizeof(test_input_monero_v2_pow_1), output, ctx); - resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE - ? test_output_monero_v2_pow_light[1] - : test_output_monero_v2_pow[1], 32) == 0; + cryptonight_hash_ctx[1](PowVariant::POW_V1, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v1, 64) == 0; #endif - // v7 tests force pow #if MAX_NUM_HASH_BLOCKS > 2 - cryptonight_hash_ctx[2](Options::PowVersion::POW_V2, test_input_monero_v2_pow_2, - sizeof(test_input_monero_v2_pow_2), output, ctx); - resultV2Pow = resultV2Pow && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE - ? test_output_monero_v2_pow_light[2] - : test_output_monero_v2_pow[2], 32) == 0; + cryptonight_hash_ctx[2](PowVariant::POW_V1, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v1, 96) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 3 + cryptonight_hash_ctx[3](PowVariant::POW_V1, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v1, 128) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 4 + cryptonight_hash_ctx[4](PowVariant::POW_V1, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_v1, 160) == 0; + #endif + + // cn xtl + + cryptonight_hash_ctx[0](PowVariant::POW_XTL,test_input, 76, output, ctx); + result = result && memcmp(output, test_output_xtl, 32) == 0; + + #if MAX_NUM_HASH_BLOCKS > 1 + cryptonight_hash_ctx[1](PowVariant::POW_XTL, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_xtl, 64) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 2 + cryptonight_hash_ctx[2](PowVariant::POW_XTL, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_xtl, 96) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 3 + cryptonight_hash_ctx[3](PowVariant::POW_XTL, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_xtl, 128) == 0; + #endif + + #if MAX_NUM_HASH_BLOCKS > 4 + cryptonight_hash_ctx[4](PowVariant::POW_XTL, test_input, 76, output, ctx); + result = result && memcmp(output, test_output_xtl, 160) == 0; #endif } _mm_free(ctx->memory); _mm_free(ctx); - return resultV1Pow && resultV2Pow & resultLiteIpbc & resultHeavy; + return result && resultLite & resultHeavy; } \ No newline at end of file diff --git a/src/crypto/CryptoNight.h b/src/crypto/CryptoNight.h index eb23d715..4032802d 100644 --- a/src/crypto/CryptoNight.h +++ b/src/crypto/CryptoNight.h @@ -34,6 +34,9 @@ #define MEMORY_LITE 1048576 /* 1 MiB */ #define MEMORY_HEAVY 4194304 /* 4 MiB */ +#define POW_DEFAULT_INDEX_SHIFT 3 +#define POW_XLT_V4_INDEX_SHIFT 4 + struct cryptonight_ctx { alignas(16) uint8_t state[MAX_NUM_HASH_BLOCKS][208]; // 208 instead of 200 to maintain aligned to 16 byte boundaries alignas(16) uint8_t* memory; @@ -48,7 +51,7 @@ class CryptoNight public: static bool init(int algo, bool aesni); - static void hash(size_t factor, Options::PowVersion powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx* ctx); + static void hash(size_t factor, PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx* ctx); private: static bool selfTest(int algo); diff --git a/src/crypto/CryptoNight_arm.h b/src/crypto/CryptoNight_arm.h index d5a2150a..d8b9aa48 100644 --- a/src/crypto/CryptoNight_arm.h +++ b/src/crypto/CryptoNight_arm.h @@ -570,7 +570,7 @@ static inline void cn_implode_scratchpad_heavy(const __m128i* input, __m128i* ou } // n-Loop version. Seems to be little bit slower then the hardcoded one. -template +template class CryptoNightMultiHash { public: @@ -697,7 +697,7 @@ public: const uint8_t tmp = reinterpret_cast(&l[hashBlock][idx[hashBlock] & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[hashBlock][idx[hashBlock] & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx[hashBlock] = EXTRACT64(cx); @@ -782,7 +782,7 @@ public: const uint8_t tmp = reinterpret_cast(&l[hashBlock][idx[hashBlock] & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[hashBlock][idx[hashBlock] & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx[hashBlock] = EXTRACT64(cx); @@ -900,8 +900,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -1008,7 +1008,7 @@ public: _mm_store_si128((__m128i*) &l[idx & MASK], _mm_xor_si128(bx, cx)); const uint8_t tmp = reinterpret_cast(&l[idx & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[idx & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx = EXTRACT64(cx); bx = cx; @@ -1078,7 +1078,7 @@ public: _mm_store_si128((__m128i*) &l[idx & MASK], _mm_xor_si128(bx, cx)); const uint8_t tmp = reinterpret_cast(&l[idx & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[idx & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx = EXTRACT64(cx); bx = cx; @@ -1178,8 +1178,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -1329,10 +1329,10 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -1439,10 +1439,10 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -1607,8 +1607,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -1808,13 +1808,13 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -1960,13 +1960,13 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -2199,8 +2199,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -2448,16 +2448,16 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -2640,16 +2640,16 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -2946,8 +2946,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -3243,19 +3243,19 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l4[idx4 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l4[idx4 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -3475,19 +3475,19 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l4[idx4 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l4[idx4 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); diff --git a/src/crypto/CryptoNight_test.h b/src/crypto/CryptoNight_test.h index b9c735f4..e51f4424 100644 --- a/src/crypto/CryptoNight_test.h +++ b/src/crypto/CryptoNight_test.h @@ -5,6 +5,7 @@ * Copyright 2014-2016 Wolf9466 * Copyright 2016 Jay D Dee * Copyright 2016-2017 XMRig + * Copyright 2018 BenDroid * * * This program is free software: you can redistribute it and/or modify @@ -24,177 +25,136 @@ #ifndef __CRYPTONIGHT_TEST_H__ #define __CRYPTONIGHT_TEST_H__ - -const static uint8_t test_input[] = { - 0x01, 0x00, 0xFB, 0x8E, 0x8A, 0xC8, 0x05, 0x89, 0x93, 0x23, 0x37, 0x1B, 0xB7, 0x90, 0xDB, 0x19, - 0x21, 0x8A, 0xFD, 0x8D, 0xB8, 0xE3, 0x75, 0x5D, 0x8B, 0x90, 0xF3, 0x9B, 0x3D, 0x55, 0x06, 0xA9, - 0xAB, 0xCE, 0x4F, 0xA9, 0x12, 0x24, 0x45, 0x00, 0x00, 0x00, 0x00, 0xEE, 0x81, 0x46, 0xD4, 0x9F, - 0xA9, 0x3E, 0xE7, 0x24, 0xDE, 0xB5, 0x7D, 0x12, 0xCB, 0xC6, 0xC6, 0xF3, 0xB9, 0x24, 0xD9, 0x46, - 0x12, 0x7C, 0x7A, 0x97, 0x41, 0x8F, 0x93, 0x48, 0x82, 0x8F, 0x0F, 0x02, - 0x03, 0x05, 0xA0, 0xDB, 0xD6, 0xBF, 0x05, 0xCF, 0x16, 0xE5, 0x03, 0xF3, 0xA6, 0x6F, 0x78, 0x00, - 0x7C, 0xBF, 0x34, 0x14, 0x43, 0x32, 0xEC, 0xBF, 0xC2, 0x2E, 0xD9, 0x5C, 0x87, 0x00, 0x38, 0x3B, - 0x30, 0x9A, 0xCE, 0x19, 0x23, 0xA0, 0x96, 0x4B, 0x00, 0x00, 0x00, 0x08, 0xBA, 0x93, 0x9A, 0x62, - 0x72, 0x4C, 0x0D, 0x75, 0x81, 0xFC, 0xE5, 0x76, 0x1E, 0x9D, 0x8A, 0x0E, 0x6A, 0x1C, 0x3F, 0x92, - 0x4F, 0xDD, 0x84, 0x93, 0xD1, 0x11, 0x56, 0x49, 0xC0, 0x5E, 0xB6, 0x01, - 0x01, 0x00, 0xFB, 0x8E, 0x8A, 0xC8, 0x05, 0x89, 0x93, 0x23, 0x37, 0x1B, 0xB7, 0x90, 0xDB, 0x19, - 0x21, 0x8A, 0xFD, 0x8D, 0xB8, 0xE3, 0x75, 0x5D, 0x8B, 0x90, 0xF3, 0x9B, 0x3D, 0x55, 0x06, 0xA9, - 0xAB, 0xCE, 0x4F, 0xA9, 0x12, 0x24, 0x45, 0x00, 0x00, 0x00, 0x00, 0xEE, 0x81, 0x46, 0xD4, 0x9F, - 0xA9, 0x3E, 0xE7, 0x24, 0xDE, 0xB5, 0x7D, 0x12, 0xCB, 0xC6, 0xC6, 0xF3, 0xB9, 0x24, 0xD9, 0x46, - 0x12, 0x7C, 0x7A, 0x97, 0x41, 0x8F, 0x93, 0x48, 0x82, 0x8F, 0x0F, 0x02, - 0x03, 0x05, 0xA0, 0xDB, 0xD6, 0xBF, 0x05, 0xCF, 0x16, 0xE5, 0x03, 0xF3, 0xA6, 0x6F, 0x78, 0x00, - 0x7C, 0xBF, 0x34, 0x14, 0x43, 0x32, 0xEC, 0xBF, 0xC2, 0x2E, 0xD9, 0x5C, 0x87, 0x00, 0x38, 0x3B, - 0x30, 0x9A, 0xCE, 0x19, 0x23, 0xA0, 0x96, 0x4B, 0x00, 0x00, 0x00, 0x08, 0xBA, 0x93, 0x9A, 0x62, - 0x72, 0x4C, 0x0D, 0x75, 0x81, 0xFC, 0xE5, 0x76, 0x1E, 0x9D, 0x8A, 0x0E, 0x6A, 0x1C, 0x3F, 0x92, - 0x4F, 0xDD, 0x84, 0x93, 0xD1, 0x11, 0x56, 0x49, 0xC0, 0x5E, 0xB6, 0x01, - 0x01, 0x00, 0xFB, 0x8E, 0x8A, 0xC8, 0x05, 0x89, 0x93, 0x23, 0x37, 0x1B, 0xB7, 0x90, 0xDB, 0x19, - 0x21, 0x8A, 0xFD, 0x8D, 0xB8, 0xE3, 0x75, 0x5D, 0x8B, 0x90, 0xF3, 0x9B, 0x3D, 0x55, 0x06, 0xA9, - 0xAB, 0xCE, 0x4F, 0xA9, 0x12, 0x24, 0x45, 0x00, 0x00, 0x00, 0x00, 0xEE, 0x81, 0x46, 0xD4, 0x9F, - 0xA9, 0x3E, 0xE7, 0x24, 0xDE, 0xB5, 0x7D, 0x12, 0xCB, 0xC6, 0xC6, 0xF3, 0xB9, 0x24, 0xD9, 0x46, - 0x12, 0x7C, 0x7A, 0x97, 0x41, 0x8F, 0x93, 0x48, 0x82, 0x8F, 0x0F, 0x02, - 0x03, 0x05, 0xA0, 0xDB, 0xD6, 0xBF, 0x05, 0xCF, 0x16, 0xE5, 0x03, 0xF3, 0xA6, 0x6F, 0x78, 0x00, - 0x7C, 0xBF, 0x34, 0x14, 0x43, 0x32, 0xEC, 0xBF, 0xC2, 0x2E, 0xD9, 0x5C, 0x87, 0x00, 0x38, 0x3B, - 0x30, 0x9A, 0xCE, 0x19, 0x23, 0xA0, 0x96, 0x4B, 0x00, 0x00, 0x00, 0x08, 0xBA, 0x93, 0x9A, 0x62, - 0x72, 0x4C, 0x0D, 0x75, 0x81, 0xFC, 0xE5, 0x76, 0x1E, 0x9D, 0x8A, 0x0E, 0x6A, 0x1C, 0x3F, 0x92, - 0x4F, 0xDD, 0x84, 0x93, 0xD1, 0x11, 0x56, 0x49, 0xC0, 0x5E, 0xB6, 0x01 +const static uint8_t test_input[380] = { + 0x03, 0x05, 0xA0, 0xDB, 0xD6, 0xBF, 0x05, 0xCF, 0x16, 0xE5, 0x03, 0xF3, 0xA6, 0x6F, 0x78, 0x00, + 0x7C, 0xBF, 0x34, 0x14, 0x43, 0x32, 0xEC, 0xBF, 0xC2, 0x2E, 0xD9, 0x5C, 0x87, 0x00, 0x38, 0x3B, + 0x30, 0x9A, 0xCE, 0x19, 0x23, 0xA0, 0x96, 0x4B, 0x00, 0x00, 0x00, 0x08, 0xBA, 0x93, 0x9A, 0x62, + 0x72, 0x4C, 0x0D, 0x75, 0x81, 0xFC, 0xE5, 0x76, 0x1E, 0x9D, 0x8A, 0x0E, 0x6A, 0x1C, 0x3F, 0x92, + 0x4F, 0xDD, 0x84, 0x93, 0xD1, 0x11, 0x56, 0x49, 0xC0, 0x5E, 0xB6, 0x01, + 0x01, 0x00, 0xFB, 0x8E, 0x8A, 0xC8, 0x05, 0x89, 0x93, 0x23, 0x37, 0x1B, 0xB7, 0x90, 0xDB, 0x19, + 0x21, 0x8A, 0xFD, 0x8D, 0xB8, 0xE3, 0x75, 0x5D, 0x8B, 0x90, 0xF3, 0x9B, 0x3D, 0x55, 0x06, 0xA9, + 0xAB, 0xCE, 0x4F, 0xA9, 0x12, 0x24, 0x45, 0x00, 0x00, 0x00, 0x00, 0xEE, 0x81, 0x46, 0xD4, 0x9F, + 0xA9, 0x3E, 0xE7, 0x24, 0xDE, 0xB5, 0x7D, 0x12, 0xCB, 0xC6, 0xC6, 0xF3, 0xB9, 0x24, 0xD9, 0x46, + 0x12, 0x7C, 0x7A, 0x97, 0x41, 0x8F, 0x93, 0x48, 0x82, 0x8F, 0x0F, 0x02, + 0x07, 0x07, 0xB4, 0x87, 0xD0, 0xD6, 0x05, 0x26, 0xE0, 0xC6, 0xDD, 0x9B, 0xC7, 0x18, 0xC3, 0xCF, + 0x52, 0x04, 0xBD, 0x4F, 0x9B, 0x27, 0xF6, 0x73, 0xB9, 0x3F, 0xEF, 0x7B, 0xB2, 0xF7, 0x2B, 0xBB, + 0x3F, 0x3E, 0x9C, 0x3E, 0x9D, 0x33, 0x1E, 0xDE, 0xAD, 0xBE, 0xEF, 0x4E, 0x00, 0x91, 0x81, 0x29, + 0x74, 0xB2, 0x70, 0xE7, 0x6D, 0xD2, 0x2A, 0x5F, 0x52, 0x04, 0x93, 0xE6, 0x18, 0x89, 0x40, 0xD8, + 0xC6, 0xE3, 0x90, 0x6E, 0xAA, 0x6A, 0xB7, 0xE2, 0x08, 0x7E, 0x78, 0x0E, + 0x01, 0x00, 0xEE, 0xB2, 0xD1, 0xD6, 0x05, 0xFF, 0x27, 0x7F, 0x26, 0xDB, 0xAA, 0xB2, 0xC9, 0x26, + 0x30, 0xC6, 0xCF, 0x11, 0x64, 0xEA, 0x6C, 0x8A, 0xE0, 0x98, 0x01, 0xF8, 0x75, 0x4B, 0x49, 0xAF, + 0x79, 0x70, 0xAE, 0xEE, 0xA7, 0x62, 0x2C, 0x00, 0x00, 0x00, 0x00, 0x47, 0x8C, 0x63, 0xE7, 0xD8, + 0x40, 0x02, 0x3C, 0xDA, 0xEA, 0x92, 0x52, 0x53, 0xAC, 0xFD, 0xC7, 0x8A, 0x4C, 0x31, 0xB2, 0xF2, + 0xEC, 0x72, 0x7B, 0xFF, 0xCE, 0xC0, 0xE7, 0x12, 0xD4, 0xE9, 0x2A, 0x01, + 0x07, 0x07, 0xA9, 0xB7, 0xD1, 0xD6, 0x05, 0x3F, 0x0D, 0x5E, 0xFD, 0xC7, 0x03, 0xFC, 0xFC, 0xD2, + 0xCE, 0xBC, 0x44, 0xD8, 0xAB, 0x44, 0xA6, 0xA0, 0x3A, 0xE4, 0x4D, 0x8F, 0x15, 0xAF, 0x62, 0x17, + 0xD1, 0xE0, 0x92, 0x85, 0xE4, 0x73, 0xF9, 0x00, 0x00, 0x00, 0xA0, 0xFC, 0x09, 0xDE, 0xAB, 0xF5, + 0x8B, 0x6F, 0x1D, 0xCA, 0xA8, 0xBA, 0xAC, 0x74, 0xDD, 0x74, 0x19, 0xD5, 0xD6, 0x10, 0xEC, 0x38, + 0xCF, 0x50, 0x29, 0x6A, 0x07, 0x0B, 0x93, 0x8F, 0x8F, 0xA8, 0x10, 0x04 }; -const static uint8_t test_output[] = { - 0x1B, 0x60, 0x6A, 0x3F, 0x4A, 0x07, 0xD6, 0x48, 0x9A, 0x1B, 0xCD, 0x07, 0x69, 0x7B, 0xD1, 0x66, - 0x96, 0xB6, 0x1C, 0x8A, 0xE9, 0x82, 0xF6, 0x1A, 0x90, 0x16, 0x0F, 0x4E, 0x52, 0x82, 0x8A, 0x7F, - 0x1A, 0x3F, 0xFB, 0xEE, 0x90, 0x9B, 0x42, 0x0D, 0x91, 0xF7, 0xBE, 0x6E, 0x5F, 0xB5, 0x6D, 0xB7, - 0x1B, 0x31, 0x10, 0xD8, 0x86, 0x01, 0x1E, 0x87, 0x7E, 0xE5, 0x78, 0x6A, 0xFD, 0x08, 0x01, 0x00, - - 0x1B, 0x60, 0x6A, 0x3F, 0x4A, 0x07, 0xD6, 0x48, 0x9A, 0x1B, 0xCD, 0x07, 0x69, 0x7B, 0xD1, 0x66, - 0x96, 0xB6, 0x1C, 0x8A, 0xE9, 0x82, 0xF6, 0x1A, 0x90, 0x16, 0x0F, 0x4E, 0x52, 0x82, 0x8A, 0x7F, - 0x1A, 0x3F, 0xFB, 0xEE, 0x90, 0x9B, 0x42, 0x0D, 0x91, 0xF7, 0xBE, 0x6E, 0x5F, 0xB5, 0x6D, 0xB7, - 0x1B, 0x31, 0x10, 0xD8, 0x86, 0x01, 0x1E, 0x87, 0x7E, 0xE5, 0x78, 0x6A, 0xFD, 0x08, 0x01, 0x00, - - 0x1B, 0x60, 0x6A, 0x3F, 0x4A, 0x07, 0xD6, 0x48, 0x9A, 0x1B, 0xCD, 0x07, 0x69, 0x7B, 0xD1, 0x66, - 0x96, 0xB6, 0x1C, 0x8A, 0xE9, 0x82, 0xF6, 0x1A, 0x90, 0x16, 0x0F, 0x4E, 0x52, 0x82, 0x8A, 0x7F, - 0x1A, 0x3F, 0xFB, 0xEE, 0x90, 0x9B, 0x42, 0x0D, 0x91, 0xF7, 0xBE, 0x6E, 0x5F, 0xB5, 0x6D, 0xB7, - 0x1B, 0x31, 0x10, 0xD8, 0x86, 0x01, 0x1E, 0x87, 0x7E, 0xE5, 0x78, 0x6A, 0xFD, 0x08, 0x01, 0x00 +// CN +const static uint8_t test_output_v0[160] = { + 0x1A, 0x3F, 0xFB, 0xEE, 0x90, 0x9B, 0x42, 0x0D, 0x91, 0xF7, 0xBE, 0x6E, 0x5F, 0xB5, 0x6D, 0xB7, + 0x1B, 0x31, 0x10, 0xD8, 0x86, 0x01, 0x1E, 0x87, 0x7E, 0xE5, 0x78, 0x6A, 0xFD, 0x08, 0x01, 0x00, + 0x1B, 0x60, 0x6A, 0x3F, 0x4A, 0x07, 0xD6, 0x48, 0x9A, 0x1B, 0xCD, 0x07, 0x69, 0x7B, 0xD1, 0x66, + 0x96, 0xB6, 0x1C, 0x8A, 0xE9, 0x82, 0xF6, 0x1A, 0x90, 0x16, 0x0F, 0x4E, 0x52, 0x82, 0x8A, 0x7F, + 0xA1, 0xB4, 0xFA, 0xE3, 0xE5, 0x76, 0xCE, 0xCF, 0xB7, 0x9C, 0xAF, 0x3E, 0x29, 0x92, 0xE4, 0xE0, + 0x31, 0x24, 0x05, 0x48, 0xBF, 0x8D, 0x5F, 0x7B, 0x11, 0x03, 0x60, 0xAA, 0xD7, 0x50, 0x3F, 0x0C, + 0x2D, 0x30, 0xF3, 0x87, 0x4F, 0x86, 0xA1, 0x4A, 0xB5, 0xA2, 0x1A, 0x08, 0xD0, 0x44, 0x2C, 0x9D, + 0x16, 0xE9, 0x28, 0x49, 0xA1, 0xFF, 0x85, 0x6F, 0x12, 0xBB, 0x7D, 0xAB, 0x11, 0x1C, 0xE7, 0xF7, + 0x2D, 0x9D, 0x19, 0xE4, 0xD2, 0x26, 0x44, 0x1E, 0xCD, 0x22, 0x08, 0x24, 0xA8, 0x97, 0x46, 0x62, + 0x04, 0x84, 0x90, 0x4A, 0xEE, 0x99, 0x14, 0xED, 0xB8, 0xC6, 0x0D, 0x37, 0xA1, 0x66, 0x17, 0xB0 }; -const static uint8_t test_output_light[] = { - 0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE, - 0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD, - 0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E, - 0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88, - - 0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE, - 0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD, - 0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E, - 0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88, - - 0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE, - 0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD, - 0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E, - 0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88 +// CN v7 +const static uint8_t test_output_v1[160] = { + 0xF2, 0x2D, 0x3D, 0x62, 0x03, 0xD2, 0xA0, 0x8B, 0x41, 0xD9, 0x02, 0x72, 0x78, 0xD8, 0xBC, 0xC9, + 0x83, 0xAC, 0xAD, 0xA9, 0xB6, 0x8E, 0x52, 0xE3, 0xC6, 0x89, 0x69, 0x2A, 0x50, 0xE9, 0x21, 0xD9, + 0xC9, 0xFA, 0xE8, 0x42, 0x5D, 0x86, 0x88, 0xDC, 0x23, 0x6B, 0xCD, 0xBC, 0x42, 0xFD, 0xB4, 0x2D, + 0x37, 0x6C, 0x6E, 0xC1, 0x90, 0x50, 0x1A, 0xA8, 0x4B, 0x04, 0xA4, 0xB4, 0xCF, 0x1E, 0xE1, 0x22, + 0xE7, 0x8C, 0x5A, 0x6E, 0x38, 0x30, 0x68, 0x4A, 0x73, 0xFC, 0x1B, 0xC6, 0x6D, 0xFC, 0x8D, 0x98, + 0xB4, 0xC2, 0x23, 0x39, 0xAD, 0xE0, 0x9D, 0xF6, 0x6D, 0x8C, 0x6A, 0xAA, 0xF9, 0xB2, 0xE3, 0x4C, + 0xB6, 0x90, 0x6C, 0xE6, 0x15, 0x5E, 0x46, 0x07, 0x9C, 0xB2, 0x6B, 0xAC, 0x3B, 0xAC, 0x1A, 0xDE, + 0x92, 0x2C, 0xD6, 0x0C, 0x46, 0x9D, 0x9B, 0xC2, 0x84, 0x52, 0x65, 0xF6, 0xBD, 0xFA, 0x0D, 0x74, + 0x00, 0x66, 0x10, 0x07, 0xF1, 0x19, 0x06, 0x3A, 0x6C, 0xFF, 0xEE, 0xB2, 0x40, 0xE5, 0x88, 0x2B, + 0x6C, 0xAB, 0x6B, 0x1D, 0x88, 0xB8, 0x44, 0x25, 0xF4, 0xEA, 0xB7, 0xEC, 0xBA, 0x12, 0x8A, 0x24 }; -const static uint8_t test_input_monero_v2_pow_0[] = { - 0x85, 0x19, 0xe0, 0x39, 0x17, 0x2b, 0x0d, 0x70, 0xe5, 0xca, 0x7b, 0x33, 0x83, 0xd6, 0xb3, 0x16, - 0x73, 0x15, 0xa4, 0x22, 0x74, 0x7b, 0x73, 0xf0, 0x19, 0xcf, 0x95, 0x28, 0xf0, 0xfd, 0xe3, 0x41, - 0xfd, 0x0f, 0x2a, 0x63, 0x03, 0x0b, 0xa6, 0x45, 0x05, 0x25, 0xcf, 0x6d, 0xe3, 0x18, 0x37, 0x66, - 0x9a, 0xf6, 0xf1, 0xdf, 0x81, 0x31, 0xfa, 0xf5, 0x0a, 0xaa, 0xb8, 0xd3, 0xa7, 0x40, 0x55, 0x89 -}; - -const static uint8_t test_input_monero_v2_pow_1[] = { - 0x37, 0xa6, 0x36, 0xd7, 0xda, 0xfd, 0xf2, 0x59, 0xb7, 0x28, 0x7e, 0xdd, 0xca, 0x2f, 0x58, 0x09, - 0x9e, 0x98, 0x61, 0x9d, 0x2f, 0x99, 0xbd, 0xb8, 0x96, 0x9d, 0x7b, 0x14, 0x49, 0x81, 0x02, 0xcc, - 0x06, 0x52, 0x01, 0xc8, 0xbe, 0x90, 0xbd, 0x77, 0x73, 0x23, 0xf4, 0x49, 0x84, 0x8b, 0x21, 0x5d, - 0x29, 0x77, 0xc9, 0x2c, 0x4c, 0x1c, 0x2d, 0xa3, 0x6a, 0xb4, 0x6b, 0x2e, 0x38, 0x96, 0x89, 0xed, - 0x97, 0xc1, 0x8f, 0xec, 0x08, 0xcd, 0x3b, 0x03, 0x23, 0x5c, 0x5e, 0x4c, 0x62, 0xa3, 0x7a, 0xd8, - 0x8c, 0x7b, 0x67, 0x93, 0x24, 0x95, 0xa7, 0x10, 0x90, 0xe8, 0x5d, 0xd4, 0x02, 0x0a, 0x93, 0x00 -}; - -const static uint8_t test_input_monero_v2_pow_2[] = { - 0x38, 0x27, 0x4c, 0x97, 0xc4, 0x5a, 0x17, 0x2c, 0xfc, 0x97, 0x67, 0x98, 0x70, 0x42, 0x2e, 0x3a, - 0x1a, 0xb0, 0x78, 0x49, 0x60, 0xc6, 0x05, 0x14, 0xd8, 0x16, 0x27, 0x14, 0x15, 0xc3, 0x06, 0xee, - 0x3a, 0x3e, 0xd1, 0xa7, 0x7e, 0x31, 0xf6, 0xa8, 0x85, 0xc3, 0xcb -}; - -const static uint8_t test_output_monero_v2_pow[3][32] = { - {0x5b, 0xb4, 0x0c, 0x58, 0x80, 0xce, 0xf2, 0xf7, 0x39, 0xbd, 0xb6, 0xaa, 0xaf, 0x16, 0x16, 0x1e, - 0xaa, 0xe5, 0x55, 0x30, 0xe7, 0xb1, 0x0d, 0x7e, 0xa9, 0x96, 0xb7, 0x51, 0xa2, 0x99, 0xe9, 0x49}, - {0x61, 0x3e, 0x63, 0x85, 0x05, 0xba, 0x1f, 0xd0, 0x5f, 0x42, 0x8d, 0x5c, 0x9f, 0x8e, 0x08, 0xf8, - 0x16, 0x56, 0x14, 0x34, 0x2d, 0xac, 0x41, 0x9a, 0xdc, 0x6a, 0x47, 0xdc, 0xe2, 0x57, 0xeb, 0x3e}, - {0xed, 0x08, 0x2e, 0x49, 0xdb, 0xd5, 0xbb, 0xe3, 0x4a, 0x37, 0x26, 0xa0, 0xd1, 0xda, 0xd9, 0x81, - 0x14, 0x60, 0x62, 0xb3, 0x9d, 0x36, 0xd6, 0x2c, 0x71, 0xeb, 0x1e, 0xd8, 0xab, 0x49, 0x45, 0x9b} -}; - -const static uint8_t test_output_monero_v2_pow_light[3][32] = { - {0xbb, 0x19, 0x6c, 0x4c, 0x0c, 0x9d, 0xc1, 0xc4, 0xe4, 0x4c, 0x2a, 0x6f, 0x9e, 0x61, 0x20, 0x0f, - 0xe3, 0xc8, 0xb4, 0xef, 0x23, 0x21, 0x34, 0xe6, 0x5c, 0x3c, 0x78, 0x62, 0xc7, 0xd3, 0xdf, 0x6a}, - {0x45, 0x21, 0x03, 0x73, 0x1d, 0xd8, 0xd7, 0x0c, 0xe3, 0x2f, 0x72, 0x6b, 0x8e, 0x71, 0xfc, 0xd9, - 0x10, 0x05, 0xfb, 0x3c, 0xb2, 0xab, 0xd7, 0x8f, 0x2b, 0x73, 0x57, 0xbb, 0x07, 0xf8, 0xc8, 0xbc}, - {0x4e, 0x78, 0x53, 0x76, 0xed, 0x27, 0x33, 0x26, 0x2d, 0x83, 0xcc, 0x25, 0x32, 0x1a, 0x9d, 0x00, - 0x03, 0xf5, 0x39, 0x53, 0x15, 0xde, 0x91, 0x9a, 0xcf, 0x1b, 0x97, 0xf0, 0xa8, 0x4f, 0xbd, 0x2d} -}; - -const static uint8_t test_input_lite_ipbc[] = { - 0x38, 0x27, 0x4c, 0x97, 0xc4, 0x5a, 0x17, 0x2c, 0xfc, 0x97, 0x67, 0x98, 0x70, 0x42, 0x2e, 0x3a, - 0x1a, 0xb0, 0x78, 0x49, 0x60, 0xc6, 0x05, 0x14, 0xd8, 0x16, 0x27, 0x14, 0x15, 0xc3, 0x06, 0xee, - 0x3a, 0x3e, 0xd1, 0xa7, 0x7e, 0x31, 0xf6, 0xa8, 0x85, 0xc3, 0xcb, - - 0x38, 0x27, 0x4c, 0x97, 0xc4, 0x5a, 0x17, 0x2c, 0xfc, 0x97, 0x67, 0x98, 0x70, 0x42, 0x2e, 0x3a, - 0x1a, 0xb0, 0x78, 0x49, 0x60, 0xc6, 0x05, 0x14, 0xd8, 0x16, 0x27, 0x14, 0x15, 0xc3, 0x06, 0xee, - 0x3a, 0x3e, 0xd1, 0xa7, 0x7e, 0x31, 0xf6, 0xa8, 0x85, 0xc3, 0xcb, - - 0x38, 0x27, 0x4c, 0x97, 0xc4, 0x5a, 0x17, 0x2c, 0xfc, 0x97, 0x67, 0x98, 0x70, 0x42, 0x2e, 0x3a, - 0x1a, 0xb0, 0x78, 0x49, 0x60, 0xc6, 0x05, 0x14, 0xd8, 0x16, 0x27, 0x14, 0x15, 0xc3, 0x06, 0xee, - 0x3a, 0x3e, 0xd1, 0xa7, 0x7e, 0x31, 0xf6, 0xa8, 0x85, 0xc3, 0xcb, - - 0x38, 0x27, 0x4c, 0x97, 0xc4, 0x5a, 0x17, 0x2c, 0xfc, 0x97, 0x67, 0x98, 0x70, 0x42, 0x2e, 0x3a, - 0x1a, 0xb0, 0x78, 0x49, 0x60, 0xc6, 0x05, 0x14, 0xd8, 0x16, 0x27, 0x14, 0x15, 0xc3, 0x06, 0xee, - 0x3a, 0x3e, 0xd1, 0xa7, 0x7e, 0x31, 0xf6, 0xa8, 0x85, 0xc3, 0xcb, - - 0x38, 0x27, 0x4c, 0x97, 0xc4, 0x5a, 0x17, 0x2c, 0xfc, 0x97, 0x67, 0x98, 0x70, 0x42, 0x2e, 0x3a, - 0x1a, 0xb0, 0x78, 0x49, 0x60, 0xc6, 0x05, 0x14, 0xd8, 0x16, 0x27, 0x14, 0x15, 0xc3, 0x06, 0xee, - 0x3a, 0x3e, 0xd1, 0xa7, 0x7e, 0x31, 0xf6, 0xa8, 0x85, 0xc3, 0xcb, - - 0x38, 0x27, 0x4c, 0x97, 0xc4, 0x5a, 0x17, 0x2c, 0xfc, 0x97, 0x67, 0x98, 0x70, 0x42, 0x2e, 0x3a, - 0x1a, 0xb0, 0x78, 0x49, 0x60, 0xc6, 0x05, 0x14, 0xd8, 0x16, 0x27, 0x14, 0x15, 0xc3, 0x06, 0xee, - 0x3a, 0x3e, 0xd1, 0xa7, 0x7e, 0x31, 0xf6, 0xa8, 0x85, 0xc3, 0xcb +// CN XTL +const static uint8_t test_output_xtl[160] = { + 0x8F, 0xE5, 0xF0, 0x5F, 0x02, 0x2A, 0x61, 0x7D, 0xE5, 0x3F, 0x79, 0x36, 0x4B, 0x25, 0xCB, 0xC3, + 0xC0, 0x8E, 0x0E, 0x1F, 0xE3, 0xBE, 0x48, 0x57, 0x07, 0x03, 0xFE, 0xE1, 0xEC, 0x0E, 0xB0, 0xB1, + 0x21, 0x26, 0xFF, 0x98, 0xE6, 0x86, 0x08, 0x5B, 0xC9, 0x96, 0x44, 0xA3, 0xB8, 0x4E, 0x28, 0x90, + 0x76, 0xED, 0xAD, 0xB9, 0xAA, 0xAC, 0x01, 0x94, 0x1D, 0xBE, 0x3E, 0xEA, 0xAD, 0xEE, 0xB2, 0xCF, + 0xB0, 0x43, 0x4B, 0x88, 0xFC, 0xB2, 0xF3, 0x82, 0x9D, 0xD7, 0xDF, 0x51, 0x97, 0x2C, 0x5A, 0xE3, + 0xC7, 0x16, 0x0B, 0xC8, 0x7C, 0xB7, 0x2F, 0x1C, 0x55, 0x33, 0xCA, 0xE1, 0xEE, 0x08, 0xA4, 0x86, + 0x60, 0xED, 0x6E, 0x9D, 0x2D, 0x05, 0x0D, 0x7D, 0x02, 0x49, 0x23, 0x39, 0x7C, 0xC3, 0x6D, 0x3D, + 0x05, 0x51, 0x28, 0xF1, 0x9B, 0x3C, 0xDF, 0xC4, 0xEA, 0x8A, 0xA6, 0x6A, 0x3C, 0x8B, 0xE2, 0xAF, + 0x47, 0x00, 0xFC, 0x36, 0xED, 0x50, 0xBB, 0xD2, 0x2E, 0x63, 0x4B, 0x93, 0x11, 0x0C, 0xA7, 0xBA, + 0x32, 0x6E, 0x47, 0x4D, 0xCE, 0xCC, 0x82, 0x54, 0x1D, 0x06, 0xF8, 0x06, 0x86, 0xBD, 0x22, 0x48 }; -const static uint8_t test_output_lite_ipbc[] = { - 0xb4, 0x42, 0xa2, 0xb9, 0x56, 0xe6, 0x3f, 0xef, 0xe8, 0x1b, 0xfa, 0x8b, 0xcb, 0xc4, 0xdd, 0xd6, 0xb6, 0x3f, - 0x86, 0x53, 0x0e, 0xea, 0xa4, 0x65, 0x88, 0x31, 0x1d, 0x29, 0x0a, 0xfb, 0xb2, 0xc0, - - 0xb4, 0x42, 0xa2, 0xb9, 0x56, 0xe6, 0x3f, 0xef, 0xe8, 0x1b, 0xfa, 0x8b, 0xcb, 0xc4, 0xdd, 0xd6, 0xb6, 0x3f, - 0x86, 0x53, 0x0e, 0xea, 0xa4, 0x65, 0x88, 0x31, 0x1d, 0x29, 0x0a, 0xfb, 0xb2, 0xc0, - - 0xb4, 0x42, 0xa2, 0xb9, 0x56, 0xe6, 0x3f, 0xef, 0xe8, 0x1b, 0xfa, 0x8b, 0xcb, 0xc4, 0xdd, 0xd6, 0xb6, 0x3f, - 0x86, 0x53, 0x0e, 0xea, 0xa4, 0x65, 0x88, 0x31, 0x1d, 0x29, 0x0a, 0xfb, 0xb2, 0xc0, - - 0xb4, 0x42, 0xa2, 0xb9, 0x56, 0xe6, 0x3f, 0xef, 0xe8, 0x1b, 0xfa, 0x8b, 0xcb, 0xc4, 0xdd, 0xd6, 0xb6, 0x3f, - 0x86, 0x53, 0x0e, 0xea, 0xa4, 0x65, 0x88, 0x31, 0x1d, 0x29, 0x0a, 0xfb, 0xb2, 0xc0, - - 0xb4, 0x42, 0xa2, 0xb9, 0x56, 0xe6, 0x3f, 0xef, 0xe8, 0x1b, 0xfa, 0x8b, 0xcb, 0xc4, 0xdd, 0xd6, 0xb6, 0x3f, - 0x86, 0x53, 0x0e, 0xea, 0xa4, 0x65, 0x88, 0x31, 0x1d, 0x29, 0x0a, 0xfb, 0xb2, 0xc0 +const static uint8_t test_output_v0_lite[160] = { + 0x36, 0x95, 0xB4, 0xB5, 0x3B, 0xB0, 0x03, 0x58, 0xB0, 0xAD, 0x38, 0xDC, 0x16, 0x0F, 0xEB, 0x9E, + 0x00, 0x4E, 0xEC, 0xE0, 0x9B, 0x83, 0xA7, 0x2E, 0xF6, 0xBA, 0x98, 0x64, 0xD3, 0x51, 0x0C, 0x88, + 0x28, 0xA2, 0x2B, 0xAD, 0x3F, 0x93, 0xD1, 0x40, 0x8F, 0xCA, 0x47, 0x2E, 0xB5, 0xAD, 0x1C, 0xBE, + 0x75, 0xF2, 0x1D, 0x05, 0x3C, 0x8C, 0xE5, 0xB3, 0xAF, 0x10, 0x5A, 0x57, 0x71, 0x3E, 0x21, 0xDD, + 0x38, 0x08, 0xE1, 0x17, 0x0B, 0x99, 0x8D, 0x1A, 0x3C, 0xCE, 0x35, 0xC5, 0xC7, 0x3A, 0x00, 0x2E, + 0xCB, 0x54, 0xF0, 0x78, 0x2E, 0x9E, 0xDB, 0xC7, 0xDF, 0x2E, 0x71, 0x9A, 0x16, 0x97, 0xC4, 0x18, + 0x4B, 0x97, 0x07, 0xFE, 0x5D, 0x98, 0x9A, 0xD6, 0xD8, 0xE5, 0x92, 0x66, 0x87, 0x7F, 0x19, 0x37, + 0xA2, 0x5E, 0xE6, 0x96, 0xB5, 0x97, 0x33, 0x89, 0xE0, 0xA7, 0xC9, 0xDD, 0x4A, 0x7E, 0x9E, 0x53, + 0xBE, 0x91, 0x2B, 0xF5, 0xF5, 0xAF, 0xDD, 0x09, 0xA2, 0xF4, 0xA4, 0x56, 0xEB, 0x96, 0x22, 0xC9, + 0x94, 0xFB, 0x7B, 0x28, 0xC9, 0x97, 0x65, 0x04, 0xAC, 0x4F, 0x84, 0x71, 0xDA, 0x6E, 0xD8, 0xC5 }; -const static uint8_t test_output_heavy[] = { - 0x4D, 0x94, 0x7D, 0xD6, 0xDB, 0x6E, 0x07, 0x48, 0x26, 0x4A, 0x51, 0x2E, 0xAC, 0xF3, 0x25, 0x4A, - 0x1F, 0x1A, 0xA2, 0x5B, 0xFC, 0x0A, 0xAD, 0x82, 0xDE, 0xA8, 0x99, 0x96, 0x88, 0x52, 0xD2, 0x7D, - 0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64, - 0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2, - 0x4D, 0x94, 0x7D, 0xD6, 0xDB, 0x6E, 0x07, 0x48, 0x26, 0x4A, 0x51, 0x2E, 0xAC, 0xF3, 0x25, 0x4A, - 0x1F, 0x1A, 0xA2, 0x5B, 0xFC, 0x0A, 0xAD, 0x82, 0xDE, 0xA8, 0x99, 0x96, 0x88, 0x52, 0xD2, 0x7D, - 0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64, - 0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2, - - 0x4D, 0x94, 0x7D, 0xD6, 0xDB, 0x6E, 0x07, 0x48, 0x26, 0x4A, 0x51, 0x2E, 0xAC, 0xF3, 0x25, 0x4A, - 0x1F, 0x1A, 0xA2, 0x5B, 0xFC, 0x0A, 0xAD, 0x82, 0xDE, 0xA8, 0x99, 0x96, 0x88, 0x52, 0xD2, 0x7D, - 0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64, - 0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2 +// CN-Lite v7 +const static uint8_t test_output_v1_lite[160] = { + 0x6D, 0x8C, 0xDC, 0x44, 0x4E, 0x9B, 0xBB, 0xFD, 0x68, 0xFC, 0x43, 0xFC, 0xD4, 0x85, 0x5B, 0x22, + 0x8C, 0x8A, 0x1B, 0xD9, 0x1D, 0x9D, 0x00, 0x28, 0x5B, 0xEC, 0x02, 0xB7, 0xCA, 0x2D, 0x67, 0x41, + 0x87, 0xC4, 0xE5, 0x70, 0x65, 0x3E, 0xB4, 0xC2, 0xB4, 0x2B, 0x7A, 0x0D, 0x54, 0x65, 0x59, 0x45, + 0x2D, 0xFA, 0xB5, 0x73, 0xB8, 0x2E, 0xC5, 0x2F, 0x15, 0x2B, 0x7F, 0xF9, 0x8E, 0x79, 0x44, 0x6F, + 0x16, 0x08, 0x74, 0xC7, 0xA2, 0xD2, 0xA3, 0x97, 0x95, 0x76, 0xCA, 0x4D, 0x06, 0x39, 0x7A, 0xAB, + 0x6C, 0x87, 0x58, 0x33, 0x4D, 0xC8, 0x5A, 0xAB, 0x04, 0x27, 0xFE, 0x8B, 0x1C, 0x23, 0x2F, 0x32, + 0xC0, 0x44, 0xFF, 0x0D, 0xB5, 0x3B, 0x27, 0x96, 0x06, 0x89, 0x7B, 0xA3, 0x0B, 0xD0, 0xCE, 0x9E, + 0x90, 0x22, 0x77, 0x5A, 0xAD, 0xA1, 0xE5, 0xB6, 0xFC, 0xCB, 0x39, 0x7E, 0x2B, 0x10, 0xEE, 0xB4, + 0x8C, 0x2B, 0xA4, 0x1F, 0x60, 0x76, 0x39, 0xD7, 0xF6, 0x46, 0x77, 0x18, 0x20, 0xAD, 0xD4, 0xC9, + 0x87, 0xF7, 0x37, 0xDA, 0xFD, 0xBA, 0xBA, 0xD2, 0xF2, 0x68, 0xDC, 0x26, 0x8D, 0x1B, 0x08, 0xC6 }; +// CN-Lite IPBC +const static uint8_t test_output_ipbc_lite[160] = { + 0xE4, 0x93, 0x8C, 0xAA, 0x59, 0x8D, 0x02, 0x8A, 0xB8, 0x6F, 0x25, 0xD2, 0xB1, 0x23, 0xD0, 0xD5, + 0x33, 0xE3, 0x9F, 0x37, 0xAC, 0xE5, 0xF8, 0xEB, 0x7A, 0xE8, 0x40, 0xEB, 0x5D, 0xB1, 0x35, 0x5F, + 0xB2, 0x47, 0x86, 0xF0, 0x7F, 0x6F, 0x4B, 0x55, 0x3E, 0xA1, 0xBB, 0xE8, 0xA1, 0x75, 0x00, 0x2D, + 0x07, 0x9A, 0x21, 0x0E, 0xBD, 0x06, 0x6A, 0xB0, 0xFD, 0x96, 0x9E, 0xE6, 0xE4, 0x69, 0x67, 0xBB, + 0x88, 0x45, 0x0B, 0x91, 0x0B, 0x7B, 0xCB, 0x21, 0x3C, 0x3C, 0x09, 0x30, 0x07, 0x71, 0x07, 0xD5, + 0xB8, 0x2D, 0x83, 0x09, 0xAF, 0x7E, 0xB2, 0xA8, 0xAC, 0x25, 0xDC, 0x10, 0xF8, 0x63, 0x6A, 0xBC, + 0x73, 0x01, 0x4E, 0xA8, 0x1C, 0xDA, 0x9A, 0x86, 0x17, 0xEC, 0xA8, 0xFB, 0xAA, 0x23, 0x23, 0x17, + 0xE1, 0x32, 0x68, 0x9C, 0x4C, 0xF4, 0x08, 0xED, 0xB0, 0x15, 0xC3, 0xA9, 0x0F, 0xF0, 0xA2, 0x7E, + 0xD9, 0xE4, 0x23, 0xA7, 0x9E, 0x91, 0xD8, 0x73, 0x94, 0xD6, 0x6C, 0x70, 0x9B, 0x8B, 0x72, 0x92, + 0xA3, 0xA4, 0x0A, 0xE2, 0x3C, 0x0A, 0x34, 0x88, 0xA1, 0x6D, 0xFE, 0x02, 0x44, 0x60, 0x7B, 0x3D +}; + + +// CN-Heavy +const static uint8_t test_output_heavy[160] = { + 0x99, 0x83, 0xF2, 0x1B, 0xDF, 0x20, 0x10, 0xA8, 0xD7, 0x07, 0xBB, 0x2F, 0x14, 0xD7, 0x86, 0x64, + 0xBB, 0xE1, 0x18, 0x7F, 0x55, 0x01, 0x4B, 0x39, 0xE5, 0xF3, 0xD6, 0x93, 0x28, 0xE4, 0x8F, 0xC2, + 0x4D, 0x94, 0x7D, 0xD6, 0xDB, 0x6E, 0x07, 0x48, 0x26, 0x4A, 0x51, 0x2E, 0xAC, 0xF3, 0x25, 0x4A, + 0x1F, 0x1A, 0xA2, 0x5B, 0xFC, 0x0A, 0xAD, 0x82, 0xDE, 0xA8, 0x99, 0x96, 0x88, 0x52, 0xD2, 0x7D, + 0x3E, 0xE1, 0x23, 0x03, 0x5A, 0x63, 0x7B, 0x66, 0xF6, 0xD7, 0xC2, 0x2A, 0x34, 0x5E, 0x88, 0xE7, + 0xFA, 0xC4, 0x25, 0x36, 0x54, 0xCB, 0xD2, 0x5C, 0x2F, 0x80, 0x2A, 0xF9, 0xCC, 0x43, 0xF7, 0xCD, + 0xE5, 0x18, 0xA8, 0x05, 0x60, 0x18, 0xA5, 0x73, 0x72, 0x9B, 0x32, 0xDC, 0x69, 0x83, 0xC1, 0xE1, + 0x1F, 0xDB, 0xDA, 0x6B, 0xAC, 0xEC, 0x9F, 0x67, 0xF8, 0x27, 0x1D, 0xC7, 0xE6, 0x46, 0x42, 0xF9, + 0x53, 0x62, 0x0A, 0x54, 0x7D, 0x43, 0xEA, 0x18, 0x94, 0xED, 0xD8, 0x92, 0x06, 0x6A, 0xA1, 0x51, + 0xAD, 0xB1, 0xFD, 0x89, 0xFB, 0x5C, 0xB4, 0x25, 0x6A, 0xDD, 0xB0, 0x09, 0xC5, 0x72, 0x87, 0xEB +}; + #endif /* __CRYPTONIGHT_TEST_H__ */ diff --git a/src/crypto/CryptoNight_x86.h b/src/crypto/CryptoNight_x86.h index 18488bff..4ebbd1c9 100644 --- a/src/crypto/CryptoNight_x86.h +++ b/src/crypto/CryptoNight_x86.h @@ -468,7 +468,7 @@ static inline void cn_implode_scratchpad_heavy(const __m128i* input, __m128i* ou } // n-Loop version. Seems to be little bit slower then the hardcoded one. -template +template class CryptoNightMultiHash { public: @@ -570,8 +570,7 @@ public: al[hashBlock] = h[hashBlock][0] ^ h[hashBlock][4]; ah[hashBlock] = h[hashBlock][1] ^ h[hashBlock][5]; - bx[hashBlock] = - _mm_set_epi64x(h[hashBlock][3] ^ h[hashBlock][7], h[hashBlock][2] ^ h[hashBlock][6]); + bx[hashBlock] = _mm_set_epi64x(h[hashBlock][3] ^ h[hashBlock][7], h[hashBlock][2] ^ h[hashBlock][6]); idx[hashBlock] = h[hashBlock][0] ^ h[hashBlock][4]; } @@ -586,12 +585,11 @@ public: cx = _mm_aesenc_si128(cx, _mm_set_epi64x(ah[hashBlock], al[hashBlock])); } - _mm_store_si128((__m128i*) &l[hashBlock][idx[hashBlock] & MASK], - _mm_xor_si128(bx[hashBlock], cx)); + _mm_store_si128((__m128i*) &l[hashBlock][idx[hashBlock] & MASK], _mm_xor_si128(bx[hashBlock], cx)); const uint8_t tmp = reinterpret_cast(&l[hashBlock][idx[hashBlock] & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[hashBlock][idx[hashBlock] & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx[hashBlock] = EXTRACT64(cx); @@ -674,7 +672,7 @@ public: const uint8_t tmp = reinterpret_cast(&l[hashBlock][idx[hashBlock] & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[hashBlock][idx[hashBlock] & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx[hashBlock] = EXTRACT64(cx); @@ -790,8 +788,8 @@ public: }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -892,7 +890,7 @@ public: _mm_store_si128((__m128i*) &l[idx & MASK], _mm_xor_si128(bx, cx)); const uint8_t tmp = reinterpret_cast(&l[idx & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[idx & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx = EXTRACT64(cx); bx = cx; @@ -959,7 +957,7 @@ public: _mm_store_si128((__m128i*) &l[idx & MASK], _mm_xor_si128(bx, cx)); const uint8_t tmp = reinterpret_cast(&l[idx & MASK])[11]; static const uint32_t table = 0x75310; - const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + const uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l[idx & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx = EXTRACT64(cx); bx = cx; @@ -1056,8 +1054,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -1203,10 +1201,10 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -1311,10 +1309,10 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -1478,8 +1476,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -1675,13 +1673,13 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -1825,13 +1823,13 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -2062,8 +2060,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -2307,16 +2305,16 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -2497,16 +2495,16 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -2801,8 +2799,8 @@ public: } }; -template -class CryptoNightMultiHash +template +class CryptoNightMultiHash { public: inline static void hash(const uint8_t* __restrict__ input, @@ -3094,19 +3092,19 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l4[idx4 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l4[idx4 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); @@ -3324,19 +3322,19 @@ public: static const uint32_t table = 0x75310; uint8_t tmp = reinterpret_cast(&l0[idx0 & MASK])[11]; - uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + uint8_t index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l0[idx0 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l1[idx1 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l1[idx1 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l2[idx2 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l2[idx2 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l3[idx3 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l3[idx3 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); tmp = reinterpret_cast(&l4[idx4 & MASK])[11]; - index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; + index = (((tmp >> INDEX_SHIFT) & 6) | (tmp & 1)) << 1; ((uint8_t*)(&l4[idx4 & MASK]))[11] = tmp ^ ((table >> index) & 0x30); idx0 = EXTRACT64(cx0); diff --git a/src/net/BoostConnection.h b/src/net/BoostConnection.h index 7f74ec5c..31b19f0f 100644 --- a/src/net/BoostConnection.h +++ b/src/net/BoostConnection.h @@ -71,10 +71,14 @@ public: { if (isConnected()) { LOG_DEBUG("[%s:%d] Disconnecting", getConnectedIp().c_str(), getConnectedPort()); + + boost::system::error_code ec; + socket_.get().lowest_layer().shutdown(boost::asio::ip::tcp::socket::shutdown_both, ec); socket_.get().lowest_layer().close(); } ioService_.stop(); + ioService_.reset(); } bool isConnected() const override diff --git a/src/net/Client.cpp b/src/net/Client.cpp index db19db38..b9300d06 100644 --- a/src/net/Client.cpp +++ b/src/net/Client.cpp @@ -30,6 +30,8 @@ #include #include +#include "PowVariant.h" + #include "interfaces/IClientListener.h" #include "log/Log.h" #include "net/Client.h" @@ -224,26 +226,34 @@ bool Client::parseJob(const rapidjson::Value ¶ms, int *code) return false; } - if (params.HasMember("variant")) { - int variantFromProxy = params["variant"].GetInt(); + PowVariant powVariant = Options::i()->powVariant(); - switch (variantFromProxy) { - case -1: - job.setPowVersion(Options::POW_AUTODETECT); - break; - case 0: - job.setPowVersion(Options::POW_V1); - break; - case 1: - job.setPowVersion(Options::POW_V2); - break; - default: - break; + if (params.HasMember("algo")) { + std::string algo = params["algo"].GetString(); + + if (algo.find("/") != std::string::npos) { + powVariant = parseVariant(algo.substr(algo.find("/")+1)); } - } else { - job.setPowVersion(Options::i()->forcePowVersion()); } + if (params.HasMember("variant")) { + const rapidjson::Value &variant = params["variant"]; + + PowVariant parsedVariant = powVariant; + + if (variant.IsInt()) { + parsedVariant = parseVariant(variant.GetInt()); + } else if (variant.IsString()) { + parsedVariant = parseVariant(variant.GetString()); + } + + if (parsedVariant != POW_AUTODETECT) { + powVariant = parsedVariant; + } + } + + job.setPowVariant(powVariant); + if (m_job != job) { m_jobs++; m_job = std::move(job); @@ -350,6 +360,15 @@ void Client::login() params.AddMember("pass", rapidjson::StringRef(m_url.password()), allocator); params.AddMember("agent", rapidjson::StringRef(m_agent), allocator); + params.AddMember("algo", rapidjson::StringRef(Options::i()->algoShortName()), allocator); + + rapidjson::Value supportedPowVariantsList(rapidjson::kArrayType); + for (auto& supportedPowVariant : getSupportedPowVariants()) { + supportedPowVariantsList.PushBack(rapidjson::StringRef(supportedPowVariant.c_str()), allocator); + } + + params.AddMember("supported-variants", supportedPowVariantsList, allocator); + doc.AddMember("params", params, allocator); rapidjson::StringBuffer buffer(0, 512); diff --git a/src/net/Connection.cpp b/src/net/Connection.cpp index 9405025a..c663df33 100644 --- a/src/net/Connection.cpp +++ b/src/net/Connection.cpp @@ -82,6 +82,10 @@ Connection::Ptr establishConnection(const ConnectionListener::Ptr& listener, } catch (...) { LOG_ERR("[%s:%d] Failed to establish connection: %s", host.c_str(), port, boost::current_exception_diagnostic_information().c_str()); + + if (connection) { + connection->disconnect(); + } } diff --git a/src/net/Job.cpp b/src/net/Job.cpp index 23dd85b0..e73cf0e4 100644 --- a/src/net/Job.cpp +++ b/src/net/Job.cpp @@ -62,7 +62,7 @@ Job::Job(int poolId, bool nicehash) : m_size(0), m_diff(0), m_target(0), - m_powVersion(Options::POW_AUTODETECT) + m_powVariant(PowVariant::POW_AUTODETECT) { } @@ -136,6 +136,21 @@ bool Job::setTarget(const char *target) return true; } +PowVariant Job::powVariant() const +{ + if (m_powVariant == PowVariant::POW_AUTODETECT) + { + return (m_blob[0] > 6 ? PowVariant::POW_V1 : PowVariant::POW_V0); + } + else if (m_powVariant == PowVariant::POW_XTL && m_blob[0] < 4) + { + return POW_V1; + } + else + { + return m_powVariant; + } +} bool Job::fromHex(const char* in, unsigned int len, unsigned char* out) { @@ -150,7 +165,6 @@ bool Job::fromHex(const char* in, unsigned int len, unsigned char* out) return true; } - void Job::toHex(const unsigned char* in, unsigned int len, char* out) { for (unsigned int i = 0; i < len; i++) { @@ -159,7 +173,6 @@ void Job::toHex(const unsigned char* in, unsigned int len, char* out) } } - bool Job::operator==(const Job &other) const { return m_id == other.m_id && memcmp(m_blob, other.m_blob, sizeof(m_blob)) == 0; diff --git a/src/net/Job.h b/src/net/Job.h index 01502b18..4bd4642c 100644 --- a/src/net/Job.h +++ b/src/net/Job.h @@ -41,6 +41,7 @@ public: bool setBlob(const char *blob); bool setTarget(const char *target); + PowVariant powVariant() const; inline bool isNicehash() const { return m_nicehash; } inline bool isValid() const { return m_size > 0 && m_diff > 0; } @@ -49,15 +50,13 @@ public: inline const uint32_t *nonce() const { return reinterpret_cast(m_blob + 39); } inline const uint8_t *blob() const { return m_blob; } inline int poolId() const { return m_poolId; } - inline int threadId() const { return m_threadId; } - inline Options::PowVersion powVersion() const { return m_powVersion; } inline size_t size() const { return m_size; } inline uint32_t *nonce() { return reinterpret_cast(m_blob + 39); } inline uint32_t diff() const { return (uint32_t) m_diff; } inline uint64_t target() const { return m_target; } inline void setNicehash(bool nicehash) { m_nicehash = nicehash; } inline void setThreadId(int threadId) { m_threadId = threadId; } - inline void setPowVersion(Options::PowVersion powVersion) { m_powVersion = powVersion; } + inline void setPowVariant(PowVariant powVariant) { m_powVariant = powVariant; } static bool fromHex(const char* in, unsigned int len, unsigned char* out); static inline uint32_t *nonce(uint8_t *blob) { return reinterpret_cast(blob + 39); } @@ -77,7 +76,7 @@ private: size_t m_size; uint64_t m_diff; uint64_t m_target; - Options::PowVersion m_powVersion; + PowVariant m_powVariant; }; #endif /* __JOB_H__ */ diff --git a/src/net/Network.cpp b/src/net/Network.cpp index 9a929711..7eeb7dba 100644 --- a/src/net/Network.cpp +++ b/src/net/Network.cpp @@ -170,12 +170,11 @@ void Network::onResultAccepted(Client *client, const SubmitResult &result, const void Network::setJob(Client *client, const Job &job) { if (m_options->colors()) { - LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m with diff \x1B[01;37m%d\x1B[0m and PoW \x1B[01;37mv%d", - client->host(), client->port(), job.diff(), job.powVersion()); + LOG_INFO("\x1B[01;35mnew job\x1B[0m from \x1B[01;37m%s:%d\x1B[0m with diff \x1B[01;37m%d\x1B[0m and PoW \x1B[01;37m%s", + client->host(), client->port(), job.diff(), getPowVariantName(job.powVariant()).c_str()); } else { - LOG_INFO("new job from %s:%d with diff %d and PoW v%d", - client->host(), client->port(), job.diff(), job.powVersion()); + LOG_INFO("new job from %s:%d with diff %d and PoW %s", client->host(), client->port(), job.diff(), getPowVariantName(job.powVariant()).c_str()); } m_state.diff = job.diff(); diff --git a/src/net/strategies/DonateStrategy.cpp b/src/net/strategies/DonateStrategy.cpp index 8e2d1561..bcd059b3 100644 --- a/src/net/strategies/DonateStrategy.cpp +++ b/src/net/strategies/DonateStrategy.cpp @@ -58,30 +58,18 @@ DonateStrategy::DonateStrategy(const char *agent, IStrategyListener *listener) : #ifndef XMRIG_NO_TLS if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_HEAVY) { url = new Url("donate2.graef.in", 8443, userId, nullptr, true, false, true); - } else if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE_IPBC) { + } else if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE) { url = new Url("donate2.graef.in", 1080, userId, nullptr, true, false, true); } else { - if (Options::i()->forcePowVersion() == Options::POW_V1) { - url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 8081, userId, nullptr, true, false, true); - } else if (Options::i()->forcePowVersion() == Options::POW_V2) { - url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 995 : 993, userId, nullptr, true, false, true); - } else { - url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8081 : 443, userId, nullptr, true, false, true); - } + url = new Url("donate2.graef.in", 443, userId, nullptr, true, false, true); } #else if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_HEAVY) { url = new Url("donate.graef.in", 8443, userId, nullptr, false, false, true); - } else if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE_IPBC) { + } else if (Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE) { url = new Url("donate.graef.in", 1080, userId, nullptr, false, false, true); } else { - if (Options::i()->forcePowVersion() == Options::POW_V1) { - url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 80 : 443, userId, nullptr, false, false, true); - } else if (Options::i()->forcePowVersion() == Options::POW_V2) { - url = new Url("donate.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 995 : 993, userId, nullptr, false, false, true); - } else { - url = new Url("donate2.graef.in", Options::i()->algo() == Options::ALGO_CRYPTONIGHT_LITE ? 8080 : 80, userId, nullptr, false, false, true); - } + url = new Url("donate2.graef.in", 80, userId, nullptr, false, false, true); } #endif diff --git a/src/version.h b/src/version.h index bc101ced..5f85da28 100644 --- a/src/version.h +++ b/src/version.h @@ -36,14 +36,14 @@ #define APP_DESC "XMRigCC CPU miner" #define APP_COPYRIGHT "Copyright (C) 2017- BenDr0id" #endif -#define APP_VERSION "1.6.2 (based on XMRig 2.5.2)" +#define APP_VERSION "1.6.3 (based on XMRig)" #define APP_DOMAIN "" #define APP_SITE "https://github.com/Bendr0id/xmrigCC" #define APP_KIND "cpu" #define APP_VER_MAJOR 1 #define APP_VER_MINOR 6 -#define APP_VER_BUILD 2 +#define APP_VER_BUILD 3 #define APP_VER_REV 0 #ifndef NDEBUG diff --git a/src/workers/MultiWorker.cpp b/src/workers/MultiWorker.cpp index 14a0fde5..d1d16ad6 100644 --- a/src/workers/MultiWorker.cpp +++ b/src/workers/MultiWorker.cpp @@ -120,7 +120,7 @@ void MultiWorker::start() *Job::nonce(m_state->blob + i * m_state->job.size()) = ++m_state->nonces[i]; } - CryptoNight::hash(m_hashMultiplier, m_state->job.powVersion(), m_state->blob, m_state->job.size(), m_hash, m_ctx); + CryptoNight::hash(m_hashMultiplier, m_state->job.powVariant(), m_state->blob, m_state->job.size(), m_hash, m_ctx); for (size_t i=0; i < m_hashMultiplier; ++i) { if (*reinterpret_cast(m_hash + 24 + i * 32) < m_state->job.target()) {