Skip to main content

EpochTree

Struct EpochTree 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn get(&self, index: u64) -> Option<&[u8]>

Read the payload of cell index.

Source

pub fn metadata(&self, index: u64) -> Option<&[u8]>

Read the opaque metadata of cell index.

Source

pub fn len(&self) -> u64

Number of cells in the tree.

Source

pub fn is_empty(&self) -> bool

Whether the tree holds no cells.

Source

pub fn arity(&self) -> u64

The configured proof-spine arity.

Source

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).

Source

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.

Source

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).

Source

pub fn leaf_proof(&self, alg_id: u64, index: u64) -> Option<LeafProof>

Produce a self-contained spine::LeafProof for cell index (Cmt::leaf_proof).

Source

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).

Source

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.

Trait Implementations§

Source§

impl Debug for EpochTree

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.