Raven Core  3.0.0
P2P Digital Currency
Classes | Macros | Typedefs | Functions | Variables
hash.h File Reference
#include <iostream>
#include <chrono>
#include "crypto/ripemd160.h"
#include "crypto/sha256.h"
#include "prevector.h"
#include "serialize.h"
#include "uint256.h"
#include "version.h"
#include "crypto/sph_blake.h"
#include "crypto/sph_bmw.h"
#include "crypto/sph_groestl.h"
#include "crypto/sph_jh.h"
#include "crypto/sph_keccak.h"
#include "crypto/sph_skein.h"
#include "crypto/sph_luffa.h"
#include "crypto/sph_cubehash.h"
#include "crypto/sph_shavite.h"
#include "crypto/sph_simd.h"
#include "crypto/sph_echo.h"
#include "crypto/sph_hamsi.h"
#include "crypto/sph_fugue.h"
#include "crypto/sph_shabal.h"
#include "crypto/sph_whirlpool.h"
#include "crypto/sph_sha2.h"
#include <vector>
Include dependency graph for hash.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CHash256
 A hasher class for Raven's 256-bit hash (double SHA-256). More...
 
class  CHash160
 A hasher class for Raven's 160-bit hash (SHA-256 + RIPEMD-160). More...
 
class  CHashWriter
 A writer stream (for serialization) that computes a 256-bit hash. More...
 
class  CHashVerifier< Source >
 Reads data from an underlying stream, while hashing the read data. More...
 
class  CSipHasher
 SipHash-2-4. More...
 

Macros

#define GLOBAL   extern
 
#define fillz()
 
#define ZBLAKE   (memcpy(&ctx_blake, &z_blake, sizeof(z_blake)))
 
#define ZBMW   (memcpy(&ctx_bmw, &z_bmw, sizeof(z_bmw)))
 
#define ZGROESTL   (memcpy(&ctx_groestl, &z_groestl, sizeof(z_groestl)))
 
#define ZJH   (memcpy(&ctx_jh, &z_jh, sizeof(z_jh)))
 
#define ZKECCAK   (memcpy(&ctx_keccak, &z_keccak, sizeof(z_keccak)))
 
#define ZSKEIN   (memcpy(&ctx_skein, &z_skein, sizeof(z_skein)))
 
#define START_OF_LAST_16_NIBBLES_OF_HASH   48
 

Typedefs

typedef uint256 ChainCode
 

Functions

template<typename T1 >
uint256 Hash (const T1 pbegin, const T1 pend)
 Compute the 256-bit hash of an object. More...
 
template<typename T1 , typename T2 >
uint256 Hash (const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end)
 Compute the 256-bit hash of the concatenation of two objects. More...
 
template<typename T1 , typename T2 , typename T3 >
uint256 Hash (const T1 p1begin, const T1 p1end, const T2 p2begin, const T2 p2end, const T3 p3begin, const T3 p3end)
 
template<typename T1 , typename T2 , typename T3 , typename T4 >
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)
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
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)
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
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)
 
template<typename T1 >
uint160 Hash160 (const T1 pbegin, const T1 pend)
 Compute the 160-bit hash an object. More...
 
uint160 Hash160 (const std::vector< unsigned char > &vch)
 Compute the 160-bit hash of a vector. More...
 
template<unsigned int N>
uint160 Hash160 (const prevector< N, unsigned char > &vch)
 Compute the 160-bit hash of a vector. More...
 
template<typename T >
uint256 SerializeHash (const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
 Compute the 256-bit hash of an object's serialization. More...
 
unsigned int MurmurHash3 (unsigned int nHashSeed, const std::vector< unsigned char > &vDataToHash)
 
void BIP32Hash (const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
 
uint64_t SipHashUint256 (uint64_t k0, uint64_t k1, const uint256 &val)
 Optimized SipHash-2-4 implementation for uint256. More...
 
uint64_t SipHashUint256Extra (uint64_t k0, uint64_t k1, const uint256 &val, uint32_t extra)
 
int GetHashSelection (const uint256 PrevBlockHash, int index)
 
template<typename T1 >
uint256 HashX16R (const T1 pbegin, const T1 pend, const uint256 PrevBlockHash)
 

Variables

GLOBAL sph_blake512_context z_blake
 
GLOBAL sph_bmw512_context z_bmw
 
GLOBAL sph_groestl512_context z_groestl
 
GLOBAL sph_jh512_context z_jh
 
GLOBAL sph_keccak512_context z_keccak
 
GLOBAL sph_skein512_context z_skein
 
GLOBAL sph_luffa512_context z_luffa
 
GLOBAL sph_cubehash512_context z_cubehash
 
GLOBAL sph_shavite512_context z_shavite
 
GLOBAL sph_simd512_context z_simd
 
GLOBAL sph_echo512_context z_echo
 
double algoHashTotal [16]
 
int algoHashHits [16]
 

Macro Definition Documentation

◆ fillz

#define fillz ( )
Value:
do { \
sph_blake512_init(&z_blake); \
sph_bmw512_init(&z_bmw); \
sph_groestl512_init(&z_groestl); \
sph_jh512_init(&z_jh); \
sph_keccak512_init(&z_keccak); \
sph_skein512_init(&z_skein); \
sph_luffa512_init(&z_luffa); \
sph_cubehash512_init(&z_cubehash); \
sph_shavite512_init(&z_shavite); \
sph_simd512_init(&z_simd); \
sph_echo512_init(&z_echo); \
} while (0)
GLOBAL sph_blake512_context z_blake
Definition: hash.h:45
GLOBAL sph_shavite512_context z_shavite
Definition: hash.h:53
GLOBAL sph_cubehash512_context z_cubehash
Definition: hash.h:52
GLOBAL sph_keccak512_context z_keccak
Definition: hash.h:49
GLOBAL sph_echo512_context z_echo
Definition: hash.h:55
GLOBAL sph_luffa512_context z_luffa
Definition: hash.h:51
GLOBAL sph_simd512_context z_simd
Definition: hash.h:54
GLOBAL sph_groestl512_context z_groestl
Definition: hash.h:47
GLOBAL sph_bmw512_context z_bmw
Definition: hash.h:46
GLOBAL sph_jh512_context z_jh
Definition: hash.h:48
GLOBAL sph_skein512_context z_skein
Definition: hash.h:50

Definition at line 56 of file hash.h.

◆ GLOBAL

#define GLOBAL   extern

Definition at line 42 of file hash.h.

◆ START_OF_LAST_16_NIBBLES_OF_HASH

#define START_OF_LAST_16_NIBBLES_OF_HASH   48

◆ ZBLAKE

#define ZBLAKE   (memcpy(&ctx_blake, &z_blake, sizeof(z_blake)))

Definition at line 69 of file hash.h.

◆ ZBMW

#define ZBMW   (memcpy(&ctx_bmw, &z_bmw, sizeof(z_bmw)))

Definition at line 70 of file hash.h.

◆ ZGROESTL

#define ZGROESTL   (memcpy(&ctx_groestl, &z_groestl, sizeof(z_groestl)))

Definition at line 71 of file hash.h.

◆ ZJH

#define ZJH   (memcpy(&ctx_jh, &z_jh, sizeof(z_jh)))

Definition at line 72 of file hash.h.

◆ ZKECCAK

#define ZKECCAK   (memcpy(&ctx_keccak, &z_keccak, sizeof(z_keccak)))

Definition at line 73 of file hash.h.

◆ ZSKEIN

#define ZSKEIN   (memcpy(&ctx_skein, &z_skein, sizeof(z_skein)))

Definition at line 74 of file hash.h.

Typedef Documentation

◆ ChainCode

typedef uint256 ChainCode

Definition at line 38 of file hash.h.

Function Documentation

◆ BIP32Hash()

void BIP32Hash ( const ChainCode chainCode,
unsigned int  nChild,
unsigned char  header,
const unsigned char  data[32],
unsigned char  output[64] 
)

Definition at line 76 of file hash.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetHashSelection()

int GetHashSelection ( const uint256  PrevBlockHash,
int  index 
)
inline

Definition at line 347 of file hash.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hash() [1/6]

template<typename T1 >
uint256 Hash ( const T1  pbegin,
const T1  pend 
)
inline

Compute the 256-bit hash of an object.

Definition at line 125 of file hash.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hash() [2/6]

template<typename T1 , typename T2 >
uint256 Hash ( const T1  p1begin,
const T1  p1end,
const T2  p2begin,
const T2  p2end 
)
inline

Compute the 256-bit hash of the concatenation of two objects.

Definition at line 136 of file hash.h.

Here is the call graph for this function:

◆ Hash() [3/6]

template<typename T1 , typename T2 , typename T3 >
uint256 Hash ( const T1  p1begin,
const T1  p1end,
const T2  p2begin,
const T2  p2end,
const T3  p3begin,
const T3  p3end 
)
inline

Definition at line 147 of file hash.h.

Here is the call graph for this function:

◆ Hash() [4/6]

template<typename T1 , typename T2 , typename T3 , typename T4 >
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 
)
inline

Definition at line 159 of file hash.h.

Here is the call graph for this function:

◆ Hash() [5/6]

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 >
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 
)
inline

Definition at line 173 of file hash.h.

Here is the call graph for this function:

◆ Hash() [6/6]

template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 >
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 
)
inline

Definition at line 189 of file hash.h.

Here is the call graph for this function:

◆ Hash160() [1/3]

template<typename T1 >
uint160 Hash160 ( const T1  pbegin,
const T1  pend 
)
inline

Compute the 160-bit hash an object.

Definition at line 208 of file hash.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Hash160() [2/3]

uint160 Hash160 ( const std::vector< unsigned char > &  vch)
inline

Compute the 160-bit hash of a vector.

Definition at line 218 of file hash.h.

Here is the call graph for this function:

◆ Hash160() [3/3]

template<unsigned int N>
uint160 Hash160 ( const prevector< N, unsigned char > &  vch)
inline

Compute the 160-bit hash of a vector.

Definition at line 225 of file hash.h.

Here is the call graph for this function:

◆ HashX16R()

template<typename T1 >
uint256 HashX16R ( const T1  pbegin,
const T1  pend,
const uint256  PrevBlockHash 
)
inline

Definition at line 361 of file hash.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ MurmurHash3()

unsigned int MurmurHash3 ( unsigned int  nHashSeed,
const std::vector< unsigned char > &  vDataToHash 
)

Definition at line 20 of file hash.cpp.

Here is the caller graph for this function:

◆ SerializeHash()

template<typename T >
uint256 SerializeHash ( const T &  obj,
int  nType = SER_GETHASH,
int  nVersion = PROTOCOL_VERSION 
)

Compute the 256-bit hash of an object's serialization.

Definition at line 301 of file hash.h.

Here is the caller graph for this function:

◆ SipHashUint256()

uint64_t SipHashUint256 ( uint64_t  k0,
uint64_t  k1,
const uint256 val 
)

Optimized SipHash-2-4 implementation for uint256.

It is identical to: SipHasher(k0, k1) .Write(val.GetUint64(0)) .Write(val.GetUint64(1)) .Write(val.GetUint64(2)) .Write(val.GetUint64(3)) .Finalize()

Definition at line 173 of file hash.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SipHashUint256Extra()

uint64_t SipHashUint256Extra ( uint64_t  k0,
uint64_t  k1,
const uint256 val,
uint32_t  extra 
)

Definition at line 213 of file hash.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ algoHashHits

int algoHashHits[16]

Definition at line 13 of file hash.cpp.

◆ algoHashTotal

double algoHashTotal[16]

Definition at line 12 of file hash.cpp.

◆ z_blake

GLOBAL sph_blake512_context z_blake

Definition at line 45 of file hash.h.

◆ z_bmw

GLOBAL sph_bmw512_context z_bmw

Definition at line 46 of file hash.h.

◆ z_cubehash

Definition at line 52 of file hash.h.

◆ z_echo

Definition at line 55 of file hash.h.

◆ z_groestl

Definition at line 47 of file hash.h.

◆ z_jh

Definition at line 48 of file hash.h.

◆ z_keccak

Definition at line 49 of file hash.h.

◆ z_luffa

Definition at line 51 of file hash.h.

◆ z_shavite

Definition at line 53 of file hash.h.

◆ z_simd

Definition at line 54 of file hash.h.

◆ z_skein

GLOBAL sph_skein512_context z_skein

Definition at line 50 of file hash.h.