1 #include "cpuminer-config.h"
7 #include "sha3/sph_shavite.h"
9 extern void inkhash(void *state, const void *input)
11 sph_shavite512_context ctx_shavite;
14 sph_shavite512_init(&ctx_shavite);
15 sph_shavite512 (&ctx_shavite, (const void*) input, 80);
16 sph_shavite512_close(&ctx_shavite, (void*) hash);
18 sph_shavite512_init(&ctx_shavite);
19 sph_shavite512(&ctx_shavite, (const void*) hash, 64);
20 sph_shavite512_close(&ctx_shavite, (void*) hash);
22 memcpy(state, hash, 32);
27 for (ii=0; ii < 32; ii++)
29 printf ("%.2x",((uint8_t*)state)[ii]);
35 int scanhash_ink(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
36 uint32_t max_nonce, uint64_t *hashes_done)
38 uint32_t n = pdata[19] - 1;
39 const uint32_t first_nonce = pdata[19];
40 //const uint32_t Htarg = ptarget[7];
42 uint32_t _ALIGN(32) hash64[8];
43 uint32_t endiandata[32];
45 //char testdata[] = {"\x70\x00\x00\x00\x5d\x38\x5b\xa1\x14\xd0\x79\x97\x0b\x29\xa9\x41\x8f\xd0\x54\x9e\x7d\x68\xa9\x5c\x7f\x16\x86\x21\xa3\x14\x20\x10\x00\x00\x00\x00\x57\x85\x86\xd1\x49\xfd\x07\xb2\x2f\x3a\x8a\x34\x7c\x51\x6d\xe7\x05\x2f\x03\x4d\x2b\x76\xff\x68\xe0\xd6\xec\xff\x9b\x77\xa4\x54\x89\xe3\xfd\x51\x17\x32\x01\x1d\xf0\x73\x10\x00"};
47 //we need bigendian data...
48 //lessons learned: do NOT endianchange directly in pdata, this will all proof-of-works be considered as stale from minerd....
52 be32enc(&endiandata[kk], ((uint32_t*)pdata)[kk]);
57 // applog(LOG_DEBUG, "Thr: %02d, firstN: %08x, maxN: %08x, ToDo: %d", thr_id, first_nonce, max_nonce, max_nonce-first_nonce);
60 /* I'm to lazy to put the loop in an inline function... so dirty copy'n'paste.... */
61 /* i know that i could set a variable, but i don't know how the compiler will optimize it, not that then the cpu needs to load the value *everytime* in a register */
65 be32enc(&endiandata[19], n);
66 inkhash(hash64, endiandata);
67 if (((hash64[7]&0xFFFFFFFF)==0) &&
68 fulltest(hash64, ptarget)) {
69 *hashes_done = n - first_nonce + 1;
72 } while (n < max_nonce && !work_restart[thr_id].restart);
74 else if (ptarget[7]<=0xF)
78 be32enc(&endiandata[19], n);
79 inkhash(hash64, endiandata);
80 if (((hash64[7]&0xFFFFFFF0)==0) &&
81 fulltest(hash64, ptarget)) {
82 *hashes_done = n - first_nonce + 1;
85 } while (n < max_nonce && !work_restart[thr_id].restart);
87 else if (ptarget[7]<=0xFF)
91 be32enc(&endiandata[19], n);
92 inkhash(hash64, endiandata);
93 if (((hash64[7]&0xFFFFFF00)==0) &&
94 fulltest(hash64, ptarget)) {
95 *hashes_done = n - first_nonce + 1;
98 } while (n < max_nonce && !work_restart[thr_id].restart);
100 else if (ptarget[7]<=0xFFF)
104 be32enc(&endiandata[19], n);
105 inkhash(hash64, endiandata);
106 if (((hash64[7]&0xFFFFF000)==0) &&
107 fulltest(hash64, ptarget)) {
108 *hashes_done = n - first_nonce + 1;
111 } while (n < max_nonce && !work_restart[thr_id].restart);
114 else if (ptarget[7]<=0xFFFF)
118 be32enc(&endiandata[19], n);
119 inkhash(hash64, endiandata);
120 if (((hash64[7]&0xFFFF0000)==0) &&
121 fulltest(hash64, ptarget)) {
122 *hashes_done = n - first_nonce + 1;
125 } while (n < max_nonce && !work_restart[thr_id].restart);
132 be32enc(&endiandata[19], n);
133 inkhash(hash64, endiandata);
134 if (fulltest(hash64, ptarget)) {
135 *hashes_done = n - first_nonce + 1;
138 } while (n < max_nonce && !work_restart[thr_id].restart);
142 *hashes_done = n - first_nonce + 1;