pub trait AlgebraicSponge<F: PrimeField, const RATE: usize>: Clone + Debug {
type Parameters;
// Required methods
fn sample_parameters() -> Self::Parameters;
fn new_with_parameters(params: &Self::Parameters) -> Self;
fn absorb_native_field_elements<T: ToConstraintField<F>>(
&mut self,
elements: &[T]
);
fn absorb_nonnative_field_elements<Target: PrimeField>(
&mut self,
elements: impl IntoIterator<Item = Target>
);
fn squeeze_native_field_elements(&mut self, num: usize) -> SmallVec<[F; 10]>;
fn squeeze_nonnative_field_elements<Target: PrimeField>(
&mut self,
num: usize
) -> SmallVec<[Target; 10]>;
fn squeeze_short_nonnative_field_elements<Target: PrimeField>(
&mut self,
num: usize
) -> SmallVec<[Target; 10]>;
// Provided methods
fn new() -> Self { ... }
fn absorb_bytes(&mut self, elements: &[u8]) { ... }
fn squeeze_short_nonnative_field_element<Target: PrimeField>(
&mut self
) -> Target { ... }
}
Expand description
The interface for a cryptographic sponge.
A sponge can absorb
or take in inputs and later squeeze
or output bytes or field elements.
The outputs are dependent on previous absorb
and squeeze
calls.
Required Associated Types§
sourcetype Parameters
type Parameters
Parameters used by the sponge.
Required Methods§
fn sample_parameters() -> Self::Parameters
sourcefn new_with_parameters(params: &Self::Parameters) -> Self
fn new_with_parameters(params: &Self::Parameters) -> Self
Initialize a new instance of the sponge.
sourcefn absorb_native_field_elements<T: ToConstraintField<F>>(
&mut self,
elements: &[T]
)
fn absorb_native_field_elements<T: ToConstraintField<F>>( &mut self, elements: &[T] )
Takes in field elements.
sourcefn absorb_nonnative_field_elements<Target: PrimeField>(
&mut self,
elements: impl IntoIterator<Item = Target>
)
fn absorb_nonnative_field_elements<Target: PrimeField>( &mut self, elements: impl IntoIterator<Item = Target> )
Takes in field elements.
sourcefn squeeze_native_field_elements(&mut self, num: usize) -> SmallVec<[F; 10]>
fn squeeze_native_field_elements(&mut self, num: usize) -> SmallVec<[F; 10]>
Takes in field elements.
sourcefn squeeze_nonnative_field_elements<Target: PrimeField>(
&mut self,
num: usize
) -> SmallVec<[Target; 10]>
fn squeeze_nonnative_field_elements<Target: PrimeField>( &mut self, num: usize ) -> SmallVec<[Target; 10]>
Takes out field elements.
sourcefn squeeze_short_nonnative_field_elements<Target: PrimeField>(
&mut self,
num: usize
) -> SmallVec<[Target; 10]>
fn squeeze_short_nonnative_field_elements<Target: PrimeField>( &mut self, num: usize ) -> SmallVec<[Target; 10]>
Takes out field elements of 168 bits.
Provided Methods§
sourcefn absorb_bytes(&mut self, elements: &[u8])
fn absorb_bytes(&mut self, elements: &[u8])
Takes in bytes.
sourcefn squeeze_short_nonnative_field_element<Target: PrimeField>(
&mut self
) -> Target
fn squeeze_short_nonnative_field_element<Target: PrimeField>( &mut self ) -> Target
Takes out a field element of 168 bits.
Object Safety§
This trait is not object safe.