PoW changes WIP
This commit is contained in:
parent
df6a397e52
commit
8b60585004
9 changed files with 121 additions and 91 deletions
|
@ -25,33 +25,6 @@
|
|||
|
||||
#include "crypto/CryptoNight.h"
|
||||
|
||||
// VARIANT ALTERATIONS
|
||||
#define VARIANT1_CHECK() \
|
||||
if (MONERO && version > 6 && size < 43) \
|
||||
{ \
|
||||
return false; \
|
||||
}
|
||||
|
||||
#define VARIANT1_INIT(part) \
|
||||
const uint64_t tweak1_2_##part =\
|
||||
(MONERO && version > 6) ? \
|
||||
(*reinterpret_cast<const uint64_t*>(reinterpret_cast<const uint8_t*>(input) + 35 + part * size) ^ \
|
||||
*(reinterpret_cast<const uint64_t*>(ctx->state##part) + 24)) : 0;
|
||||
|
||||
#define VARIANT1_1(p) \
|
||||
do if(version > 6) \
|
||||
{ \
|
||||
const uint8_t tmp = reinterpret_cast<const uint8_t*>(p)[11]; \
|
||||
static const uint32_t table = 0x75310; \
|
||||
const uint8_t index = (((tmp >> 3) & 6) | (tmp & 1)) << 1; \
|
||||
((uint8_t*)(p))[11] = tmp ^ ((table >> index) & 0x30); \
|
||||
} while(0)
|
||||
|
||||
#define VARIANT1_2(p, part) \
|
||||
do if(MONERO && version > 6) { \
|
||||
(p) ^= tweak1_2_##part ; \
|
||||
} while(0)
|
||||
|
||||
|
||||
#if defined(XMRIG_ARM)
|
||||
# include "crypto/CryptoNight_arm.h"
|
||||
|
@ -66,66 +39,58 @@
|
|||
|
||||
|
||||
|
||||
bool (*cryptonight_hash_ctx)(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t) = nullptr;
|
||||
void (*cryptonight_hash_ctx)(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t) = nullptr;
|
||||
|
||||
|
||||
static bool cryptonight_av1_aesni(const void *input, size_t size, void *output, struct cryptonight_ctx *ctx, uint8_t version) {
|
||||
static void cryptonight_av1_aesni(const void *input, size_t size, void *output, struct cryptonight_ctx *ctx, uint8_t version) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
return cryptonight_hash<0x80000, MEMORY, 0x1FFFF0, false, true>(input, size, output, ctx, version);
|
||||
# else
|
||||
return false;
|
||||
cryptonight_hash<MONERO_ITER, MONERO_MEMORY, MONERO_MASK, false, true>(input, size, output, ctx, version);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static bool cryptonight_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
static void cryptonight_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
return cryptonight_double_hash<0x80000, MEMORY, 0x1FFFF0, false, true>(input, size, output, ctx, version);
|
||||
# else
|
||||
return false;
|
||||
cryptonight_double_hash<MONERO_ITER, MONERO_MEMORY, MONERO_MASK, false, true>(input, size, output, ctx, version);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static bool cryptonight_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
return cryptonight_hash<0x80000, MEMORY, 0x1FFFF0, true, true>(input, size, output, ctx, version);
|
||||
static void cryptonight_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
cryptonight_hash<MONERO_ITER, MONERO_MEMORY, MONERO_MASK, true, true>(input, size, output, ctx, version);
|
||||
}
|
||||
|
||||
|
||||
static bool cryptonight_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
return cryptonight_double_hash<0x80000, MEMORY, 0x1FFFF0, true, true>(input, size, output, ctx, version);
|
||||
static void cryptonight_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
cryptonight_double_hash<MONERO_ITER, MONERO_MEMORY, MONERO_MASK, true, true>(input, size, output, ctx, version);
|
||||
}
|
||||
|
||||
|
||||
#ifndef XMRIG_NO_AEON
|
||||
static bool cryptonight_lite_av1_aesni(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
static void cryptonight_lite_av1_aesni(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
return cryptonight_hash<0x40000, MEMORY_LITE, 0xFFFF0, false, false>(input, size, output, ctx, version);
|
||||
# else
|
||||
return false;
|
||||
cryptonight_hash<AEON_ITER, AEON_MEMORY, AEON_MASK, false, false>(input, size, output, ctx, version);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static bool cryptonight_lite_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
static void cryptonight_lite_av2_aesni_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
# if !defined(XMRIG_ARMv7)
|
||||
return cryptonight_double_hash<0x40000, MEMORY_LITE, 0xFFFF0, false, false>(input, size, output, ctx, version);
|
||||
# else
|
||||
return false;
|
||||
cryptonight_double_hash<AEON_ITER, AEON_MEMORY, AEON_MASK, false, false>(input, size, output, ctx, version);
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
static bool cryptonight_lite_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
return cryptonight_hash<0x40000, MEMORY_LITE, 0xFFFF0, true, false>(input, size, output, ctx, version);
|
||||
static void cryptonight_lite_av3_softaes(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
cryptonight_hash<AEON_ITER, AEON_MEMORY, AEON_MASK, true, false>(input, size, output, ctx, version);
|
||||
}
|
||||
|
||||
|
||||
static bool cryptonight_lite_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
return cryptonight_double_hash<0x40000, MEMORY_LITE, 0xFFFF0, true, false>(input, size, output, ctx, version);
|
||||
static void cryptonight_lite_av4_softaes_double(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t version) {
|
||||
cryptonight_double_hash<AEON_ITER, AEON_MEMORY, AEON_MASK, true, false>(input, size, output, ctx, version);
|
||||
}
|
||||
|
||||
bool (*cryptonight_variations[8])(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t) = {
|
||||
void (*cryptonight_variations[8])(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t) = {
|
||||
cryptonight_av1_aesni,
|
||||
cryptonight_av2_aesni_double,
|
||||
cryptonight_av3_softaes,
|
||||
|
@ -136,7 +101,7 @@ bool (*cryptonight_variations[8])(const void *input, size_t size, void *output,
|
|||
cryptonight_lite_av4_softaes_double
|
||||
};
|
||||
#else
|
||||
bool (*cryptonight_variations[4])(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t) = {
|
||||
void (*cryptonight_variations[4])(const void *input, size_t size, void *output, cryptonight_ctx *ctx, uint8_t) = {
|
||||
cryptonight_av1_aesni,
|
||||
cryptonight_av2_aesni_double,
|
||||
cryptonight_av3_softaes,
|
||||
|
@ -147,8 +112,9 @@ bool (*cryptonight_variations[4])(const void *input, size_t size, void *output,
|
|||
|
||||
bool CryptoNight::hash(const Job &job, JobResult &result, cryptonight_ctx *ctx)
|
||||
{
|
||||
const bool rc = cryptonight_hash_ctx(job.blob(), job.size(), result.result, ctx, job.version());
|
||||
return rc && *reinterpret_cast<uint64_t*>(result.result + 24) < job.target();
|
||||
cryptonight_hash_ctx(job.blob(), job.size(), result.result, ctx, job.version());
|
||||
|
||||
return *reinterpret_cast<uint64_t*>(result.result + 24) < job.target();
|
||||
}
|
||||
|
||||
|
||||
|
@ -170,9 +136,9 @@ bool CryptoNight::init(int algo, int variant)
|
|||
}
|
||||
|
||||
|
||||
bool CryptoNight::hash(const uint8_t *input, size_t size, uint8_t *output, cryptonight_ctx *ctx, uint8_t version)
|
||||
void CryptoNight::hash(const uint8_t *input, size_t size, uint8_t *output, cryptonight_ctx *ctx, uint8_t version)
|
||||
{
|
||||
return cryptonight_hash_ctx(input, size, output, ctx, version);
|
||||
cryptonight_hash_ctx(input, size, output, ctx, version);
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,17 +149,17 @@ bool CryptoNight::selfTest(int algo) {
|
|||
|
||||
char output[64];
|
||||
|
||||
struct cryptonight_ctx *ctx = (struct cryptonight_ctx*) _mm_malloc(sizeof(struct cryptonight_ctx), 16);
|
||||
ctx->memory = (uint8_t *) _mm_malloc(MEMORY * 2, 16);
|
||||
struct cryptonight_ctx *ctx = static_cast<cryptonight_ctx *>(_mm_malloc(sizeof(cryptonight_ctx), 16));
|
||||
ctx->memory = static_cast<uint8_t *>(_mm_malloc(MONERO_MEMORY * 2, 16));
|
||||
|
||||
const bool rc = cryptonight_hash_ctx(test_input, 76, output, ctx, 0);
|
||||
cryptonight_hash_ctx(test_input, 76, output, ctx, 0);
|
||||
|
||||
_mm_free(ctx->memory);
|
||||
_mm_free(ctx);
|
||||
|
||||
# ifndef XMRIG_NO_AEON
|
||||
return rc && memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output1 : test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
|
||||
return memcmp(output, algo == Options::ALGO_CRYPTONIGHT_LITE ? test_output1 : test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
|
||||
# else
|
||||
return rc && memcmp(output, test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
|
||||
return memcmp(output, test_output0, (Options::i()->doubleHash() ? 64 : 32)) == 0;
|
||||
# endif
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue