Skip to main content

Seal

Struct Seal 

Source
pub struct Seal { /* private fields */ }
Expand description

The general structural commitment lattice: a sealed, resumable frontier.

Carries, per algorithm with a frontier at tree_size, the digests of the perfect k-ary subtrees of the frontier (the resume state), and an optional opaque metadata channel (Meta). Member roots and run-extents are derived views — see the module docs. The committed epoch timeline and binding root are the polydigest combinator’s facet, not stored here.

Implementations§

Source§

impl Seal

Source

pub fn new( tree_size: u64, arity: u64, frontiers: Vec<(u64, Vec<Vec<u8>>)>, ) -> Result<Seal, Error>

Seal a resumable frontier at tree_size with no metadata attached.

arity is the spine arity k (2..=256); frontiers carries each algorithm’s frontier peaks (the digests of the perfect k-ary subtrees of the frontier, left to right), sorted by algorithm ID.

This is the only way to construct a Seal, so every value in circulation carries a correctly-sized frontier. The committed epoch timeline is not an input — it is the polydigest combinator’s concern.

§Errors

Returns Error::BadArity if arity is outside 2..=256, or Error::MalformedFrontier if any algorithm’s peak count does not match the canonical frontier length for (tree_size, arity).

Source

pub fn with_meta(self, meta: Meta) -> Seal

Attach an opaque metadata payload, consuming and returning self.

The library never reads or validates the payload; any byte sequence is accepted. Calling this again replaces any previously attached payload.

Source

pub fn tree_size(&self) -> u64

The tree size this frontier was sealed at.

Source

pub fn arity(&self) -> u64

The spine arity k this frontier was sealed under.

Source

pub fn frontiers(&self) -> &[(u64, Vec<Vec<u8>>)]

A read borrow of each algorithm’s frontier peaks: (alg_id, peaks), sorted by algorithm ID. These are the resume state; the member root is their fold (Self::member_root).

Source

pub fn peaks(&self, alg_id: u64) -> Option<&[Vec<u8>]>

The frontier peaks of a single algorithm, if it has a frontier in this seal.

Source

pub fn meta(&self) -> Option<&Meta>

A read borrow of the attached opaque metadata, if any.

Returns None when no metadata was attached via Self::with_meta. The library never interprets the bytes; fidelity (round-trip) is the only guarantee.

Source

pub fn member_roots( &self, hashers: &[(u64, &dyn Hasher)], bag: fn(&dyn Hasher, &[Vec<u8>], u64) -> Vec<u8>, ) -> Vec<(u64, Vec<u8>)>

Derived view. Each algorithm’s member root: (alg_id, member_root), sorted by algorithm ID. A member root is the consumer’s bag of that algorithm’s frontier peaks under its own hash — the raw per-algorithm root the leaves authenticate against. Folded on demand, never stored.

The Seal stores peaks only and is topology-agnostic: how the peaks bag into one root is the consumer’s choice, supplied as bag(hasher, peaks, arity) — the append-only log passes its mountain backward-bag, the mutable tree its rebalanced fold. The same bag applies to every algorithm (one topology per structure).

hashers resolves an algorithm’s own hash; an algorithm with no hasher in hashers is skipped (its member root cannot be folded).

Source

pub fn member_root( &self, alg_id: u64, hasher: &dyn Hasher, bag: fn(&dyn Hasher, &[Vec<u8>], u64) -> Vec<u8>, ) -> Option<Vec<u8>>

Derived view. A single algorithm’s member root — the consumer’s bag of its frontier peaks under hasher. Returns None if the algorithm has no frontier in this seal. See Self::member_roots for the bag contract.

Source

pub fn all_member_roots( &self, hashers: &[(u64, &dyn Hasher)], bag: fn(&dyn Hasher, &[Vec<u8>], u64) -> Vec<u8>, ) -> Result<Vec<(u64, Vec<u8>)>, Error>

Derived view. Every algorithm’s member root, in sealed (sorted) order, bagged under the supplied hashers — or Error::MissingHasher naming the first algorithm with no hasher.

Unlike Self::member_roots, which is the produce-side view a caller may legitimately take over a subset of hashers, this is the complete member-root child set the polydigest binding-root fold commits. Folding over a truncated child list would yield a combined root no algorithm published, so a missing hasher is an error, never a silent skip. See Self::member_roots for the bag contract.

§Errors

Returns Error::MissingHasher (naming the algorithm) if any algorithm with a frontier in this seal has no hasher in hashers.

Source

pub fn run_extents(&self) -> Vec<RunExtent>

Derived view. The committed canonicalization run-extents: the height >= 1 nodes of the frontier at the sealed size, in left-to-right order. Derived from (tree_size, arity) alone — never inferred from a digest. Promotions (height-0 frontier nodes) commit nothing and are omitted.

Trait Implementations§

Source§

impl Clone for Seal

Source§

fn clone(&self) -> Seal

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Seal

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Seal

Source§

impl PartialEq for Seal

Source§

fn eq(&self, other: &Seal) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Seal

Auto Trait Implementations§

§

impl Freeze for Seal

§

impl RefUnwindSafe for Seal

§

impl Send for Seal

§

impl Sync for Seal

§

impl Unpin for Seal

§

impl UnsafeUnpin for Seal

§

impl UnwindSafe for Seal

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.