pub struct MultiField32Challenger<F, PF, P, const WIDTH: usize, const RATE: usize>{ /* private fields */ }Expand description
A challenger that samples in F: PrimeField32 while the transcript sponge lives in PF.
Wraps DuplexChallenger<PF>: all permutations and PF rate state are
exactly those of inner. This type only adapts
F→PF: pending scalars are packed withreduce_packed(radix $2^{\texttt{absorb_radix_bits::()}}$) into up to RATEPFrate slots, thenDuplexChallenger::absorb_rate_padded_with_tagruns (zero-padded tail, length tag = number ofFs absorbed).PF→F: after each duplex, each rate cell is split withsplit_pf_to_field_order_limbs(base|F|,squeeze_field_order_num_limbslimbs per cell) into a flat queue consumed byCanSample::sample. Each extracted limb is uniform over the entireFdomain (bias< 1/|F|). The inneroutput_bufferis then cleared so the next empty batch triggers a new duplex likeDuplexChallenger::sample.
observe(Hash) / observe(MerkleCap) flush pending Fs through that packed absorb, then
absorb digest words natively via the same absorb_rate_padded_with_tag (length tag = number of
PF words in the block)—no PF → F → repack detour.
Implementations§
Source§impl<F, PF, P, const WIDTH: usize, const RATE: usize> MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> MultiField32Challenger<F, PF, P, WIDTH, RATE>
Sourcepub const fn absorb_radix_bits(&self) -> u32
pub const fn absorb_radix_bits(&self) -> u32
Radix bit-width $b$ for packing observed F values via reduce_packed: the smallest
b with F::ORDER_U32 - 1 < 2^b (see p3_field::absorb_radix_bits).
Sourcepub fn absorb_num_f_elms(&self) -> usize
pub fn absorb_num_f_elms(&self) -> usize
Maximum number of F elements packed into a single PF rate slot injectively (see
p3_field::max_absorb_injective_limbs). Pending scalars are absorbed in chunks of this
size; at most RATE such packed words are written per duplex step.
Sourcepub fn squeeze_num_f_elms(&self) -> usize
pub fn squeeze_num_f_elms(&self) -> usize
Number of base-|F| limbs taken from each squeezed PF rate cell when refilling the
F queue (see p3_field::squeeze_field_order_num_limbs and
p3_field::split_pf_to_field_order_limbs). Chooses near-uniform limbs over F for
uniform PF.
Sourcepub const fn pending_f_squeeze_len(&self) -> usize
pub const fn pending_f_squeeze_len(&self) -> usize
Number of F challenges still queued from the current squeeze batch (after sample pops).
pub fn new(permutation: P) -> Result<Self, String>
Trait Implementations§
Source§impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanFinalizeDigest for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanFinalizeDigest for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§type Digest = [PF; RATE]
type Digest = [PF; RATE]
Source§fn finalize(self) -> [PF; RATE]
fn finalize(self) -> [PF; RATE]
Source§impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<&MerkleCap<F, [PF; N]>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<&MerkleCap<F, [PF; N]>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<[F; N]> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<[F; N]> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanObserve<F> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanObserve<F> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<Hash<F, PF, N>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<Hash<F, PF, N>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<MerkleCap<F, [PF; N]>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, const N: usize, P, const WIDTH: usize, const RATE: usize> CanObserve<MerkleCap<F, [PF; N]>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanObserve<Vec<Vec<F>>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanObserve<Vec<Vec<F>>> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§impl<F, EF, PF, P, const WIDTH: usize, const RATE: usize> CanSample<EF> for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
F: PrimeField32,
EF: BasedVectorSpace<F>,
PF: PrimeField,
P: CryptographicPermutation<[PF; WIDTH]>,
impl<F, EF, PF, P, const WIDTH: usize, const RATE: usize> CanSample<EF> for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
F: PrimeField32,
EF: BasedVectorSpace<F>,
PF: PrimeField,
P: CryptographicPermutation<[PF; WIDTH]>,
Source§fn sample_array<const N: usize>(&mut self) -> [T; N]
fn sample_array<const N: usize>(&mut self) -> [T; N]
N challenge values from the transcript.Source§fn sample_vec(&mut self, n: usize) -> Vec<T>
fn sample_vec(&mut self, n: usize) -> Vec<T>
Vec of n challenge values from the transcript.Source§impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanSampleBits<usize> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> CanSampleBits<usize> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§fn sample_bits(&mut self, bits: usize) -> usize
fn sample_bits(&mut self, bits: usize) -> usize
The sampled bits are not perfectly uniform, but we can bound the error: every sequence appears with probability 1/p-close to uniform (1/2^b).
Proof:
We denote p = F::ORDER_U32, and b = bits.
If X follows a uniform distribution over F, if we consider the first b bits of X, each
sequence appears either with probability P1 = ⌊p / 2^b⌋ / p or P2 = (1 + ⌊p / 2^b⌋) / p.
We have 1/2^b - 1/p ≤ P1, P2 ≤ 1/2^b + 1/p
Source§impl<F, PF, P, const WIDTH: usize, const RATE: usize> Clone for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
F: PrimeField32 + Clone,
PF: PrimeField + Clone,
P: CryptographicPermutation<[PF; WIDTH]> + Clone,
impl<F, PF, P, const WIDTH: usize, const RATE: usize> Clone for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
F: PrimeField32 + Clone,
PF: PrimeField + Clone,
P: CryptographicPermutation<[PF; WIDTH]> + Clone,
Source§fn clone(&self) -> MultiField32Challenger<F, PF, P, WIDTH, RATE>
fn clone(&self) -> MultiField32Challenger<F, PF, P, WIDTH, RATE>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F, PF, P, const WIDTH: usize, const RATE: usize> Debug for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
F: PrimeField32 + Debug,
PF: PrimeField + Debug,
P: CryptographicPermutation<[PF; WIDTH]> + Debug,
impl<F, PF, P, const WIDTH: usize, const RATE: usize> Debug for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
F: PrimeField32 + Debug,
PF: PrimeField + Debug,
P: CryptographicPermutation<[PF; WIDTH]> + Debug,
Source§impl<F, PF, P, const WIDTH: usize, const RATE: usize> FieldChallenger<F> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> FieldChallenger<F> for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Source§fn observe_algebra_element<A: BasedVectorSpace<F>>(&mut self, alg_elem: A)
fn observe_algebra_element<A: BasedVectorSpace<F>>(&mut self, alg_elem: A)
Source§fn observe_algebra_slice<A: BasedVectorSpace<F> + Clone>(
&mut self,
alg_elems: &[A],
)
fn observe_algebra_slice<A: BasedVectorSpace<F> + Clone>( &mut self, alg_elems: &[A], )
Source§fn sample_algebra_element<A: BasedVectorSpace<F>>(&mut self) -> A
fn sample_algebra_element<A: BasedVectorSpace<F>>(&mut self) -> A
Source§fn observe_base_as_algebra_element<EF>(&mut self, val: F)where
EF: Algebra<F> + BasedVectorSpace<F>,
fn observe_base_as_algebra_element<EF>(&mut self, val: F)where
EF: Algebra<F> + BasedVectorSpace<F>,
Auto Trait Implementations§
impl<F, PF, P, const WIDTH: usize, const RATE: usize> Freeze for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> RefUnwindSafe for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> Send for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
P: Send,
impl<F, PF, P, const WIDTH: usize, const RATE: usize> Sync for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> Unpin for MultiField32Challenger<F, PF, P, WIDTH, RATE>
impl<F, PF, P, const WIDTH: usize, const RATE: usize> UnsafeUnpin for MultiField32Challenger<F, PF, P, WIDTH, RATE>where
P: UnsafeUnpin,
PF: UnsafeUnpin,
impl<F, PF, P, const WIDTH: usize, const RATE: usize> UnwindSafe for MultiField32Challenger<F, PF, P, WIDTH, RATE>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more