diff --git a/cpu-miner.c b/cpu-miner.c index e1ea4be..dab312c 100644 --- a/cpu-miner.c +++ b/cpu-miner.c @@ -654,11 +654,22 @@ static void stratum_gen_work(struct stratum_ctx *sctx, struct work *work) memcpy(work->xnonce2, sctx->job.xnonce2, sctx->xnonce2_size); /* Generate merkle root */ - sha256d(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size); - for (i = 0; i < sctx->job.merkle_count; i++) { - memcpy(merkle_root + 32, sctx->job.merkle[i], 32); - sha256d(merkle_root, merkle_root, 64); - } + if (opt_algo == ALGO_GOSTD) + { + gostd(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size); + for (i = 0; i < sctx->job.merkle_count; i++) { + memcpy(merkle_root + 32, merkle_root, 32); + gostd(merkle_root, merkle_root, 64); + } + } + else + { + sha256d(merkle_root, sctx->job.coinbase, sctx->job.coinbase_size); + for (i = 0; i < sctx->job.merkle_count; i++) { + memcpy(merkle_root + 32, sctx->job.merkle[i], 32); + sha256d(merkle_root, merkle_root, 64); + } + } /* Increment extranonce2 */ for (i = 0; i < sctx->xnonce2_size && !++sctx->job.xnonce2[i]; i++); diff --git a/gost.c b/gost.c index 41586ed..327d8ff 100644 --- a/gost.c +++ b/gost.c @@ -1223,6 +1223,16 @@ void sph_gostd(void *cc, const void *data, size_t len) hash_256(digest, 64, cc); } +void gostd(void *output, const void *input, size_t len) +{ + unsigned char hash[64]; + + sph_gost512(hash, (const void*)input, len); + sph_gost256(hash, (const void*)hash, 64); + + memcpy(output, hash, 32); +} + int scanhash_gostd(int thr_id, uint32_t *pdata, const uint32_t *ptarget, uint32_t max_nonce, unsigned long *hashes_done) { diff --git a/miner.h b/miner.h index 2437f63..f78a705 100644 --- a/miner.h +++ b/miner.h @@ -134,6 +134,8 @@ void sha256_init(uint32_t *state); void sha256_transform(uint32_t *state, const uint32_t *block, int swap); void sha256d(unsigned char *hash, const unsigned char *data, int len); +void gostd(void *output, const void *input, size_t len); + #if defined(__ARM_NEON__) || defined(__i386__) || defined(__x86_64__) #define HAVE_SHA256_4WAY 1 int sha256_use_4way();