Features of 1.6.5 (#140)
* Hashrate improve -> add autodetection mode for cpu-affinity * Hashrate improve, more stable hashrates -> refactor memory allocation * Add TubeV4 support (cn-heavy + ipbc mod + soft-aes mod) * Update ccp-httpd lib to fix stop/freeze of cc communication on some miners * Fix cn-heavy on arm processors
This commit is contained in:
parent
7897f8f645
commit
90699d58ec
38 changed files with 5525 additions and 3114 deletions
|
@ -34,88 +34,94 @@
|
|||
#include "crypto/CryptoNight_test.h"
|
||||
|
||||
template <size_t NUM_HASH_BLOCKS>
|
||||
static void cryptonight_aesni(PowVariant 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, ScratchPad** scratchPad) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
if (powVersion == PowVariant::POW_V1) {
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_ALLOY) {
|
||||
CryptoNightMultiHash<0x100000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x100000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_XTL) {
|
||||
CryptoNightMultiHash<0x80000, POW_XLT_V4_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x80000, POW_XLT_V4_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_MSR) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_RTO) {
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashLiteIpbc(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashLiteTube(input, size, output, scratchPad);
|
||||
}else {
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, 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, scratchPad);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
template <size_t NUM_HASH_BLOCKS>
|
||||
static void cryptonight_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
|
||||
static void cryptonight_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, ScratchPad** scratchPad) {
|
||||
if (powVersion == PowVariant::POW_V1) {
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_ALLOY) {
|
||||
CryptoNightMultiHash<0x100000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x100000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_XTL) {
|
||||
CryptoNightMultiHash<0x80000, POW_XLT_V4_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x80000, POW_XLT_V4_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_MSR) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_RTO) {
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashLiteIpbc(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashLiteTube(input, size, output, scratchPad);
|
||||
} else {
|
||||
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, 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, scratchPad);
|
||||
}
|
||||
}
|
||||
|
||||
template <size_t NUM_HASH_BLOCKS>
|
||||
static void cryptonight_lite_aesni(PowVariant 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, ScratchPad** scratchPad) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
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);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_TUBE) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, false, NUM_HASH_BLOCKS>::hashLiteTube(input, size, output, scratchPad);
|
||||
} else {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, 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, scratchPad);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
template <size_t NUM_HASH_BLOCKS>
|
||||
static void cryptonight_lite_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
|
||||
static void cryptonight_lite_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, ScratchPad** scratchPad) {
|
||||
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);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashPowV2(input, size, output, scratchPad);
|
||||
} else if (powVersion == PowVariant::POW_TUBE) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_LITE, 0xFFFF0, true, NUM_HASH_BLOCKS>::hashLiteTube(input, size, output, scratchPad);
|
||||
} else {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, 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, scratchPad);
|
||||
}
|
||||
}
|
||||
|
||||
template <size_t NUM_HASH_BLOCKS>
|
||||
static void cryptonight_heavy_aesni(PowVariant 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, ScratchPad** scratchPad) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
if (powVersion == PowVariant::POW_XHV) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, scratchPad);
|
||||
}
|
||||
else if (powVersion == PowVariant::POW_TUBE) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavyTube(input, size, output, scratchPad);
|
||||
}
|
||||
else {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, scratchPad);
|
||||
}
|
||||
# endif
|
||||
}
|
||||
|
||||
template <size_t NUM_HASH_BLOCKS>
|
||||
static void cryptonight_heavy_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx) {
|
||||
static void cryptonight_heavy_softaes(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, ScratchPad** scratchPad) {
|
||||
if (powVersion == PowVariant::POW_XHV) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, scratchPad);
|
||||
}
|
||||
else if (powVersion == PowVariant::POW_TUBE) {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavyTube(input, size, output, scratchPad);
|
||||
}
|
||||
else {
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
|
||||
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, scratchPad);
|
||||
}
|
||||
}
|
||||
|
||||
void (*cryptonight_hash_ctx[MAX_NUM_HASH_BLOCKS])(PowVariant 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, ScratchPad** scratchPad);
|
||||
|
||||
template <size_t HASH_FACTOR>
|
||||
void setCryptoNightHashMethods(Options::Algo algo, bool aesni)
|
||||
|
@ -161,9 +167,9 @@ bool CryptoNight::init(int algo, bool aesni)
|
|||
return selfTest(algo);
|
||||
}
|
||||
|
||||
void CryptoNight::hash(size_t factor, PowVariant 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, ScratchPad** scratchPad)
|
||||
{
|
||||
cryptonight_hash_ctx[factor-1](powVersion, input, size, output, ctx);
|
||||
cryptonight_hash_ctx[factor-1](powVersion, input, size, output, scratchPad);
|
||||
}
|
||||
|
||||
bool CryptoNight::selfTest(int algo)
|
||||
|
@ -187,8 +193,14 @@ bool CryptoNight::selfTest(int algo)
|
|||
|
||||
uint8_t output[160];
|
||||
|
||||
auto ctx = (struct cryptonight_ctx*) _mm_malloc(sizeof(struct cryptonight_ctx), 16);
|
||||
ctx->memory = (uint8_t *) _mm_malloc(MEMORY * 6, 16);
|
||||
ScratchPad* scratchPads [MAX_NUM_HASH_BLOCKS];
|
||||
|
||||
for (size_t i = 0; i < MAX_NUM_HASH_BLOCKS; ++i) {
|
||||
ScratchPad* scratchPad = static_cast<ScratchPad *>(_mm_malloc(sizeof(ScratchPad), 4096));
|
||||
scratchPad->memory = (uint8_t *) _mm_malloc(MEMORY * 6, 16);
|
||||
|
||||
scratchPads[i] = scratchPad;
|
||||
}
|
||||
|
||||
bool result = true;
|
||||
bool resultLite = true;
|
||||
|
@ -197,188 +209,206 @@ bool CryptoNight::selfTest(int algo)
|
|||
if (algo == Options::ALGO_CRYPTONIGHT_HEAVY) {
|
||||
// cn-heavy
|
||||
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 32) == 0;
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 1
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 64) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 2
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy, 96) == 0;
|
||||
#endif
|
||||
|
||||
// cn-heavy haven
|
||||
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_XHV, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_XHV, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy_haven, 32) == 0;
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 1
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_XHV, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_XHV, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy_haven, 64) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 2
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_XHV, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_XHV, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy_haven, 96) == 0;
|
||||
#endif
|
||||
|
||||
// cn-heavy bittube
|
||||
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy_tube, 32) == 0;
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 1
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy_tube, 64) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 2
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
resultHeavy = resultHeavy && memcmp(output, test_output_heavy_tube, 96) == 0;
|
||||
#endif
|
||||
} else if (algo == Options::ALGO_CRYPTONIGHT_LITE) {
|
||||
// cn-lite v0
|
||||
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
resultLite = resultLite && memcmp(output, test_output_v0_lite, 32) == 0;
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 1
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
resultLite = resultLite && memcmp(output, test_output_v0_lite, 64) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 2
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
resultLite = resultLite && memcmp(output, test_output_v0_lite, 96) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 3
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
resultLite = resultLite && memcmp(output, test_output_v0_lite, 128) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 4
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_TUBE, test_input, 76, output, scratchPads);
|
||||
resultLite = resultLite && memcmp(output, test_output_ipbc_lite, 160) == 0;
|
||||
#endif
|
||||
|
||||
} else {
|
||||
// cn v0
|
||||
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V0,test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V0,test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v0, 32) == 0;
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 1
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v0, 64) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 2
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v0, 96) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 3
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v0, 128) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 4
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_V0, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_V0, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v0, 160) == 0;
|
||||
#endif
|
||||
|
||||
// cn v7
|
||||
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V1, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v1, 32) == 0;
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 1
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V1, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v1, 64) == 0;
|
||||
#endif
|
||||
|
||||
#if MAX_NUM_HASH_BLOCKS > 2
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V1, test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_V1, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_v1, 160) == 0;
|
||||
#endif
|
||||
|
||||
// cn xtl
|
||||
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_XTL,test_input, 76, output, ctx);
|
||||
cryptonight_hash_ctx[0](PowVariant::POW_XTL,test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[1](PowVariant::POW_XTL, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[2](PowVariant::POW_XTL, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[3](PowVariant::POW_XTL, test_input, 76, output, scratchPads);
|
||||
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);
|
||||
cryptonight_hash_ctx[4](PowVariant::POW_XTL, test_input, 76, output, scratchPads);
|
||||
result = result && memcmp(output, test_output_xtl, 160) == 0;
|
||||
#endif
|
||||
}
|
||||
_mm_free(ctx->memory);
|
||||
_mm_free(ctx);
|
||||
|
||||
for (size_t i = 0; i < MAX_NUM_HASH_BLOCKS; ++i) {
|
||||
_mm_free(scratchPads[i]->memory);
|
||||
_mm_free(scratchPads[i]);
|
||||
}
|
||||
|
||||
return result && resultLite & resultHeavy;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue