Module rand

Source
Expand description

Pseudorandom number utilities for HashX’s program generator

HashX uses pseudorandom numbers to make individual decisions in the program generation process. The program generator consumes u8 and u32 values that use a shared u64 generator, implemented using SipHash1,3.

We use the RngCore trait for this underlying u64 generator, allowing substitute random number generators for testing or for special purposes that don’t require compatibility with HashX proper.

The stateful u8 and u32 layer comes from this module’s RngBuffer. It’s important for the u8 and u32 queues to share a common generator. The order of dequeueing u8 items vs u32 items intentionally modifies the assignment of particular u64 RngCore values to the two queues.

Structs§

RngBuffer 🔒
Wrap a RngCore implementation for fast u8 and u32 output.
SipRand
HashX-style random number generator built on SipHash1,3