imt

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTreeEmpty = errors.New("tree is empty")

Functions

func IndexTreeOutput

func IndexTreeOutput(merklePath []*PathItem, key []byte, hashAlgorithm crypto.Hash) ([]byte, error)

IndexTreeOutput calculates the output hash of the index Merkle tree hash chain from hash chain, key and data hash.

Types

type LeafData

type LeafData interface {
	Key() []byte
	AddToHasher(hasher abhash.Hasher)
}

LeafData indexed tree leaf. NB!: indexed tree leaves must be sorted lexicographically by key in strict order k1 < k2 < ... kn

type PathItem

type PathItem struct {
	Key  hex.Bytes `json:"key"`
	Hash hex.Bytes `json:"hash"`
}

PathItem helper struct for proof extraction, contains Hash and Key of node

type Tree

type Tree struct {
	// contains filtered or unexported fields
}

func New

func New(hashAlgorithm crypto.Hash, leaves []LeafData) (*Tree, error)

New creates a new indexed Merkle tree.

func (*Tree) GetMerklePath

func (s *Tree) GetMerklePath(key []byte) ([]*PathItem, error)

GetMerklePath extracts the indexed merkle hash chain from the given leaf key to root. A hash chain is always returned. If the key is not present, a chain is returned from where the key is supposed to be.

func (*Tree) GetRootHash

func (s *Tree) GetRootHash() []byte

GetRootHash returns the root Hash of the indexed Merkle tree.

func (*Tree) PrettyPrint

func (s *Tree) PrettyPrint() string

PrettyPrint returns a human-readable string representation of the indexed Merkle tree.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL