Browse Source

use double GOST 34.11 for hash function

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

28
src/main.cpp

@ -11,6 +11,7 @@
#include "init.h" #include "init.h"
#include "ui_interface.h" #include "ui_interface.h"
#include "checkqueue.h" #include "checkqueue.h"
#include "Gost.h" // i2pd
#include <boost/algorithm/string/replace.hpp> #include <boost/algorithm/string/replace.hpp>
#include <boost/filesystem.hpp> #include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp> #include <boost/filesystem/fstream.hpp>
@ -4703,9 +4704,9 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
void static LitecoinMiner(CWallet *pwallet) void static LitecoinMiner(CWallet *pwallet)
{ {
printf("AnoncoinMiner started\n"); printf("UnioncoinMiner started\n");
SetThreadPriority(THREAD_PRIORITY_LOWEST); SetThreadPriority(THREAD_PRIORITY_LOWEST);
RenameThread("anoncoin-miner"); RenameThread("unioncoin-miner");
// Each thread has its own key and counter // Each thread has its own key and counter
CReserveKey reservekey(pwallet); CReserveKey reservekey(pwallet);
@ -4727,7 +4728,7 @@ void static LitecoinMiner(CWallet *pwallet)
CBlock *pblock = &pblocktemplate->block; CBlock *pblock = &pblocktemplate->block;
IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); 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)); ::GetSerializeSize(*pblock, SER_NETWORK, PROTOCOL_VERSION));
// //
@ -4754,24 +4755,13 @@ void static LitecoinMiner(CWallet *pwallet)
unsigned int nHashesDone = 0; unsigned int nHashesDone = 0;
uint256 thash; uint256 thash;
// TODO:
//char scratchpad[SCRYPT_SCRATCHPAD_SIZE];
loop loop
{ {
#if defined(USE_SSE2) // GOST 34.11-256 (GOST 34.11-512 (pblock->header))
// Detection would work, but in cases where we KNOW it always has SSE2, uint8_t digest[64];
// it is faster to use directly than to use a function pointer or conditional. i2p::crypto::GOSTR3411_2012_512 ((const uint8_t *)(&pblock->nVersion), 80, digest);
#if defined(_M_X64) || defined(__x86_64__) || defined(_M_AMD64) || (defined(MAC_OSX) && defined(__i386__)) i2p::crypto::GOSTR3411_2012_256 (digest, 64, thash.begin ());
// 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
if (thash <= hashTarget) if (thash <= hashTarget)
{ {

8
src/main.h

@ -10,6 +10,8 @@
#include "net.h" #include "net.h"
#include "script.h" #include "script.h"
#include "Gost.h" // i2pd
#include <list> #include <list>
class CWallet; class CWallet;
@ -1360,9 +1362,11 @@ public:
uint256 GetPoWHash() const 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; uint256 thash;
// TODO: i2p::crypto::GOSTR3411_2012_256 (digest, 64, thash.begin ());
// scrypt_1024_1_1_256(BEGIN(nVersion), BEGIN(thash));
return thash; return thash;
} }

Loading…
Cancel
Save