Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/guide-rngs.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,10 @@ You may wish to refer to the [pcg-random] and [xoshiro] websites.

| name | full name | performance | memory | quality | period | features |
|------|-----------|-------------|--------|---------|--------|----------|
| [`SmallRng`] | (unspecified) | 11 GB/s | 16 bytes | ★★★☆☆ | ≥ `u32` * 2<sup>64</sup> | not portable |
| [`Pcg32`] | PCG XSH RR 64/32 (LCG) | 5 GB/s | 16 bytes | ★★★☆☆ | `u32` * 2<sup>64</sup> | |
| [`Pcg64`] | PCG XSL 128/64 (LCG) | 7 GB/s | 32 bytes | ★★★☆☆ | `u64` * 2<sup>128</sup> | |
| [`Pcg64Mcg`] | PCG XSL 128/64 (MCG) | 8 GB/s | 16 bytes | ★★★☆☆ | `u64` * 2<sup>126</sup> | |
| [`SmallRng`] | (unspecified) | (unspecified) | (unspecified) | ★★★☆☆ | ≥ `u32` * 2<sup>64</sup> | not portable |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The purpose of SmallRng is to be a fast, low-memory PRNG. Maybe we should use inspecific words like 'fast', 'small' here? Or 'competitive'?

| [`Pcg32`] | PCG XSH RR 64/32 (LCG) | 5 GB/s | 16 bytes | ★★★☆☆ | `u32` * 2<sup>64</sup> | jump-ahead |
| [`Pcg64`] | PCG XSL 128/64 (LCG) | 7 GB/s | 32 bytes | ★★★☆☆ | `u64` * 2<sup>128</sup> | jump-ahead |
| [`Pcg64Mcg`] | PCG XSL 128/64 (MCG) | 8 GB/s | 16 bytes | ★★★☆☆ | `u64` * 2<sup>126</sup> | jump-ahead |
| [`XorShiftRng`] | Xorshift 32/128 | 7 GB/s | 16 bytes | ★☆☆☆☆ | `u32` * 2<sup>128</sup> - 1 | — |
| [`Xoshiro256PlusPlus`] | Xoshiro256++ | 11 GB/s | 32 bytes | ★★★☆☆ | `u64` * 2<sup>256</sup> - 1 | jump-ahead |
| [`Xoshiro256Plus`] | Xoshiro256+ | 13 GB/s | 32 bytes | ★★☆☆☆ | `u64` * 2<sup>256</sup> - 1 | jump-ahead |
Expand Down Expand Up @@ -79,9 +79,10 @@ table since CSPRNGs may not have observable defects.

| name | full name | performance | initialization | memory | security (predictability) | forward secrecy |
|------|-----------|--------------|--------------|----------|----------------|-------------------------|
| [`StdRng`] | (unspecified) | 4.1 GB/s | fast | 136 bytes | widely trusted | no |
| [`StdRng`] | (unspecified) | (unspecified) | fast | (unspecified) | widely trusted | no |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, performance is part of the selection criteria so could write 'fast'.

| [`ChaCha20Rng`] | ChaCha20 | 2.6 GB/s | fast | 136 bytes | [rigorously analysed](https://tools.ietf.org/html/rfc7539#section-1) | no |
| [`ChaCha8Rng`] | ChaCha8 | 5.8 GB/s | fast | 136 bytes | small security margin | no |
| [`ChaCha12Rng`] | ChaCha12 | 4.1 GB/s | fast | 136 bytes | [large security margin](https://eprint.iacr.org/2019/1492) | no |
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I measure the size as 320 bytes now. I recall that the buffer size has been increased to better support some SIMD backends. This size is untested in the stream-ciphers repo.

Update this to 320 with a footnote clarifying that it may change?

| [`ChaCha8Rng`] | ChaCha8 | 5.8 GB/s | fast | 136 bytes | [sufficient security margin](https://eprint.iacr.org/2019/1492) | no |
| [`Hc128Rng`] | HC-128 | 4.6 GB/s | slow | 4176 bytes | [recommended by eSTREAM](http://www.ecrypt.eu.org/stream/) | no |
| [`IsaacRng`] | ISAAC | 2.1 GB/s | slow | 2072 bytes | [unknown](https://burtleburtle.net/bob/rand/isaacafa.html) | unknown |
| [`Isaac64Rng`] | ISAAC-64 | 3.7 GB/s | slow | 4136 bytes| unknown | unknown |
Expand Down Expand Up @@ -322,6 +323,7 @@ by P. Hellekalek.
[`Xoshiro256Plus`]: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.Xoshiro256Plus.html
[`SplitMix64`]: https://docs.rs/rand_xoshiro/latest/rand_xoshiro/struct.SplitMix64.html
[`ChaCha20Rng`]: https://docs.rs/chacha20/latest/chacha20/struct.ChaCha20Rng.html
[`ChaCha12Rng`]: https://docs.rs/chacha20/latest/chacha20/struct.ChaCha12Rng.html
[`ChaCha8Rng`]: https://docs.rs/chacha20/latest/chacha20/struct.ChaCha8Rng.html
[`Hc128Rng`]: https://docs.rs/rand_hc/latest/rand_hc/struct.Hc128Rng.html
[`IsaacRng`]: https://docs.rs/rand_isaac/latest/rand_isaac/isaac/struct.IsaacRng.html
Expand Down