pub struct ChainStreamVerifier { /* private fields */ }Expand description
Streaming chain verifier that resolves the key epoch incrementally from the first chained entry it sees, without requiring the caller to buffer the whole chained region in memory.
Before the epoch is resolved, every candidate epoch in the ChainKeyRing is tried against
each incoming entry in parallel (at most 2: current + previous — a small, fixed, O(1) memory
cost independent of file size); once exactly one candidate’s genesis produces a valid link,
verification collapses to a single incremental ChainVerifier for the rest of the stream.
This lets zeph-session’s read_chunked verify a
replay-trusted log’s chain without materializing the whole file — the same bounded-memory
shape its chunked read already provides for the torn-tail check.
Implementations§
Source§impl ChainStreamVerifier
impl ChainStreamVerifier
Sourcepub fn new(
ring: &ChainKeyRing,
domain: impl Into<String>,
file_identity: impl Into<Vec<u8>>,
) -> Self
pub fn new( ring: &ChainKeyRing, domain: impl Into<String>, file_identity: impl Into<Vec<u8>>, ) -> Self
Start a streaming verifier for one chained region.
Sourcepub fn verify_next(
&mut self,
content: &[u8],
stored: &ChainHash,
) -> Result<(), ChainError>
pub fn verify_next( &mut self, content: &[u8], stored: &ChainHash, ) -> Result<(), ChainError>
Verify the next entry in on-disk order, resolving the key epoch on the first call.
§Errors
Returns ChainError::Unverifiable on the first call if no candidate epoch’s genesis
produces a valid link, or ChainError::Mismatch on any call once the epoch is resolved
and a later entry breaks the chain.
Sourcepub fn head(&self) -> Option<ChainHash>
pub fn head(&self) -> Option<ChainHash>
The verified head hash, once at least one entry has been verified.
Sourcepub fn resolution(&self) -> Option<KeyResolution>
pub fn resolution(&self) -> Option<KeyResolution>
How the key epoch was resolved, once at least one entry has been verified.