Equity
Bitcoin Protocol Library
Public Member Functions | Static Public Member Functions | List of all members
Utility::MerkleTree Class Reference

A Merkle Tree with some idiosyncracies specific to Bitcoin. More...

#include <MerkleTree.h>

Public Member Functions

 MerkleTree (Crypto::Sha256HashList const &hashes)
 
Crypto::Sha256Hash root () const
 Returns the root.
 
Crypto::Sha256Hash hashAt (size_t i) const
 Returns the hash at the given index. More...
 
Crypto::Sha256HashList proof (size_t i) const
 Returns a proof for the hash at the given index. More...
 

Static Public Member Functions

static bool verify (Crypto::Sha256Hash const &hash, size_t i, Crypto::Sha256HashList const &proof, Crypto::Sha256Hash const &root)
 Verifies that the given hash is the hash at the given index, given a proof and a root. More...
 

Detailed Description

A Merkle Tree with some idiosyncracies specific to Bitcoin.

Constructor & Destructor Documentation

Utility::MerkleTree::MerkleTree ( Crypto::Sha256HashList const &  hashes)
Parameters
hashesordered list of hashes

Member Function Documentation

Crypto::Sha256Hash Utility::MerkleTree::hashAt ( size_t  i) const

Returns the hash at the given index.

Parameters
iindex
Crypto::Sha256HashList Utility::MerkleTree::proof ( size_t  i) const

Returns a proof for the hash at the given index.

Parameters
iindex
bool Utility::MerkleTree::verify ( Crypto::Sha256Hash const &  hash,
size_t  i,
Crypto::Sha256HashList const &  proof,
Crypto::Sha256Hash const &  root 
)
static

Verifies that the given hash is the hash at the given index, given a proof and a root.

Parameters
hashhash to verify
ilocation of the hash
prooflist of hashes in depth-first order used to verify the hash
rootroot value that should be the result of the proof

The documentation for this class was generated from the following files: