]>
Commit | Line | Data |
---|---|---|
10016762 TP |
1 | #include <miner.h> |
2 | ||
3 | #include <stdlib.h> | |
4 | #include <stdint.h> | |
5 | #include <string.h> | |
6 | #include <stdio.h> | |
7 | ||
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> | |
21 | #include <sha3/sph_shabal.h> | |
22 | #include <sha3/sph_whirlpool.h> | |
23 | #include <sha3/sph_sha2.h> | |
24 | #include <sha3/sph_haval.h> | |
25 | ||
26 | //#define DEBUG_ALGO | |
27 | ||
28 | void x17hash(void *output, const void *input) | |
29 | { | |
30 | unsigned char _ALIGN(64) hash[64]; | |
31 | ||
32 | sph_blake512_context ctx_blake; | |
33 | sph_bmw512_context ctx_bmw; | |
34 | sph_groestl512_context ctx_groestl; | |
35 | sph_jh512_context ctx_jh; | |
36 | sph_keccak512_context ctx_keccak; | |
37 | sph_skein512_context ctx_skein; | |
38 | sph_luffa512_context ctx_luffa; | |
39 | sph_cubehash512_context ctx_cubehash; | |
40 | sph_shavite512_context ctx_shavite; | |
41 | sph_simd512_context ctx_simd; | |
42 | sph_echo512_context ctx_echo; | |
43 | sph_hamsi512_context ctx_hamsi; | |
44 | sph_fugue512_context ctx_fugue; | |
45 | sph_shabal512_context ctx_shabal; | |
46 | sph_whirlpool_context ctx_whirlpool; | |
47 | sph_sha512_context ctx_sha512; | |
48 | sph_haval256_5_context ctx_haval; | |
49 | ||
50 | sph_blake512_init(&ctx_blake); | |
51 | sph_blake512(&ctx_blake, input, 80); | |
52 | sph_blake512_close(&ctx_blake, hash); | |
53 | ||
54 | sph_bmw512_init(&ctx_bmw); | |
55 | sph_bmw512(&ctx_bmw, hash, 64); | |
56 | sph_bmw512_close(&ctx_bmw, hash); | |
57 | ||
58 | sph_groestl512_init(&ctx_groestl); | |
59 | sph_groestl512(&ctx_groestl, hash, 64); | |
60 | sph_groestl512_close(&ctx_groestl, hash); | |
61 | ||
62 | sph_skein512_init(&ctx_skein); | |
63 | sph_skein512(&ctx_skein, hash, 64); | |
64 | sph_skein512_close(&ctx_skein, hash); | |
65 | ||
66 | sph_jh512_init(&ctx_jh); | |
67 | sph_jh512(&ctx_jh, hash, 64); | |
68 | sph_jh512_close(&ctx_jh, hash); | |
69 | ||
70 | sph_keccak512_init(&ctx_keccak); | |
71 | sph_keccak512(&ctx_keccak, hash, 64); | |
72 | sph_keccak512_close(&ctx_keccak, hash); | |
73 | ||
74 | sph_luffa512_init(&ctx_luffa); | |
75 | sph_luffa512(&ctx_luffa, hash, 64); | |
76 | sph_luffa512_close(&ctx_luffa, hash); | |
77 | ||
78 | sph_cubehash512_init(&ctx_cubehash); | |
79 | sph_cubehash512(&ctx_cubehash, hash, 64); | |
80 | sph_cubehash512_close(&ctx_cubehash, hash); | |
81 | ||
82 | sph_shavite512_init(&ctx_shavite); | |
83 | sph_shavite512(&ctx_shavite, hash, 64); | |
84 | sph_shavite512_close(&ctx_shavite, hash); | |
85 | ||
86 | sph_simd512_init(&ctx_simd); | |
87 | sph_simd512(&ctx_simd, hash, 64); | |
88 | sph_simd512_close(&ctx_simd, hash); | |
89 | ||
90 | sph_echo512_init(&ctx_echo); | |
91 | sph_echo512(&ctx_echo, hash, 64); | |
92 | sph_echo512_close(&ctx_echo, hash); | |
93 | ||
94 | sph_hamsi512_init(&ctx_hamsi); | |
95 | sph_hamsi512(&ctx_hamsi, hash, 64); | |
96 | sph_hamsi512_close(&ctx_hamsi, hash); | |
97 | ||
98 | sph_fugue512_init(&ctx_fugue); | |
99 | sph_fugue512(&ctx_fugue, hash, 64); | |
100 | sph_fugue512_close(&ctx_fugue, hash); | |
101 | ||
102 | sph_shabal512_init(&ctx_shabal); | |
103 | sph_shabal512(&ctx_shabal, hash, 64); | |
104 | sph_shabal512_close(&ctx_shabal, hash); | |
105 | ||
106 | sph_whirlpool_init(&ctx_whirlpool); | |
107 | sph_whirlpool(&ctx_whirlpool, hash, 64); | |
108 | sph_whirlpool_close(&ctx_whirlpool, hash); | |
109 | ||
110 | sph_sha512_init(&ctx_sha512); | |
111 | sph_sha512(&ctx_sha512,(const void*) hash, 64); | |
112 | sph_sha512_close(&ctx_sha512,(void*) hash); | |
113 | ||
114 | sph_haval256_5_init(&ctx_haval); | |
115 | sph_haval256_5(&ctx_haval,(const void*) hash, 64); | |
116 | sph_haval256_5_close(&ctx_haval, hash); | |
117 | ||
118 | memcpy(output, hash, 32); | |
119 | } | |
120 | ||
121 | int scanhash_x17(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) | |
122 | { | |
123 | uint32_t _ALIGN(64) hash[8]; | |
124 | uint32_t _ALIGN(64) endiandata[20]; | |
125 | uint32_t *pdata = work->data; | |
126 | uint32_t *ptarget = work->target; | |
127 | ||
128 | const uint32_t Htarg = ptarget[7]; | |
129 | const uint32_t first_nonce = pdata[19]; | |
130 | uint32_t nonce = first_nonce; | |
131 | volatile uint8_t *restart = &(work_restart[thr_id].restart); | |
132 | ||
133 | if (opt_benchmark) | |
134 | ptarget[7] = 0x0cff; | |
135 | ||
136 | for (int k=0; k < 19; k++) | |
137 | be32enc(&endiandata[k], pdata[k]); | |
138 | ||
139 | do { | |
140 | be32enc(&endiandata[19], nonce); | |
141 | x17hash(hash, endiandata); | |
142 | ||
143 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { | |
144 | work_set_target_ratio(work, hash); | |
145 | pdata[19] = nonce; | |
146 | *hashes_done = pdata[19] - first_nonce; | |
147 | return 1; | |
148 | } | |
149 | nonce++; | |
150 | ||
151 | } while (nonce < max_nonce && !(*restart)); | |
152 | ||
153 | pdata[19] = nonce; | |
154 | *hashes_done = pdata[19] - first_nonce + 1; | |
155 | return 0; | |
156 | } |