Crate bc_rand

Crate bc_rand 

Source
Expand description

§Blockchain Commons Random Number Utilities

bc-rand exposes a uniform API for the random number primitives used in higher-level Blockchain Commons projects, including a cryptographically strong random number generator SecureRandomNumberGenerator and a deterministic random number generator SeededRandomNumberGenerator.

These primitive random number generators implement the RandomNumberGenerator trait to produce random numbers compatible with the RandomNumberGenerator Swift protocol used in MacOS and iOS, which is important when using the deterministic random number generator for cross-platform testing.

The crate also includes several convenience functions for generating secure and deterministic random numbers.

Structs§

SecureRandomNumberGenerator
A random number generator that can be used as a source of cryptographically-strong randomness.
SeededRandomNumberGenerator
A random number generator that can be used as a source of deterministic pseudo-randomness for testing purposes.

Traits§

RandomNumberGenerator

Functions§

fake_random_data
Creates a vector of random data with a fixed seed.
fill_random_data
Fill the given slice with cryptographically strong random bytes.
make_fake_random_number_generator
Creates a seeded random number generator with a fixed seed.
random_data
Generate a vector of cryptographically strong random bytes of the given size.
rng_fill_random_data
Fills the given slice with random bytes.
rng_next_in_closed_range
rng_next_in_range
Returns a random value within the specified range, using the given generator as a source for randomness.
rng_next_with_upper_bound
Returns a random value that is less than the given upper bound.
rng_random_array
rng_random_bool
rng_random_data
Returns a vector of random bytes of the given size.
rng_random_u32
thread_rng