Skip to content

Commit 289d9de

Browse files
committed
allium algo, with proper pool diff ratio 256
cleaned up...
1 parent 582e576 commit 289d9de

File tree

8 files changed

+122
-0
lines changed

8 files changed

+122
-0
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ cpuminer_SOURCES = \
5454
lyra2/Lyra2.c lyra2/Sponge.c \
5555
yescrypt/yescrypt-common.c yescrypt/yescrypt-best.c \
5656
yescrypt/sha256_Y.c \
57+
algo/allium.c \
5758
algo/axiom.c \
5859
algo/bastion.c \
5960
algo/blake.c \

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Version 1.3.4
2+
- Add allium algo
23
- Add x12 algo
34
- Add x16s algo
45

algo/allium.c

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
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+
static char* format_hash(char* buf, uint8_t *hash)
18+
{
19+
int len = 0;
20+
for (int i=0; i < 32; i += 4) {
21+
len += sprintf(buf+len, "%02x%02x%02x%02x ",
22+
hash[i], hash[i+1], hash[i+2], hash[i+3]);
23+
}
24+
return buf;
25+
}
26+
27+
void allium_hash(void *state, const void *input)
28+
{
29+
uint32_t hashA[8], hashB[8];
30+
31+
sph_blake256_context ctx_blake;
32+
sph_keccak256_context ctx_keccak;
33+
sph_skein256_context ctx_skein;
34+
sph_groestl256_context ctx_groestl;
35+
sph_cubehash256_context ctx_cube;
36+
37+
// sph_blake256_set_rounds(14);
38+
39+
sph_blake256_init(&ctx_blake);
40+
sph_blake256(&ctx_blake, input, 80);
41+
sph_blake256_close(&ctx_blake, hashA);
42+
43+
sph_keccak256_init(&ctx_keccak);
44+
sph_keccak256(&ctx_keccak, hashA, 32);
45+
sph_keccak256_close(&ctx_keccak, hashB);
46+
47+
LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);
48+
49+
sph_cubehash256_init(&ctx_cube);
50+
sph_cubehash256(&ctx_cube, hashA, 32);
51+
sph_cubehash256_close(&ctx_cube, hashB);
52+
53+
LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 8, 8);
54+
55+
sph_skein256_init(&ctx_skein);
56+
sph_skein256(&ctx_skein, hashA, 32);
57+
sph_skein256_close(&ctx_skein, hashB);
58+
59+
sph_groestl256_init(&ctx_groestl);
60+
sph_groestl256(&ctx_groestl, hashB, 32);
61+
sph_groestl256_close(&ctx_groestl, hashA);
62+
63+
memcpy(state, hashA, 32);
64+
}
65+
66+
int scanhash_allium(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
67+
{
68+
uint32_t _ALIGN(128) hash[8];
69+
uint32_t _ALIGN(128) endiandata[20];
70+
uint32_t *pdata = work->data;
71+
uint32_t *ptarget = work->target;
72+
73+
const uint32_t Htarg = ptarget[7];
74+
const uint32_t first_nonce = pdata[19];
75+
uint32_t n = first_nonce;
76+
77+
if(opt_benchmark){
78+
ptarget[7] = 0x00ff;
79+
}
80+
81+
for (int i=0; i < 19; i++) {
82+
be32enc(&endiandata[i], pdata[i]);
83+
}
84+
85+
do {
86+
be32enc(&endiandata[19], n);
87+
allium_hash(hash, endiandata);
88+
89+
if (hash[7] < Htarg && fulltest(hash, ptarget)) {
90+
work_set_target_ratio(work, hash);
91+
*hashes_done = n - first_nonce + 1;
92+
pdata[19] = n;
93+
return 1;
94+
}
95+
n++;
96+
97+
} while (n < max_nonce && !work_restart[thr_id].restart);
98+
99+
*hashes_done = n - first_nonce + 1;
100+
pdata[19] = n;
101+
102+
return 0;
103+
}

cpu-miner.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ enum algos {
8282
ALGO_HEAVY, /* Heavy */
8383
ALGO_NEOSCRYPT, /* NeoScrypt(128, 2, 1) with Salsa20/20 and ChaCha20/20 */
8484
ALGO_QUARK, /* Quark */
85+
ALGO_ALLIUM, /* Garlicoin double lyra2 */
8586
ALGO_AXIOM, /* Shabal 256 Memohash */
8687
ALGO_BASTION,
8788
ALGO_BLAKE, /* Blake 256 */
@@ -141,6 +142,7 @@ static const char *algo_names[] = {
141142
"heavy",
142143
"neoscrypt",
143144
"quark",
145+
"allium",
144146
"axiom",
145147
"bastion",
146148
"blake",
@@ -296,6 +298,7 @@ static char const usage[] = "\
296298
Usage: " PACKAGE_NAME " [OPTIONS]\n\
297299
Options:\n\
298300
-a, --algo=ALGO specify the algorithm to use\n\
301+
allium Garlicoin double lyra2\n\
299302
axiom Shabal-256 MemoHash\n\
300303
bitcore Timetravel with 10 algos\n\
301304
blake Blake-256 14-rounds (SFR)\n\
@@ -1809,6 +1812,7 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
18091812
case ALGO_YESCRYPT:
18101813
work_set_target(work, sctx->job.diff / (65536.0 * opt_diff_factor));
18111814
break;
1815+
case ALGO_ALLIUM:
18121816
case ALGO_FRESH:
18131817
case ALGO_DMD_GR:
18141818
case ALGO_GROESTL:
@@ -2141,6 +2145,7 @@ static void *miner_thread(void *userdata)
21412145
case ALGO_YESCRYPT:
21422146
max64 = 0x1ff;
21432147
break;
2148+
case ALGO_ALLIUM:
21442149
case ALGO_LYRA2:
21452150
case ALGO_LYRA2REV2:
21462151
case ALGO_TIMETRAVEL:
@@ -2205,6 +2210,9 @@ static void *miner_thread(void *userdata)
22052210
/* scan nonces for a proof-of-work hash */
22062211
switch (opt_algo) {
22072212

2213+
case ALGO_ALLIUM:
2214+
rc = scanhash_allium(thr_id, &work, max_nonce, &hashes_done);
2215+
break;
22082216
case ALGO_AXIOM:
22092217
rc = scanhash_axiom(thr_id, &work, max_nonce, &hashes_done);
22102218
break;

cpuminer.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@
202202
<ClCompile Include="util.c">
203203
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
204204
</ClCompile>
205+
<ClCompile Include="algo\allium.c" />
205206
<ClCompile Include="algo\axiom.c" />
206207
<ClCompile Include="algo\bastion.c" />
207208
<ClCompile Include="algo\bitcore.c" />

cpuminer.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,9 @@
174174
<ClCompile Include="compat\jansson\strconv.c">
175175
<Filter>jansson</Filter>
176176
</ClCompile>
177+
<ClCompile Include="algo\allium.c">
178+
<Filter>algo</Filter>
179+
</ClCompile>
177180
<ClCompile Include="algo\bastion.c">
178181
<Filter>algo</Filter>
179182
</ClCompile>

miner.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
198198

199199
struct work;
200200

201+
int scanhash_allium(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
201202
int scanhash_axiom(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
202203
int scanhash_bastion(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
203204
int scanhash_blake(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
@@ -491,6 +492,7 @@ void format_hashrate(double hashrate, char *output);
491492
void print_hash_tests(void);
492493

493494
void sha256d(unsigned char *hash, const unsigned char *data, int len);
495+
void allium_hash(void *state, const void *input);
494496
void axiomhash(void *state, const void *input);
495497
void bastionhash(void *output, const void *input);
496498
void blakehash(void *state, const void *input);

util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2313,6 +2313,9 @@ void print_hash_tests(void)
23132313
memset(buf, 0, sizeof(buf));
23142314
//buf[0] = 1; buf[64] = 2; // for endian tests
23152315

2316+
allium_hash(&hash[0], &buf[0]);
2317+
printpfx("allium", hash);
2318+
23162319
axiomhash(&hash[0], &buf[0]);
23172320
printpfx("axiom", hash);
23182321

0 commit comments

Comments
 (0)