sigma_rs/duplex_sponge/mod.rs
1//! Duplex Sponge Interface
2//!
3//! This module defines the [`DuplexSpongeInterface`] trait, which provides
4//! a generic interface for cryptographic sponge functions that support
5//! duplex operations: alternating absorb and squeeze phases.
6
7pub mod keccak;
8pub mod shake;
9
10/// A trait defining the behavior of a duplex sponge construction.
11///
12/// A duplex sponge allows for:
13/// - **Absorbing** input data into the sponge state
14/// - **Squeezing** output data from the sponge state
15///
16/// This is the core primitive used for building cryptographic codecs.
17pub trait DuplexSpongeInterface {
18 /// Creates a new sponge instance with a given initialization vector (IV).
19 ///
20 /// The IV enables domain separation and reproducibility between parties.
21 fn new(iv: [u8; 32]) -> Self;
22
23 /// Absorbs input data into the sponge state.
24 fn absorb(&mut self, input: &[u8]);
25
26 /// Squeezes output data from the sponge state.
27 fn squeeze(&mut self, length: usize) -> Vec<u8>;
28
29 /// Applies a state ratcheting mechanism to prevent backtracking attacks.
30 fn ratchet(&mut self);
31}