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