Documentation
¶
Index ¶
- func GetRoot(tree *merkletree.MerkleTree) []byte
- func VerifyTree(tree *merkletree.MerkleTree) (bool, error)
- type Content
- type FileIntegrity
- type MerkleManager
- func (m *MerkleManager) BuildAndCache(key string, cids []string) (*merkletree.MerkleTree, error)
- func (m *MerkleManager) BuildTree(cids []string) (*merkletree.MerkleTree, error)
- func (m *MerkleManager) ClearCache()
- func (m *MerkleManager) GenerateProof(tree *merkletree.MerkleTree, cid string) ([][]byte, error)
- func (m *MerkleManager) GetCachedTree(key string) (*merkletree.MerkleTree, bool)
- func (m *MerkleManager) RemoveFromCache(key string)
- func (m *MerkleManager) VerifyContent(tree *merkletree.MerkleTree, cid string) (bool, error)
- func (m *MerkleManager) VerifyFileIntegrity(cids []string, expectedRoot []byte) error
- func (m *MerkleManager) VerifyProof(tree *merkletree.MerkleTree, cid string, proof [][]byte) (bool, error)
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 (Content) CalculateHash ¶
CalculateHash 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