Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
equihash.cpp
Go to the documentation of this file.
1#include <equihash/pow.hpp>
2
4
5#define EQUIHASH_NONCE 2
6
7namespace fc { namespace equihash {
8
9 _POW::Seed sha_to_seed( sha256 seed )
10 {
11 _POW::Seed new_seed;
12
13 // Seed is 128 bits. Half of sha256 to create seed. Should still have enough randomness
14 new_seed.v[0] = (unsigned int) seed._hash[0];
15 new_seed.v[0] ^= (unsigned int) seed._hash[2];
16 new_seed.v[1] = (unsigned int)( seed._hash[0] >> 32 );
17 new_seed.v[1] ^= (unsigned int)( seed._hash[2] >> 32 );
18 new_seed.v[2] = (unsigned int) seed._hash[1];
19 new_seed.v[2] ^= (unsigned int) seed._hash[3];
20 new_seed.v[3] = (unsigned int)( seed._hash[1] >> 32 );
21 new_seed.v[3] ^= (unsigned int)( seed._hash[3] >> 32 );
22
23 return new_seed;
24 }
25
26 bool proof::is_valid() const
27 {
28 _POW::Proof test( n, k, sha_to_seed( seed ), EQUIHASH_NONCE, inputs );
29 return test.Test();
30
31 }
32
34 {
35 auto hash = _POW::Equihash( n, k, sha_to_seed( seed ) );
36 auto result = hash.FindProof( EQUIHASH_NONCE );
37
38 proof p;
39 p.n = n;
40 p.k = k;
41 p.seed = seed;
42 p.inputs = result.inputs;
43
44 return p;
45 }
46
47} } // fc::equihash
const mie::Vuint & p
Definition bn.cpp:27
uint64_t _hash[4]
Definition sha256.hpp:100
#define EQUIHASH_NONCE
Definition equihash.cpp:5
_POW::Seed sha_to_seed(sha256 seed)
Definition equihash.cpp:9
namespace sysio::chain
Definition authority.cpp:3
unsigned int uint32_t
Definition stdint.h:126
std::vector< uint32_t > inputs
Definition equihash.hpp:12
bool is_valid() const
Definition equihash.cpp:26
static proof hash(uint32_t n, uint32_t k, sha256 seed)
Definition equihash.cpp:33