MCPcopy Create free account
hub / github.com/ElementsProject/elements / CHash256

Class CHash256

src/hash.h:24–46  ·  view source on GitHub ↗

A hasher class for Bitcoin's 256-bit hash (double SHA-256). */

Source from the content-addressed store, hash-verified

22
23/** A hasher class for Bitcoin's 256-bit hash (double SHA-256). */
24class CHash256 {
25private:
26 CSHA256 sha;
27public:
28 static const size_t OUTPUT_SIZE = CSHA256::OUTPUT_SIZE;
29
30 void Finalize(Span<unsigned char> output) {
31 assert(output.size() == OUTPUT_SIZE);
32 unsigned char buf[CSHA256::OUTPUT_SIZE];
33 sha.Finalize(buf);
34 sha.Reset().Write(buf, CSHA256::OUTPUT_SIZE).Finalize(output.data());
35 }
36
37 CHash256& Write(Span<const unsigned char> input) {
38 sha.Write(input.data(), input.size());
39 return *this;
40 }
41
42 CHash256& Reset() {
43 sha.Reset();
44 return *this;
45 }
46};
47
48/** A hasher class for Bitcoin's 160-bit hash (SHA-256 + RIPEMD-160). */
49class CHash160 {

Callers 11

HashFunction · 0.85
VerifyPubKeyMethod · 0.85
ContextualCheckBlockFunction · 0.85
GetHashMethod · 0.85
ComputeHeaderMethod · 0.85
EvalScriptFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
MerkleComputationFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
HASHFunction · 0.85

Calls 4

WriteMethod · 0.45
dataMethod · 0.45
sizeMethod · 0.45
ResetMethod · 0.45

Tested by 3

BOOST_AUTO_TEST_CASEFunction · 0.68
MerkleComputationFunction · 0.68
BOOST_AUTO_TEST_CASEFunction · 0.68