RdRand.jl

Generate random numbers using Intel's RDRAND instruction
Popularity
5 Stars
Updated Last
3 Years Ago
Started In
July 2013

RdRand.jl

Introduction

The RdRand package provides an interface for using Intel's RDRAND instruction, which provides extremely high quality random numbers. The instruction is currently only available on Ivy Bridge processors.

On a 1.8 GHz Intel Core i5 (i5-3427U) each rdrand() call takes about 50 nanoseconds, while rand(), which uses a SIMD Mersenne Twister implementation, takes about 5 nanoseconds.

Installation

In the Julia interpreter type:

Pkg.add("RdRand")

API

  • rdrand(): provides a random number on the interval [0,1]
  • rdrand16(): provides a UInt16 random number
  • rdrand32(): provides a UInt32 random number
  • rdrand64(): provides a UInt64 random number

Randomness

The random numbers are generated by combining a high quality hardware source of entropy (thermal noise) with a cryptographically secure random number generator (CSPRNG). Quoting Intel's guide:

With respect to the RNG taxonomy discussed above, the DRNG follows the cascade construction RNG model, using a processor resident entropy source to repeatedly seed a hardware-implemented CSPRNG. Unlike software approaches, it includes a high-quality entropy source implementation that can be sampled quickly to repeatedly seed the CSPRNG with high-quality entropy. Furthermore, it represents a self-contained hardware module that is isolated from software attacks on its internal state. The result is a solution that achieves RNG objectives with considerable robustness: statistical quality (independence, uniform distribution), highly unpredictable random number sequences, high performance, and protection against attack.

image