merkle

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: GPL-3.0 Imports: 4 Imported by: 0

README

merkle

This is a port of OpenZeppelin's JS merkle-tree library to Go. It excludes the StandardTree wrapper types since our use-case doesn't require it. It also moves all non-omni-required logic to the test package to decrease the surface area of the library.

Documentation

Overview

Package merkle provides an API to generate merkle trees and proofs from 32 byte leaves. It is a port of the OpenZeppelin JS merkle-tree library. See https://github.com/OpenZeppelin/merkle-tree/tree/master.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MakeTree

func MakeTree(leaves [][32]byte) ([][32]byte, error)

MakeTree returns a merkle tree given the leaves.

func StdLeafHash

func StdLeafHash(data []byte) [32]byte

StdLeafHash returns the standard leaf hash of the given data. The data is hashed twice with keccak256 to prevent pre-image attacks.

Types

type MultiProof

type MultiProof struct {
	Leaves     [][32]byte
	Proof      [][32]byte
	ProofFlags []bool
}

MultiProof is a merkle-multi-proof for multiple leaves.

func GetMultiProof

func GetMultiProof(tree [][32]byte, indices ...int) (MultiProof, error)

GetMultiProof returns a merkle-multi-proof for the given leaf indices.

Jump to

Keyboard shortcuts

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