Skip to content

Commit

Permalink
Changes to cover audit comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Lolliedieb committed Feb 28, 2024
1 parent 2ceef73 commit 5d94a52
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
10 changes: 5 additions & 5 deletions kernels/fishhash.cl
Expand Up @@ -436,15 +436,15 @@ __kernel void mine ( __global uint8 * dag,

barrier(CLK_LOCAL_MEM_FENCE);

// Share mix.s0 and mix.s4 for the address calculation
share->uint2s[thread_id] = (uint2) (mix.s0, mix.s4);
// Share mix groups for the change to cover audit comments
share->uint2s[thread_id] = (uint2) (mix.s0^mix.s1^mix.s2^mix.s3, mix.s4^mix.s5^mix.s6^mix.s7);

barrier(CLK_LOCAL_MEM_FENCE);

// FishHash address calculation
uint p0 = share->uints[0] % dagSize;
uint p1 = share->uints[1] % dagSize;
uint p2 = share->uints[2] % dagSize;
uint p0 = (share->uints[0] ^ share->uints[3] ^ share->uints[6]) % dagSize;
uint p1 = (share->uints[1] ^ share->uints[4] ^ share->uints[7]) % dagSize;
uint p2 = (share->uints[2] ^ share->uints[5] ^ a) % dagSize;

uint8 fetch0 = dag[4*p0 + thread_id];
uint8 fetch1 = dag[4*p1 + thread_id];
Expand Down
12 changes: 9 additions & 3 deletions libFishHash/FishHash.cpp
Expand Up @@ -141,9 +141,15 @@ namespace FishHash {
for (uint32_t i = 0; i < num_dataset_accesses; ++i) {

// Calculate new fetching indexes
const uint32_t p0 = mix.word32s[0] % index_limit;
const uint32_t p1 = mix.word32s[4] % index_limit;
const uint32_t p2 = mix.word32s[8] % index_limit;
uint32_t mixGroup[8];
for (uint32_t c=0; c<8; c++) {
mixGroup[c] = (mix.word32s[4*c + 0] ^ mix.word32s[4*c + 1] ^ mix.word32s[4*c + 2] ^ mix.word32s[4*c + 3]);
}


uint32_t p0 = (mixGroup[0] ^ mixGroup[3] ^ mixGroup[6]) % index_limit;
uint32_t p1 = (mixGroup[1] ^ mixGroup[4] ^ mixGroup[7]) % index_limit;
uint32_t p2 = (mixGroup[2] ^ mixGroup[5] ^ i) % index_limit;

hash1024 fetch0 = lookup(ctx, p0);
hash1024 fetch1 = lookup(ctx, p1);
Expand Down

0 comments on commit 5d94a52

Please sign in to comment.