smt

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

View Source
var ErrInvalidKeyLength = errors.New("invalid key length")

Functions

func CalculatePathRoot

func CalculatePathRoot(path [][]byte, leafHash []byte, key []byte, hashAlgorithm crypto.Hash) ([]byte, error)

func IsBitSet

func IsBitSet(bytes []byte, bitPosition int) bool

Types

type Data

type Data interface {
	Key() []byte
	AddToHasher(hasher hash.Hash)
}

type SMT

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

func New

func New(hasher hash.Hash, keyLength int, data []Data) (*SMT, error)

New creates a new sparse merkle tree.

func (*SMT) GetAuthPath

func (s *SMT) GetAuthPath(key []byte) ([][]byte, Data, error)

GetAuthPath returns authentication path and leaf node data for given key.

func (*SMT) GetRootHash

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

GetRootHash returns the root hash of the SMT.

func (*SMT) PrettyPrint

func (s *SMT) PrettyPrint() string

Jump to

Keyboard shortcuts

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