pub trait CanSampleUniformBits<F> {
// Required method
fn sample_uniform_bits<const RESAMPLE: bool>(
&mut self,
bits: usize,
) -> Result<usize, ResamplingError>;
}Expand description
Uniform bit sampling interface.
This trait provides a method for drawing uniformly distributed bitstrings from a Fiat–Shamir transcript. The goal is to obtain an integer supported on the range $[0, 2^{bits})$ with each value having equal probability.
Required Methods§
Sourcefn sample_uniform_bits<const RESAMPLE: bool>(
&mut self,
bits: usize,
) -> Result<usize, ResamplingError>
fn sample_uniform_bits<const RESAMPLE: bool>( &mut self, bits: usize, ) -> Result<usize, ResamplingError>
Sample a random bits-bit integer from the transcript with a guarantee of
uniformly sampled bits.
Performance overhead depends on the field and number of bits requested. E.g. for KoalaBear sampling up to 24 bits uniformly is essentially free.
If REJECTION_SAMPLE is set to true then this function will sample multiple field
elements until it finds one which will produce uniform bits.
If REJECTION_SAMPLE is set to false then this function will sample a single field
element and produce and error if the value would produce non-uniform bits.
The probability of a panic or a resample is about 1/P for most fields.
See UniformSamplingField implementation for each field for details.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".