merkle

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package merkle provides functionality for creating and manipulating Merkle trees, with a focus on efficient and secure verification of data integrity.

The package offers tools for constructing Merkle trees, managing tree nodes, and generating and verifying Merkle proofs. It includes constants for default tree depth and empty leaf values. Key features include the ability to create new empty trees, set leaf values, retrieve proofs, and calculate the root hash of the tree.

Additionally, the package provides a hash function for big integers and utility functions for navigating the Merkle tree structure, such as obtaining parent and sibling indices and determining whether a node is a right child.

Note: The package assumes the use of 256-bit integers for node values.

Index

Constants

This section is empty.

Variables

View Source
var EmptyLeafValue = new(uint256.Int).Mod(
	uint256.MustFromBig(new(big.Int).SetBytes(makeSeedForEmptyLeaf())),
	uint256.MustFromBig(ff.Modulus()),
)

Functions

func ConnectToMerkleProofService added in v1.4.0

func ConnectToMerkleProofService(ctx context.Context, merkleProofServiceHost string, useTLS bool) (merkle.QueryClient, error)

Types

type Proof

type Proof struct {
	Leaf      TreeNode   `json:"leaf"`      // The Merkle tree node, which authenticity is proved by the Path.
	LeafIndex int        `json:"leafIndex"` // Index of the Leaf in the Merkle tree.
	Path      []TreeNode `json:"path"`
}

func GetEmptyLeafProof added in v1.4.0

func GetEmptyLeafProof(ctx context.Context, client merkle.QueryClient, registryAddress string) (uint32, Proof, error)

func GetProof added in v1.4.0

func GetProof(ctx context.Context, client merkle.QueryClient, registryAddress string, leaf string) (Proof, error)

type TreeNode

type TreeNode struct {
	Value *uint256.Int
}

func (TreeNode) MarshalText

func (n TreeNode) MarshalText() (text []byte, err error)

func (*TreeNode) UnmarshalText

func (n *TreeNode) UnmarshalText(text []byte) error

Jump to

Keyboard shortcuts

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