merkle

package
v0.0.0-...-3e50352 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func VerifyProof

func VerifyProof(leafData []byte, proof *MerkleProof, rootHash []byte, hf HashFunction) bool

Types

type HashFunction

type HashFunction interface {
	Hash(data []byte) []byte
	Name() string
}

type MerkleNode

type MerkleNode struct {
	Left  *MerkleNode
	Right *MerkleNode
	Hash  []byte
}

type MerkleProof

type MerkleProof struct {
	Path  []ProofItem
	Index int
}

type MerkleTree

type MerkleTree struct {
	Root         *MerkleNode
	HashFunction HashFunction
	Leaves       []*MerkleNode
}

func NewMerkleTree

func NewMerkleTree(data [][]byte, hf HashFunction) *MerkleTree

func (*MerkleTree) GenerateProof

func (t *MerkleTree) GenerateProof(index int) (*MerkleProof, error)

func (*MerkleTree) GetRootHash

func (t *MerkleTree) GetRootHash() []byte

func (*MerkleTree) PrintMerkleTree

func (t *MerkleTree) PrintMerkleTree()

func (*MerkleTree) String

func (t *MerkleTree) String() string

type ProofItem

type ProofItem struct {
	Hash     []byte
	Position string // "left" | "right"
}

type SHA3_256Hash

type SHA3_256Hash struct{}

func (SHA3_256Hash) Hash

func (h SHA3_256Hash) Hash(data []byte) []byte

func (SHA3_256Hash) Name

func (h SHA3_256Hash) Name() string

type SHA256Hash

type SHA256Hash struct{}

func (SHA256Hash) Hash

func (h SHA256Hash) Hash(data []byte) []byte

func (SHA256Hash) Name

func (h SHA256Hash) Name() string

Jump to

Keyboard shortcuts

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