From b6cf57cea56bc22b2965fcc94a06068949cbe437 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 23 Mar 2017 14:00:48 -0400 Subject: [PATCH] use double GOST 34.11 for hash function --- src/main.cpp | 28 +++++++++------------------- src/main.h | 8 ++++++-- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index a0e6d90..e23f672 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -11,6 +11,7 @@ #include "init.h" #include "ui_interface.h" #include "checkqueue.h" +#include "Gost.h" // i2pd #include #include #include @@ -4703,9 +4704,9 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) void static LitecoinMiner(CWallet *pwallet) { - printf("AnoncoinMiner started\n"); + printf("UnioncoinMiner started\n"); SetThreadPriority(THREAD_PRIORITY_LOWEST); - RenameThread("anoncoin-miner"); + RenameThread("unioncoin-miner"); // Each thread has its own key and counter CReserveKey reservekey(pwallet); @@ -4727,7 +4728,7 @@ void static LitecoinMiner(CWallet *pwallet) CBlock *pblock = &pblocktemplate->block; IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); - printf("Running AnoncoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(), + printf("Running UnioncoinMiner with %"PRIszu" transactions in block (%u bytes)\n", pblock->vtx.size(), ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION)); // @@ -4754,24 +4755,13 @@ void static LitecoinMiner(CWallet *pwallet) unsigned int nHashesDone = 0; uint256 thash; - // TODO: - //char scratchpad[SCRYPT_SCRATCHPAD_SIZE]; loop { -#if defined(USE_SSE2) - // Detection would work, but in cases where we KNOW it always has SSE2, - // it is faster to use directly than to use a function pointer or conditional. -#if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__)) - // Always SSE2: x86_64 or Intel MacOS X - // scrypt_1024_1_1_256_sp_sse2(BEGIN(pblock->nVersion), BEGIN(thash), scratchpad); -#else - // Detect SSE2: 32bit x86 Linux or Windows - //scrypt_1024_1_1_256_sp(BEGIN(pblock->nVersion), BEGIN(thash), scratchpad); -#endif -#else - // Generic scrypt - //scrypt_1024_1_1_256_sp_generic(BEGIN(pblock->nVersion), BEGIN(thash), scratchpad); -#endif + // GOST 34.11-256 (GOST 34.11-512 (pblock->header)) + uint8_t digest[64]; + i2p::crypto::GOSTR3411_2012_512 ((const uint8_t *)(&pblock->nVersion), 80, digest); + i2p::crypto::GOSTR3411_2012_256 (digest, 64, thash.begin ()); + if (thash <= hashTarget) { diff --git a/src/main.h b/src/main.h index a784e3e..6d4af7d 100644 --- a/src/main.h +++ b/src/main.h @@ -10,6 +10,8 @@ #include "net.h" #include "script.h" +#include "Gost.h" // i2pd + #include class CWallet; @@ -1360,9 +1362,11 @@ public: uint256 GetPoWHash() const { + // GOST 34.11-256 (GOST 34.11-512 (header)) + uint8_t digest[64]; + i2p::crypto::GOSTR3411_2012_512 ((const uint8_t *)&nVersion, 80, digest); uint256 thash; - // TODO: - // scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(thash)); + i2p::crypto::GOSTR3411_2012_256 (digest, 64, thash.begin ()); return thash; }