Skip to main content

sigma_proofs/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
7use alloc::vec::Vec;
8
9pub mod keccak;
10pub mod shake;
11
12/// A trait defining the behavior of a duplex sponge construction.
13///
14/// A duplex sponge allows for:
15/// - **Absorbing** input data into the sponge state
16/// - **Squeezing** output data from the sponge state
17///
18/// This is the core primitive used for building cryptographic codecs.
19pub trait DuplexSpongeInterface {
20    /// Creates a new sponge instance with a given initialization vector (IV).
21    ///
22    /// The IV enables domain separation and reproducibility between parties.
23    fn new(iv: [u8; 64]) -> Self
24    where
25        Self: Sized;
26
27    /// Absorbs input data into the sponge state.
28    fn absorb(&mut self, input: &[u8]);
29
30    /// Squeezes output data from the sponge state.
31    fn squeeze(&mut self, length: usize) -> Vec<u8>;
32}