From f5f92e53dcd41b718ccdf8ed72d989b52c5b79ef Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 19 Oct 2017 14:49:46 -0400 Subject: [PATCH] correct regenhash --- algorithm/gostcoin.c | 19 +++++++++++++------ algorithm/gostcoin.h | 2 -- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/algorithm/gostcoin.c b/algorithm/gostcoin.c index b58129cd..4485d4d5 100644 --- a/algorithm/gostcoin.c +++ b/algorithm/gostcoin.c @@ -1,16 +1,23 @@ #include "config.h" #include "miner.h" +#include "sph/sph_gost.h" #include #include #include -int gostcoin_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce) -{ - return 0; // TODO -} - void gostcoin_regenhash(struct work *work) { - // TODO: + uint32_t data[20]; + uint32_t *nonce = (uint32_t *)(work->data + 76); + + be32enc_vect(data, (const uint32_t *)work->data, 19); + data[19] = htobe32(*nonce); + + unsigned char h1[64], h2[32]; + sph_gost512(h1, (const void*)data, 80); + sph_gost256(h2, (const void*)h1, 64); + + int i; + for (i = 0 ; i < 32; i++) work->hash[i] = h2[31-i]; } diff --git a/algorithm/gostcoin.h b/algorithm/gostcoin.h index 9bc69929..42552d67 100644 --- a/algorithm/gostcoin.h +++ b/algorithm/gostcoin.h @@ -3,8 +3,6 @@ #include "miner.h" -extern int gostcoin_test(unsigned char *pdata, const unsigned char *ptarget, - uint32_t nonce); extern void gostcoin_regenhash(struct work *work); #endif /* SIBCOIN_H */