1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//! Module containing primitives pertaining to random generation in the context of seeds generation.
use crate;
use AesCtrParams;
/// 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.