8 #include "sha3/sph_shavite.h"
9 #include "sha3/sph_simd.h"
10 #include "sha3/sph_echo.h"
14 extern void freshhash(void* output, const void* input, uint32_t len)
16 unsigned char hash[128]; // uint32_t hashA[16], hashB[16];
20 sph_shavite512_context ctx_shavite;
21 sph_simd512_context ctx_simd;
22 sph_echo512_context ctx_echo;
24 sph_shavite512_init(&ctx_shavite);
25 sph_shavite512(&ctx_shavite, input, len);
26 sph_shavite512_close(&ctx_shavite, hashA);
28 sph_simd512_init(&ctx_simd);
29 sph_simd512(&ctx_simd, hashA, 64);
30 sph_simd512_close(&ctx_simd, hashB);
32 sph_shavite512_init(&ctx_shavite);
33 sph_shavite512(&ctx_shavite, hashB, 64);
34 sph_shavite512_close(&ctx_shavite, hashA);
36 sph_simd512_init(&ctx_simd);
37 sph_simd512(&ctx_simd, hashA, 64);
38 sph_simd512_close(&ctx_simd, hashB);
40 sph_echo512_init(&ctx_echo);
41 sph_echo512(&ctx_echo, hashB, 64);
42 sph_echo512_close(&ctx_echo, hashA);
44 memcpy(output, hash, 32);
47 int scanhash_fresh(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
49 uint32_t _ALIGN(128) hash32[8];
50 uint32_t _ALIGN(128) endiandata[20];
51 uint32_t *pdata = work->data;
52 uint32_t *ptarget = work->target;
54 const uint32_t first_nonce = pdata[19];
55 const uint32_t Htarg = ptarget[7];
56 const uint32_t len = 80;
57 uint32_t n = pdata[19] - 1;
76 // we need bigendian data...
77 for (int kk=0; kk < 32; kk++) {
78 be32enc(&endiandata[kk], ((uint32_t*)pdata)[kk]);
82 printf("[%d] Htarg=%X\n", thr_id, Htarg);
84 for (int m=0; m < 6; m++) {
85 if (Htarg <= htmax[m]) {
86 uint32_t mask = masks[m];
89 be32enc(&endiandata[19], n);
90 freshhash(hash32, endiandata, len);
92 if ((!(hash32[7] & mask)) && fulltest(hash32, ptarget)) {
93 work_set_target_ratio(work, hash32);
94 *hashes_done = n - first_nonce + 1;
98 if (!(n % 0x1000) && !thr_id) printf(".");
99 if (!(hash32[7] & mask)) {
100 printf("[%d]",thr_id);
101 if (fulltest(hash32, ptarget)) {
102 work_set_target_ratio(work, hash32);
103 *hashes_done = n - first_nonce + 1;
108 } while (n < max_nonce && !work_restart[thr_id].restart);
109 // see blake.c if else to understand the loop on htmax => mask
114 *hashes_done = n - first_nonce + 1;