Skip to content

Commit

Permalink
allium algo, with proper pool diff ratio 256
Browse files Browse the repository at this point in the history
cleaned up...
  • Loading branch information
tpruvot committed May 6, 2018
1 parent 582e576 commit 289d9de
Show file tree
Hide file tree
Showing 8 changed files with 122 additions and 0 deletions.
1 change: 1 addition & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ cpuminer_SOURCES = \
lyra2/Lyra2.c lyra2/Sponge.c \
yescrypt/yescrypt-common.c yescrypt/yescrypt-best.c \
yescrypt/sha256_Y.c \
algo/allium.c \
algo/axiom.c \
algo/bastion.c \
algo/blake.c \
Expand Down
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Version 1.3.4
- Add allium algo
- Add x12 algo
- Add x16s algo

Expand Down
103 changes: 103 additions & 0 deletions algo/allium.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
/**
* Allium algo Implementation
*/

#include <memory.h>

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

#include "lyra2/Lyra2.h"

#include "miner.h"

static char* format_hash(char* buf, uint8_t *hash)
{
int len = 0;
for (int i=0; i < 32; i += 4) {
len += sprintf(buf+len, "%02x%02x%02x%02x ",
hash[i], hash[i+1], hash[i+2], hash[i+3]);
}
return buf;
}

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

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

// sph_blake256_set_rounds(14);

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, 8, 8);

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

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

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_allium(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 n = first_nonce;

if(opt_benchmark){
ptarget[7] = 0x00ff;
}

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

do {
be32enc(&endiandata[19], n);
allium_hash(hash, endiandata);

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

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

*hashes_done = n - first_nonce + 1;
pdata[19] = n;

return 0;
}
8 changes: 8 additions & 0 deletions cpu-miner.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ enum algos {
ALGO_HEAVY, /* Heavy */
ALGO_NEOSCRYPT, /* NeoScrypt(128, 2, 1) with Salsa20/20 and ChaCha20/20 */
ALGO_QUARK, /* Quark */
ALGO_ALLIUM, /* Garlicoin double lyra2 */
ALGO_AXIOM, /* Shabal 256 Memohash */
ALGO_BASTION,
ALGO_BLAKE, /* Blake 256 */
Expand Down Expand Up @@ -141,6 +142,7 @@ static const char *algo_names[] = {
"heavy",
"neoscrypt",
"quark",
"allium",
"axiom",
"bastion",
"blake",
Expand Down Expand Up @@ -296,6 +298,7 @@ static char const usage[] = "\
Usage: " PACKAGE_NAME " [OPTIONS]\n\
Options:\n\
-a, --algo=ALGO specify the algorithm to use\n\
allium Garlicoin double lyra2\n\
axiom Shabal-256 MemoHash\n\
bitcore Timetravel with 10 algos\n\
blake Blake-256 14-rounds (SFR)\n\
Expand Down Expand Up @@ -1809,6 +1812,7 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work)
case ALGO_YESCRYPT:
work_set_target(work, sctx->job.diff / (65536.0 * opt_diff_factor));
break;
case ALGO_ALLIUM:
case ALGO_FRESH:
case ALGO_DMD_GR:
case ALGO_GROESTL:
Expand Down Expand Up @@ -2141,6 +2145,7 @@ static void *miner_thread(void *userdata)
case ALGO_YESCRYPT:
max64 = 0x1ff;
break;
case ALGO_ALLIUM:
case ALGO_LYRA2:
case ALGO_LYRA2REV2:
case ALGO_TIMETRAVEL:
Expand Down Expand Up @@ -2205,6 +2210,9 @@ static void *miner_thread(void *userdata)
/* scan nonces for a proof-of-work hash */
switch (opt_algo) {

case ALGO_ALLIUM:
rc = scanhash_allium(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 @@ -202,6 +202,7 @@
<ClCompile Include="util.c">
<Optimization Condition="'$(Configuration)'=='Release'">Full</Optimization>
</ClCompile>
<ClCompile Include="algo\allium.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 @@ -174,6 +174,9 @@
<ClCompile Include="compat\jansson\strconv.c">
<Filter>jansson</Filter>
</ClCompile>
<ClCompile Include="algo\allium.c">
<Filter>algo</Filter>
</ClCompile>
<ClCompile Include="algo\bastion.c">
<Filter>algo</Filter>
</ClCompile>
Expand Down
2 changes: 2 additions & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,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_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 @@ -491,6 +492,7 @@ 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 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 @@ -2313,6 +2313,9 @@ void print_hash_tests(void)
memset(buf, 0, sizeof(buf));
//buf[0] = 1; buf[64] = 2; // for endian tests

allium_hash(&hash[0], &buf[0]);
printpfx("allium", hash);

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

Expand Down

0 comments on commit 289d9de

Please sign in to comment.