use super::Unit;
pub trait DuplexSpongeInterface<U = u8>: Default + Clone + zeroize::Zeroize
where
U: Unit,
{
fn new(iv: [u8; 32]) -> Self;
fn absorb_unchecked(&mut self, input: &[U]) -> &mut Self;
fn squeeze_unchecked(&mut self, output: &mut [U]) -> &mut Self;
fn ratchet_unchecked(&mut self) -> &mut Self;
}
impl Unit for u8 {
fn write(bunch: &[Self], w: &mut impl std::io::Write) -> Result<(), std::io::Error> {
w.write_all(bunch)
}
fn read(r: &mut impl std::io::Read, bunch: &mut [Self]) -> Result<(), std::io::Error> {
r.read_exact(bunch)
}
}