pub fn generate_permutation(
perm: &mut [u16],
rng: &mut impl CryptoRng,
) -> Result<(), MlKemError>Expand description
Generate a uniform random permutation of 0..n using Fisher-Yates.
Iterates from the last index down to 1, swapping each element with a uniformly chosen earlier (or equal) element. Uses rejection sampling on 16-bit random values to avoid modular bias.
§Arguments
perm- Output slice of lengthn, initialized to[0, 1, ..., n-1]then shuffled in place.rng- A cryptographic RNG for generating swap indices.
§Errors
Returns MlKemError::RngFailure if the RNG fails.