Skip to content

Commit

Permalink
Separate keccak for flex
Browse files Browse the repository at this point in the history
  • Loading branch information
MoneroOcean committed Jun 1, 2024
1 parent 91bad8a commit 8f0e8be
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 21 deletions.
3 changes: 0 additions & 3 deletions src/backend/cpu/CpuBackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@
#include "crypto/common/VirtualMemory.h"
#include "crypto/rx/Rx.h"
#include "crypto/rx/RxDataset.h"
#include "crypto/ghostrider/sph_keccak.h"


#ifdef XMRIG_FEATURE_API
Expand Down Expand Up @@ -360,8 +359,6 @@ void xmrig::CpuBackend::setJob(const Job &job)
d_ptr->algo = job.algorithm();
d_ptr->profileName = cpu.threads().profileName(job.algorithm());

hard_coded_eb = (d_ptr->algo.id() != Algorithm::FLEX_KCN) ? 1 : 6;

if (d_ptr->profileName.isNull() || threads.empty()) {
LOG_WARN("%s " RED_BOLD("disabled") YELLOW(" (no suitable configuration found)"), Tags::cpu());

Expand Down
20 changes: 10 additions & 10 deletions src/crypto/flex/flex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ extern "C" {
#include "../ghostrider/sph_bmw.h"
#include "../ghostrider/sph_groestl.h"
#include "../ghostrider/sph_jh.h"
#include "../ghostrider/sph_keccak.h"
#include "../ghostrider/sph_skein.h"
#include "../ghostrider/sph_luffa.h"
#include "../ghostrider/sph_cubehash.h"
Expand All @@ -24,6 +23,7 @@ extern "C" {
#include "../ghostrider/sph_shabal.h"
#include "../ghostrider/sph_whirlpool.h"
#include "../ghostrider/sph_sha2.h"
#include "./flex_keccak.h"
}
#include <stdio.h>

Expand Down Expand Up @@ -137,9 +137,9 @@ void flex_hash(const char* input, char* output, cryptonight_ctx** ctx) {
sph_whirlpool_context ctx_whirlpool;
void *in = (void*) input;
int size = 80;
sph_keccak512_init(&ctx_keccak);
sph_keccak512(&ctx_keccak, in, size);
sph_keccak512_close(&ctx_keccak, hash);
flex_keccak512_init(&ctx_keccak);
flex_keccak512(&ctx_keccak, in, size);
flex_keccak512_close(&ctx_keccak, hash);
uint8_t selectedAlgoOutput[15] = {0};
uint8_t selectedCNAlgoOutput[14] = {0};
getAlgoString(&hash, 64, selectedAlgoOutput, 14);
Expand Down Expand Up @@ -234,9 +234,9 @@ void flex_hash(const char* input, char* output, cryptonight_ctx** ctx) {
sph_groestl512_close(&ctx_groestl, hash);
break;
case KECCAK:
sph_keccak512_init(&ctx_keccak);
sph_keccak512(&ctx_keccak, in, size);
sph_keccak512_close(&ctx_keccak, hash);
flex_keccak512_init(&ctx_keccak);
flex_keccak512(&ctx_keccak, in, size);
flex_keccak512_close(&ctx_keccak, hash);
break;
case SKEIN:
sph_skein512_init(&ctx_skein);
Expand Down Expand Up @@ -292,8 +292,8 @@ void flex_hash(const char* input, char* output, cryptonight_ctx** ctx) {
in = (void*) hash;
size = 64;
}
sph_keccak256_init(&ctx_keccak);
sph_keccak256(&ctx_keccak, in, size);
sph_keccak256_close(&ctx_keccak, hash);
flex_keccak256_init(&ctx_keccak);
flex_keccak256(&ctx_keccak, in, size);
flex_keccak256_close(&ctx_keccak, hash);
memcpy(output, hash, 32);
}
2 changes: 1 addition & 1 deletion src/crypto/flex/flex_keccak.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" {
#endif

// Taken from keccak-gate.c
int flex_hard_coded_eb = 6;
static const int flex_hard_coded_eb = 6;

/*
* Parameters:
Expand Down
3 changes: 0 additions & 3 deletions src/crypto/flex/flex_keccak.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
extern "C" {
#endif

// Taken from keccak-gate.h
extern int flex_hard_coded_eb;

#include "../ghostrider/sph_types.h"
#include <stddef.h>

Expand Down
2 changes: 1 addition & 1 deletion src/crypto/ghostrider/sph_keccak.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ extern "C" {
#endif

// Taken from keccak-gate.c
int hard_coded_eb = 1;
static const int hard_coded_eb = 1;

/*
* Parameters:
Expand Down
3 changes: 0 additions & 3 deletions src/crypto/ghostrider/sph_keccak.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@
extern "C" {
#endif

// Taken from keccak-gate.h
extern int hard_coded_eb;

#include "sph_types.h"
#include <stddef.h>

Expand Down

0 comments on commit 8f0e8be

Please sign in to comment.