pub struct MacAccumulator { /* private fields */ }Expand description
Accumulates leaf plaintexts into a file MAC, in walk order.
Construct with MacAccumulator::new, feed every non-comment leaf the
selector said to include, then MacAccumulator::finish.
Implementations§
Source§impl MacAccumulator
impl MacAccumulator
Sourcepub fn new(mac_only_encrypted: bool) -> Self
pub fn new(mac_only_encrypted: bool) -> Self
Start a MAC. mac_only_encrypted pre-seeds the digest and changes which
leaves the caller should feed.
Sourcepub fn mac_only_encrypted(&self) -> bool
pub fn mac_only_encrypted(&self) -> bool
Whether this accumulator is in mac_only_encrypted mode, so a walker can
ask rather than thread the flag separately.
Sourcepub fn feed(&mut self, plaintext: &Plaintext)
pub fn feed(&mut self, plaintext: &Plaintext)
Feed one leaf.
The caller owns the two policy decisions — comments are excluded, and
under mac_only_encrypted only leaves that end up encrypted count —
because both depend on the selector, which lives a layer up.
Sourcepub fn leaves_fed(&self) -> usize
pub fn leaves_fed(&self) -> usize
How many leaves were fed. The denominator.
A MAC over zero leaves is a perfectly valid SHA-512 and will happily match another MAC over zero leaves, so a walker that silently stopped finding leaves would verify green while checking nothing. Callers that gate on this MAC should assert the count is what they expect — the same anti-vacuity discipline the fleet’s Nix gates carry.