forked from tpruvot/cpuminer-multi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaxiom.c
79 lines (63 loc) · 1.66 KB
/
axiom.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#include "miner.h"
#include <string.h>
#include <stdint.h>
#include "sha3/sph_shabal.h"
static __thread uint32_t _ALIGN(128) M[65536][8];
void axiomhash(void *output, const void *input)
{
sph_shabal256_context ctx;
const int N = 65536;
sph_shabal256_init(&ctx);
sph_shabal256(&ctx, input, 80);
sph_shabal256_close(&ctx, M[0]);
for(int i = 1; i < N; i++) {
//sph_shabal256_init(&ctx);
sph_shabal256(&ctx, M[i-1], 32);
sph_shabal256_close(&ctx, M[i]);
}
for(int b = 0; b < N; b++)
{
const int p = b > 0 ? b - 1 : 0xFFFF;
const int q = M[p][0] % 0xFFFF;
const int j = (b + q) % N;
//sph_shabal256_init(&ctx);
#if 0
sph_shabal256(&ctx, M[p], 32);
sph_shabal256(&ctx, M[j], 32);
#else
uint8_t _ALIGN(128) hash[64];
memcpy(hash, M[p], 32);
memcpy(&hash[32], M[j], 32);
sph_shabal256(&ctx, hash, 64);
#endif
sph_shabal256_close(&ctx, M[b]);
}
memcpy(output, M[N-1], 32);
}
int scanhash_axiom(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t _ALIGN(128) hash32[8];
uint32_t _ALIGN(128) endiandata[20];
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
const uint32_t Htarg = ptarget[7];
const uint32_t first_nonce = pdata[19];
uint32_t n = first_nonce;
for (int i=0; i < 19; i++) {
be32enc(&endiandata[i], pdata[i]);
}
do {
be32enc(&endiandata[19], n);
axiomhash(hash32, endiandata);
if (hash32[7] < Htarg && fulltest(hash32, ptarget)) {
work_set_target_ratio(work, hash32);
*hashes_done = n - first_nonce + 1;
pdata[19] = n;
return true;
}
n++;
} while (n < max_nonce && !work_restart[thr_id].restart);
*hashes_done = n - first_nonce + 1;
pdata[19] = n;
return 0;
}