Skip to main content

random_bits_core

Function random_bits_core 

Source
pub(crate) fn random_bits_core<T, R: TryRng + ?Sized>(
    rng: &mut R,
    x: &mut T,
    n_bits: u32,
) -> Result<(), R::Error>
where T: Encoding,
Expand description

Fill the given limbs slice with random bits.

NOTE: Assumes that the limbs in the given slice are zeroed!

When combined with a platform-independent “4-byte sequential” rng, this function is platform-independent. We consider an RNG “X-byte sequential” whenever rng.fill_bytes(&mut bytes[..i]); rng.fill_bytes(&mut bytes[i..]) constructs the same bytes, as long as i is a multiple of X. Note that the TryRng trait does not require this behaviour from rng.