Skip to main content

ProofVerifier

Struct ProofVerifier 

Source
pub struct ProofVerifier<const N: usize> { /* private fields */ }
Expand description

Three-layer proof verifier.

Encapsulates the epoch and nonce tracker needed for P1/P2/P3 verification.

Implementations§

Source§

impl<const N: usize> ProofVerifier<N>

Source

pub const fn new(epoch: u32) -> Self

Creates a new proof verifier with the given epoch.

By default, nonce == 0 is rejected (no zero-nonce bypass). Use set_allow_zero_nonce to enable the sentinel behaviour for boot-time contexts.

Source

pub fn set_allow_zero_nonce(&mut self, allow: bool)

Set whether nonce == 0 is allowed to bypass replay checks.

Source

pub fn set_epoch(&mut self, epoch: u32)

Updates the current epoch.

Source

pub fn verify_p1( &self, table: &CapabilityTable<N>, cap_index: u32, cap_generation: u32, required_rights: CapRights, ) -> Result<(), ProofError>

P1: Capability existence + rights check.

Budget: < 1 us. No allocation. All checks execute regardless of intermediate failures to prevent timing side-channel leakage. The final error returned is deliberately the most generic (InvalidHandle) to avoid leaking which check failed.

§Errors

Returns ProofError::InvalidHandle if the handle is invalid. Returns ProofError::StaleCapability if the epoch does not match. Returns ProofError::InsufficientRights if the rights are insufficient.

Source

pub fn verify_p2( &mut self, table: &CapabilityTable<N>, tree: &DerivationTree<N>, cap_index: u32, cap_generation: u32, ctx: &PolicyContext, ) -> Result<(), ProofError>

P2: Structural invariant validation (constant-time).

Budget: < 100 us. All checks execute regardless of intermediate failures to prevent timing side-channel leakage (ADR-135).

Checks: ownership chain, region bounds, lease expiry, delegation depth, nonce replay.

§Errors

Returns ProofError::PolicyViolation if any structural check fails.

Source

pub fn verify_p3( &self, table: &CapabilityTable<N>, tree: &DerivationTree<N>, cap_index: u32, cap_generation: u32, max_depth: u8, ) -> Result<(), ProofError>

P3: Deep proof — derivation chain integrity verification.

Walks the derivation tree from the given capability back to its root and verifies:

  1. Every ancestor is valid (not revoked).
  2. Depth decreases monotonically toward the root.
  3. Epoch values are non-decreasing from root to leaf.
  4. The chain terminates at a root node (depth 0).
  5. The chain length does not exceed max_depth.

Budget: < 10 us for depth <= 8 (typical). Worst-case O(depth).

§Errors

Returns ProofError::DerivationChainBroken if the chain is invalid, tampered, or does not reach a root.

Auto Trait Implementations§

§

impl<const N: usize> Freeze for ProofVerifier<N>

§

impl<const N: usize> RefUnwindSafe for ProofVerifier<N>

§

impl<const N: usize> Send for ProofVerifier<N>

§

impl<const N: usize> Sync for ProofVerifier<N>

§

impl<const N: usize> Unpin for ProofVerifier<N>

§

impl<const N: usize> UnsafeUnpin for ProofVerifier<N>

§

impl<const N: usize> UnwindSafe for ProofVerifier<N>

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, 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.