generateNoise function

Uint8List generateNoise(
  1. Uint8List seed,
  2. int length,
  3. int modulus
)

Generates length bytes of deterministic noise from seed using SHAKE128. Then, each byte is reduced mod modulus.

Implementation

Uint8List generateNoise(Uint8List seed, int length, int modulus) {
  // Expand the seed with SHAKE128 to obtain length bytes
  Uint8List expanded = shake128(seed, length);

  // Adjust values to be within the range [0, modulus)
  for (int i = 0; i < expanded.length; i++) {
    expanded[i] = expanded[i] % modulus;
  }

  return expanded;
}