Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type HTree ¶
type HTree struct {
// contains filtered or unexported fields
}
HTree accepts a sequence of leaf hashes via its Add method. A leaf hash is the result of calling LeafHash on a string. After adding all leaf hashes in the sequence, their merkle root hash may be read via the Root method.
Note that a Tree works by converting its input from a sequence of strings to the corresponding sequence of leaf hashes and feeding those to an HTree.
func NewProofHTree ¶
NewProofHTree produces a new HTree that can compactly prove a given reference hash is in it. After adding elements to the tree, call Proof to get the proof.
func (*HTree) Add ¶
Add adds a leaf hash to the sequence in h. The caller must not reuse the space in item. It is an error to call Add after a call to Root or Proof.
type Proof ¶
type Proof []ProofStep
Proof is a merkle proof.
func (Proof) Hash ¶
Hash computes the hash of a merkle proof. A valid merkle proof hash matches the root hash of the merkle tree it came from.
To validate a proof made with NewProofTree(..., x) (for some byte sequence x) it is necessary to call proof.Hash(..., LeafHash(..., ..., x))
To validate a proof made with NewProofHTree(..., x) it is only necessary to call proof.Hash(..., x).
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree accepts a sequence of strings via its Add method. It builds a merkle hash tree from them. After adding all strings in the sequence, their merkle root hash may be read via the Root method.
func NewProofTree ¶
NewProofTree produces a new Tree that can compactly prove a given string is in it. After adding elements to the tree, call Proof to get the proof.
func (*Tree) Add ¶
Add adds a string to the sequence in m. The caller may reuse the space in str. It is an error to call Add after a call to Root or Proof.