merkle

package
v0.0.0-...-0866dc8 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Proof

type Proof struct {
	// Lemma is made up of 3 parts to keep consistent with ionian-rust:
	// 1. Target content hash (leaf node).
	// 2. Hashes from bottom to top of sibing nodes.
	// 3. Root hash.
	Lemma []common.Hash `json:"lemma"`

	// Path contains flags to indicate that whether the corresponding node is on the left side.
	// All true for the left most leaf node, and all false for the right most leaf node.
	Path []bool `json:"path"`
}

Proof represents a merkle tree proof of target content, e.g. chunk or segment of file.

func (*Proof) Validate

func (proof *Proof) Validate(root common.Hash, content []byte, position, numLeafNodes uint64) error

func (*Proof) ValidateHash

func (proof *Proof) ValidateHash(root, contentHash common.Hash, position, numLeafNodes uint64) error

type Tree

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

Tree represents a binary merkle tree, e.g. bitcoin-like merkle tree or complete BMT.

func (*Tree) ProofAt

func (tree *Tree) ProofAt(i int) Proof

func (*Tree) Root

func (tree *Tree) Root() common.Hash

type TreeBuilder

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

TreeBuilder is used to build complete binary merkle tree.

func (*TreeBuilder) Append

func (builder *TreeBuilder) Append(content []byte)

func (*TreeBuilder) AppendHash

func (builder *TreeBuilder) AppendHash(hash common.Hash)

func (*TreeBuilder) Build

func (builder *TreeBuilder) Build() *Tree

Jump to

Keyboard shortcuts

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