merklearray

package
v0.0.0-...-76c1feb Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Verify

func Verify(root crypto.Digest, elems map[uint64]crypto.Digest, proof []crypto.Digest) error

Verify ensures that the positions in elems correspond to the respective hashes in a tree with the given root hash. The proof is expected to be the proof returned by Prove().

Types

type Array

type Array interface {
	Length() uint64
	GetHash(pos uint64) (crypto.Digest, error)
}

An Array represents a dense array of leaf elements that are combined into a Merkle tree. The GetHash method returns the hash of a particular element in the array.

type Tree

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

Tree is a Merkle tree, represented by layers of nodes (hashes) in the tree at each height.

func Build

func Build(array Array) (*Tree, error)

Build constructs a Merkle tree given an array.

func (*Tree) Prove

func (tree *Tree) Prove(idxs []uint64) ([]crypto.Digest, error)

Prove constructs a proof for some set of positions in the array that was used to construct the tree.

func (*Tree) Root

func (tree *Tree) Root() crypto.Digest

Root returns the root hash of the tree.

Jump to

Keyboard shortcuts

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