go_merkle

package module
v0.0.0-...-7a9e958 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: MIT Imports: 2 Imported by: 5

README

Go Merkle tree light implementation

This implementation will construct the Merkle tree where parent hash are hash of concatenation of its leafs, but firstly will go lexicographically smaller hash. Also, to check the path ypu should concatenate hashes in lexicographically order.

More precisely:

According to Openzeppelin contracts "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/cryptography/MerkleProof.sol", Hash of a and b will be:

  • hash(ab), if a < b
  • hash(ba), otherwise

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Content

type Content interface {
	CalculateHash() []byte
	Equals(other Content) bool
}

type DefaultContent

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

func (*DefaultContent) CalculateHash

func (d *DefaultContent) CalculateHash() []byte

func (*DefaultContent) Equals

func (d *DefaultContent) Equals(other Content) bool

type HashF

type HashF func(data ...[]byte) []byte

type Tree

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

func NewTree

func NewTree(hash HashF, list ...Content) *Tree

func (*Tree) Path

func (t *Tree) Path(content Content) ([][]byte, bool)

func (*Tree) Root

func (t *Tree) Root() []byte

Jump to

Keyboard shortcuts

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