Skip to main content

ChallengeStore

Trait ChallengeStore 

Source
pub trait ChallengeStore {
    // Required methods
    fn issue(
        &self,
        session_context: &[u8],
        ttl_seconds: i64,
    ) -> Result<(Vec<u8>, i64), String>;
    fn validate(
        &self,
        challenge: &[u8],
        session_context: &[u8],
        now: i64,
    ) -> Result<(), String>;
    fn consume(
        &self,
        challenge: &[u8],
        session_context: &[u8],
        now: i64,
    ) -> Result<(), String>;
}
Expand description

Tracks verifier-issued challenges so each is accepted at most once within its freshness window (SPEC §10).

Required Methods§

Source

fn issue( &self, session_context: &[u8], ttl_seconds: i64, ) -> Result<(Vec<u8>, i64), String>

Generate a fresh challenge bound to session_context (which must be empty or exactly 32 bytes; empty = unbound), valid for ttl_seconds (which must be positive). Returns the challenge and its expiry (unix seconds).

Source

fn validate( &self, challenge: &[u8], session_context: &[u8], now: i64, ) -> Result<(), String>

Report whether challenge could be consumed right now — issued, unexpired, unconsumed, and bound to session_context — WITHOUT consuming it. verify_bundle calls this before any signature work.

Source

fn consume( &self, challenge: &[u8], session_context: &[u8], now: i64, ) -> Result<(), String>

Atomically remove the challenge’s issuance record. Exactly one consume of a given challenge may ever succeed; all later calls (and calls with a mismatched session_context, which do NOT remove the record) return an error. Removing the record keeps the store’s capacity a count of PENDING challenges — a consumed challenge frees its slot immediately.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T: ChallengeStore + ?Sized> ChallengeStore for &T

Source§

fn issue( &self, session_context: &[u8], ttl_seconds: i64, ) -> Result<(Vec<u8>, i64), String>

Source§

fn validate( &self, challenge: &[u8], session_context: &[u8], now: i64, ) -> Result<(), String>

Source§

fn consume( &self, challenge: &[u8], session_context: &[u8], now: i64, ) -> Result<(), String>

Implementors§