code wiki / (root) / nx_random.nx

nx_random.nx

buildroot/runtime/nx_random.nx

5215 B169 linesdepth 3pulls 3 transitivereach 649 importersview sourcekind tool
docsdependenciesstructsconstsfunctions

about

nx_random.nx -- xoshiro256++ pseudo-random number generator. Used by: - Fuzzing harness (nx_fuzz) - Sampling / property-based testing - Deterministic ID generation (UUIDv7-style) - Stack-canary seeding (when nx_argv builds AT_RANDOM auxv) - Hash-table key randomization (DoS-resistance) xoshiro256++ is the modern recommendation from Blackman + Vigna (2019). Period 2^256 - 1, fast (4 ops per output), passes all of TestU01 / PractRand. Better than Mersenne Twister for general-purpose use. NOT a CSPRNG. For cryptographic randomness use the kernel getrandom() syscall via nx_csprng (deferred to a separate module). Reference: https://prng.di.unimi.it/xoshiro256plusplus.c

dependencies 1 imports · 4 importers

syscalls.nx nx_random.nx nx_csprng.nx nx_random_gate.nx nx_shapley.nx nx_uuid.nx

imports: syscalls.nx

imported by: nx_csprng.nxnx_random_gate.nxnx_shapley.nxnx_uuid.nx

call flow from main pre-order; caps 40 nodes / depth 6 declared; ↻ = already shown

main nx_rng_new nx_rng_splitmix nx_rng_next nx_rng_rotl nx_rng_below nx_rng_next ↻ nx_rng_fill nx_rng_next ↻

structs

28struct NxRng

consts

35const NX_RNG_BYTES: i64 = 32

functions

38func nx_rng_rotl(x: i64, k: i64) -> i64
called by 1: nx_rng_next
47func nx_rng_splitmix(state_ptr: *i64) -> i64
called by 1: nx_rng_new
60func nx_rng_new(seed: i64) -> *NxRng
75func nx_rng_next(r: *NxRng) -> i64
91func nx_rng_below(r: *NxRng, bound: i64) -> i64
103func nx_rng_byte(r: *NxRng) -> i64
calls 1: nx_rng_next
108func nx_rng_fill(r: *NxRng, dst: *u8, n: i64) -> i64
127func main() -> i64