Skip to content

Commit

Permalink
add argon2d16000
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaolin1579 committed Jan 31, 2021
1 parent a5e507f commit 1e055a7
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 0 deletions.
2 changes: 2 additions & 0 deletions algo-gate-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ bool register_algo_gate( int algo, algo_gate_t *gate )
case ALGO_ARGON2D250: register_argon2d_crds_algo ( gate ); break;
case ALGO_ARGON2D500: register_argon2d_dyn_algo ( gate ); break;
case ALGO_ARGON2D4096: register_argon2d4096_algo ( gate ); break;
case ALGO_ARGON2D16000: register_argon2d_bcrs_algo ( gate ); break;
case ALGO_AXIOM: register_axiom_algo ( gate ); break;
case ALGO_BLAKE: register_blake_algo ( gate ); break;
case ALGO_BLAKE2B: register_blake2b_algo ( gate ); break;
Expand Down Expand Up @@ -422,6 +423,7 @@ const char* const algo_alias_map[][2] =
{ "argon2d-crds", "argon2d250" },
{ "argon2d-dyn", "argon2d500" },
{ "argon2d-uis", "argon2d4096" },
{ "argon2d-bcrs", "argon2d16000" },
{ "bcd", "x13bcd" },
{ "bitcore", "timetravel10" },
{ "bitzeny", "yescryptr8" },
Expand Down
67 changes: 67 additions & 0 deletions algo/argon2/argon2d/argon2d-gate.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,70 @@ bool register_argon2d4096_algo( algo_gate_t* gate )
return true;
}

// Bitcreds

void argon2d_bcrs_hash( void *output, const void *input )
{
argon2_context context;
context.out = (uint8_t *)output;
context.outlen = (uint32_t)OUTPUT_BYTES;
context.pwd = (uint8_t *)input;
context.pwdlen = (uint32_t)INPUT_BYTES;
context.salt = (uint8_t *)input; //salt = input
context.saltlen = (uint32_t)INPUT_BYTES;
context.secret = NULL;
context.secretlen = 0;
context.ad = NULL;
context.adlen = 0;
context.allocate_cbk = NULL;
context.free_cbk = NULL;
context.flags = DEFAULT_ARGON2_FLAG; // = ARGON2_DEFAULT_FLAGS
// main configurable Argon2 hash parameters
context.m_cost = 16000; // Memory in KiB (~16384KB)
context.lanes = 1; // Degree of Parallelism
context.threads = 1; // Threads
context.t_cost = 1; // Iterations
context.version = ARGON2_VERSION_10;

argon2_ctx( &context, Argon2_d );
}

int scanhash_argon2d_bcrs( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr )
{
uint32_t _ALIGN(64) edata[20];
uint32_t _ALIGN(64) hash[8];
uint32_t *pdata = work->data;
uint32_t *ptarget = work->target;
int thr_id = mythr->id; // thr_id arg is deprecated
const uint32_t first_nonce = pdata[19];
const uint32_t Htarg = ptarget[7];
uint32_t nonce = first_nonce;

swab32_array( edata, pdata, 20 );

do {
be32enc(&edata[19], nonce);
argon2d_bcrs_hash( hash, edata );
if ( hash[7] <= Htarg && fulltest( hash, ptarget ) && !opt_benchmark )
{
pdata[19] = nonce;
submit_solution( work, hash, mythr );
}
nonce++;
} while (nonce < max_nonce && !work_restart[thr_id].restart);

pdata[19] = nonce;
*hashes_done = pdata[19] - first_nonce + 1;
return 0;
}

bool register_argon2d_bcrs_algo( algo_gate_t* gate )
{
gate->scanhash = (void*)&scanhash_argon2d_bcrs;
gate->hash = (void*)&argon2d_bcrs_hash;
gate->optimizations = SSE2_OPT | AVX2_OPT | AVX512_OPT;
opt_target_factor = 65536.0;
return true;
}

9 changes: 9 additions & 0 deletions algo/argon2/argon2d/argon2d-gate.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,14 @@ bool register_argon2d4096_algo( algo_gate_t* gate );
int scanhash_argon2d4096( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );

// Bitcreds: version = 0x10, m_cost = 16000.
bool register_argon2d_bcrs_algo( algo_gate_t* gate );

void argon2d_bcrs_hash( void *state, const void *input );

int scanhash_argon2d_bcrs( struct work *work, uint32_t max_nonce,
uint64_t *hashes_done, struct thr_info *mythr );


#endif

3 changes: 3 additions & 0 deletions miner.h
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,7 @@ enum algos {
ALGO_ARGON2D250,
ALGO_ARGON2D500,
ALGO_ARGON2D4096,
ALGO_ARGON2D16000,
ALGO_AXIOM,
ALGO_BLAKE,
ALGO_BLAKE2B,
Expand Down Expand Up @@ -616,6 +617,7 @@ static const char* const algo_names[] = {
"argon2d250",
"argon2d500",
"argon2d4096",
"argon2d16000",
"axiom",
"blake",
"blake2b",
Expand Down Expand Up @@ -774,6 +776,7 @@ Options:\n\
argon2d250 argon2d-crds, Credits (CRDS)\n\
argon2d500 argon2d-dyn, Dynamic (DYN)\n\
argon2d4096 argon2d-uis, Unitus (UIS)\n\
argon2d16000 argon2d-bcrs, Bitcreds (BCRS)\n\
axiom Shabal-256 MemoHash\n\
blake blake256r14 (SFR)\n\
blake2b Blake2b 256\n\
Expand Down

0 comments on commit 1e055a7

Please sign in to comment.