Browse Source

use double GOST 34.11 for hash function

pull/5/head
orignal 7 years ago
parent
commit
b6cf57cea5
  1. 28
      src/main.cpp
  2. 8
      src/main.h

28
src/main.cpp

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#include "init.h"
#include "ui_interface.h"
#include "checkqueue.h"
#include "Gost.h" // i2pd
#include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
@ -4703,9 +4704,9 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey) @@ -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) @@ -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) @@ -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)
{

8
src/main.h

@ -10,6 +10,8 @@ @@ -10,6 +10,8 @@
#include "net.h"
#include "script.h"
#include "Gost.h" // i2pd
#include <list>
class CWallet;
@ -1360,9 +1362,11 @@ public: @@ -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;
}

Loading…
Cancel
Save