This is the mail archive of the gsl-discuss@sources.redhat.com mailing list for the GSL project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: True Random Numbers


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]