83 template<
typename T1,
typename T2>
109 CHashWriter(
int nTypeIn,
int nVersionIn) : nType(nTypeIn), nVersion(nVersionIn) {}
114 void write(
const char *pch,
size_t size) {
115 ctx.
Write((
const unsigned char*)pch, size);
156 template<
typename Source>
165 void read(
char* pch,
size_t nSize)
167 source->read(pch, nSize);
168 this->write(pch, nSize);
175 size_t now = std::min<size_t>(nSize, 1024);
204 void BIP32Hash(
const ChainCode &chainCode,
unsigned int nChild,
unsigned char header,
const unsigned char data[32],
unsigned char output[64]);
214 #endif // BITCOIN_HASH_H CSHA256 & Write(const unsigned char *data, size_t len)
void write(const char *pch, size_t size)
void BIP32Hash(const ChainCode &chainCode, unsigned int nChild, unsigned char header, const unsigned char data[32], unsigned char output[64])
const std::chrono::seconds now
void Finalize(Span< unsigned char > output)
CHashVerifier< Source > & operator>>(T &&obj)
void Finalize(Span< unsigned char > output)
unsigned int MurmurHash3(unsigned int nHashSeed, Span< const unsigned char > vDataToHash)
uint256 GetSHA256()
Compute the SHA256 hash of all data written to this object.
constexpr std::size_t size() const noexcept
A hasher class for Bitcoin's 256-bit hash (double SHA-256).
void ignore(size_t nSize)
Reads data from an underlying stream, while hashing the read data.
void Serialize(Stream &s, char a)
uint256 SerializeHash(const T &obj, int nType=SER_GETHASH, int nVersion=PROTOCOL_VERSION)
Compute the 256-bit hash of an object's serialization.
uint256 SHA256Uint256(const uint256 &input)
Single-SHA256 a 32-byte input (represented as uint256).
constexpr auto MakeUCharSpan(V &&v) -> decltype(UCharSpanCast(MakeSpan(std::forward< V >(v))))
Like MakeSpan, but for (const) unsigned char member types only.
uint64_t GetCheapHash()
Returns the first 64 bits from the resulting hash.
static const size_t OUTPUT_SIZE
void Finalize(unsigned char hash[OUTPUT_SIZE])
CHashWriter(int nTypeIn, int nVersionIn)
CRIPEMD160 & Write(const unsigned char *data, size_t len)
uint160 Hash160(const T1 &in1)
Compute the 160-bit hash an object.
uint256 GetHash()
Compute the double-SHA256 hash of all data written to this object.
constexpr C * data() const noexcept
static const int PROTOCOL_VERSION
network protocol versioning
CHashVerifier(Source *source_)
static uint64_t ReadLE64(const unsigned char *ptr)
CHashWriter TaggedHash(const std::string &tag)
Return a CHashWriter primed for tagged hashes (as specified in BIP 340).
static const size_t OUTPUT_SIZE
static const size_t OUTPUT_SIZE
CHashWriter & operator<<(const T &obj)
void Unserialize(Stream &s, char &a)
void read(char *pch, size_t nSize)
A writer stream (for serialization) that computes a 256-bit hash.
A Span is an object that can refer to a contiguous sequence of objects.
uint256 Hash(const T &in1)
Compute the 256-bit hash of an object.
A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160).
void Finalize(unsigned char hash[OUTPUT_SIZE])
A hasher class for SHA-256.
CHash160 & Write(Span< const unsigned char > input)
CHash256 & Write(Span< const unsigned char > input)
A hasher class for RIPEMD-160.