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
impl Seal
Sourcepub fn new(
tree_size: u64,
arity: u64,
frontiers: Vec<(u64, Vec<Vec<u8>>)>,
) -> Result<Seal, Error>
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).
Sourcepub fn with_meta(self, meta: Meta) -> Seal
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.
Sourcepub fn frontiers(&self) -> &[(u64, Vec<Vec<u8>>)]
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).
Sourcepub fn peaks(&self, alg_id: u64) -> Option<&[Vec<u8>]>
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.
Sourcepub fn meta(&self) -> Option<&Meta>
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.
Sourcepub fn member_roots(
&self,
hashers: &[(u64, &dyn Hasher)],
bag: fn(&dyn Hasher, &[Vec<u8>], u64) -> Vec<u8>,
) -> Vec<(u64, Vec<u8>)>
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).
Sourcepub fn member_root(
&self,
alg_id: u64,
hasher: &dyn Hasher,
bag: fn(&dyn Hasher, &[Vec<u8>], u64) -> Vec<u8>,
) -> Option<Vec<u8>>
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.
Sourcepub fn all_member_roots(
&self,
hashers: &[(u64, &dyn Hasher)],
bag: fn(&dyn Hasher, &[Vec<u8>], u64) -> Vec<u8>,
) -> Result<Vec<(u64, Vec<u8>)>, Error>
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.
Sourcepub fn run_extents(&self) -> Vec<RunExtent>
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.