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"
19 #include "sha3/sph_hamsi.h"
20 #include "sha3/sph_fugue.h"
22 void x13hash(void *output, const void *input)
24 unsigned char hash[128]; // uint32_t hashA[16], hashB[16];
27 sph_blake512_context ctx_blake;
28 sph_bmw512_context ctx_bmw;
29 sph_groestl512_context ctx_groestl;
30 sph_jh512_context ctx_jh;
31 sph_keccak512_context ctx_keccak;
32 sph_skein512_context ctx_skein;
33 sph_luffa512_context ctx_luffa;
34 sph_cubehash512_context ctx_cubehash;
35 sph_shavite512_context ctx_shavite;
36 sph_simd512_context ctx_simd;
37 sph_echo512_context ctx_echo;
38 sph_hamsi512_context ctx_hamsi;
39 sph_fugue512_context ctx_fugue;
41 sph_blake512_init(&ctx_blake);
42 sph_blake512(&ctx_blake, input, 80);
43 sph_blake512_close(&ctx_blake, hash);
45 sph_bmw512_init(&ctx_bmw);
46 sph_bmw512(&ctx_bmw, hash, 64);
47 sph_bmw512_close(&ctx_bmw, hashB);
49 sph_groestl512_init(&ctx_groestl);
50 sph_groestl512(&ctx_groestl, hashB, 64);
51 sph_groestl512_close(&ctx_groestl, hash);
53 sph_skein512_init(&ctx_skein);
54 sph_skein512(&ctx_skein, hash, 64);
55 sph_skein512_close(&ctx_skein, hashB);
57 sph_jh512_init(&ctx_jh);
58 sph_jh512(&ctx_jh, hashB, 64);
59 sph_jh512_close(&ctx_jh, hash);
61 sph_keccak512_init(&ctx_keccak);
62 sph_keccak512(&ctx_keccak, hash, 64);
63 sph_keccak512_close(&ctx_keccak, hashB);
65 sph_luffa512_init(&ctx_luffa);
66 sph_luffa512(&ctx_luffa, hashB, 64);
67 sph_luffa512_close(&ctx_luffa, hash);
69 sph_cubehash512_init(&ctx_cubehash);
70 sph_cubehash512(&ctx_cubehash, hash, 64);
71 sph_cubehash512_close(&ctx_cubehash, hashB);
73 sph_shavite512_init(&ctx_shavite);
74 sph_shavite512(&ctx_shavite, hashB, 64);
75 sph_shavite512_close(&ctx_shavite, hash);
77 sph_simd512_init(&ctx_simd);
78 sph_simd512(&ctx_simd, hash, 64);
79 sph_simd512_close(&ctx_simd, hashB);
81 sph_echo512_init(&ctx_echo);
82 sph_echo512(&ctx_echo, hashB, 64);
83 sph_echo512_close(&ctx_echo, hash);
85 sph_hamsi512_init(&ctx_hamsi);
86 sph_hamsi512(&ctx_hamsi, hash, 64);
87 sph_hamsi512_close(&ctx_hamsi, hashB);
89 sph_fugue512_init(&ctx_fugue);
90 sph_fugue512(&ctx_fugue, hashB, 64);
91 sph_fugue512_close(&ctx_fugue, hash);
93 memcpy(output, hash, 32);
96 int scanhash_x13(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
98 uint32_t _ALIGN(128) hash32[8];
99 uint32_t _ALIGN(128) endiandata[20];
100 uint32_t *pdata = work->data;
101 uint32_t *ptarget = work->target;
103 const uint32_t first_nonce = pdata[19];
104 const uint32_t Htarg = ptarget[7];
106 uint32_t n = pdata[19] - 1;
125 // we need bigendian data...
126 for (int k=0; k < 19; k++)
127 be32enc(&endiandata[k], pdata[k]);
130 printf("[%d] Htarg=%X\n", thr_id, Htarg);
132 for (int m=0; m < 6; m++) {
133 if (Htarg <= htmax[m]) {
134 uint32_t mask = masks[m];
137 be32enc(&endiandata[19], n);
138 x13hash(hash32, endiandata);
140 if ((!(hash32[7] & mask)) && fulltest(hash32, ptarget)) {
141 work_set_target_ratio(work, hash32);
142 *hashes_done = n - first_nonce + 1;
146 if (!(n % 0x1000) && !thr_id) printf(".");
147 if (!(hash32[7] & mask)) {
148 printf("[%d]",thr_id);
149 if (fulltest(hash32, ptarget)) {
150 work_set_target_ratio(work, hash32);
151 *hashes_done = n - first_nonce + 1;
156 } while (n < max_nonce && !work_restart[thr_id].restart);
157 // see blake.c if else to understand the loop on htmax => mask
162 *hashes_done = n - first_nonce + 1;