Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
tpruvot
GitHub Repository: tpruvot/cpuminer-multi
Path: blob/linux/algo/allium.c
1201 views
1
/**
2
* Allium algo Implementation
3
*/
4
5
#include <memory.h>
6
7
#include "sha3/sph_blake.h"
8
#include "sha3/sph_keccak.h"
9
#include "sha3/sph_cubehash.h"
10
#include "sha3/sph_skein.h"
11
#include "sha3/sph_groestl.h"
12
13
#include "lyra2/Lyra2.h"
14
15
#include "miner.h"
16
17
void allium_hash(void *state, const void *input)
18
{
19
uint32_t hashA[8], hashB[8];
20
21
sph_blake256_context ctx_blake;
22
sph_keccak256_context ctx_keccak;
23
sph_skein256_context ctx_skein;
24
sph_groestl256_context ctx_groestl;
25
sph_cubehash256_context ctx_cube;
26
27
// sph_blake256_set_rounds(14);
28
29
sph_blake256_init(&ctx_blake);
30
sph_blake256(&ctx_blake, input, 80);
31
sph_blake256_close(&ctx_blake, hashA);
32
33
sph_keccak256_init(&ctx_keccak);
34
sph_keccak256(&ctx_keccak, hashA, 32);
35
sph_keccak256_close(&ctx_keccak, hashB);
36
37
LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);
38
39
sph_cubehash256_init(&ctx_cube);
40
sph_cubehash256(&ctx_cube, hashA, 32);
41
sph_cubehash256_close(&ctx_cube, hashB);
42
43
LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);
44
45
sph_skein256_init(&ctx_skein);
46
sph_skein256(&ctx_skein, hashA, 32);
47
sph_skein256_close(&ctx_skein, hashB);
48
49
sph_groestl256_init(&ctx_groestl);
50
sph_groestl256(&ctx_groestl, hashB, 32);
51
sph_groestl256_close(&ctx_groestl, hashA);
52
53
memcpy(state, hashA, 32);
54
}
55
56
int scanhash_allium(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
57
{
58
uint32_t _ALIGN(128) hash[8];
59
uint32_t _ALIGN(128) endiandata[20];
60
uint32_t *pdata = work->data;
61
uint32_t *ptarget = work->target;
62
63
const uint32_t Htarg = ptarget[7];
64
const uint32_t first_nonce = pdata[19];
65
uint32_t n = first_nonce;
66
67
if(opt_benchmark){
68
ptarget[7] = 0x00ff;
69
}
70
71
for (int i=0; i < 19; i++) {
72
be32enc(&endiandata[i], pdata[i]);
73
}
74
75
do {
76
be32enc(&endiandata[19], n);
77
allium_hash(hash, endiandata);
78
79
if (hash[7] < Htarg && fulltest(hash, ptarget)) {
80
work_set_target_ratio(work, hash);
81
*hashes_done = n - first_nonce + 1;
82
pdata[19] = n;
83
return 1;
84
}
85
n++;
86
87
} while (n < max_nonce && !work_restart[thr_id].restart);
88
89
*hashes_done = n - first_nonce + 1;
90
pdata[19] = n;
91
92
return 0;
93
}
94
95