Skip to content

Commit 225dc7b

Browse files
committed
add alliumV2 (squashed and cleaned)
Signed-off-by: Tanguy Pruvot <[email protected]>
1 parent 41da2b4 commit 225dc7b

File tree

10 files changed

+110
-2
lines changed

10 files changed

+110
-2
lines changed

Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ cpuminer_SOURCES = \
5555
yescrypt/yescrypt-common.c yescrypt/yescrypt-best.c \
5656
yescrypt/sha256_Y.c \
5757
algo/allium.c \
58+
algo/alliumV2.c \
5859
algo/axiom.c \
5960
algo/bastion.c \
6061
algo/blake.c \

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
Version 1.3.6 (dev)
2+
- Add alliumv2 algo
3+
14
Version 1.3.5
25
- Add allium algo
36
- Add x12 algo

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Algorithms
2424
*__scrypt:N__
2525
*__scrypt-jane:N__
2626
*__sha256d__ (Bitcoin, Freicoin, Peercoin/PPCoin, Terracoin, ...)
27+
*__allium__ (Garlicoin [GRLC])
28+
*__alliumv2__ (TuxCoin [TUX])
2729
*__axiom__ (Axiom Shabal-256 based MemoHash)
2830
*__bastion__ (Joincoin [J])
2931
*__bitcore__ Permuted serie of 10 algos (BitCore)

algo/alliumV2.c

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
#include <memory.h>
2+
3+
#include "sha3/sph_blake.h"
4+
#include "sha3/sph_groestl.h"
5+
#include "sha3/sph_cubehash.h"
6+
#include "sha3/sph_skein.h"
7+
#include "sha3/sph_keccak.h"
8+
9+
#include "lyra2/Lyra2.h"
10+
11+
#include "miner.h"
12+
13+
void alliumV2_hash(void *state, const void *input)
14+
{
15+
uint32_t _ALIGN(128) hashA[8], hashB[8];
16+
17+
sph_blake256_context ctx_blake;
18+
sph_keccak256_context ctx_keccak;
19+
sph_cubehash256_context ctx_cubehash;
20+
sph_skein256_context ctx_skein;
21+
sph_groestl256_context ctx_groestl;
22+
23+
sph_blake256_init(&ctx_blake);
24+
sph_blake256(&ctx_blake, input, 80);
25+
sph_blake256_close(&ctx_blake, hashA);
26+
27+
sph_keccak256_init(&ctx_keccak);
28+
sph_keccak256(&ctx_keccak, hashA, 32);
29+
sph_keccak256_close(&ctx_keccak, hashB);
30+
31+
LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 4, 4);
32+
33+
sph_cubehash256_init(&ctx_cubehash);
34+
sph_cubehash256(&ctx_cubehash, hashA, 32);
35+
sph_cubehash256_close(&ctx_cubehash, hashB);
36+
37+
LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 4, 4);
38+
39+
sph_skein256_init(&ctx_skein);
40+
sph_skein256(&ctx_skein, hashA, 32);
41+
sph_skein256_close(&ctx_skein, hashB);
42+
43+
sph_groestl256_init(&ctx_groestl);
44+
sph_groestl256(&ctx_groestl, hashB, 32);
45+
sph_groestl256_close(&ctx_groestl, hashA);
46+
47+
memcpy(state, hashA, 32);
48+
}
49+
50+
int scanhash_alliumV2(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
51+
{
52+
uint32_t _ALIGN(128) hash[8];
53+
uint32_t _ALIGN(128) endiandata[20];
54+
uint32_t *pdata = work->data;
55+
uint32_t *ptarget = work->target;
56+
57+
const uint32_t Htarg = ptarget[7];
58+
const uint32_t first_nonce = pdata[19];
59+
uint32_t nonce = first_nonce;
60+
61+
if (opt_benchmark)
62+
ptarget[7] = 0x0000ff;
63+
64+
for (int i=0; i < 19; i++) {
65+
be32enc(&endiandata[i], pdata[i]);
66+
}
67+
68+
do {
69+
be32enc(&endiandata[19], nonce);
70+
alliumV2_hash(hash, endiandata);
71+
72+
if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
73+
work_set_target_ratio(work, hash);
74+
pdata[19] = nonce;
75+
*hashes_done = pdata[19] - first_nonce;
76+
return 1;
77+
}
78+
nonce++;
79+
80+
} while (nonce < max_nonce && !work_restart[thr_id].restart);
81+
82+
pdata[19] = nonce;
83+
*hashes_done = pdata[19] - first_nonce + 1;
84+
return 0;
85+
}

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
AC_INIT([cpuminer-multi], [1.3.5])
1+
AC_INIT([cpuminer-multi], [1.3.6])
22

33
AC_PREREQ([2.59c])
44
AC_CANONICAL_SYSTEM

cpu-miner.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ enum algos {
8383
ALGO_NEOSCRYPT, /* NeoScrypt(128, 2, 1) with Salsa20/20 and ChaCha20/20 */
8484
ALGO_QUARK, /* Quark */
8585
ALGO_ALLIUM, /* Garlicoin double lyra2 */
86+
ALGO_ALLIUMV2, /* AlliumV2 (Tuxcoin) */
8687
ALGO_AXIOM, /* Shabal 256 Memohash */
8788
ALGO_BASTION,
8889
ALGO_BLAKE, /* Blake 256 */
@@ -146,6 +147,7 @@ static const char *algo_names[] = {
146147
"neoscrypt",
147148
"quark",
148149
"allium",
150+
"alliumv2",
149151
"axiom",
150152
"bastion",
151153
"blake",
@@ -304,6 +306,7 @@ Usage: " PACKAGE_NAME " [OPTIONS]\n\
304306
Options:\n\
305307
-a, --algo=ALGO specify the algorithm to use\n\
306308
allium Garlicoin double lyra2\n\
309+
alliumV2 AlliumV2 (Tuxcoin)\n\
307310
axiom Shabal-256 MemoHash\n\
308311
bitcore Timetravel with 10 algos\n\
309312
blake Blake-256 14-rounds (SFR)\n\
@@ -1838,6 +1841,7 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
18381841
work_set_target(work, sctx->job.diff / (65536.0 * opt_diff_factor));
18391842
break;
18401843
case ALGO_ALLIUM:
1844+
case ALGO_ALLIUMV2:
18411845
case ALGO_FRESH:
18421846
case ALGO_DMD_GR:
18431847
case ALGO_GROESTL:
@@ -2172,6 +2176,7 @@ static void *miner_thread(void *userdata)
21722176
max64 = 0x1ff;
21732177
break;
21742178
case ALGO_ALLIUM:
2179+
case ALGO_ALLIUMV2:
21752180
case ALGO_LYRA2:
21762181
case ALGO_LYRA2REV2:
21772182
case ALGO_PHI1612:
@@ -2242,6 +2247,9 @@ static void *miner_thread(void *userdata)
22422247
case ALGO_ALLIUM:
22432248
rc = scanhash_allium(thr_id, &work, max_nonce, &hashes_done);
22442249
break;
2250+
case ALGO_ALLIUMV2:
2251+
rc = scanhash_alliumV2(thr_id, &work, max_nonce, &hashes_done);
2252+
break;
22452253
case ALGO_AXIOM:
22462254
rc = scanhash_axiom(thr_id, &work, max_nonce, &hashes_done);
22472255
break;

cpuminer.vcxproj

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

cpuminer.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,9 @@
177177
<ClCompile Include="algo\allium.c">
178178
<Filter>algo</Filter>
179179
</ClCompile>
180+
<ClCompile Include="algo\alliumV2.c">
181+
<Filter>algo</Filter>
182+
</ClCompile>
180183
<ClCompile Include="algo\bastion.c">
181184
<Filter>algo</Filter>
182185
</ClCompile>

miner.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,7 @@ void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
199199
struct work;
200200

201201
int scanhash_allium(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
202+
int scanhash_alliumV2(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
202203
int scanhash_axiom(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
203204
int scanhash_bastion(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
204205
int scanhash_blake(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
@@ -495,7 +496,8 @@ void format_hashrate(double hashrate, char *output);
495496
void print_hash_tests(void);
496497

497498
void sha256d(unsigned char *hash, const unsigned char *data, int len);
498-
void allium_hash(void *state, const void *input);
499+
void allium_hash(void *output, const void *input);
500+
void alliumV2_hash(void *output, const void *input);
499501
void axiomhash(void *state, const void *input);
500502
void bastionhash(void *output, const void *input);
501503
void blakehash(void *state, const void *input);

util.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,6 +2329,9 @@ void print_hash_tests(void)
23292329
allium_hash(&hash[0], &buf[0]);
23302330
printpfx("allium", hash);
23312331

2332+
alliumV2_hash(&hash[0], &buf[0]);
2333+
printpfx("alliumV2", hash);
2334+
23322335
axiomhash(&hash[0], &buf[0]);
23332336
printpfx("axiom", hash);
23342337

0 commit comments

Comments
 (0)