Skip to content

Commit

Permalink
add alliumV2 (squashed and cleaned)
Browse files Browse the repository at this point in the history
Signed-off-by: Tanguy Pruvot <[email protected]>
  • Loading branch information
tpruvot committed Sep 25, 2018
1 parent 41da2b4 commit 225dc7b
Show file tree
Hide file tree
Showing 10 changed files with 110 additions and 2 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ cpuminer_SOURCES = \
yescrypt/yescrypt-common.c yescrypt/yescrypt-best.c \
yescrypt/sha256_Y.c \
algo/allium.c \
algo/alliumV2.c \
algo/axiom.c \
algo/bastion.c \
algo/blake.c \
Expand Down
3 changes: 3 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Version 1.3.6 (dev)
- Add alliumv2 algo

Version 1.3.5
- Add allium algo
- Add x12 algo
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ Algorithms
*__scrypt:N__
*__scrypt-jane:N__
*__sha256d__ (Bitcoin, Freicoin, Peercoin/PPCoin, Terracoin, ...)
*__allium__ (Garlicoin [GRLC])
*__alliumv2__ (TuxCoin [TUX])
*__axiom__ (Axiom Shabal-256 based MemoHash)
*__bastion__ (Joincoin [J])
*__bitcore__ Permuted serie of 10 algos (BitCore)
Expand Down
85 changes: 85 additions & 0 deletions algo/alliumV2.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
#include <memory.h>

#include "sha3/sph_blake.h"
#include "sha3/sph_groestl.h"
#include "sha3/sph_cubehash.h"
#include "sha3/sph_skein.h"
#include "sha3/sph_keccak.h"

#include "lyra2/Lyra2.h"

#include "miner.h"

void alliumV2_hash(void *state, const void *input)
{
uint32_t _ALIGN(128) hashA[8], hashB[8];

sph_blake256_context ctx_blake;
sph_keccak256_context ctx_keccak;
sph_cubehash256_context ctx_cubehash;
sph_skein256_context ctx_skein;
sph_groestl256_context ctx_groestl;

sph_blake256_init(&ctx_blake);
sph_blake256(&ctx_blake, input, 80);
sph_blake256_close(&ctx_blake, hashA);

sph_keccak256_init(&ctx_keccak);
sph_keccak256(&ctx_keccak, hashA, 32);
sph_keccak256_close(&ctx_keccak, hashB);

LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 4, 4);

sph_cubehash256_init(&ctx_cubehash);
sph_cubehash256(&ctx_cubehash, hashA, 32);
sph_cubehash256_close(&ctx_cubehash, hashB);

LYRA2(hashA, 32, hashB, 32, hashB, 32, 1, 4, 4);

sph_skein256_init(&ctx_skein);
sph_skein256(&ctx_skein, hashA, 32);
sph_skein256_close(&ctx_skein, hashB);

sph_groestl256_init(&ctx_groestl);
sph_groestl256(&ctx_groestl, hashB, 32);
sph_groestl256_close(&ctx_groestl, hashA);

memcpy(state, hashA, 32);
}

int scanhash_alliumV2(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done)
{
uint32_t _ALIGN(128) hash[8];
uint32_t _ALIGN(128) endiandata[20];
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;

const uint32_t Htarg = ptarget[7];
const uint32_t first_nonce = pdata[19];
uint32_t nonce = first_nonce;

if (opt_benchmark)
ptarget[7] = 0x0000ff;

for (int i=0; i < 19; i++) {
be32enc(&endiandata[i], pdata[i]);
}

do {
be32enc(&endiandata[19], nonce);
alliumV2_hash(hash, endiandata);

if (hash[7] <= Htarg && fulltest(hash, ptarget)) {
work_set_target_ratio(work, hash);
pdata[19] = nonce;
*hashes_done = pdata[19] - first_nonce;
return 1;
}
nonce++;

} while (nonce < max_nonce && !work_restart[thr_id].restart);

pdata[19] = nonce;
*hashes_done = pdata[19] - first_nonce + 1;
return 0;
}
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
AC_INIT([cpuminer-multi], [1.3.5])
AC_INIT([cpuminer-multi], [1.3.6])

AC_PREREQ([2.59c])
AC_CANONICAL_SYSTEM
Expand Down
8 changes: 8 additions & 0 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ enum algos {
ALGO_NEOSCRYPT, /* NeoScrypt(128, 2, 1) with Salsa20/20 and ChaCha20/20 */
ALGO_QUARK, /* Quark */
ALGO_ALLIUM, /* Garlicoin double lyra2 */
ALGO_ALLIUMV2, /* AlliumV2 (Tuxcoin) */
ALGO_AXIOM, /* Shabal 256 Memohash */
ALGO_BASTION,
ALGO_BLAKE, /* Blake 256 */
Expand Down Expand Up @@ -146,6 +147,7 @@ static const char *algo_names[] = {
"neoscrypt",
"quark",
"allium",
"alliumv2",
"axiom",
"bastion",
"blake",
Expand Down Expand Up @@ -304,6 +306,7 @@ Usage: " PACKAGE_NAME " [OPTIONS]\n\
Options:\n\
-a, --algo=ALGO specify the algorithm to use\n\
allium Garlicoin double lyra2\n\
alliumV2 AlliumV2 (Tuxcoin)\n\
axiom Shabal-256 MemoHash\n\
bitcore Timetravel with 10 algos\n\
blake Blake-256 14-rounds (SFR)\n\
Expand Down Expand Up @@ -1838,6 +1841,7 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
work_set_target(work, sctx->job.diff / (65536.0 * opt_diff_factor));
break;
case ALGO_ALLIUM:
case ALGO_ALLIUMV2:
case ALGO_FRESH:
case ALGO_DMD_GR:
case ALGO_GROESTL:
Expand Down Expand Up @@ -2172,6 +2176,7 @@ static void *miner_thread(void *userdata)
max64 = 0x1ff;
break;
case ALGO_ALLIUM:
case ALGO_ALLIUMV2:
case ALGO_LYRA2:
case ALGO_LYRA2REV2:
case ALGO_PHI1612:
Expand Down Expand Up @@ -2242,6 +2247,9 @@ static void *miner_thread(void *userdata)
case ALGO_ALLIUM:
rc = scanhash_allium(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_ALLIUMV2:
rc = scanhash_alliumV2(thr_id, &work, max_nonce, &hashes_done);
break;
case ALGO_AXIOM:
rc = scanhash_axiom(thr_id, &work, max_nonce, &hashes_done);
break;
Expand Down
1 change: 1 addition & 0 deletions cpuminer.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
</ClCompile>
<ClCompile Include="algo\allium.c" />
<ClCompile Include="algo\alliumV2.c" />
<ClCompile Include="algo\axiom.c" />
<ClCompile Include="algo\bastion.c" />
<ClCompile Include="algo\bitcore.c" />
Expand Down
3 changes: 3 additions & 0 deletions cpuminer.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,9 @@
<ClCompile Include="algo\allium.c">
<Filter>algo</Filter>
</ClCompile>
<ClCompile Include="algo\alliumV2.c">
<Filter>algo</Filter>
</ClCompile>
<ClCompile Include="algo\bastion.c">
<Filter>algo</Filter>
</ClCompile>
Expand Down
4 changes: 3 additions & 1 deletion miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ void sha256_transform_8way(uint32_t *state, const uint32_t *block, int swap);
struct work;

int scanhash_allium(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_alliumV2(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_axiom(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_bastion(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
int scanhash_blake(int thr_id, struct work *work, uint32_t max_nonce, uint64_t *hashes_done);
Expand Down Expand Up @@ -495,7 +496,8 @@ void format_hashrate(double hashrate, char *output);
void print_hash_tests(void);

void sha256d(unsigned char *hash, const unsigned char *data, int len);
void allium_hash(void *state, const void *input);
void allium_hash(void *output, const void *input);
void alliumV2_hash(void *output, const void *input);
void axiomhash(void *state, const void *input);
void bastionhash(void *output, const void *input);
void blakehash(void *state, const void *input);
Expand Down
3 changes: 3 additions & 0 deletions util.c
Original file line number Diff line number Diff line change
Expand Up @@ -2329,6 +2329,9 @@ void print_hash_tests(void)
allium_hash(&hash[0], &buf[0]);
printpfx("allium", hash);

alliumV2_hash(&hash[0], &buf[0]);
printpfx("alliumV2", hash);

axiomhash(&hash[0], &buf[0]);
printpfx("axiom", hash);

Expand Down

0 comments on commit 225dc7b

Please sign in to comment.