imt

package
v0.0.0-...-eab7081 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2023 License: Apache-2.0 Imports: 4 Imported by: 1

Documentation

Overview

Package imt provides an Incremental Merkle Tree

Index

Constants

View Source
const (
	TreeDepth = 32
	MaxLeaves = ^uint32(0)
)

Variables

This section is empty.

Functions

func BranchRoot

func BranchRoot(item []byte, branch [TreeDepth][]byte, index uint32) ([]byte, error)

BranchRoot calculates and returns the merkle root for the given leaf item, a merkle branch, and the index of item in the tree

func ZeroHashes

func ZeroHashes() [][]byte

ZeroHashes returns the array of TreeDepth zero hashes

Types

type Tree

type Tree struct {
	Branch [TreeDepth][]byte
	// contains filtered or unexported fields
}

func InitializeTree

func InitializeTree(branch [][]byte, count uint32) *Tree

func (*Tree) Count

func (t *Tree) Count() uint32

Count returns the number of inserts performed on the Tree

func (*Tree) GetProofForNextIndex

func (t *Tree) GetProofForNextIndex() (proof [TreeDepth][32]byte)

GetProofForNextIndex returns the proof for the next index.

func (*Tree) Insert

func (t *Tree) Insert(node []byte) error

Insert inserts node into the Merkle Tree

func (*Tree) Print

func (t *Tree) Print()

Print dumps the tree (for debugging)

func (*Tree) Root

func (t *Tree) Root() []byte

Root calculates and returns Tree's current root

func (*Tree) RootWithContext

func (t *Tree) RootWithContext(zeroes [][]byte) []byte

RootWithCtx calculates and returns Tree's current root given array of zeroes

func (*Tree) SetCount

func (t *Tree) SetCount(count uint32)

Set the count . (Used when restoring from genesis state)

Jump to

Keyboard shortcuts

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