pub struct DeterministicSeeder<G: ByteRandomGenerator> { /* private fields */ }Expand description
Seeder backed by a CSPRNG
§Why this Seeder implementation?
Seeder is a trait available to the external user, and we expect some of them to implement
their own seeding strategy. Since this trait is public, it means that the implementer can be
arbitrarily slow. For this reason, it is better to only use it once when we initialize the
engine, and use the CSPRNG to generate other seeds when needed, because that gives us the
control on the performances.
§Is it safe?
The answer to this question is the following: as long as the CSPRNG used in this Seeder is
seeded with a Seed coming from an entropy source then yes, seeding other CSPRNGs using this
CSPRNG is safe.
§Why is it deterministic?
A CSPRNG is a Cryptograhically Secure Pseudo Random Number Generator.
Cryptographically Secure means that if one looks at the numbers it outputs, it looks exactly like numbers drawn from a random distribution, this property is also known as “indistinguishable from random”. Here our CSPRNG outputs numbers uniformly so each value for a byte should appear with the same probability.
Pseudo Random indicates that for the same initial state (here Seed) it will generate the same exact set of numbers in the same order, making it deterministic.
Implementations§
Source§impl<G: ByteRandomGenerator> DeterministicSeeder<G>
impl<G: ByteRandomGenerator> DeterministicSeeder<G>
Trait Implementations§
Source§impl<G: ByteRandomGenerator> Seeder for DeterministicSeeder<G>
impl<G: ByteRandomGenerator> Seeder for DeterministicSeeder<G>
Auto Trait Implementations§
impl<G> Freeze for DeterministicSeeder<G>where
G: Freeze,
impl<G> RefUnwindSafe for DeterministicSeeder<G>where
G: RefUnwindSafe,
impl<G> Send for DeterministicSeeder<G>where
G: Send,
impl<G> Sync for DeterministicSeeder<G>where
G: Sync,
impl<G> Unpin for DeterministicSeeder<G>where
G: Unpin,
impl<G> UnwindSafe for DeterministicSeeder<G>where
G: UnwindSafe,
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> 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