generateNoise function
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;
}