Add Haven v3 support (#134)

This commit is contained in:
Ben Gräf 2018-06-14 21:22:21 +02:00 committed by GitHub
parent ae15b9f5ac
commit 3ecda3e63a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 466 additions and 402 deletions

View file

@ -92,13 +92,23 @@ static void cryptonight_lite_softaes(PowVariant powVersion, const uint8_t* input
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) {
# if !defined(XMRIG_ARMv7)
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
if (powVersion == PowVariant::POW_XHV) {
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, ctx);
}
else {
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, false, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
}
# 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) {
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
if (powVersion == PowVariant::POW_XHV) {
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, ctx);
}
else {
CryptoNightMultiHash<0x40000, POW_DEFAULT_INDEX_SHIFT, MEMORY_HEAVY, 0x3FFFF0, true, NUM_HASH_BLOCKS>::hashHeavy(input, size, output, ctx);
}
}
void (*cryptonight_hash_ctx[MAX_NUM_HASH_BLOCKS])(PowVariant powVersion, const uint8_t* input, size_t size, uint8_t* output, cryptonight_ctx *ctx);
@ -195,6 +205,21 @@ bool CryptoNight::selfTest(int algo)
cryptonight_hash_ctx[2](PowVariant::POW_V0, test_input, 76, output, ctx);
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);
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);
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);
resultHeavy = resultHeavy && memcmp(output, test_output_heavy_haven, 96) == 0;
#endif
} else if (algo == Options::ALGO_CRYPTONIGHT_LITE) {
// cn-lite v0