8 #include "sha3/sph_blake.h"
9 #include "sha3/sph_bmw.h"
10 #include "sha3/sph_groestl.h"
11 #include "sha3/sph_jh.h"
12 #include "sha3/sph_keccak.h"
13 #include "sha3/sph_skein.h"
14 #include "sha3/sph_luffa.h"
15 #include "sha3/sph_cubehash.h"
16 #include "sha3/sph_shavite.h"
17 #include "sha3/sph_simd.h"
18 #include "sha3/sph_echo.h"
21 void x11hash(void *output, const void *input)
23 sph_blake512_context ctx_blake;
24 sph_bmw512_context ctx_bmw;
25 sph_groestl512_context ctx_groestl;
26 sph_skein512_context ctx_skein;
27 sph_jh512_context ctx_jh;
28 sph_keccak512_context ctx_keccak;
30 sph_luffa512_context ctx_luffa1;
31 sph_cubehash512_context ctx_cubehash1;
32 sph_shavite512_context ctx_shavite1;
33 sph_simd512_context ctx_simd1;
34 sph_echo512_context ctx_echo1;
36 //these uint512 in the c++ source of the client are backed by an array of uint32
37 uint32_t _ALIGN(64) hashA[16], hashB[16];
39 sph_blake512_init(&ctx_blake);
40 sph_blake512 (&ctx_blake, input, 80);
41 sph_blake512_close (&ctx_blake, hashA);
43 sph_bmw512_init(&ctx_bmw);
44 sph_bmw512 (&ctx_bmw, hashA, 64);
45 sph_bmw512_close(&ctx_bmw, hashB);
47 sph_groestl512_init(&ctx_groestl);
48 sph_groestl512 (&ctx_groestl, hashB, 64);
49 sph_groestl512_close(&ctx_groestl, hashA);
51 sph_skein512_init(&ctx_skein);
52 sph_skein512 (&ctx_skein, hashA, 64);
53 sph_skein512_close (&ctx_skein, hashB);
55 sph_jh512_init(&ctx_jh);
56 sph_jh512 (&ctx_jh, hashB, 64);
57 sph_jh512_close(&ctx_jh, hashA);
59 sph_keccak512_init(&ctx_keccak);
60 sph_keccak512 (&ctx_keccak, hashA, 64);
61 sph_keccak512_close(&ctx_keccak, hashB);
63 sph_luffa512_init (&ctx_luffa1);
64 sph_luffa512 (&ctx_luffa1, hashB, 64);
65 sph_luffa512_close (&ctx_luffa1, hashA);
67 sph_cubehash512_init (&ctx_cubehash1);
68 sph_cubehash512 (&ctx_cubehash1, hashA, 64);
69 sph_cubehash512_close(&ctx_cubehash1, hashB);
71 sph_shavite512_init (&ctx_shavite1);
72 sph_shavite512 (&ctx_shavite1, hashB, 64);
73 sph_shavite512_close(&ctx_shavite1, hashA);
75 sph_simd512_init (&ctx_simd1);
76 sph_simd512 (&ctx_simd1, hashA, 64);
77 sph_simd512_close(&ctx_simd1, hashB);
79 sph_echo512_init (&ctx_echo1);
80 sph_echo512 (&ctx_echo1, hashB, 64);
81 sph_echo512_close(&ctx_echo1, hashA);
83 memcpy(output, hashA, 32);
86 int scanhash_x11(int thr_id, uint32_t *pdata, const uint32_t *ptarget,
87 uint32_t max_nonce, uint64_t *hashes_done)
89 const uint32_t first_nonce = pdata[19];
90 uint32_t _ALIGN(64) endiandata[20];
91 uint32_t nonce = first_nonce;
92 volatile uint8_t *restart = &(work_restart[thr_id].restart);
95 ((uint32_t*)ptarget)[7] = 0x0cff;
97 for (int k=0; k < 19; k++)
98 be32enc(&endiandata[k], pdata[k]);
100 const uint32_t Htarg = ptarget[7];
103 be32enc(&endiandata[19], nonce);
104 x11hash(hash, endiandata);
106 if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
108 *hashes_done = pdata[19] - first_nonce;
113 } while (nonce < max_nonce && !(*restart));
116 *hashes_done = pdata[19] - first_nonce + 1;