]>
Commit | Line | Data |
---|---|---|
ba2fbc77 TP |
1 | #include "miner.h" |
2 | ||
3 | #include <stdio.h> | |
4 | #include <stdlib.h> | |
5 | #include <stdint.h> | |
6 | #include <string.h> | |
7 | ||
8 | #include "sha3/sph_groestl.h" | |
9 | ||
10 | // static __thread sph_groestl512_context ctx; | |
11 | ||
12 | void groestlhash(void *output, const void *input) | |
13 | { | |
14 | uint32_t _ALIGN(32) hash[16]; | |
15 | sph_groestl512_context ctx; | |
16 | ||
17 | // memset(&hash[0], 0, sizeof(hash)); | |
18 | ||
19 | sph_groestl512_init(&ctx); | |
20 | sph_groestl512(&ctx, input, 80); | |
21 | sph_groestl512_close(&ctx, hash); | |
22 | ||
23 | //sph_groestl512_init(&ctx); | |
24 | sph_groestl512(&ctx, hash, 64); | |
25 | sph_groestl512_close(&ctx, hash); | |
26 | ||
27 | memcpy(output, hash, 32); | |
28 | } | |
29 | ||
f7c584dc | 30 | int scanhash_groestl(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done) |
ba2fbc77 | 31 | { |
f7c584dc TP |
32 | uint32_t _ALIGN(128) hash[8]; |
33 | uint32_t _ALIGN(128) endiandata[20]; | |
34 | uint32_t *pdata = work->data; | |
35 | uint32_t *ptarget = work->target; | |
36 | ||
37 | const uint32_t Htarg = ptarget[7]; | |
ba2fbc77 TP |
38 | const uint32_t first_nonce = pdata[19]; |
39 | uint32_t nonce = first_nonce; | |
40 | ||
41 | if (opt_benchmark) | |
f7c584dc | 42 | ptarget[7] = 0x00ff; |
ba2fbc77 | 43 | |
f7c584dc TP |
44 | for (int k=0; k < 19; k++) |
45 | be32enc(&endiandata[k], pdata[k]); | |
ba2fbc77 TP |
46 | |
47 | do { | |
ba2fbc77 TP |
48 | be32enc(&endiandata[19], nonce); |
49 | groestlhash(hash, endiandata); | |
50 | ||
51 | if (hash[7] <= Htarg && fulltest(hash, ptarget)) { | |
f7c584dc | 52 | work_set_target_ratio(work, hash); |
ba2fbc77 TP |
53 | pdata[19] = nonce; |
54 | *hashes_done = pdata[19] - first_nonce; | |
55 | return 1; | |
56 | } | |
57 | nonce++; | |
58 | ||
59 | } while (nonce < max_nonce && !work_restart[thr_id].restart); | |
60 | ||
61 | pdata[19] = nonce; | |
62 | *hashes_done = pdata[19] - first_nonce + 1; | |
63 | return 0; | |
64 | } |