merkle

package
v1.8.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2024 License: GPL-3.0 Imports: 8 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

This section is empty.

Functions

func ConnectToMerkleProofService added in v1.4.0

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

Types

type EmptyLeafProver added in v1.8.0

type EmptyLeafProver interface {
	GetEmptyLeafProof(
		ctx context.Context,
		in *merkle.GetEmptyLeafProofRequest,
		opts ...grpc.CallOption,
	) (*merkle.GetEmptyLeafProofResponse, error)
}

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 EmptyLeafProver, registryAddress string) (uint32, Proof, error)

func GetProof added in v1.4.0

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

type Prover added in v1.8.0

type Prover interface {
	Proof(
		ctx context.Context,
		in *merkle.QueryProofRequest,
		opts ...grpc.CallOption,
	) (*merkle.QueryProofResponse, 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