package testonly
import "github.com/transparency-dev/merkle/testonly"
Package testonly contains code and data for testing Merkle trees, such as a reference implementation of in-memory Merkle tree.
Index ¶
- func CompactTrees() [][][]byte
- func EmptyRootHash() []byte
- func LeafInputs() [][]byte
- func NodeHashes() [][][]byte
- func RootHashes() [][]byte
- type Tree
- func New(hasher merkle.LogHasher) *Tree
- func (t *Tree) Append(hashes ...[]byte)
- func (t *Tree) AppendData(entries ...[]byte)
- func (t *Tree) ConsistencyProof(size1, size2 uint64) ([][]byte, error)
- func (t *Tree) Hash() []byte
- func (t *Tree) HashAt(size uint64) []byte
- func (t *Tree) InclusionProof(index, size uint64) ([][]byte, error)
- func (t *Tree) LeafHash(index uint64) []byte
- func (t *Tree) Size() uint64
Functions ¶
func CompactTrees ¶
func CompactTrees() [][][]byte
CompactTrees returns a slice of compact.Tree internal hashes for all subsequent trees built from LeafInputs() using the RFC 6962 hashing strategy.
func EmptyRootHash ¶
func EmptyRootHash() []byte
EmptyRootHash returns the root hash for an empty Merkle tree that uses SHA256-based strategy from RFC 6962.
func LeafInputs ¶
func LeafInputs() [][]byte
LeafInputs returns a slice of leaf inputs for testing Merkle trees.
func NodeHashes ¶
func NodeHashes() [][][]byte
NodeHashes returns a structured slice of node hashes for all complete subtrees of a Merkle tree built from LeafInputs() using the RFC 6962 hashing strategy. The first index in the slice is the tree level (zero being the leaves level), the second is the horizontal index within a level.
func RootHashes ¶
func RootHashes() [][]byte
RootHashes returns a slice of Merkle tree root hashes for all subsequent trees built from LeafInputs() using the RFC 6962 hashing strategy. Hashes are indexed by tree size starting from an empty tree.
Types ¶
type Tree ¶
type Tree struct {
// contains filtered or unexported fields
}
Tree implements an append-only Merkle tree. For testing.
func New ¶
New returns a new empty Merkle tree.
func (*Tree) Append ¶
Append adds the given leaf hashes to the end of the tree.
func (*Tree) AppendData ¶
AppendData adds the leaf hashes of the given entries to the end of the tree.
func (*Tree) ConsistencyProof ¶
ConsistencyProof returns the consistency proof between the two given tree sizes. Requires 0 <= size1 <= size2 <= Size(), otherwise may panic.
func (*Tree) Hash ¶
Hash returns the current root hash of the tree.
func (*Tree) HashAt ¶
HashAt returns the root hash at the given size. Requires 0 <= size <= Size(), otherwise panics.
func (*Tree) InclusionProof ¶
InclusionProof returns the inclusion proof for the given leaf index in the tree of the given size. Requires 0 <= index < size <= Size(), otherwise may panic.
func (*Tree) LeafHash ¶
LeafHash returns the leaf hash at the given index. Requires 0 <= index < Size(), otherwise panics.
func (*Tree) Size ¶
Size returns the current number of leaves in the tree.
Source Files ¶
- Version
- v0.0.2 (latest)
- Published
- May 5, 2023
- Platform
- linux/amd64
- Imports
- 4 packages
- Last checked
- 4 days ago –
Tools for package owners.