pub struct ChainVerifier { /* private fields */ }Expand description
Incremental form of verify_chain, for callers that stream the
audit log rather than materialising it.
A full audit log does not fit comfortably in memory on a busy
community, and the verification is a strict left fold — each
envelope needs only its predecessor’s entry_hash. Feeding
envelopes in ascending write order through Self::push keeps
memory constant regardless of log size.
The fold state is just (prev_hash, index), so verification can
also be resumed across pages via Self::resume — pass the
Self::head and Self::index returned by the previous page.
A resumed verifier is only as trustworthy as the head it is given:
resuming from a head an adversary supplied verifies nothing about
the entries before it.
Implementations§
Source§impl ChainVerifier
impl ChainVerifier
Sourcepub fn new() -> Self
pub fn new() -> Self
Start at the genesis anchor — the first v2+ envelope pushed
must carry GENESIS_HASH as its prev_hash.
Sourcepub fn resume(head: [u8; 32], index: usize) -> Self
pub fn resume(head: [u8; 32], index: usize) -> Self
Resume from a previously-returned Self::head and
Self::index, so a page of envelopes can be verified as a
continuation of the page before it.
Sourcepub fn push(&mut self, env: &AuditEnvelope) -> Result<(), ChainBreak>
pub fn push(&mut self, env: &AuditEnvelope) -> Result<(), ChainBreak>
Verify one envelope as the successor of everything pushed so far. Envelopes must arrive in ascending write order.
On Err the verifier is left at the breaking entry and must
not be reused — the chain past a break carries no meaning.
Sourcepub fn head(&self) -> Option<[u8; 32]>
pub fn head(&self) -> Option<[u8; 32]>
entry_hash of the last verified v2+ envelope — the head of
the chain so far. None if nothing chainable has been pushed.
Sourcepub fn index(&self) -> usize
pub fn index(&self) -> usize
Number of envelopes pushed, chainable or not. Pass to
Self::resume so a continuation reports absolute indices.
Sourcepub fn skipped_legacy(&self) -> usize
pub fn skipped_legacy(&self) -> usize
Count of pre-v2 envelopes skipped as unchainable.
Read this, don’t ignore it. Legacy rows are skipped rather
than verified, so they are an insertion point: a forged
envelope marked schema_version: 1 passes untouched. A store
that should hold no legacy rows reporting a non-zero count
here is itself the finding.
Trait Implementations§
Source§impl Clone for ChainVerifier
impl Clone for ChainVerifier
Source§fn clone(&self) -> ChainVerifier
fn clone(&self) -> ChainVerifier
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ChainVerifier
impl Debug for ChainVerifier
Auto Trait Implementations§
impl Freeze for ChainVerifier
impl RefUnwindSafe for ChainVerifier
impl Send for ChainVerifier
impl Sync for ChainVerifier
impl Unpin for ChainVerifier
impl UnsafeUnpin for ChainVerifier
impl UnwindSafe for ChainVerifier
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> BorrowUnordered for T
impl<T> BorrowUnordered for T
fn as_unordered(&self) -> &Unordered<T>
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
impl<T> Clear for Twhere
T: InitializableFromZeroed + ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> InitializableFromZeroed for Twhere
T: Default,
impl<T> InitializableFromZeroed for Twhere
T: Default,
Source§unsafe fn initialize(place: *mut T)
unsafe fn initialize(place: *mut T)
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
impl<T, U, C> IntoWithContext<U, C> for Twhere
U: FromWithContext<T, C>,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<T> ResourceProvider<()> for T
impl<T> ResourceProvider<()> for T
Source§fn get_resource(&self) -> &()
fn get_resource(&self) -> &()
T.