This is the mail archive of the
gsl-discuss@sources.redhat.com
mailing list for the GSL project.
Re: True Random Numbers
- From: "Robert G. Brown" <rgb at phy dot duke dot edu>
- To: hobbsk at ohiou dot edu
- Cc: GSL-Discuss <gsl-discuss at sources dot redhat dot com>
- Date: Fri, 5 Nov 2004 16:49:46 -0500 (EST)
- Subject: Re: True Random Numbers
- References: <1099684684.23357.101.camel@gargon.hooperlab>
On Fri, 5 Nov 2004, Kevin H. Hobbs wrote:
> Is it possible, or easy, to use the GSL random number distributions with
> true random number devices? I'm thinking of a generator that really
> just reads from /dev/random or a device driver for one of the really
> fancy hardware random number devices.
It is pretty easy, really. I wrapped /dev/random in the GSL-style
wrapper some time ago as part of an effort I had underway to write a
random number tester that was fully integrated with the GSL (which
exists and works, BTW, although I quit before re-implementing e.g. all
of diehard). The tester also times the various GSL routines. This is
one of the biggest problems with /dev/random -- it is s l o o o o w. It
has to accumulate enough entropy to replenish the rands it returns, and
its sources have a very definitely finite and system-state dependent
rate of generating entropy.
There are some clever things one can do -- using /dev/random to seed a
good, fast, diehard-passing RNG such as the default mt19937, or using it
to randomize a shuffling routine drawing on one or more GSL generators
to break up presumed long range correlations -- but the more complex
things won't be worth it unless you've got an application that actually
is sensitive to the weaknesses of all the routines already in the GSL.
If you're just trying to get a result that is "really random" in the
sense of being unpredictable (to generate e.g. security keys) then a
/dev/random wrap is a good way to go.
Let me know if you want the wrapper code (or you can probably figure it
out easily enough for yourself now that you know it can be done). I
don't think I ever posted rand_rate on my website for public use, but I
certainly could easily enough if there is any interest in it. I still
think that having diehard and/or the NIST suite fully integrated with
GSL, including an example (like /dev/random) of wrapping your own RNG to
extend the suite, would be very useful. I just don't have time to work
on it just now.
rgb
Robert G. Brown http://www.phy.duke.edu/~rgb/
Duke University Dept. of Physics, Box 90305
Durham, N.C. 27708-0305
Phone: 1-919-660-2567 Fax: 919-660-2525 email:rgb@phy.duke.edu