pub struct EpochTree { /* private fields */ }Expand description
The polydigest combinator over a Cmt — the Epoch Merkle Tree (polydigest(cmt)).
Wraps a structural Cmt and adds the binding/combined root and the
combined-currency seal. The structural surface (set, get, inclusion, the
per-node multi-hash) delegates to the inner tree; the binding facet is this
type’s own.
Implementations§
Source§impl EpochTree
impl EpochTree
Sourcepub fn new(config: Config) -> Result<EpochTree, Error>
pub fn new(config: Config) -> Result<EpochTree, Error>
Create an empty epoch tree.
§Errors
Propagates cmt::Error::InvalidArity if config.arity is out of range.
Sourcepub fn register_algorithm(
&mut self,
alg_id: u64,
hasher: Box<dyn Hasher>,
) -> Result<(), Error>
pub fn register_algorithm( &mut self, alg_id: u64, hasher: Box<dyn Hasher>, ) -> Result<(), Error>
Register an algorithm, hashing every existing cell under it
(Cmt::register_algorithm).
§Errors
Propagates cmt::Error::DuplicateAlgorithm.
Sourcepub fn add_algorithm_at(
&mut self,
alg_id: u64,
index: u64,
hasher: Box<dyn Hasher>,
) -> Result<usize, Error>
pub fn add_algorithm_at( &mut self, alg_id: u64, index: u64, hasher: Box<dyn Hasher>, ) -> Result<usize, Error>
Add alg_id to a single cell after the fact (Cmt::add_algorithm_at),
recomputing only that cell’s ancestor path (O(log n)).
§Errors
Propagates cmt::Error::DuplicateAlgorithm / cmt::Error::IndexGap.
Sourcepub fn set(
&mut self,
index: u64,
payload: Vec<u8>,
metadata: Vec<u8>,
) -> Result<(), Error>
pub fn set( &mut self, index: u64, payload: Vec<u8>, metadata: Vec<u8>, ) -> Result<(), Error>
Set the payload (and opaque metadata) of cell index
(Cmt::set).
§Errors
Propagates cmt::Error::IndexGap.
Sourcepub fn root(&self, alg_id: u64) -> Option<Vec<u8>>
pub fn root(&self, alg_id: u64) -> Option<Vec<u8>>
The current per-algorithm member root under alg_id — the raw root
the leaves authenticate against (Cmt::root).
Sourcepub fn combined_root(&self, alg_id: u64) -> Option<Vec<u8>>
pub fn combined_root(&self, alg_id: u64) -> Option<Vec<u8>>
The current live combined root under alg_id’s hash — the primary
identity of the tree, the epoch facet over the structural member roots.
The combined root is the canonicalization fold (combined_root) over
every registered algorithm’s member root as children, under alg_id’s own
hash. A mutable tree is dense and active from genesis, so its committed
timeline is trivial and no coverage child joins the fold; genesis
promotion is native, so for the common one-algorithm tree the combined
root equals Self::root.
Computed live from the inner tree’s materialized member roots — no seal
required — and symmetric with the append-only log’s combined root.
Returns None if alg_id is unregistered or the tree is empty.
Sourcepub fn inclusion_proof(
&self,
alg_id: u64,
index: u64,
) -> Option<(Vec<u8>, Vec<ProofStep>)>
pub fn inclusion_proof( &self, alg_id: u64, index: u64, ) -> Option<(Vec<u8>, Vec<ProofStep>)>
Generate an inclusion proof for cell index under alg_id
(Cmt::inclusion_proof).
Sourcepub fn leaf_proof(&self, alg_id: u64, index: u64) -> Option<LeafProof>
pub fn leaf_proof(&self, alg_id: u64, index: u64) -> Option<LeafProof>
Produce a self-contained spine::LeafProof for cell index
(Cmt::leaf_proof).
Sourcepub fn non_membership_proof(
&self,
alg_id: u64,
index: u64,
) -> Option<(Vec<u8>, Vec<ProofStep>)>
pub fn non_membership_proof( &self, alg_id: u64, index: u64, ) -> Option<(Vec<u8>, Vec<ProofStep>)>
Generate a non-membership proof for index under alg_id
(Cmt::non_membership_proof).
Sourcepub fn seal(self) -> Result<Sealed, Error>
pub fn seal(self) -> Result<Sealed, Error>
Consume the tree and seal it into the one commitment currency Sealed.
The inner Cmt computes the structural Seal (the resumable
frontier); this combinator pairs it with the trivial committed timeline
(0, MAX) per registered algorithm — the only timeline a mutable tree can
assert — to form the Sealed (the BoundSnapshot
epoch facet over the structural seal, D13). One-way: there is no unseal
and no path back to an EpochTree (C-SEAL-ONEWAY).
§Errors
Propagates cmt::Error::EmptySeal on an empty tree and
cmt::Error::MalformedSeal if the spine rejects the frontier; the
combined currency cannot itself fail once the structural seal succeeds, so
a Sealed build error is mapped back to MalformedSeal.