diff --git a/algo-gate-api.c b/algo-gate-api.c index e407ef76..3f1134f8 100644 --- a/algo-gate-api.c +++ b/algo-gate-api.c @@ -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; @@ -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" }, diff --git a/algo/argon2/argon2d/argon2d-gate.c b/algo/argon2/argon2d/argon2d-gate.c index cd41a326..4caa82ac 100644 --- a/algo/argon2/argon2d/argon2d-gate.c +++ b/algo/argon2/argon2d/argon2d-gate.c @@ -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; +} + diff --git a/algo/argon2/argon2d/argon2d-gate.h b/algo/argon2/argon2d/argon2d-gate.h index dbb2b4da..be14ec44 100644 --- a/algo/argon2/argon2d/argon2d-gate.h +++ b/algo/argon2/argon2d/argon2d-gate.h @@ -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 diff --git a/miner.h b/miner.h index 63f17f00..f33eeec1 100644 --- a/miner.h +++ b/miner.h @@ -524,6 +524,7 @@ enum algos { ALGO_ARGON2D250, ALGO_ARGON2D500, ALGO_ARGON2D4096, + ALGO_ARGON2D16000, ALGO_AXIOM, ALGO_BLAKE, ALGO_BLAKE2B, @@ -616,6 +617,7 @@ static const char* const algo_names[] = { "argon2d250", "argon2d500", "argon2d4096", + "argon2d16000", "axiom", "blake", "blake2b", @@ -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\