imt

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IndexTreeOutput

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

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 hash.Hash)
}

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  []byte
	Hash []byte
}

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