mirror of
https://github.com/xmrig/xmrig.git
synced 2025-12-24 21:32:47 -05:00
Add Flex algo (for KCN coin) algo support
This commit is contained in:
@@ -37,6 +37,7 @@
|
||||
#include "crypto/rx/RxDataset.h"
|
||||
#include "crypto/rx/RxVm.h"
|
||||
#include "crypto/ghostrider/ghostrider.h"
|
||||
#include "crypto/flex/flex.h"
|
||||
#include "net/JobResults.h"
|
||||
|
||||
|
||||
@@ -168,7 +169,13 @@ bool xmrig::CpuWorker<N>::selfTest()
|
||||
|
||||
# ifdef XMRIG_ALGO_GHOSTRIDER
|
||||
if (m_algorithm.family() == Algorithm::GHOSTRIDER) {
|
||||
return (N == 8) && verify(Algorithm::GHOSTRIDER_RTM, test_output_gr);
|
||||
switch (m_algorithm.id()) {
|
||||
case Algorithm::GHOSTRIDER_RTM:
|
||||
return (N == 8) && verify(Algorithm::GHOSTRIDER_RTM, test_output_gr);
|
||||
case Algorithm::FLEX_KCN:
|
||||
return verify(Algorithm::FLEX_KCN, test_output_flex);
|
||||
default:;
|
||||
}
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -327,11 +334,20 @@ void xmrig::CpuWorker<N>::start()
|
||||
|
||||
# ifdef XMRIG_ALGO_GHOSTRIDER
|
||||
case Algorithm::GHOSTRIDER:
|
||||
if (N == 8) {
|
||||
ghostrider::hash_octa(m_job.blob(), job.size(), m_hash, m_ctx, m_ghHelper);
|
||||
}
|
||||
else {
|
||||
valid = false;
|
||||
switch (job.algorithm()) {
|
||||
case Algorithm::GHOSTRIDER_RTM:
|
||||
if (N == 8) {
|
||||
ghostrider::hash_octa(m_job.blob(), job.size(), m_hash, m_ctx, m_ghHelper);
|
||||
}
|
||||
else {
|
||||
valid = false;
|
||||
}
|
||||
break;
|
||||
case Algorithm::FLEX_KCN:
|
||||
flex_hash(reinterpret_cast<const char*>(m_job.blob()), reinterpret_cast<char*>(m_hash), m_ctx);
|
||||
break;
|
||||
default:
|
||||
valid = false;
|
||||
}
|
||||
break;
|
||||
# endif
|
||||
@@ -398,7 +414,8 @@ template<size_t N>
|
||||
bool xmrig::CpuWorker<N>::verify(const Algorithm &algorithm, const uint8_t *referenceValue)
|
||||
{
|
||||
# ifdef XMRIG_ALGO_GHOSTRIDER
|
||||
if (algorithm == Algorithm::GHOSTRIDER_RTM) {
|
||||
switch (algorithm) {
|
||||
case Algorithm::GHOSTRIDER_RTM: {
|
||||
uint8_t blob[N * 80] = {};
|
||||
for (size_t i = 0; i < N; ++i) {
|
||||
blob[i * 80 + 0] = static_cast<uint8_t>(i);
|
||||
@@ -425,6 +442,19 @@ bool xmrig::CpuWorker<N>::verify(const Algorithm &algorithm, const uint8_t *refe
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
case Algorithm::FLEX_KCN: {
|
||||
const uint8_t header[80] = {
|
||||
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0xcc, 0xa6, 0x6a,
|
||||
0x44, 0xf8, 0xbd, 0x55, 0x45, 0xc3, 0x16, 0x4a, 0x3a, 0x76, 0xda, 0x50, 0x39, 0x53, 0x28, 0xc9, 0x07, 0x56, 0x33, 0x77,
|
||||
0x5b, 0xc4, 0xc8, 0x79, 0x8f, 0xd6, 0x77, 0x2b, 0x70, 0x0d, 0x21, 0x5c, 0xf0, 0xff, 0x0f, 0x1e, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
char hash[32] = {};
|
||||
flex_hash(reinterpret_cast<const char*>(header), hash, m_ctx);
|
||||
return memcmp(referenceValue, hash, sizeof hash) == 0;
|
||||
}
|
||||
default:;
|
||||
}
|
||||
# endif
|
||||
|
||||
|
||||
Reference in New Issue
Block a user