Expand description
Thread-local PRNG seeded externally (raw_rand recommended).
The IC executes canister code single-threaded, so RefCell provides
sufficient interior mutability without locking or poisoning semantics.
Use update calls for randomness so the PRNG state advances, and seed in init + post_upgrade via timers.
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).