Struct benaloh_challenge::RecordingRng
source · pub struct RecordingRng<'a, R: Rng> { /* private fields */ }
Expand description
This recording RNG wraps a real RNG and records the random data as it is passed to the caller
When it is dropped, the recording RNG calls zeroize()
to zero the recorded data in memory.
Implementations§
source§impl<'a, R: Rng> RecordingRng<'a, R>
impl<'a, R: Rng> RecordingRng<'a, R>
sourcepub fn fetch_recorded(&mut self) -> Vec<u8>
pub fn fetch_recorded(&mut self) -> Vec<u8>
Fetch the recorded bytes. This consumes the recording RNG so it may no longer be used.
sourcepub fn into_playback(self) -> PlaybackRng
pub fn into_playback(self) -> PlaybackRng
Transform the recording RNG into a PlaybackRng for playback in check_commitment
.
This comsumes the recording RNG so it may no longer be used.
Trait Implementations§
source§impl<'a, R: Rng> RngCore for RecordingRng<'a, R>
impl<'a, R: Rng> RngCore for RecordingRng<'a, R>
source§fn fill_bytes(&mut self, dest: &mut [u8])
fn fill_bytes(&mut self, dest: &mut [u8])
Fill
dest
with random data. Read moreimpl<'a, R: RngCore + CryptoRng> CryptoRng for RecordingRng<'a, R>
Auto Trait Implementations§
impl<'a, R> RefUnwindSafe for RecordingRng<'a, R>where
R: RefUnwindSafe,
impl<'a, R> Send for RecordingRng<'a, R>where
R: Send,
impl<'a, R> Sync for RecordingRng<'a, R>where
R: Sync,
impl<'a, R> Unpin for RecordingRng<'a, R>
impl<'a, R> !UnwindSafe for RecordingRng<'a, R>
Blanket Implementations§
source§impl<T> CryptoRngCore for Twhere
T: CryptoRng + RngCore,
impl<T> CryptoRngCore for Twhere
T: CryptoRng + RngCore,
source§fn as_rngcore(&mut self) -> &mut dyn RngCore
fn as_rngcore(&mut self) -> &mut dyn RngCore
Upcast to an
RngCore
trait object.source§impl<R> Rng for Rwhere
R: RngCore + ?Sized,
impl<R> Rng for Rwhere
R: RngCore + ?Sized,
source§fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
fn gen<T>(&mut self) -> Twhere
Standard: Distribution<T>,
source§fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
fn gen_range<T, R>(&mut self, range: R) -> Twhere
T: SampleUniform,
R: SampleRange<T>,
Generate a random value in the given range. Read more
source§fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
fn sample<T, D>(&mut self, distr: D) -> Twhere
D: Distribution<T>,
Sample a new value, using the given distribution. Read more
source§fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
fn sample_iter<T, D>(self, distr: D) -> DistIter<D, Self, T>where
D: Distribution<T>,
Self: Sized,
Create an iterator that generates values using the given distribution. Read more
source§fn gen_bool(&mut self, p: f64) -> bool
fn gen_bool(&mut self, p: f64) -> bool
Return a bool with a probability
p
of being true. Read moresource§fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool
Return a bool with a probability of
numerator/denominator
of being
true. I.e. gen_ratio(2, 3)
has chance of 2 in 3, or about 67%, of
returning true. If numerator == denominator
, then the returned value
is guaranteed to be true
. If numerator == 0
, then the returned
value is guaranteed to be false
. Read more