PRCYCoin  2.0.0.7rc1
P2P Digital Currency
hash.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2014 The Bitcoin developers
3 // Copyright (c) 2014-2015 The Dash developers
4 // Copyright (c) 2015-2018 The PIVX developers
5 // Copyright (c) 2018-2020 The DAPS Project developers
6 // Distributed under the MIT software license, see the accompanying
7 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
8 
9 #ifndef BITCOIN_HASH_H
10 #define BITCOIN_HASH_H
11 
12 #include "crypto/ripemd160.h"
13 #include "crypto/sha256.h"
14 #include "prevector.h"
15 #include "serialize.h"
16 #include "uint256.h"
17 #include "version.h"
18 
19 #include "crypto/sph_blake.h"
20 #include "crypto/sph_bmw.h"
21 #include "crypto/sph_groestl.h"
22 #include "crypto/sph_jh.h"
23 #include "crypto/sph_keccak.h"
24 #include "crypto/sph_skein.h"
25 
26 #include <iomanip>
27 #include <openssl/sha.h>
28 #include <sstream>
29 #include <vector>
30 
31 
33 class CHash256
34 {
35 private:
37 
38 public:
39  static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE;
40 
41  void Finalize(unsigned char hash[OUTPUT_SIZE])
42  {
43  unsigned char buf[CSHA256::OUTPUT_SIZE];
44  sha.Finalize(buf);
46  }
47 
48  CHash256& Write(const unsigned char* data, size_t len)
49  {
50  sha.Write(data, len);
51  return *this;
52  }
53 
55  {
56  sha.Reset();
57  return *this;
58  }
59 };
60 
61 #ifdef GLOBALDEFINED
62 #define GLOBAL
63 #else
64 #define GLOBAL extern
65 #endif
66 
67 GLOBAL sph_blake512_context z_blake;
68 GLOBAL sph_bmw512_context z_bmw;
72 GLOBAL sph_skein512_context z_skein;
73 
74 #define fillz() \
75  do { \
76  sph_blake512_init(&z_blake); \
77  sph_bmw512_init(&z_bmw); \
78  sph_groestl512_init(&z_groestl); \
79  sph_jh512_init(&z_jh); \
80  sph_keccak512_init(&z_keccak); \
81  sph_skein512_init(&z_skein); \
82  } while (0)
83 
84 #define ZBLAKE (memcpy(&ctx_blake, &z_blake, sizeof(z_blake)))
85 #define ZBMW (memcpy(&ctx_bmw, &z_bmw, sizeof(z_bmw)))
86 #define ZGROESTL (memcpy(&ctx_groestl, &z_groestl, sizeof(z_groestl)))
87 #define ZJH (memcpy(&ctx_jh, &z_jh, sizeof(z_jh)))
88 #define ZKECCAK (memcpy(&ctx_keccak, &z_keccak, sizeof(z_keccak)))
89 #define ZSKEIN (memcpy(&ctx_skein, &z_skein, sizeof(z_skein)))
90 
91 /* ----------- Bitcoin Hash ------------------------------------------------- */
93 class CHash160
94 {
95 private:
97 
98 public:
99  static const size_t OUTPUT_SIZE = CRIPEMD160::OUTPUT_SIZE;
100 
101  void Finalize(unsigned char hash[OUTPUT_SIZE])
102  {
103  unsigned char buf[CSHA256::OUTPUT_SIZE];
104  sha.Finalize(buf);
106  }
107 
108  CHash160& Write(const unsigned char* data, size_t len)
109  {
110  sha.Write(data, len);
111  return *this;
112  }
113 
115  {
116  sha.Reset();
117  return *this;
118  }
119 };
120 
122 inline std::string Hash(std::string input)
123 {
124  unsigned char hash[SHA256_DIGEST_LENGTH];
125  SHA256_CTX sha256;
126  SHA256_Init(&sha256);
127  SHA256_Update(&sha256, input.c_str(), input.size());
128  SHA256_Final(hash, &sha256);
129  std::stringstream ss;
130  for (int i = 0; i < SHA256_DIGEST_LENGTH; i++) {
131  ss << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
132  }
133  return ss.str();
134 }
135 
137 inline void Hash(void* in, unsigned int len, unsigned char* out)
138 {
139  SHA256_CTX sha256;
140  SHA256_Init(&sha256);
141  SHA256_Update(&sha256, in, len);
142  SHA256_Final(out, &sha256);
143 }
144 
146 template <typename T1>
147 inline uint256 Hash(const T1 pbegin, const T1 pend)
148 {
149  static const unsigned char pblank[1] = {};
150  uint256 result;
151  CHash256().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0])).Finalize((unsigned char*)&result);
152  return result;
153 }
154 
156 template <typename T1, typename T2>
157 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end)
158 {
159  static const unsigned char pblank[1] = {};
160  uint256 result;
161  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Finalize((unsigned char*)&result);
162  return result;
163 }
164 
166 template <typename T1, typename T2, typename T3>
167 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end)
168 {
169  static const unsigned char pblank[1] = {};
170  uint256 result;
171  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Finalize((unsigned char*)&result);
172  return result;
173 }
174 
176 template <typename T1, typename T2, typename T3, typename T4>
177 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end)
178 {
179  static const unsigned char pblank[1] = {};
180  uint256 result;
181  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Finalize((unsigned char*)&result);
182  return result;
183 }
184 
186 template <typename T1, typename T2, typename T3, typename T4, typename T5>
187 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end, const T5 p5begin, const T5 p5end)
188 {
189  static const unsigned char pblank[1] = {};
190  uint256 result;
191  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0])).Finalize((unsigned char*)&result);
192  return result;
193 }
194 
196 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6>
197 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end, const T5 p5begin, const T5 p5end, const T6 p6begin, const T6 p6end)
198 {
199  static const unsigned char pblank[1] = {};
200  uint256 result;
201  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0])).Write(p6begin == p6end ? pblank : (const unsigned char*)&p6begin[0], (p6end - p6begin) * sizeof(p6begin[0])).Finalize((unsigned char*)&result);
202  return result;
203 }
204 
206 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7>
207 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end, const T5 p5begin, const T5 p5end, const T6 p6begin, const T6 p6end, const T7 p7begin, const T7 p7end)
208 {
209  static const unsigned char pblank[1] = {};
210  uint256 result;
211  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0])).Write(p6begin == p6end ? pblank : (const unsigned char*)&p6begin[0], (p6end - p6begin) * sizeof(p6begin[0])).Write(p7begin == p7end ? pblank : (const unsigned char*)&p7begin[0], (p7end - p7begin) * sizeof(p7begin[0])).Finalize((unsigned char*)&result);
212  return result;
213 }
214 
216 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8>
217 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end, const T5 p5begin, const T5 p5end, const T6 p6begin, const T6 p6end, const T7 p7begin, const T7 p7end, const T8 p8begin, const T8 p8end)
218 {
219  static const unsigned char pblank[1] = {};
220  uint256 result;
221  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0])).Write(p6begin == p6end ? pblank : (const unsigned char*)&p6begin[0], (p6end - p6begin) * sizeof(p6begin[0])).Write(p7begin == p7end ? pblank : (const unsigned char*)&p7begin[0], (p7end - p7begin) * sizeof(p7begin[0])).Write(p8begin == p8end ? pblank : (const unsigned char*)&p8begin[0], (p8end - p8begin) * sizeof(p8begin[0])).Finalize((unsigned char*)&result);
222  return result;
223 }
224 
226 template <typename T1, typename T2, typename T3, typename T4, typename T5, typename T6, typename T7, typename T8, typename T9>
227 inline uint256 Hash(const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end, const T4 p4begin, const T4 p4end, const T5 p5begin, const T5 p5end, const T6 p6begin, const T6 p6end, const T7 p7begin, const T7 p7end, const T8 p8begin, const T8 p8end, const T9 p9begin, const T9 p9end)
228 {
229  static const unsigned char pblank[1] = {};
230  uint256 result;
231  CHash256().Write(p1begin == p1end ? pblank : (const unsigned char*)&p1begin[0], (p1end - p1begin) * sizeof(p1begin[0])).Write(p2begin == p2end ? pblank : (const unsigned char*)&p2begin[0], (p2end - p2begin) * sizeof(p2begin[0])).Write(p3begin == p3end ? pblank : (const unsigned char*)&p3begin[0], (p3end - p3begin) * sizeof(p3begin[0])).Write(p4begin == p4end ? pblank : (const unsigned char*)&p4begin[0], (p4end - p4begin) * sizeof(p4begin[0])).Write(p5begin == p5end ? pblank : (const unsigned char*)&p5begin[0], (p5end - p5begin) * sizeof(p5begin[0])).Write(p6begin == p6end ? pblank : (const unsigned char*)&p6begin[0], (p6end - p6begin) * sizeof(p6begin[0])).Write(p7begin == p7end ? pblank : (const unsigned char*)&p7begin[0], (p7end - p7begin) * sizeof(p7begin[0])).Write(p8begin == p8end ? pblank : (const unsigned char*)&p8begin[0], (p8end - p8begin) * sizeof(p8begin[0])).Write(p9begin == p9end ? pblank : (const unsigned char*)&p9begin[0], (p9end - p9begin) * sizeof(p9begin[0])).Finalize((unsigned char*)&result);
232  return result;
233 }
234 
236 template <typename T1>
237 inline uint160 Hash160(const T1 pbegin, const T1 pend)
238 {
239  static unsigned char pblank[1] = {};
240  uint160 result;
241  CHash160().Write(pbegin == pend ? pblank : (const unsigned char*)&pbegin[0], (pend - pbegin) * sizeof(pbegin[0])).Finalize((unsigned char*)&result);
242  return result;
243 }
244 
246 inline uint160 Hash160(const std::vector<unsigned char>& vch)
247 {
248  return Hash160(vch.begin(), vch.end());
249 }
250 
252 template<unsigned int N>
254 {
255  return Hash160(vch.begin(), vch.end());
256 }
257 
260 {
261 private:
263 
264 public:
265  int nType;
266  int nVersion;
267 
268  CHashWriter(int nTypeIn, int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {}
269 
270  CHashWriter& write(const char* pch, size_t size)
271  {
272  ctx.Write((const unsigned char*)pch, size);
273  return (*this);
274  }
275 
276  // invalidates the object
278  {
279  uint256 result;
280  ctx.Finalize((unsigned char*)&result);
281  return result;
282  }
283 
284  template <typename T>
285  CHashWriter& operator<<(const T& obj)
286  {
287  // Serialize to this stream
288  ::Serialize(*this, obj, nType, nVersion);
289  return (*this);
290  }
291 };
292 
294 template <typename T>
295 uint256 SerializeHash(const T& obj, int nType = SER_GETHASH, int nVersion = PROTOCOL_VERSION)
296 {
297  CHashWriter ss(nType, nVersion);
298  ss << obj;
299  return ss.GetHash();
300 }
301 
302 unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector<unsigned char>& vDataToHash);
303 
304 void BIP32Hash(const unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64]);
305 
306 //int HMAC_SHA512_Init(HMAC_SHA512_CTX *pctx, const void *pkey, size_t len);
307 //int HMAC_SHA512_Update(HMAC_SHA512_CTX *pctx, const void *pdata, size_t len);
308 //int HMAC_SHA512_Final(unsigned char *pmd, HMAC_SHA512_CTX *pctx);
309 
310 /* ----------- Quark Hash ------------------------------------------------ */
311 template <typename T1>
312 inline uint256 HashQuark(const T1 pbegin, const T1 pend)
313 
314 {
315  sph_blake512_context ctx_blake;
316  sph_bmw512_context ctx_bmw;
317  sph_groestl512_context ctx_groestl;
318  sph_jh512_context ctx_jh;
319  sph_keccak512_context ctx_keccak;
320  sph_skein512_context ctx_skein;
321  static unsigned char pblank[1];
322 
323  uint512 mask = 8;
324  uint512 zero = 0;
325 
326  uint512 hash[9];
327 
328  sph_blake512_init(&ctx_blake);
329  // ZBLAKE;
330  sph_blake512(&ctx_blake, (pbegin == pend ? pblank : static_cast<const void*>(&pbegin[0])), (pend - pbegin) * sizeof(pbegin[0]));
331  sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[0]));
332 
333  sph_bmw512_init(&ctx_bmw);
334  // ZBMW;
335  sph_bmw512(&ctx_bmw, static_cast<const void*>(&hash[0]), 64);
336  sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[1]));
337 
338  if ((hash[1] & mask) != zero) {
339  sph_groestl512_init(&ctx_groestl);
340  // ZGROESTL;
341  sph_groestl512(&ctx_groestl, static_cast<const void*>(&hash[1]), 64);
342  sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[2]));
343  } else {
344  sph_skein512_init(&ctx_skein);
345  // ZSKEIN;
346  sph_skein512(&ctx_skein, static_cast<const void*>(&hash[1]), 64);
347  sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[2]));
348  }
349 
350  sph_groestl512_init(&ctx_groestl);
351  // ZGROESTL;
352  sph_groestl512(&ctx_groestl, static_cast<const void*>(&hash[2]), 64);
353  sph_groestl512_close(&ctx_groestl, static_cast<void*>(&hash[3]));
354 
355  sph_jh512_init(&ctx_jh);
356  // ZJH;
357  sph_jh512(&ctx_jh, static_cast<const void*>(&hash[3]), 64);
358  sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[4]));
359 
360  if ((hash[4] & mask) != zero) {
361  sph_blake512_init(&ctx_blake);
362  // ZBLAKE;
363  sph_blake512(&ctx_blake, static_cast<const void*>(&hash[4]), 64);
364  sph_blake512_close(&ctx_blake, static_cast<void*>(&hash[5]));
365  } else {
366  sph_bmw512_init(&ctx_bmw);
367  // ZBMW;
368  sph_bmw512(&ctx_bmw, static_cast<const void*>(&hash[4]), 64);
369  sph_bmw512_close(&ctx_bmw, static_cast<void*>(&hash[5]));
370  }
371 
372  sph_keccak512_init(&ctx_keccak);
373  // ZKECCAK;
374  sph_keccak512(&ctx_keccak, static_cast<const void*>(&hash[5]), 64);
375  sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[6]));
376 
377  sph_skein512_init(&ctx_skein);
378  // SKEIN;
379  sph_skein512(&ctx_skein, static_cast<const void*>(&hash[6]), 64);
380  sph_skein512_close(&ctx_skein, static_cast<void*>(&hash[7]));
381 
382  if ((hash[7] & mask) != zero) {
383  sph_keccak512_init(&ctx_keccak);
384  // ZKECCAK;
385  sph_keccak512(&ctx_keccak, static_cast<const void*>(&hash[7]), 64);
386  sph_keccak512_close(&ctx_keccak, static_cast<void*>(&hash[8]));
387  } else {
388  sph_jh512_init(&ctx_jh);
389  // ZJH;
390  sph_jh512(&ctx_jh, static_cast<const void*>(&hash[7]), 64);
391  sph_jh512_close(&ctx_jh, static_cast<void*>(&hash[8]));
392  }
393  return hash[8].trim256();
394 }
395 
396 void scrypt_hash(const char* pass, unsigned int pLen, const char* salt, unsigned int sLen, char* output, unsigned int N, unsigned int r, unsigned int p, unsigned int dkLen);
397 
398 #endif // BITCOIN_HASH_H
sph_keccak.h
Keccak interface.
CHash256::Finalize
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: hash.h:41
SerializeHash
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
Definition: hash.h:295
sph_keccak512_init
void sph_keccak512_init(void *cc)
Initialize a Keccak-512 context.
Definition: keccak.c:1795
CSHA256::Write
CSHA256 & Write(const unsigned char *data, size_t len)
Definition: sha256.cpp:141
CRIPEMD160
A hasher class for RIPEMD-160.
Definition: ripemd160.h:12
SER_GETHASH
@ SER_GETHASH
Definition: serialize.h:161
CHash256::Reset
CHash256 & Reset()
Definition: hash.h:54
sph_skein.h
Skein interface.
CHashWriter::operator<<
CHashWriter & operator<<(const T &obj)
Definition: hash.h:285
CRIPEMD160::Finalize
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: ripemd160.cpp:273
uint512::trim256
uint256 trim256() const
Definition: uint256.h:82
uint256.h
sph_jh512_close
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
sha256
Internal SHA-256 implementation.
Definition: sha256.cpp:15
CRIPEMD160::OUTPUT_SIZE
static const size_t OUTPUT_SIZE
Definition: ripemd160.h:20
Hash160
uint160 Hash160(const T1 pbegin, const T1 pend)
Compute the 160-bit hash an object.
Definition: hash.h:237
CSHA256::Reset
CSHA256 & Reset()
Definition: sha256.cpp:184
z_bmw
GLOBAL sph_bmw512_context z_bmw
Definition: hash.h:68
sph_groestl.h
Groestl interface.
version.h
sph_jh512
void sph_jh512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: jh.c:1095
CHashWriter::write
CHashWriter & write(const char *pch, size_t size)
Definition: hash.h:270
r
void const uint64_t uint64_t * r
Definition: field_5x52_asm_impl.h:10
prevector::end
iterator end()
Definition: prevector.h:292
CHash160::Write
CHash160 & Write(const unsigned char *data, size_t len)
Definition: hash.h:108
BIP32Hash
void BIP32Hash(const unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
Definition: hash.cpp:73
z_jh
GLOBAL sph_jh512_context z_jh
Definition: hash.h:70
CHash256::OUTPUT_SIZE
static const size_t OUTPUT_SIZE
Definition: hash.h:39
CHash160
A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160).
Definition: hash.h:93
sph_bmw.h
BMW interface.
CRIPEMD160::Write
CRIPEMD160 & Write(const unsigned char *data, size_t len)
Definition: ripemd160.cpp:247
CHash160::Finalize
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: hash.h:101
MurmurHash3
unsigned int MurmurHash3(unsigned int nHashSeed, const std::vector< unsigned char > &vDataToHash)
Definition: hash.cpp:15
uint256
256-bit unsigned big integer.
Definition: uint256.h:38
sph_jh.h
JH interface.
CSHA256::Finalize
void Finalize(unsigned char hash[OUTPUT_SIZE])
Definition: sha256.cpp:167
CHash256::Write
CHash256 & Write(const unsigned char *data, size_t len)
Definition: hash.h:48
HashQuark
uint256 HashQuark(const T1 pbegin, const T1 pend)
Definition: hash.h:312
ripemd160.h
sph_blake.h
BLAKE interface.
sph_keccak_context
This structure is a context for Keccak computations: it contains the intermediate values and some dat...
Definition: sph_keccak.h:76
CSHA256::OUTPUT_SIZE
static const size_t OUTPUT_SIZE
Definition: sha256.h:20
sha256.h
prevector
Implements a drop-in replacement for std::vector<T> which stores up to N elements directly (without h...
Definition: prevector.h:36
uint160
160-bit unsigned big integer.
Definition: uint256.h:27
sph_keccak512_close
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
CHash160::sha
CSHA256 sha
Definition: hash.h:96
CHashWriter::CHashWriter
CHashWriter(int nTypeIn, int nVersionIn)
Definition: hash.h:268
z_blake
GLOBAL sph_blake512_context z_blake
Definition: hash.h:67
CHashWriter::nVersion
int nVersion
Definition: hash.h:266
sph_jh_context
This structure is a context for JH computations: it contains the intermediate values and some data fr...
Definition: sph_jh.h:76
Serialize
void Serialize(Stream &s, char a, int, int=0)
Definition: serialize.h:206
CHashWriter
A writer stream (for serialization) that computes a 256-bit hash.
Definition: hash.h:259
scrypt_hash
void scrypt_hash(const char *pass, unsigned int pLen, const char *salt, unsigned int sLen, char *output, unsigned int N, unsigned int r, unsigned int p, unsigned int dkLen)
Definition: hash.cpp:83
prevector::begin
iterator begin()
Definition: prevector.h:290
z_keccak
GLOBAL sph_keccak512_context z_keccak
Definition: hash.h:71
sph_groestl512
void sph_groestl512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: groestl.c:3103
CSHA256
A hasher class for SHA-256.
Definition: sha256.h:12
sph_jh512_init
void sph_jh512_init(void *cc)
Initialize a JH-512 context.
Definition: jh.c:1088
serialize.h
CHash256
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
Definition: hash.h:33
prevector.h
uint512
512-bit unsigned big integer.
Definition: uint256.h:73
GLOBAL
#define GLOBAL
Definition: hash.h:64
Hash
std::string Hash(std::string input)
Compute the 256-bit hash of a std::string.
Definition: hash.h:122
CHashWriter::GetHash
uint256 GetHash()
Definition: hash.h:277
CHash160::Reset
CHash160 & Reset()
Definition: hash.h:114
z_groestl
GLOBAL sph_groestl512_context z_groestl
Definition: hash.h:69
z_skein
GLOBAL sph_skein512_context z_skein
Definition: hash.h:72
sph_groestl_big_context
This structure is a context for Groestl-384 and Groestl-512 computations: it contains the intermediat...
Definition: sph_groestl.h:115
sph_groestl512_init
void sph_groestl512_init(void *cc)
Initialize a Groestl-512 context.
Definition: groestl.c:3096
CHash160::OUTPUT_SIZE
static const size_t OUTPUT_SIZE
Definition: hash.h:99
CHash256::sha
CSHA256 sha
Definition: hash.h:36
sph_keccak512
void sph_keccak512(void *cc, const void *data, size_t len)
Process some data bytes.
Definition: keccak.c:1802
sph_groestl512_close
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:3110
CHashWriter::nType
int nType
Definition: hash.h:265
CHashWriter::ctx
CHash256 ctx
Definition: hash.h:262