Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/algo/myr-groestl.c
1201 views
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
#include "sha3/sph_sha2.h"
10
11
void myriadhash(void *output, const void *input)
12
{
13
uint32_t _ALIGN(32) hash[16];
14
sph_groestl512_context ctx;
15
sph_sha256_context sha_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_sha256_init(&sha_ctx);
24
sph_sha256(&sha_ctx, hash, 64);
25
sph_sha256_close(&sha_ctx, hash);
26
27
memcpy(output, hash, 32);
28
}
29
30
int scanhash_myriad(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
31
{
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];
38
const uint32_t first_nonce = pdata[19];
39
uint32_t nonce = first_nonce;
40
41
if (opt_benchmark)
42
ptarget[7] = 0x0000ff;
43
44
for (int i=0; i < 19; i++) {
45
be32enc(&endiandata[i], pdata[i]);
46
}
47
48
do {
49
be32enc(&endiandata[19], nonce);
50
myriadhash(hash, endiandata);
51
52
if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
53
work_set_target_ratio(work, hash);
54
pdata[19] = nonce;
55
*hashes_done = pdata[19] - first_nonce;
56
return 1;
57
}
58
nonce++;
59
60
} while (nonce < max_nonce && !work_restart[thr_id].restart);
61
62
pdata[19] = nonce;
63
*hashes_done = pdata[19] - first_nonce + 1;
64
return 0;
65
}
66
67