Documentation ¶
Overview ¶
Package merkle provides Sia-specific Merkle tree utilities.
Index ¶
- Constants
- func BuildDiffProof(actions []renterhost.RPCWriteAction, sectorRoots []crypto.Hash) (treeHashes, leafHashes []crypto.Hash)
- func BuildProof(sector *[renterhost.SectorSize]byte, start, end int, ...) []crypto.Hash
- func BuildSectorRangeProof(sectorRoots []crypto.Hash, start, end int) []crypto.Hash
- func DiffProofSize(actions []renterhost.RPCWriteAction, numLeaves int) int
- func MetaRoot(roots []crypto.Hash) crypto.Hash
- func ProofSize(n, start, end int) int
- func SectorRoot(sector *[renterhost.SectorSize]byte) crypto.Hash
- func VerifyDiffProof(actions []renterhost.RPCWriteAction, numLeaves int, ...) bool
- func VerifyProof(proof []crypto.Hash, segments []byte, start, end int, root crypto.Hash) bool
- func VerifySectorRangeProof(proof []crypto.Hash, rangeRoots []crypto.Hash, start, end, numRoots int, ...) bool
Constants ¶
const ( // SegmentSize is the number of bytes in each leaf node of a sector's Merkle // tree. Although "LeafSize" would be a more accurate term, Sia refers to // leaves as "segments", so we will follow suit. SegmentSize = crypto.HashSize * 2 // SegmentsPerSector is a convenience value. SegmentsPerSector = renterhost.SectorSize / SegmentSize )
Variables ¶
This section is empty.
Functions ¶
func BuildDiffProof ¶
func BuildDiffProof(actions []renterhost.RPCWriteAction, sectorRoots []crypto.Hash) (treeHashes, leafHashes []crypto.Hash)
BuildDiffProof constructs a diff proof for the specified actions. ActionUpdate is not supported.
func BuildProof ¶
func BuildProof(sector *[renterhost.SectorSize]byte, start, end int, precalc func(i, j int) crypto.Hash) []crypto.Hash
BuildProof constructs a proof for the segment range [start, end). If a non- nil precalc function is provided, it will be used to supply precalculated subtree Merkle roots. For example, if the root of the left half of the Merkle tree is precomputed, precalc should return it for i == 0 and j == SegmentsPerSector/2. If a precalculated root is not available, precalc should return the zero hash.
func BuildSectorRangeProof ¶
BuildSectorRangeProof constructs a proof for the sector range [start, end).
func DiffProofSize ¶
func DiffProofSize(actions []renterhost.RPCWriteAction, numLeaves int) int
DiffProofSize returns the size of a diff proof for the specified actions.
func ProofSize ¶
ProofSize returns the size of a Merkle proof for the leaf range [start, end) within a tree containing n leaves.
func SectorRoot ¶
func SectorRoot(sector *[renterhost.SectorSize]byte) crypto.Hash
SectorRoot computes the Merkle root of a sector using SegmentSize bytes per leaf.
func VerifyDiffProof ¶
func VerifyDiffProof(actions []renterhost.RPCWriteAction, numLeaves int, treeHashes, leafHashes []crypto.Hash, oldRoot, newRoot crypto.Hash) bool
VerifyDiffProof verifies a proof produced by BuildDiffProof. ActionUpdate is not supported.
func VerifyProof ¶
VerifyProof verifies a proof produced by BuildProof. Only sector-sized proofs can be verified.
Types ¶
This section is empty.