PRCYCoin  2.0.0.7rc1
P2P Digital Currency
Classes | Macros | Functions | Variables
hash.h File Reference
#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 <iomanip>
#include <openssl/sha.h>
#include <sstream>
#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 Bitcoin's 256-bit hash (double SHA-256). More...
 
class  CHash160
 A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160). More...
 
class  CHashWriter
 A writer stream (for serialization) that computes a 256-bit hash. 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)))
 

Functions

std::string Hash (std::string input)
 Compute the 256-bit hash of a std::string. More...
 
void Hash (void *in, unsigned int len, unsigned char *out)
 Compute the 256-bit hash of a void pointer. More...
 
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)
 Compute the 256-bit hash of the concatenation of three objects. More...
 
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)
 Compute the 256-bit hash of the concatenation of three objects. More...
 
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)
 Compute the 256-bit hash of the concatenation of three objects. More...
 
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)
 Compute the 256-bit hash of the concatenation of three objects. More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 >
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)
 Compute the 256-bit hash of the concatenation of seven objects. More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 >
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)
 Compute the 256-bit hash of the concatenation of eight objects. More...
 
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 , typename T9 >
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)
 Compute the 256-bit hash of the concatenation of nine objects. More...
 
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 unsigned char chainCode[32], unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
 
template<typename T1 >
uint256 HashQuark (const T1 pbegin, const T1 pend)
 
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)
 

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
 

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); \
} while (0)

Definition at line 74 of file hash.h.

◆ GLOBAL

#define GLOBAL   extern

Definition at line 64 of file hash.h.

◆ ZBLAKE

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

Definition at line 84 of file hash.h.

◆ ZBMW

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

Definition at line 85 of file hash.h.

◆ ZGROESTL

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

Definition at line 86 of file hash.h.

◆ ZJH

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

Definition at line 87 of file hash.h.

◆ ZKECCAK

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

Definition at line 88 of file hash.h.

◆ ZSKEIN

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

Definition at line 89 of file hash.h.

Function Documentation

◆ BIP32Hash()

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

Definition at line 73 of file hash.cpp.

Here is the caller graph for this function:

◆ Hash() [1/11]

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 157 of file hash.h.

Here is the call graph for this function:

◆ Hash() [2/11]

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

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

Definition at line 167 of file hash.h.

Here is the call graph for this function:

◆ Hash() [3/11]

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

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

Definition at line 177 of file hash.h.

Here is the call graph for this function:

◆ Hash() [4/11]

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

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

Definition at line 187 of file hash.h.

Here is the call graph for this function:

◆ Hash() [5/11]

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

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

Definition at line 197 of file hash.h.

Here is the call graph for this function:

◆ Hash() [6/11]

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

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

Definition at line 207 of file hash.h.

Here is the call graph for this function:

◆ Hash() [7/11]

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

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

Definition at line 217 of file hash.h.

Here is the call graph for this function:

◆ Hash() [8/11]

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

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

Definition at line 227 of file hash.h.

Here is the call graph for this function:

◆ Hash() [9/11]

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

Compute the 256-bit hash of an object.

Definition at line 147 of file hash.h.

Here is the call graph for this function:

◆ Hash() [10/11]

std::string Hash ( std::string  input)
inline

Compute the 256-bit hash of a std::string.

Definition at line 122 of file hash.h.

Here is the caller graph for this function:

◆ Hash() [11/11]

void Hash ( void *  in,
unsigned int  len,
unsigned char *  out 
)
inline

Compute the 256-bit hash of a void pointer.

Definition at line 137 of file hash.h.

◆ Hash160() [1/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 253 of file hash.h.

Here is the call 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 246 of file hash.h.

Here is the call graph for this function:

◆ Hash160() [3/3]

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

Compute the 160-bit hash an object.

Definition at line 237 of file hash.h.

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

◆ HashQuark()

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

Definition at line 312 of file hash.h.

◆ MurmurHash3()

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

Definition at line 15 of file hash.cpp.

Here is the caller graph for this function:

◆ 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 at line 83 of file hash.cpp.

Here is the call graph for this function:
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 295 of file hash.h.

Here is the caller graph for this function:

Variable Documentation

◆ z_blake

GLOBAL sph_blake512_context z_blake

Definition at line 67 of file hash.h.

◆ z_bmw

GLOBAL sph_bmw512_context z_bmw

Definition at line 68 of file hash.h.

◆ z_groestl

Definition at line 69 of file hash.h.

◆ z_jh

Definition at line 70 of file hash.h.

◆ z_keccak

Definition at line 71 of file hash.h.

◆ z_skein

GLOBAL sph_skein512_context z_skein

Definition at line 72 of file hash.h.

z_bmw
GLOBAL sph_bmw512_context z_bmw
Definition: hash.h:68
z_jh
GLOBAL sph_jh512_context z_jh
Definition: hash.h:70
z_blake
GLOBAL sph_blake512_context z_blake
Definition: hash.h:67
z_keccak
GLOBAL sph_keccak512_context z_keccak
Definition: hash.h:71
z_groestl
GLOBAL sph_groestl512_context z_groestl
Definition: hash.h:69
z_skein
GLOBAL sph_skein512_context z_skein
Definition: hash.h:72