merkle

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package merkle provides Merkle tree manipulation functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Rehash added in v1.3.10

func Rehash(h [][]byte, nf []NodeFetch, hc func(left, right []byte) []byte) ([][]byte, error)

Rehash computes the proof based on the slice of NodeFetch structs, and the corresponding hashes of these nodes. The slices must be of the same length. The hc parameter computes node's hash based on hashes of its children.

Warning: The passed-in slice of hashes can be modified in-place.

Types

type NodeFetch

type NodeFetch struct {
	ID     compact.NodeID
	Rehash bool
}

NodeFetch bundles a node ID with additional information on how to use the node to construct a proof.

func CalcConsistencyProofNodeAddresses

func CalcConsistencyProofNodeAddresses(size1, size2 int64) ([]NodeFetch, error)

CalcConsistencyProofNodeAddresses returns the tree node IDs needed to build a consistency proof between two specified tree sizes. All the returned nodes represent complete subtrees in the tree of size2 or above.

Use Rehash function to compose the proof after the node hashes are fetched.

func CalcInclusionProofNodeAddresses

func CalcInclusionProofNodeAddresses(size, index int64) ([]NodeFetch, error)

CalcInclusionProofNodeAddresses returns the tree node IDs needed to build an inclusion proof for a specified tree size and leaf index. All the returned nodes represent complete subtrees in the tree of this size or above.

Use Rehash function to compose the proof after the node hashes are fetched.

Directories

Path Synopsis
Package compact provides compact Merkle tree data structures.
Package compact provides compact Merkle tree data structures.
Package coniks provides CONIKS hashing for maps.
Package coniks provides CONIKS hashing for maps.
Package rfc6962 provides hashing functionality according to RFC6962.
Package rfc6962 provides hashing functionality according to RFC6962.
smt
Package smt contains the implementation of the sparse Merkle tree logic.
Package smt contains the implementation of the sparse Merkle tree logic.
node
Package node implements a sparse Merkle tree node.
Package node implements a sparse Merkle tree node.
Package testonly contains code and data for testing Merkle trees.
Package testonly contains code and data for testing Merkle trees.

Jump to

Keyboard shortcuts

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