Integrated xfh freehaven-protocol aka cn-heavy-superfast (#211)

This commit is contained in:
Ben Gräf 2018-11-18 14:46:45 +01:00 committed by GitHub
parent e874148820
commit 9987d6e2fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 28 additions and 2 deletions

View file

@ -78,7 +78,9 @@ static void cryptonight_aesni(AsmOptimization asmOptimization, PowVariant powVer
}
} else if (powVersion == PowVariant::POW_RTO) {
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashLiteTube(input, size, output, scratchPad);
}else {
} else if (powVersion == PowVariant::POW_XFH) {
CryptoNightMultiHash<0x20000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, scratchPad);
} else {
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, false, NUM_HASH_BLOCKS>::hash(input, size, output, scratchPad);
}
# endif
@ -126,6 +128,8 @@ static void cryptonight_softaes(AsmOptimization asmOptimization, PowVariant powV
}
} else if (powVersion == PowVariant::POW_RTO) {
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashLiteTube(input, size, output, scratchPad);
} else if (powVersion == PowVariant::POW_XFH) {
CryptoNightMultiHash<0x20000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hashHeavyHaven(input, size, output, scratchPad);
} else {
CryptoNightMultiHash<0x80000, POW_DEFAULT_INDEX_SHIFT, MEMORY, 0x1FFFF0, true, NUM_HASH_BLOCKS>::hash(input, size, output, scratchPad);
}
@ -508,6 +512,11 @@ bool CryptoNight::selfTest(int algo)
cryptonight_hash_ctx[4](asmOptimization, PowVariant::POW_V2, test_input, 76, output, scratchPads);
result = result && memcmp(output, test_output_v2, 160) == 0;
#endif
// cn xfh aka cn-heavy-superfast
cryptonight_hash_ctx[0](asmOptimization, PowVariant::POW_XFH, test_input, 76, output, scratchPads);
result = result && memcmp(output, test_output_xfh, 32) == 0;
}
for (size_t i = 0; i < MAX_NUM_HASH_BLOCKS; ++i) {

View file

@ -116,6 +116,12 @@ const static uint8_t test_output_alloy[32] = {
0x5D, 0x77, 0x16, 0x21, 0x42, 0x97, 0x5C, 0xB8, 0x50, 0xC0, 0xA5, 0x1F, 0x64, 0x07, 0xBD, 0x33
};
// CN XFH
const static uint8_t test_output_xfh[32] = {
0x40, 0x86, 0x5A, 0xA8, 0x87, 0x41, 0xEC, 0x1D, 0xCC, 0xBD, 0x2B, 0xC6, 0xFF, 0x36, 0xB9, 0x4D,
0x54, 0x71, 0x58, 0xDB, 0x94, 0x69, 0x8E, 0x3C, 0xA0, 0x3D, 0xE4, 0x81, 0x9A, 0x65, 0x9F, 0xEF
};
// CN-LITE
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,