Skip to main content

Module rng

Module rng 

Source
Expand description

Random number generation.

For most purposes in Arti, we use one of two random number generators:

  • rand::rng() (formerly called rand::thread_rng(), up till rand 0.9)
  • The CautiousRng implemented here.

CautiousRng should be used whenever we are generating a medium- or long-term cryptographic key: one that will be stored to disk, or used for more than a single communication. It is slower than rand::rng(), but is more robust against several kinds of failure.

Re-exportsยง

use std::convert::Infallible; ๐Ÿ”’
use digest::ExtendableOutput; ๐Ÿ”’
use digest::Update; ๐Ÿ”’
use rand::rngs::SysRng; ๐Ÿ”’
use rand_core::TryRng; ๐Ÿ”’
use shake::Shake256; ๐Ÿ”’
use zeroize::Zeroizing; ๐Ÿ”’
pub use testing::FakeEntropicRng;

Modulesยง

backup ๐Ÿ”’
A backup RNG, independent of other known sources.
testing ๐Ÿ”’
Functionality for testing Rng code that requires an EntropicRng.

Structsยง

CautiousRng
An exceptionally cautious wrapper for SysRng

Traitsยง

EntropicRng
Trait representing an Rng where every output is derived from supposedly strong entropy.