[erlang-questions] New random module?

Torben Hoffmann <>
Thu Nov 25 08:52:15 CET 2010


Hi,

Maybe this could be of interest to you...

Some time ago I created a fork of the cryptographic application by Martin
Logan where I have created a module called hash_random that follows the
guidelines for implementing a DRBG based on a hash function as per NIST
Special Publication 800-90.

There is half-baked code for accessing a good entropy source written in C
that should be easy to port to different platforms - this needs more work
though.
The hash_random should, however, be good to go - just pass in a good entropy
function and rock'n'roll!

The fork is at https://github.com/lehoff/cryptographic

I have been short for time so this has not gotten the attention that it
deserves.

Background info on the reason for the fork to answer the question "Why
Erlang?" up front:
 I wanted to create an encryption library that works on all major platforms
without the tie to OpenSSL since the intention was to create an application
that could easily be distributed to non-Erlangers without asking them to
install Erlang and OpenSSL.

Cheers,
Torben

On Thu, Nov 25, 2010 at 04:28, Kenji Rikitake <>wrote:

> The state for XORshift is indeed 32 bytes or eight 32-bit words.  My
> mistake.
>
> The mantissa part of IEEE floats has 53 bits, so two calls of
> 32-bit integer RNGs will be sufficient (this is not only the XORshift
> issue but also for other 32-bit integer-based RNGs).
>
> So far as I know
> XORshift 7-stage version RNG passed the Dieharder tests
> as well as the 2006 Wichmann-Hill RNG (converted to 32-bit
> unsigned integers) did.
> (Both didn't pass all the tests for one key,
>  but giving an independent seed made them pass the tests
>  with "WEAK" or "FAILED" results.)
>
> In the message <>
> dated Thu, Nov 25, 2010 at 12:31:28PM +1300,
> Richard O'Keefe <> writes:
> > On 24/11/2010, at 9:41 PM, Kenji Rikitake wrote:
> >
> > > In the message <>
> > > dated Wed, Nov 24, 2010 at 05:00:01PM +0900,
> > > Kenji Rikitake <> writes:
> > >> * XORshift 7 stage (Panneton-L'Ecuyer, 2005[1], state: 8 bytes,
> period: 2^256-1)
> > >
> > > [1] Francis Panneton and Pierre L'ecuyer. 2005. On the xorshift random
> > > number generators. ACM Trans. Model. Comput. Simul. 15, 4 (October
> > > 2005), 346-361. DOI=10.1145/1113316.1113319
> http://doi.acm.org/10.1145/1113316.1113319
> >
> > The C code for the 7 stage Xorshift generator displayed in figure 1
> > of that paper has 32 bytes of state, not 8.  The 'doubles' you get
> > from it have only 32 bits worth of randomness; the bottom 21 bits
> > are 0.  The paper concludes by saying "These generators are fast,
> > but not reliable, according to our analysis."  They don't report the
> > results of tests on the 7 stage generator.
>
> ________________________________________________________________
> erlang-questions (at) erlang.org mailing list.
> See http://www.erlang.org/faq.html
> To unsubscribe; mailto:
>
>


-- 
http://www.linkedin.com/in/torbenhoffmann


More information about the erlang-questions mailing list