nx_random.nx
buildroot/runtime/nx_random.nx
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
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
structs
| 28 | struct NxRng |
consts
| 35 | const NX_RNG_BYTES: i64 = 32 |
functions
| 38 | func nx_rng_rotl(x: i64, k: i64) -> i64 called by 1: nx_rng_next |
| 47 | func nx_rng_splitmix(state_ptr: *i64) -> i64 called by 1: nx_rng_new |
| 60 | func nx_rng_new(seed: i64) -> *NxRng |
| 75 | func nx_rng_next(r: *NxRng) -> i64 |
| 91 | func nx_rng_below(r: *NxRng, bound: i64) -> i64 |
| 103 | func nx_rng_byte(r: *NxRng) -> i64 calls 1: nx_rng_next |
| 108 | func nx_rng_fill(r: *NxRng, dst: *u8, n: i64) -> i64 |
| 127 | func main() -> i64 |