#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

#34 in Algorithms

Download history 125081/week @ 2024-06-19 145612/week @ 2024-06-26 132454/week @ 2024-07-03 142066/week @ 2024-07-10 143718/week @ 2024-07-17 138914/week @ 2024-07-24 138197/week @ 2024-07-31 149964/week @ 2024-08-07 174283/week @ 2024-08-14 169433/week @ 2024-08-21 156339/week @ 2024-08-28 189558/week @ 2024-09-04 189585/week @ 2024-09-11 179814/week @ 2024-09-18 199996/week @ 2024-09-25 167262/week @ 2024-10-02

775,834 downloads per month
Used in 4,187 crates (7 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

~170KB