diff --git a/README.md b/README.md index ec405085..6f75dbb3 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ Algorithms * cryptonight (v0, v1, v2, xtl, msr, rto, xao) * cryptonight-light (v0, v1) * cryptonight-heavy (v0, xhv, tube) +* cryptonight-superfast (v0) Usage ----- @@ -24,7 +25,7 @@ So far this native Node.js addon can do the following hashing algos ```javascript var multiHashing = require('cryptonight-hashing'); -var algorithms = ['cryptonight', 'cryptonight_light', 'cryptonight_heavy' ]; +var algorithms = ['cryptonight', 'cryptonight_light', 'cryptonight_heavy', 'cryptonight_superfast' ]; var data = new Buffer("7000000001e980924e4e1109230383e66d62945ff8e749903bea4336755c00000000000051928aff1b4d72416173a8c3948159a09a73ac3bb556aa6bfbcad1a85da7f4c1d13350531e24031b939b9e2b", "hex"); diff --git a/multihashing.cc b/multihashing.cc index cede960f..c946b7b6 100644 --- a/multihashing.cc +++ b/multihashing.cc @@ -144,6 +144,31 @@ NAN_METHOD(cryptonight_heavy) { info.GetReturnValue().Set(returnValue); } +NAN_METHOD(cryptonight_superfast) { + if (info.Length() < 1) return THROW_ERROR_EXCEPTION("You must provide one argument."); + + Local target = info[0]->ToObject(); + if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument 1 should be a buffer object."); + + int variant = 0; + + if (info.Length() >= 2) { + if (!info[1]->IsNumber()) return THROW_ERROR_EXCEPTION("Argument 2 should be a number"); + variant = Nan::To(info[1]).FromMaybe(0); + } + + char output[32]; + init_ctx(); + switch (variant) { + case 0: cryptonight_single_hash(reinterpret_cast(Buffer::Data(target)), Buffer::Length(target), reinterpret_cast(output), &ctx); + break; + default: cryptonight_single_hash(reinterpret_cast(Buffer::Data(target)), Buffer::Length(target), reinterpret_cast(output), &ctx); + } + + v8::Local returnValue = Nan::CopyBuffer(output, 32).ToLocalChecked(); + info.GetReturnValue().Set(returnValue); +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// class CCryptonightAsync : public Nan::AsyncWorker { @@ -360,6 +385,69 @@ NAN_METHOD(cryptonight_heavy_async) { Nan::AsyncQueueWorker(new CCryptonightHeavyAsync(callback, Buffer::Data(target), Buffer::Length(target), variant)); } +class CCryptonightSuperfastAsync : public Nan::AsyncWorker { + + private: + + struct cryptonight_ctx* m_ctx; + const char* const m_input; + const uint32_t m_input_len; + const int m_variant; + char m_output[32]; + + public: + + CCryptonightSuperfastAsync(Nan::Callback* const callback, const char* const input, const uint32_t input_len, const int variant) + : Nan::AsyncWorker(callback), m_ctx(static_cast(_mm_malloc(sizeof(cryptonight_ctx), 16))), + m_input(input), m_input_len(input_len), m_variant(variant) { + m_ctx->memory = static_cast(_mm_malloc(xmrig::CRYPTONIGHT_SUPERFAST_MEMORY, 4096)); + } + + ~CCryptonightSuperfastAsync() { + _mm_free(m_ctx->memory); + _mm_free(m_ctx); + } + + void Execute () { + switch (m_variant) { + case 0: cryptonight_single_hash(reinterpret_cast(m_input), m_input_len, reinterpret_cast(m_output), &m_ctx); + break; + default: cryptonight_single_hash(reinterpret_cast(m_input), m_input_len, reinterpret_cast(m_output), &m_ctx); + } + } + + void HandleOKCallback () { + Nan::HandleScope scope; + + v8::Local argv[] = { + Nan::Null(), + v8::Local(Nan::CopyBuffer(m_output, 32).ToLocalChecked()) + }; + callback->Call(2, argv, async_resource); + } +}; + +NAN_METHOD(cryptonight_superfast_async) { + if (info.Length() < 2) return THROW_ERROR_EXCEPTION("You must provide at least two arguments."); + + Local target = info[0]->ToObject(); + if (!Buffer::HasInstance(target)) return THROW_ERROR_EXCEPTION("Argument should be a buffer object."); + + int variant = 0; + + int callback_arg_num; + if (info.Length() >= 3) { + if (!info[1]->IsNumber()) return THROW_ERROR_EXCEPTION("Argument 2 should be a number"); + variant = Nan::To(info[1]).FromMaybe(0); + callback_arg_num = 2; + } else { + callback_arg_num = 1; + } + + Callback *callback = new Nan::Callback(info[callback_arg_num].As()); + Nan::AsyncQueueWorker(new CCryptonightSuperfastAsync(callback, Buffer::Data(target), Buffer::Length(target), variant)); +} + //////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -370,6 +458,8 @@ NAN_MODULE_INIT(init) { Nan::Set(target, Nan::New("cryptonight_light_async").ToLocalChecked(), Nan::GetFunction(Nan::New(cryptonight_light_async)).ToLocalChecked()); Nan::Set(target, Nan::New("cryptonight_heavy").ToLocalChecked(), Nan::GetFunction(Nan::New(cryptonight_heavy)).ToLocalChecked()); Nan::Set(target, Nan::New("cryptonight_heavy_async").ToLocalChecked(), Nan::GetFunction(Nan::New(cryptonight_heavy_async)).ToLocalChecked()); + Nan::Set(target, Nan::New("cryptonight_superfast").ToLocalChecked(), Nan::GetFunction(Nan::New(cryptonight_superfast)).ToLocalChecked()); + Nan::Set(target, Nan::New("cryptonight_superfast_async").ToLocalChecked(), Nan::GetFunction(Nan::New(cryptonight_superfast_async)).ToLocalChecked()); } NODE_MODULE(cryptonight, init) diff --git a/tests/cryptonight_superfast.txt b/tests/cryptonight_superfast.txt new file mode 100644 index 00000000..72b5ada6 --- /dev/null +++ b/tests/cryptonight_superfast.txt @@ -0,0 +1 @@ +40865aa88741ec1dccbd2bc6ff36b94d547158db94698e3ca03de4819a659fef 0305a0dbd6bf05cf16e503f3a66f78007cbf34144332ecbfc22ed95c8700383b309ace1923a0964b00000008ba939a62724c0d7581fce5761e9d8a0e6a1c3f924fdd8493d1115649c05eb601 diff --git a/tests/run.sh b/tests/run.sh index 1e088096..a6edf6a0 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -8,6 +8,7 @@ node test.js node test_async.js node test_async_light.js node test_async_heavy.js +node test_async_superfast.js node test_sync-1.js node test_sync-2.js node test_sync-xtl.js @@ -20,6 +21,8 @@ node test_sync_light-1.js node test_sync_heavy.js node test_sync_heavy-xhv.js node test_sync_heavy-tube.js +node test_sync_superfast.js node test_perf.js node test_perf_light.js node test_perf_heavy.js +node test_perf_superfast.js diff --git a/tests/test_async_superfast.js b/tests/test_async_superfast.js new file mode 100644 index 00000000..93c499df --- /dev/null +++ b/tests/test_async_superfast.js @@ -0,0 +1,29 @@ +"use strict"; +let multiHashing = require('../build/Release/cryptonight-hashing'); +let fs = require('fs'); +let lineReader = require('readline'); + +let testsFailed = 0, testsPassed = 0, line_count = 0; +let lr = lineReader.createInterface({ + input: fs.createReadStream('cryptonight_superfast.txt') +}); +lr.on('line', function (line) { + let line_data = line.split(/ (.+)/); + line_count += 1; + multiHashing.cryptonight_superfast_async(Buffer.from(line_data[1], 'hex'), function(err, result){ + result = result.toString('hex'); + if (line_data[0] !== result){ + console.error(line_data[1] + ": " + result); + testsFailed += 1; + } else { + testsPassed += 1; + } + if (line_count === (testsFailed + testsPassed)){ + if (testsFailed > 0){ + console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_superfast_async'); + } else { + console.log(testsPassed + ' tests passed on: cryptonight_superfast_async'); + } + } + }); +}); diff --git a/tests/test_perf_superfast.js b/tests/test_perf_superfast.js new file mode 100644 index 00000000..f8f6ee6d --- /dev/null +++ b/tests/test_perf_superfast.js @@ -0,0 +1,12 @@ +"use strict"; +let multiHashing = require('../build/Release/cryptonight-hashing'); + +const ITER = 100; +let input = Buffer.from("test"); + +let start = Date.now(); +for (let i = ITER; i; -- i) { + multiHashing.cryptonight_superfast(input); +} +let end = Date.now(); +console.log("Perf: " + 1000 * ITER / (end - start) + " H/s"); diff --git a/tests/test_sync_superfast.js b/tests/test_sync_superfast.js new file mode 100644 index 00000000..db76530e --- /dev/null +++ b/tests/test_sync_superfast.js @@ -0,0 +1,26 @@ +"use strict"; +let multiHashing = require('../build/Release/cryptonight-hashing'); +let fs = require('fs'); +let lineReader = require('readline'); + +let testsFailed = 0, testsPassed = 0; +let lr = lineReader.createInterface({ + input: fs.createReadStream('cryptonight_superfast.txt') +}); +lr.on('line', function (line) { + let line_data = line.split(/ (.+)/); + let result = multiHashing.cryptonight_superfast(Buffer.from(line_data[1], 'hex')).toString('hex'); + if (line_data[0] !== result){ + console.error(line_data[1] + ": " + result); + testsFailed += 1; + } else { + testsPassed += 1; + } +}); +lr.on('close', function(){ + if (testsFailed > 0){ + console.log(testsFailed + '/' + (testsPassed + testsFailed) + ' tests failed on: cryptonight_superfast'); + } else { + console.log(testsPassed + ' tests passed on: cryptonight_superfast'); + } +}); diff --git a/xmrig/common/xmrig.h b/xmrig/common/xmrig.h index 52650f0d..fae224fe 100644 --- a/xmrig/common/xmrig.h +++ b/xmrig/common/xmrig.h @@ -31,9 +31,10 @@ namespace xmrig enum Algo { INVALID_ALGO = -1, - CRYPTONIGHT, /* CryptoNight (Monero) */ - CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ - CRYPTONIGHT_HEAVY /* CryptoNight-Heavy (RYO) */ + CRYPTONIGHT, /* CryptoNight (Monero) */ + CRYPTONIGHT_LITE, /* CryptoNight-Lite (AEON) */ + CRYPTONIGHT_HEAVY, /* CryptoNight-Heavy (RYO) */ + CRYPTONIGHT_SUPERFAST /* CryptoNight-Superfast (XFH) */ }; @@ -59,7 +60,7 @@ enum AlgoVariant { enum Variant { VARIANT_AUTO = -1, // Autodetect - VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy + VARIANT_0 = 0, // Original CryptoNight or CryptoNight-Heavy or CryptoNight-Superfast VARIANT_1 = 1, // CryptoNight variant 1 also known as Monero7 and CryptoNightV7 VARIANT_TUBE = 2, // Modified CryptoNight-Heavy (TUBE only) VARIANT_XTL = 3, // Modified CryptoNight variant 1 (Stellite only) diff --git a/xmrig/crypto/CryptoNight_arm.h b/xmrig/crypto/CryptoNight_arm.h index 4fcebc3e..4a18a69d 100644 --- a/xmrig/crypto/CryptoNight_arm.h +++ b/xmrig/crypto/CryptoNight_arm.h @@ -243,7 +243,7 @@ static inline void cn_explode_scratchpad(const __m128i *input, __m128i *output) xin6 = _mm_load_si128(input + 10); xin7 = _mm_load_si128(input + 11); - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { for (size_t i = 0; i < 16; i++) { aes_round(k0, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); aes_round(k1, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); @@ -323,12 +323,12 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output) aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); } } - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) { xout0 = _mm_xor_si128(_mm_load_si128(input + i + 0), xout0); xout1 = _mm_xor_si128(_mm_load_si128(input + i + 1), xout1); @@ -510,7 +510,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si ah0 ^= ch; idx0 = al0; - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { const int64x2_t x = vld1q_s64(reinterpret_cast(&l0[idx0 & MASK])); const int64_t n = vgetq_lane_s64(x, 0); const int32_t d = vgetq_lane_s32(x, 2); @@ -518,7 +518,7 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - if (VARIANT == xmrig::VARIANT_XHV) { + if (VARIANT == xmrig::VARIANT_XHV || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { idx0 = (~d) ^ q; } else { @@ -641,7 +641,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si ah0 ^= ch; idx0 = al0; - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { const int64x2_t x = vld1q_s64(reinterpret_cast(&l0[idx0 & MASK])); const int64_t n = vgetq_lane_s64(x, 0); const int32_t d = vgetq_lane_s32(x, 2); @@ -649,7 +649,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - if (VARIANT == xmrig::VARIANT_XHV) { + if (VARIANT == xmrig::VARIANT_XHV || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { idx0 = (~d) ^ q; } else { @@ -684,7 +684,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si ah1 ^= ch; idx1 = al1; - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { const int64x2_t x = vld1q_s64(reinterpret_cast(&l1[idx1 & MASK])); const int64_t n = vgetq_lane_s64(x, 0); const int32_t d = vgetq_lane_s32(x, 2); @@ -692,7 +692,7 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si ((int64_t*)&l1[idx1 & MASK])[0] = n ^ q; - if (VARIANT == xmrig::VARIANT_XHV) { + if (VARIANT == xmrig::VARIANT_XHV || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { idx1 = (~d) ^ q; } else { diff --git a/xmrig/crypto/CryptoNight_constants.h b/xmrig/crypto/CryptoNight_constants.h index f13891a7..9c27c401 100644 --- a/xmrig/crypto/CryptoNight_constants.h +++ b/xmrig/crypto/CryptoNight_constants.h @@ -49,11 +49,16 @@ constexpr const size_t CRYPTONIGHT_HEAVY_MEMORY = 4 * 1024 * 1024; constexpr const uint32_t CRYPTONIGHT_HEAVY_MASK = 0x3FFFF0; constexpr const uint32_t CRYPTONIGHT_HEAVY_ITER = 0x40000; +constexpr const size_t CRYPTONIGHT_SUPERFAST_MEMORY = 2 * 1024 * 1024; +constexpr const uint32_t CRYPTONIGHT_SUPERFAST_MASK = 0x1FFFF0; +constexpr const uint32_t CRYPTONIGHT_SUPERFAST_ITER = 0x20000; -template inline constexpr size_t cn_select_memory() { return 0; } -template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_MEMORY; } -template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_LITE_MEMORY; } -template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_HEAVY_MEMORY; } + +template inline constexpr size_t cn_select_memory() { return 0; } +template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_MEMORY; } +template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_LITE_MEMORY; } +template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_HEAVY_MEMORY; } +template<> inline constexpr size_t cn_select_memory() { return CRYPTONIGHT_SUPERFAST_MEMORY; } inline size_t cn_select_memory(Algo algorithm) @@ -69,6 +74,9 @@ inline size_t cn_select_memory(Algo algorithm) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MEMORY; + case CRYPTONIGHT_SUPERFAST: + return CRYPTONIGHT_SUPERFAST_MEMORY; + default: break; } @@ -77,10 +85,11 @@ inline size_t cn_select_memory(Algo algorithm) } -template inline constexpr uint32_t cn_select_mask() { return 0; } -template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_MASK; } -template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_LITE_MASK; } -template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_HEAVY_MASK; } +template inline constexpr uint32_t cn_select_mask() { return 0; } +template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_MASK; } +template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_LITE_MASK; } +template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_HEAVY_MASK; } +template<> inline constexpr uint32_t cn_select_mask() { return CRYPTONIGHT_SUPERFAST_MASK; } inline uint32_t cn_select_mask(Algo algorithm) @@ -96,6 +105,9 @@ inline uint32_t cn_select_mask(Algo algorithm) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_MASK; + case CRYPTONIGHT_SUPERFAST: + return CRYPTONIGHT_SUPERFAST_MASK; + default: break; } @@ -104,19 +116,20 @@ inline uint32_t cn_select_mask(Algo algorithm) } -template inline constexpr uint32_t cn_select_iter() { return 0; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_MSR_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_XAO_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } -template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } +template inline constexpr uint32_t cn_select_iter() { return 0; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_MSR_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_XAO_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_LITE_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_HEAVY_ITER; } +template<> inline constexpr uint32_t cn_select_iter() { return CRYPTONIGHT_SUPERFAST_ITER; } inline uint32_t cn_select_iter(Algo algorithm, Variant variant) @@ -143,6 +156,9 @@ inline uint32_t cn_select_iter(Algo algorithm, Variant variant) case CRYPTONIGHT_HEAVY: return CRYPTONIGHT_HEAVY_ITER; + case CRYPTONIGHT_SUPERFAST: + return CRYPTONIGHT_SUPERFAST_ITER; + default: break; } diff --git a/xmrig/crypto/CryptoNight_x86.h b/xmrig/crypto/CryptoNight_x86.h index 8dcdd414..dedbe539 100644 --- a/xmrig/crypto/CryptoNight_x86.h +++ b/xmrig/crypto/CryptoNight_x86.h @@ -248,7 +248,7 @@ static inline void cn_explode_scratchpad(const __m128i *input, __m128i *output) xin6 = _mm_load_si128(input + 10); xin7 = _mm_load_si128(input + 11); - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { for (size_t i = 0; i < 16; i++) { aes_round(k0, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); aes_round(k1, &xin0, &xin1, &xin2, &xin3, &xin4, &xin5, &xin6, &xin7); @@ -328,12 +328,12 @@ static inline void cn_implode_scratchpad(const __m128i *input, __m128i *output) aes_round(k8, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); aes_round(k9, &xout0, &xout1, &xout2, &xout3, &xout4, &xout5, &xout6, &xout7); - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { mix_and_propagate(xout0, xout1, xout2, xout3, xout4, xout5, xout6, xout7); } } - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { for (size_t i = 0; i < MEM / sizeof(__m128i); i += 8) { xout0 = _mm_xor_si128(_mm_load_si128(input + i + 0), xout0); xout1 = _mm_xor_si128(_mm_load_si128(input + i + 1), xout1); @@ -535,14 +535,14 @@ inline void cryptonight_single_hash(const uint8_t *__restrict__ input, size_t si ah0 ^= ch; idx0 = al0; - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { int64_t n = ((int64_t*)&l0[idx0 & MASK])[0]; int32_t d = ((int32_t*)&l0[idx0 & MASK])[2]; int64_t q = n / (d | 0x5); ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - if (VARIANT == xmrig::VARIANT_XHV) { + if (VARIANT == xmrig::VARIANT_XHV || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { d = ~d; } @@ -717,14 +717,14 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si ah0 ^= ch; idx0 = al0; - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { int64_t n = ((int64_t*)&l0[idx0 & MASK])[0]; int32_t d = ((int32_t*)&l0[idx0 & MASK])[2]; int64_t q = n / (d | 0x5); ((int64_t*)&l0[idx0 & MASK])[0] = n ^ q; - if (VARIANT == xmrig::VARIANT_XHV) { + if (VARIANT == xmrig::VARIANT_XHV || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { d = ~d; } @@ -758,14 +758,14 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si ah1 ^= ch; idx1 = al1; - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { int64_t n = ((int64_t*)&l1[idx1 & MASK])[0]; int32_t d = ((int32_t*)&l1[idx1 & MASK])[2]; int64_t q = n / (d | 0x5); ((int64_t*)&l1[idx1 & MASK])[0] = n ^ q; - if (VARIANT == xmrig::VARIANT_XHV) { + if (VARIANT == xmrig::VARIANT_XHV || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { d = ~d; } @@ -844,12 +844,12 @@ inline void cryptonight_double_hash(const uint8_t *__restrict__ input, size_t si a = _mm_xor_si128(a, _mm_set_epi64x(ch##part, cl##part)); \ idx = _mm_cvtsi128_si64(a); \ \ - if (ALGO == xmrig::CRYPTONIGHT_HEAVY) { \ + if (ALGO == xmrig::CRYPTONIGHT_HEAVY || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { \ int64_t n = ((int64_t*)&l[idx & MASK])[0]; \ int32_t d = ((int32_t*)&l[idx & MASK])[2]; \ int64_t q = n / (d | 0x5); \ ((int64_t*)&l[idx & MASK])[0] = n ^ q; \ - if (VARIANT == xmrig::VARIANT_XHV) { \ + if (VARIANT == xmrig::VARIANT_XHV || ALGO == xmrig::CRYPTONIGHT_SUPERFAST) { \ d = ~d; \ } \ \