Trait ark_sponge::CryptographicSponge [−][src]
pub trait CryptographicSponge: Clone { type Parameters; fn new(params: &Self::Parameters) -> Self; fn absorb(&mut self, input: &impl Absorb); fn squeeze_bytes(&mut self, num_bytes: usize) -> Vec<u8>; fn squeeze_bits(&mut self, num_bits: usize) -> Vec<bool>; fn squeeze_field_elements_with_sizes<F: PrimeField>(
&mut self,
sizes: &[FieldElementSize]
) -> Vec<F> { ... } fn squeeze_field_elements<F: PrimeField>(
&mut self,
num_elements: usize
) -> Vec<F> { ... } fn fork(&self, domain: &[u8]) -> Self { ... } }
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.
Associated Types
type Parameters
[src]
type Parameters
[src]Parameters used by the sponge.
Required methods
fn new(params: &Self::Parameters) -> Self
[src]
fn new(params: &Self::Parameters) -> Self
[src]Initialize a new instance of the sponge.
fn squeeze_bytes(&mut self, num_bytes: usize) -> Vec<u8>
[src]
fn squeeze_bytes(&mut self, num_bytes: usize) -> Vec<u8>
[src]Squeeze num_bytes
bytes from the sponge.
fn squeeze_bits(&mut self, num_bits: usize) -> Vec<bool>
[src]
fn squeeze_bits(&mut self, num_bits: usize) -> Vec<bool>
[src]Squeeze num_bits
bits from the sponge.
Provided methods
fn squeeze_field_elements_with_sizes<F: PrimeField>(
&mut self,
sizes: &[FieldElementSize]
) -> Vec<F>
[src]
fn squeeze_field_elements_with_sizes<F: PrimeField>(
&mut self,
sizes: &[FieldElementSize]
) -> Vec<F>
[src]Squeeze sizes.len()
field elements from the sponge, where the i
-th element of
the output has size sizes[i]
.
If the implementation is field-based, to squeeze native field elements,
call self.squeeze_native_field_elements
instead.
TODO: Support general Field.
Note that when FieldElementSize
is FULL
, the output is not strictly uniform. Output
space is uniform in [0, 2^{F::MODULUS_BITS - 1}]
fn squeeze_field_elements<F: PrimeField>(
&mut self,
num_elements: usize
) -> Vec<F>
[src]
fn squeeze_field_elements<F: PrimeField>(
&mut self,
num_elements: usize
) -> Vec<F>
[src]Squeeze num_elements
nonnative field elements from the sponge.
Because of rust limitation, for field-based implementation, using this method to squeeze
native field elements will have runtime casting cost. For better efficiency, use squeeze_native_field_elements
.
Implementors
type Parameters = PoseidonParameters<F>
fn squeeze_field_elements_with_sizes<F2: PrimeField>(
&mut self,
sizes: &[FieldElementSize]
) -> Vec<F2>
[src]