Skip to main content

MacAccumulator

Struct MacAccumulator 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn finish(self) -> Mac

Finish the digest. fmt.Sprintf("%X", …) — uppercase, 128 chars.

Auto Trait Implementations§

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> 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> Same for T

Source§

type Output = T

Should always be Self
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.