Raven Core  3.0.0
P2P Digital Currency
hash.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Copyright (c) 2017-2019 The Raven Core developers
4 // Distributed under the MIT software license, see the accompanying
5 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
6 
7 #ifndef RAVEN_HASH_H
8 #define RAVEN_HASH_H
9 #include <iostream>
10 #include <chrono>
11 #include "crypto/ripemd160.h"
12 #include "crypto/sha256.h"
13 #include "prevector.h"
14 #include "serialize.h"
15 #include "uint256.h"
16 #include "version.h"
17 
18 #include "crypto/sph_blake.h"
19 #include "crypto/sph_bmw.h"
20 #include "crypto/sph_groestl.h"
21 #include "crypto/sph_jh.h"
22 #include "crypto/sph_keccak.h"
23 #include "crypto/sph_skein.h"
24 #include "crypto/sph_luffa.h"
25 #include "crypto/sph_cubehash.h"
26 #include "crypto/sph_shavite.h"
27 #include "crypto/sph_simd.h"
28 #include "crypto/sph_echo.h"
29 #include "crypto/sph_hamsi.h"
30 #include "crypto/sph_fugue.h"
31 #include "crypto/sph_shabal.h"
32 #include "crypto/sph_whirlpool.h"
33 extern "C" {
34 #include "crypto/sph_sha2.h"
35 }
36 #include <vector>
37 
39 #ifdef GLOBALDEFINED
40 #define GLOBAL
41 #else
42 #define GLOBAL extern
43 #endif
44 
45 GLOBAL sph_blake512_context z_blake;
46 GLOBAL sph_bmw512_context z_bmw;
50 GLOBAL sph_skein512_context z_skein;
56 #define fillz() do { \
57  sph_blake512_init(&z_blake); \
58  sph_bmw512_init(&z_bmw); \
59  sph_groestl512_init(&z_groestl); \
60  sph_jh512_init(&z_jh); \
61  sph_keccak512_init(&z_keccak); \
62  sph_skein512_init(&z_skein); \
63  sph_luffa512_init(&z_luffa); \
64  sph_cubehash512_init(&z_cubehash); \
65  sph_shavite512_init(&z_shavite); \
66  sph_simd512_init(&z_simd); \
67  sph_echo512_init(&z_echo); \
68 } while (0)
69 #define ZBLAKE (memcpy(&ctx_blake, &z_blake, sizeof(z_blake)))
70 #define ZBMW (memcpy(&ctx_bmw, &z_bmw, sizeof(z_bmw)))
71 #define ZGROESTL (memcpy(&ctx_groestl, &z_groestl, sizeof(z_groestl)))
72 #define ZJH (memcpy(&ctx_jh, &z_jh, sizeof(z_jh)))
73 #define ZKECCAK (memcpy(&ctx_keccak, &z_keccak, sizeof(z_keccak)))
74 #define ZSKEIN (memcpy(&ctx_skein, &z_skein, sizeof(z_skein)))
75 
76 class CHash256 {
77 private:
79 public:
80  static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE;
81 
82  void Finalize(unsigned char hash[OUTPUT_SIZE]) {
83  unsigned char buf[CSHA256::OUTPUT_SIZE];
84  sha.Finalize(buf);
85  sha.Reset().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(hash);
86  }
87 
88  CHash256& Write(const unsigned char *data, size_t len) {
89  sha.Write(data, len);
90  return *this;
91  }
92 
94  sha.Reset();
95  return *this;
96  }
97 };
98 
100 class CHash160 {
101 private:
103 public:
104  static const size_t OUTPUT_SIZE = CRIPEMD160::OUTPUT_SIZE;
105 
106  void Finalize(unsigned char hash[OUTPUT_SIZE]) {
107  unsigned char buf[CSHA256::OUTPUT_SIZE];
108  sha.Finalize(buf);
110  }
111 
112  CHash160& Write(const unsigned char *data, size_t len) {
113  sha.Write(data, len);
114  return *this;
115  }
116 
118  sha.Reset();
119  return *this;
120  }
121 };
122 
124 template<typename T1>
125 inline uint256 Hash(const T1 pbegin, const T1 pend)
126 {
127  static const unsigned char pblank[1] = {};
128  uint256 result;
129  CHash256().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0]))
130  .Finalize((unsigned char*)&result);
131  return result;
132 }
133 
135 template<typename T1, typename T2>
136 inline uint256 Hash(const T1 p1begin, const T1 p1end,
137  const T2 p2begin, const T2 p2end) {
138  static const unsigned char pblank[1] = {};
139  uint256 result;
140  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]))
141  .Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]))
142  .Finalize((unsigned char*)&result);
143  return result;
144 }
145 
146 template<typename T1, typename T2, typename T3>
147 inline uint256 Hash(const T1 p1begin, const T1 p1end,
148  const T2 p2begin, const T2 p2end,
149  const T3 p3begin, const T3 p3end) {
150  static const unsigned char pblank[1] = {};
151  uint256 result;
152  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]))
153  .Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]))
154  .Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0]))
155  .Finalize((unsigned char*)&result);
156  return result;
157 }
158 template<typename T1, typename T2, typename T3, typename T4>
159 inline uint256 Hash(const T1 p1begin, const T1 p1end,
160  const T2 p2begin, const T2 p2end,
161  const T3 p3begin, const T3 p3end,
162  const T4 p4begin, const T4 p4end) {
163  static const unsigned char pblank[1] = {};
164  uint256 result;
165  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]))
166  .Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]))
167  .Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0]))
168  .Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0]))
169  .Finalize((unsigned char*)&result);
170  return result;
171 }
172 template<typename T1, typename T2, typename T3, typename T4, typename T5>
173 inline uint256 Hash(const T1 p1begin, const T1 p1end,
174  const T2 p2begin, const T2 p2end,
175  const T3 p3begin, const T3 p3end,
176  const T4 p4begin, const T4 p4end,
177  const T5 p5begin, const T5 p5end) {
178  static const unsigned char pblank[1] = {};
179  uint256 result;
180  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]))
181  .Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]))
182  .Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0]))
183  .Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0]))
184  .Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0]))
185  .Finalize((unsigned char*)&result);
186  return result;
187 }
188 template<typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
189 inline uint256 Hash(const T1 p1begin, const T1 p1end,
190  const T2 p2begin, const T2 p2end,
191  const T3 p3begin, const T3 p3end,
192  const T4 p4begin, const T4 p4end,
193  const T5 p5begin, const T5 p5end,
194  const T6 p6begin, const T6 p6end) {
195  static const unsigned char pblank[1] = {};
196  uint256 result;
197  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0]))
198  .Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0]))
199  .Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0]))
200  .Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0]))
201  .Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0]))
202  .Write(p6begin == p6end ? pblank : (const unsigned char*)&p6begin[0], (p6end - p6begin) * sizeof(p6begin[0]))
203  .Finalize((unsigned char*)&result);
204  return result;
205 }
207 template<typename T1>
208 inline uint160 Hash160(const T1 pbegin, const T1 pend)
209 {
210  static unsigned char pblank[1] = {};
211  uint160 result;
212  CHash160().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0]))
213  .Finalize((unsigned char*)&result);
214  return result;
215 }
216 
218 inline uint160 Hash160(const std::vector<unsigned char>& vch)
219 {
220  return Hash160(vch.begin(), vch.end());
221 }
222 
224 template<unsigned int N>
226 {
227  return Hash160(vch.begin(), vch.end());
228 }
229 
232 {
233 private:
235 
236 public:
237  int nType;
238  int nVersion;
239 
240  CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {}
241 
242  int GetType() const { return nType; }
243  int GetVersion() const { return nVersion; }
244 
245  void write(const char *pch, size_t size) {
246  ctx.Write((const unsigned char*)pch, size);
247  }
248 
249  // invalidates the object
251  uint256 result;
252  ctx.Finalize((unsigned char*)&result);
253  return result;
254  }
255 
256  template<typename T>
257  CHashWriter& operator<<(const T& obj) {
258  // Serialize to this stream
259  ::Serialize(*this, obj);
260  return (*this);
261  }
262 };
263 
265 template<typename Source>
267 {
268 private:
269  Source* source;
270 
271 public:
272  explicit CHashVerifier(Source* source_) : CHashWriter(source_->GetType(), source_->GetVersion()), source(source_) {}
273 
274  void read(char* pch, size_t nSize)
275  {
276  source->read(pch, nSize);
277  this->write(pch, nSize);
278  }
279 
280  void ignore(size_t nSize)
281  {
282  char data[1024];
283  while (nSize > 0) {
284  size_t now = std::min<size_t>(nSize, 1024);
285  read(data, now);
286  nSize -= now;
287  }
288  }
289 
290  template<typename T>
292  {
293  // Unserialize from this stream
294  ::Unserialize(*this, obj);
295  return (*this);
296  }
297 };
298 
300 template<typename T>
301 uint256 SerializeHash(const T& obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
302 {
303  CHashWriter ss(nType, nVersion);
304  ss << obj;
305  return ss.GetHash();
306 }
307 
308 unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char>& vDataToHash);
309 
310 void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]);
311 
314 {
315 private:
316  uint64_t v[4];
317  uint64_t tmp;
318  int count;
319 
320 public:
322  CSipHasher(uint64_t k0, uint64_t k1);
327  CSipHasher& Write(uint64_t data);
329  CSipHasher& Write(const unsigned char* data, size_t size);
331  uint64_t Finalize() const;
332 };
333 
344 uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256& val);
345 uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256& val, uint32_t extra);
346 
347 inline int GetHashSelection(const uint256 PrevBlockHash, int index) {
348  assert(index >= 0);
349  assert(index < 16);
350 
351  #define START_OF_LAST_16_NIBBLES_OF_HASH 48
352  int hashSelection = PrevBlockHash.GetNibble(START_OF_LAST_16_NIBBLES_OF_HASH + index);
353  return(hashSelection);
354 }
355 
356 extern double algoHashTotal[16];
357 extern int algoHashHits[16];
358 
359 
360 template<typename T1>
361 inline uint256 HashX16R(const T1 pbegin, const T1 pend, const uint256 PrevBlockHash)
362 {
363 // static std::chrono::duration<double>[16];
364  int hashSelection;
365 
366  sph_blake512_context ctx_blake; //0
367  sph_bmw512_context ctx_bmw; //1
368  sph_groestl512_context ctx_groestl; //2
369  sph_jh512_context ctx_jh; //3
370  sph_keccak512_context ctx_keccak; //4
371  sph_skein512_context ctx_skein; //5
372  sph_luffa512_context ctx_luffa; //6
373  sph_cubehash512_context ctx_cubehash; //7
374  sph_shavite512_context ctx_shavite; //8
375  sph_simd512_context ctx_simd; //9
376  sph_echo512_context ctx_echo; //A
377  sph_hamsi512_context ctx_hamsi; //B
378  sph_fugue512_context ctx_fugue; //C
379  sph_shabal512_context ctx_shabal; //D
380  sph_whirlpool_context ctx_whirlpool; //E
381  sph_sha512_context ctx_sha512; //F
382 
383  static unsigned char pblank[1];
384 
385  uint512 hash[16];
386 
387  for (int i=0;i<16;i++)
388  {
389  const void *toHash;
390  int lenToHash;
391  if (i == 0) {
392  toHash = (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0]));
393  lenToHash = (pend - pbegin) * sizeof(pbegin[0]);
394  } else {
395  toHash = static_cast<const void*>(&hash[i-1]);
396  lenToHash = 64;
397  }
398 
399  hashSelection = GetHashSelection(PrevBlockHash, i);
400 
401  switch(hashSelection) {
402  case 0:
403  sph_blake512_init(&ctx_blake);
404  sph_blake512 (&ctx_blake, toHash, lenToHash);
405  sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[i]));
406  break;
407  case 1:
408  sph_bmw512_init(&ctx_bmw);
409  sph_bmw512 (&ctx_bmw, toHash, lenToHash);
410  sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[i]));
411  break;
412  case 2:
413  sph_groestl512_init(&ctx_groestl);
414  sph_groestl512 (&ctx_groestl, toHash, lenToHash);
415  sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[i]));
416  break;
417  case 3:
418  sph_jh512_init(&ctx_jh);
419  sph_jh512 (&ctx_jh, toHash, lenToHash);
420  sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[i]));
421  break;
422  case 4:
423  sph_keccak512_init(&ctx_keccak);
424  sph_keccak512 (&ctx_keccak, toHash, lenToHash);
425  sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[i]));
426  break;
427  case 5:
428  sph_skein512_init(&ctx_skein);
429  sph_skein512 (&ctx_skein, toHash, lenToHash);
430  sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[i]));
431  break;
432  case 6:
433  sph_luffa512_init(&ctx_luffa);
434  sph_luffa512 (&ctx_luffa, toHash, lenToHash);
435  sph_luffa512_close(&ctx_luffa, static_cast<void*>(&hash[i]));
436  break;
437  case 7:
438  sph_cubehash512_init(&ctx_cubehash);
439  sph_cubehash512 (&ctx_cubehash, toHash, lenToHash);
440  sph_cubehash512_close(&ctx_cubehash, static_cast<void*>(&hash[i]));
441  break;
442  case 8:
443  sph_shavite512_init(&ctx_shavite);
444  sph_shavite512(&ctx_shavite, toHash, lenToHash);
445  sph_shavite512_close(&ctx_shavite, static_cast<void*>(&hash[i]));
446  break;
447  case 9:
448  sph_simd512_init(&ctx_simd);
449  sph_simd512 (&ctx_simd, toHash, lenToHash);
450  sph_simd512_close(&ctx_simd, static_cast<void*>(&hash[i]));
451  break;
452  case 10:
453  sph_echo512_init(&ctx_echo);
454  sph_echo512 (&ctx_echo, toHash, lenToHash);
455  sph_echo512_close(&ctx_echo, static_cast<void*>(&hash[i]));
456  break;
457  case 11:
458  sph_hamsi512_init(&ctx_hamsi);
459  sph_hamsi512 (&ctx_hamsi, toHash, lenToHash);
460  sph_hamsi512_close(&ctx_hamsi, static_cast<void*>(&hash[i]));
461  break;
462  case 12:
463  sph_fugue512_init(&ctx_fugue);
464  sph_fugue512 (&ctx_fugue, toHash, lenToHash);
465  sph_fugue512_close(&ctx_fugue, static_cast<void*>(&hash[i]));
466  break;
467  case 13:
468  sph_shabal512_init(&ctx_shabal);
469  sph_shabal512 (&ctx_shabal, toHash, lenToHash);
470  sph_shabal512_close(&ctx_shabal, static_cast<void*>(&hash[i]));
471  break;
472  case 14:
473  sph_whirlpool_init(&ctx_whirlpool);
474  sph_whirlpool(&ctx_whirlpool, toHash, lenToHash);
475  sph_whirlpool_close(&ctx_whirlpool, static_cast<void*>(&hash[i]));
476  break;
477  case 15:
478  sph_sha512_init(&ctx_sha512);
479  sph_sha512 (&ctx_sha512, toHash, lenToHash);
480  sph_sha512_close(&ctx_sha512, static_cast<void*>(&hash[i]));
481  break;
482  }
483  }
484 
485  return hash[15].trim256();
486 }
487 
488 
489 #endif // RAVEN_HASH_H
double algoHashTotal[16]
Definition: hash.cpp:12
CSHA256 & Write(const unsigned char *data, size_t len)
Definition: sha256.cpp:202
GLOBAL sph_blake512_context z_blake
Definition: hash.h:45
uint256 trim256() const
Definition: uint256.h:172
void sph_fugue512(void *cc, const void *data, size_t len)
Definition: sph_fugue.c:1190
void write(const char *pch, size_t size)
Definition: hash.h:245
void sph_shabal512_init(void *cc)
Initialize a Shabal-512 context.
Definition: sph_shabal.c:781
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
Definition: hash.cpp:76
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector< unsigned char > &vDataToHash)
Definition: hash.cpp:20
This structure is a context for ECHO computations: it contains the intermediate values and some data ...
Definition: sph_echo.h:102
JH interface.
GLOBAL sph_shavite512_context z_shavite
Definition: hash.h:53
int algoHashHits[16]
Definition: hash.cpp:13
BLAKE interface.
int GetNibble(int index) const
Definition: uint256.h:128
Skein interface.
int nVersion
Definition: hash.h:238
void sph_echo512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: echo.c:1011
#define GLOBAL
Definition: hash.h:42
void sph_hamsi512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: sph_hamsi.c:844
void sph_simd512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: simd.c:1780
CHash256 & Write(const unsigned char *data, size_t len)
Definition: hash.h:88
uint256 ChainCode
Definition: hash.h:38
void sph_simd512_close(void *cc, void *dst)
Terminate the current SIMD-512 computation and output the result into the provided buffer...
Definition: simd.c:1786
This structure is a context for SHAvite-384 and SHAvite-512 computations: it contains the intermediat...
Definition: sph_shavite.h:109
CHash160 & Reset()
Definition: hash.h:117
CSHA256 sha
Definition: hash.h:78
GLOBAL sph_cubehash512_context z_cubehash
Definition: hash.h:52
void sph_echo512_init(void *cc)
Initialize an ECHO-512 context.
Definition: echo.c:1004
void sph_jh512_init(void *cc)
Initialize a JH-512 context.
Definition: jh.c:1088
A hasher class for Raven&#39;s 256-bit hash (double SHA-256).
Definition: hash.h:76
Hamsi interface.
uint160 Hash160(const T1 pbegin, const T1 pend)
Compute the 160-bit hash an object.
Definition: hash.h:208
GLOBAL sph_keccak512_context z_keccak
Definition: hash.h:49
void ignore(size_t nSize)
Definition: hash.h:280
Reads data from an underlying stream, while hashing the read data.
Definition: hash.h:266
uint64_t SipHashUint256(uint64_t k0, uint64_t k1, const uint256 &val)
Optimized SipHash-2-4 implementation for uint256.
Definition: hash.cpp:173
void sph_luffa512_close(void *cc, void *dst)
Terminate the current Luffa-512 computation and output the result into the provided buffer...
Definition: luffa.c:1411
Shabal interface.
This structure is a context for Shabal computations: it contains the intermediate values and some dat...
Definition: sph_shabal.h:80
SIMD interface.
void sph_luffa512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: luffa.c:1404
void Serialize(Stream &s, char a)
Definition: serialize.h:182
void sph_shavite512_init(void *cc)
Initialize a SHAvite-512 context.
Definition: shavite.c:1734
void sph_cubehash512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: cubehash.c:702
uint256 HashX16R(const T1 pbegin, const T1 pend, const uint256 PrevBlockHash)
Definition: hash.h:361
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: hash.h:82
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object&#39;s serialization.
Definition: hash.h:301
iterator end()
Definition: prevector.h:293
ECHO interface.
SHAvite-3 interface.
This structure is a context for SIMD computations: it contains the intermediate values and some data ...
Definition: sph_simd.h:97
CSHA256 & Reset()
Definition: sha256.cpp:245
SHA-224, SHA-256, SHA-384 and SHA-512 interface.
void sph_shabal512_close(void *cc, void *dst)
Terminate the current Shabal-512 computation and output the result into the provided buffer...
Definition: sph_shabal.c:795
void sph_jh512_close(void *cc, void *dst)
Terminate the current JH-512 computation and output the result into the provided buffer.
Definition: jh.c:1102
This structure is a context for Hamsi-384 and Hamsi-512 computations: it contains the intermediate va...
Definition: sph_hamsi.h:110
void sph_hamsi512_init(void *cc)
Initialize a Hamsi-512 context.
Definition: sph_hamsi.c:837
int count
Definition: hash.h:318
static const size_t OUTPUT_SIZE
Definition: ripemd160.h:21
#define START_OF_LAST_16_NIBBLES_OF_HASH
WHIRLPOOL interface.
void sph_cubehash512_close(void *cc, void *dst)
Terminate the current CubeHash-512 computation and output the result into the provided buffer...
Definition: cubehash.c:709
GLOBAL sph_echo512_context z_echo
Definition: hash.h:55
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: sha256.cpp:228
CHash160 & Write(const unsigned char *data, size_t len)
Definition: hash.h:112
CHashVerifier< Source > & operator>>(T &obj)
Definition: hash.h:291
GLOBAL sph_luffa512_context z_luffa
Definition: hash.h:51
uint256 Hash(const T1 pbegin, const T1 pend)
Compute the 256-bit hash of an object.
Definition: hash.h:125
int GetHashSelection(const uint256 PrevBlockHash, int index)
Definition: hash.h:347
CHashWriter(int nTypeIn, int nVersionIn)
Definition: hash.h:240
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition: prevector.h:37
uint64_t tmp
Definition: hash.h:317
Luffa interface.
void sph_whirlpool_init(void *cc)
CubeHash interface.
CRIPEMD160 & Write(const unsigned char *data, size_t len)
Definition: ripemd160.cpp:248
void sph_shavite512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: shavite.c:1741
CHash256 ctx
Definition: hash.h:234
uint256 GetHash()
Definition: hash.h:250
BMW interface.
256-bit opaque blob.
Definition: uint256.h:123
void sph_echo512_close(void *cc, void *dst)
Terminate the current ECHO-512 computation and output the result into the provided buffer...
Definition: echo.c:1018
Source * source
Definition: hash.h:269
GLOBAL sph_simd512_context z_simd
Definition: hash.h:54
void sph_keccak512_init(void *cc)
Initialize a Keccak-512 context.
Definition: keccak.c:1795
void sph_hamsi512_close(void *cc, void *dst)
Terminate the current Hamsi-512 computation and output the result into the provided buffer...
Definition: sph_hamsi.c:851
This structure is a context for Luffa-512 computations.
Definition: sph_luffa.h:104
void sph_keccak512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: keccak.c:1802
GLOBAL sph_groestl512_context z_groestl
Definition: hash.h:47
void sph_fugue512_close(void *cc, void *dst)
Definition: sph_fugue.c:1196
GLOBAL sph_bmw512_context z_bmw
Definition: hash.h:46
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: hash.h:106
CHashVerifier(Source *source_)
Definition: hash.h:272
void sph_shavite512_close(void *cc, void *dst)
Terminate the current SHAvite-512 computation and output the result into the provided buffer...
Definition: shavite.c:1748
uint64_t SipHashUint256Extra(uint64_t k0, uint64_t k1, const uint256 &val, uint32_t extra)
Definition: hash.cpp:213
160-bit opaque blob.
Definition: uint256.h:112
SipHash-2-4.
Definition: hash.h:313
static const size_t OUTPUT_SIZE
Definition: sha256.h:22
int GetVersion() const
Definition: hash.h:243
static const size_t OUTPUT_SIZE
Definition: hash.h:80
CHashWriter & operator<<(const T &obj)
Definition: hash.h:257
void Unserialize(Stream &s, char &a)
Definition: serialize.h:194
iterator begin()
Definition: prevector.h:291
void read(char *pch, size_t nSize)
Definition: hash.h:274
GLOBAL sph_jh512_context z_jh
Definition: hash.h:48
void sph_groestl512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: groestl.c:3102
A writer stream (for serialization) that computes a 256-bit hash.
Definition: hash.h:231
This structure is a context for JH computations: it contains the intermediate values and some data fr...
Definition: sph_jh.h:76
void sph_keccak512_close(void *cc, void *dst)
Terminate the current Keccak-512 computation and output the result into the provided buffer...
Definition: keccak.c:1809
void sph_shabal512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: sph_shabal.c:788
int GetType() const
Definition: hash.h:242
A hasher class for Raven&#39;s 160-bit hash (SHA-256 + RIPEMD-160).
Definition: hash.h:100
Groestl interface.
void sph_groestl512_init(void *cc)
Initialize a Groestl-512 context.
Definition: groestl.c:3095
CSHA256 sha
Definition: hash.h:102
void sph_simd512_init(void *cc)
Initialize an SIMD-512 context.
Definition: simd.c:1774
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: ripemd160.cpp:274
This structure is a context for Keccak computations: it contains the intermediate values and some dat...
Definition: sph_keccak.h:76
void sph_jh512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: jh.c:1095
void sph_groestl512_close(void *cc, void *dst)
Terminate the current Groestl-512 computation and output the result into the provided buffer...
Definition: groestl.c:3109
A hasher class for SHA-256.
Definition: sha256.h:14
CHash256 & Reset()
Definition: hash.h:93
void sph_cubehash512_init(void *cc)
Initialize a CubeHash-512 context.
Definition: cubehash.c:695
Keccak interface.
int nType
Definition: hash.h:237
This structure is a context for CubeHash computations: it contains the intermediate values and some d...
Definition: sph_cubehash.h:77
A hasher class for RIPEMD-160.
Definition: ripemd160.h:13
void sph_fugue512_init(void *cc)
Definition: sph_fugue.c:1184
GLOBAL sph_skein512_context z_skein
Definition: hash.h:50
This structure is a context for Groestl-384 and Groestl-512 computations: it contains the intermediat...
Definition: sph_groestl.h:115
void sph_luffa512_init(void *cc)
Initialize a Luffa-512 context.
Definition: luffa.c:1393