Expand description
Canister-local deterministic PRNG seeded externally (e.g. via raw_rand).
The IC executes canister code single-threaded, so RefCell provides
sufficient interior mutability without locking.
The RNG must be explicitly seeded before use (typically during init or post-upgrade) and is intended for update calls where state advancement is permitted.
Enums§
- RngError
- RngError Errors raised when randomness is unavailable.
Functions§
- fill_
bytes - Fill the provided buffer with random bytes.
- is_
seeded - Returns true if the RNG has been seeded.
- next_u8
- Produce an 8-bit random value (derived from
next_u16). - next_
u16 - Produce a 16-bit random value from the shared RNG.
- next_
u32 - Produce a 32-bit random value from the shared RNG.
- next_
u64 - Produce a 64-bit random value from the shared RNG.
- next_
u128 - Produce a 128-bit random value from the shared RNG.
- random_
bytes - Produce random bytes using the shared RNG.
- random_
hex - Produce hex-encoded random bytes using the shared RNG.
- seed_
from - Seed the RNG with a 32-byte value (e.g. management canister
raw_randoutput).