#random #rand #rdseed

no-std rdrand

An implementation of random number generator based on rdrand and rdseed instructions

25 releases

0.8.3 Dec 17, 2023
0.8.2 Apr 16, 2022
0.8.1 Oct 3, 2021
0.8.0 Apr 10, 2021
0.0.4 Dec 21, 2014

#35 in Hardware support

Download history 40166/week @ 2023-12-23 73049/week @ 2023-12-30 100603/week @ 2024-01-06 105494/week @ 2024-01-13 104399/week @ 2024-01-20 95496/week @ 2024-01-27 110231/week @ 2024-02-03 108919/week @ 2024-02-10 91860/week @ 2024-02-17 110403/week @ 2024-02-24 108812/week @ 2024-03-02 102845/week @ 2024-03-09 113218/week @ 2024-03-16 121350/week @ 2024-03-23 132655/week @ 2024-03-30 106533/week @ 2024-04-06

495,518 downloads per month
Used in 5,163 crates (6 directly)

ISC license

30KB
455 lines

An implementation of random number generators based on rdrand and rdseed instructions.

The random number generators provided by this crate are fairly slow (the latency for these instructions is pretty high), but provide high quality random bits. Caveat is: neither AMD’s nor Intel’s designs are public and therefore are not verifiable for lack of backdoors.

Unless you know what you are doing, use the random number generators provided by the rand crate (such as OsRng) instead.

Here are a measurements for select processor architectures. Check Agner’s instruction tables for up-to-date listings.

Architecture Latency (cycles) Maximum throughput (per core)
u16 u32 u64
AMD Ryzen ~1200 ~1200 ~2500 ~12MB/s @ 3.7GHz
Intel Skylake 460 460 460 ~72MB/s @ 4.2GHz
Intel Haswell 320 320 320 ~110MB/s @ 4.4GHz

Dependencies

~165KB