mirror of
https://github.com/GOSTSec/gostcoin
synced 2025-01-30 08:24:20 +00:00
hash in Little Endian
This commit is contained in:
parent
22c32cd4d3
commit
246f600b43
11
src/hash.h
11
src/hash.h
@ -7,6 +7,7 @@
|
||||
|
||||
#include "uint256.h"
|
||||
#include "serialize.h"
|
||||
#include "util.h"
|
||||
#include "Gost.h"
|
||||
|
||||
#include <openssl/sha.h>
|
||||
@ -20,9 +21,13 @@ inline uint256 Hash(const T1 pbegin, const T1 pend)
|
||||
// GOST 34.11-256 (GOST 34.11-512 (...))
|
||||
static unsigned char pblank[1];
|
||||
uint8_t hash1[64];
|
||||
i2p::crypto::GOSTR3411_2012_512 ((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), hash1);
|
||||
uint256 hash2;
|
||||
i2p::crypto::GOSTR3411_2012_256 (hash1, 64, hash2.begin ());
|
||||
i2p::crypto::GOSTR3411_2012_512 ((pbegin == pend ? pblank : (unsigned char*)&pbegin[0]), (pend - pbegin) * sizeof(pbegin[0]), hash1);
|
||||
uint8_t digest[32];
|
||||
i2p::crypto::GOSTR3411_2012_256 (hash1, 64, digest);
|
||||
// to little endian
|
||||
uint256 hash2;
|
||||
for (int i = 0; i < 32; i++)
|
||||
hash2.begin ()[i] = digest[31-i];
|
||||
return hash2;
|
||||
}
|
||||
|
||||
|
13
src/main.cpp
13
src/main.cpp
@ -32,7 +32,7 @@ CTxMemPool mempool;
|
||||
unsigned int nTransactionsUpdated = 0;
|
||||
|
||||
map<uint256, CBlockIndex*> mapBlockIndex;
|
||||
uint256 hashGenesisBlock("0x0000022ebc4fc755b87492cc6733b953cc08f11adca0b0e566bd67165ea17cb7");
|
||||
uint256 hashGenesisBlock("0x00000dd00df9728558f339d2e034e2c862329d509018b56d699aec5b6fa6ba1f");
|
||||
static CBigNum bnProofOfWorkLimit( CBigNum().SetCompact(0x1e0ffff0) );
|
||||
CBlockIndex* pindexGenesisBlock = NULL;
|
||||
int nBestHeight = -1;
|
||||
@ -2911,13 +2911,13 @@ bool InitBlockIndex() {
|
||||
block.hashPrevBlock = 0;
|
||||
block.hashMerkleRoot = block.BuildMerkleTree();
|
||||
block.nVersion = 1;
|
||||
block.nTime = 1491140178;
|
||||
block.nTime = 1491156549;
|
||||
block.nBits = 0x1e0ffff0;
|
||||
/*CBigNum n;
|
||||
n.SetHex ("0000ffff00000000000000000000000000000000000000000000000000000000"); // 4
|
||||
block.nBits = n.GetCompact ();
|
||||
printf("nbits %x\n", block.nBits);*/
|
||||
block.nNonce = 517611960;
|
||||
block.nNonce = 517725659;
|
||||
|
||||
if (fTestNet)
|
||||
{
|
||||
@ -2926,7 +2926,7 @@ bool InitBlockIndex() {
|
||||
}
|
||||
|
||||
// temporary code for finding nonce for genesis, should be removed later one
|
||||
/* uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256();
|
||||
/*uint256 hashTarget = CBigNum().SetCompact(block.nBits).getuint256();
|
||||
printf("hash target %s\n", hashTarget.ToString().c_str());
|
||||
while(true)
|
||||
{
|
||||
@ -4662,11 +4662,8 @@ bool CheckWork(CBlock* pblock, CWallet& wallet, CReserveKey& reservekey)
|
||||
uint256 hashTarget = CBigNum().SetCompact(pblock->nBits).getuint256();
|
||||
|
||||
if (hash > hashTarget)
|
||||
{
|
||||
printf ("Block failed %s\n", hash.GetHex().c_str());
|
||||
pblock->print ();
|
||||
return false;
|
||||
}
|
||||
|
||||
//// debug print
|
||||
printf("AnoncoinMiner:\n");
|
||||
printf("proof-of-work found \n hash: %s \ntarget: %s\n", hash.GetHex().c_str(), hashTarget.GetHex().c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user