merkle

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetRoot

func GetRoot(tree *merkletree.MerkleTree) []byte

GetRoot returns the Merkle root hash for a tree

func VerifyTree

func VerifyTree(tree *merkletree.MerkleTree) (bool, error)

VerifyTree verifies the entire Merkle tree

Types

type Content

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

Content implements merkletree.Content interface for CID-based content

func NewContent

func NewContent(cid string) Content

NewContent creates a new Content from a CID

func (Content) CalculateHash

func (c Content) CalculateHash() ([]byte, error)

CalculateHash implements the Content interface

func (Content) Equals

func (c Content) Equals(other merkletree.Content) (bool, error)

Equals implements the Content interface

type FileIntegrity

type FileIntegrity struct {
	FilePath   string   // Path to the file
	CIDs       []string // List of CIDs (chunks or diffs)
	MerkleRoot []byte   // Merkle root hash
	IsValid    bool     // Validation result
}

FileIntegrity represents the integrity information for a file

type MerkleManager

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

MerkleManager manages Merkle trees for file integrity verification

func NewMerkleManager

func NewMerkleManager() *MerkleManager

NewMerkleManager creates a new Merkle tree manager

func (*MerkleManager) BuildAndCache

func (m *MerkleManager) BuildAndCache(key string, cids []string) (*merkletree.MerkleTree, error)

BuildAndCache builds a tree and caches it with a key

func (*MerkleManager) BuildTree

func (m *MerkleManager) BuildTree(cids []string) (*merkletree.MerkleTree, error)

BuildTree builds a Merkle tree from a list of CIDs

func (*MerkleManager) ClearCache

func (m *MerkleManager) ClearCache()

ClearCache clears the tree cache

func (*MerkleManager) GenerateProof

func (m *MerkleManager) GenerateProof(tree *merkletree.MerkleTree, cid string) ([][]byte, error)

GenerateProof generates a Merkle proof for a specific CID in the tree

func (*MerkleManager) GetCachedTree

func (m *MerkleManager) GetCachedTree(key string) (*merkletree.MerkleTree, bool)

GetCachedTree retrieves a cached tree

func (*MerkleManager) RemoveFromCache

func (m *MerkleManager) RemoveFromCache(key string)

RemoveFromCache removes a specific tree from cache

func (*MerkleManager) VerifyContent

func (m *MerkleManager) VerifyContent(tree *merkletree.MerkleTree, cid string) (bool, error)

VerifyContent verifies a specific content item in the tree

func (*MerkleManager) VerifyFileIntegrity

func (m *MerkleManager) VerifyFileIntegrity(cids []string, expectedRoot []byte) error

VerifyFileIntegrity verifies the integrity of a file using its CIDs and expected root

func (*MerkleManager) VerifyProof

func (m *MerkleManager) VerifyProof(tree *merkletree.MerkleTree, cid string, proof [][]byte) (bool, error)

VerifyProof verifies a Merkle proof for a specific content

Jump to

Keyboard shortcuts

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