ANN: Crypt::ISAAC 0.9

K

Kirk Haines

This is to announce the release of Crypt::ISAAC, a pure Ruby implementation
of the ISAAC psuedo-random number generator. ISAAC is an algorithm for
generating cryptographically secure psuedo-random numbers. This library has
been part of the Iowa package for a couple of years. This version will
become the canonical version, however.

Crypt::ISAAC can be used to setup multiple independent streams of random
numbers, and offers a simple interface identical to that of Kernel.rand():


require 'crypt/isaac'

rng1 = Crypt::ISAAC.new
rng2 = Crypt::ISAAC.new

ri1 = rng1.rand(1000000)
ri2 = rng2.rand(1000000)
rf1 = rng1.rand
rf2 = rng2-rand

puts "#{ri1} -- #{ri2}"
puts "#{rf1} -- #{rf2}"


I am releasing the library as version 0.9 just because while I have been
using it for a couple of years, nobody else has ever looked at it, so there
may well be some tweaks and nudges to bits of it before I call it 1.0.


Kirk Haines
 
M

Mauricio Fernández

This is to announce the release of Crypt::ISAAC, a pure Ruby implementation
of the ISAAC psuedo-random number generator. ISAAC is an algorithm for
generating cryptographically secure psuedo-random numbers. This library has
been part of the Iowa package for a couple of years. This version will
become the canonical version, however.

Crypt::ISAAC can be used to setup multiple independent streams of random
numbers, and offers a simple interface identical to that of Kernel.rand():

I have just uploaded Crypt::ISAAC 0.9-1 to the preliminary Ruby Production
Archive (RPA) repository (http://rubyforge.org/frs/?group_id=265).

Installation/upgrade is achieved with

$ rpa install crypt-isaac

and happens atomically, as usual.

=== More information on RPA and rpa-base at
http://rpa-base.rubyforge.org

$ rpa query -x crypt-isaac
Matching available ports:
name: crypt-isaac
version: 0.9-1
classification: Top.Library
requires:
description: ISAAC is a cryptographically secure PRNG.

ISAAC is a cryptographically secure PRNG for generating high quality random
numbers. Detailed information about the algorithm can be found at:

http://burtleburtle.net/bob/rand/isaac.html

This is a pure Ruby implementation of the algorithm. It is reasonably
fast for a pure Ruby implementation, but the speed really can not be
compared to simply using Kernel.rand(). On an 800Mhz PIII computer
running Ruby 1.8.2, and while the machine is also serving as general
desktop, the library seems to consistently generate between 15000 and
16000 random numbers per second.
 
J

Joel VanderWerf

Kirk said:
This is to announce the release of Crypt::ISAAC, a pure Ruby implementation
of the ISAAC psuedo-random number generator. ISAAC is an algorithm for
generating cryptographically secure psuedo-random numbers. This library has
been part of the Iowa package for a couple of years. This version will
become the canonical version, however.

Crypt::ISAAC can be used to setup multiple independent streams of random
numbers, and offers a simple interface identical to that of Kernel.rand():


require 'crypt/isaac'

rng1 = Crypt::ISAAC.new
rng2 = Crypt::ISAAC.new

ri1 = rng1.rand(1000000)
ri2 = rng2.rand(1000000)
rf1 = rng1.rand
rf2 = rng2-rand

puts "#{ri1} -- #{ri2}"
puts "#{rf1} -- #{rf2}"


I am releasing the library as version 0.9 just because while I have been
using it for a couple of years, nobody else has ever looked at it, so there
may well be some tweaks and nudges to bits of it before I call it 1.0.

Thanks for that, Kirk. But I think I will need repeatability (as with
Kernel#srand), for use in simulations, and also speed. So I kludged up a
extension at http://redshift.sourceforge.net/isaac. It's public domain,
just like the original ISAAC.

One difference: since I am interested in simulations, I followed
Jenkins' advice and set the state vector length to 16 longs rather than
256 (smaller, faster, less secure). In the next iteration, I will make
this selectable from the API.

It's not well tested, but usage is:


[ruby/prj/isaac/ext/isaac] irb -r isaac.so
irb(main):001:0> r = ISAAC.new
=> #<ISAAC:0x40208aa0>
irb(main):002:0> r.srand [234,546,7868,98]
=> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
irb(main):003:0> r.rand32
=> 413434623
irb(main):004:0> r.rand32
=> 1012446849
irb(main):005:0> r.rand32
=> 3846288904

The input (and output) of #srand is an array of up to 16 longs used to
seed the generator.

Also in the next version: float output, distributions as in the Rand.rb
that someone pointed out, better namespace, etc.
 
B

Bob Jenkins

Joel VanderWerf said:
Kirk said:
This is to announce the release of Crypt::ISAAC, a pure Ruby implementation
of the ISAAC psuedo-random number generator. ISAAC is an algorithm for
generating cryptographically secure psuedo-random numbers. This library has
been part of the Iowa package for a couple of years. This version will
become the canonical version, however.

Crypt::ISAAC can be used to setup multiple independent streams of random
numbers, and offers a simple interface identical to that of Kernel.rand():


require 'crypt/isaac'

rng1 = Crypt::ISAAC.new
rng2 = Crypt::ISAAC.new

ri1 = rng1.rand(1000000)
ri2 = rng2.rand(1000000)
rf1 = rng1.rand
rf2 = rng2-rand

puts "#{ri1} -- #{ri2}"
puts "#{rf1} -- #{rf2}"


I am releasing the library as version 0.9 just because while I have been
using it for a couple of years, nobody else has ever looked at it, so there
may well be some tweaks and nudges to bits of it before I call it 1.0.

Thanks for that, Kirk. But I think I will need repeatability (as with
Kernel#srand), for use in simulations, and also speed. So I kludged up a
extension at http://redshift.sourceforge.net/isaac. It's public domain,
just like the original ISAAC.

One difference: since I am interested in simulations, I followed
Jenkins' advice and set the state vector length to 16 longs rather than
256 (smaller, faster, less secure). In the next iteration, I will make
this selectable from the API.

It's not well tested, but usage is:


[ruby/prj/isaac/ext/isaac] irb -r isaac.so
irb(main):001:0> r = ISAAC.new
=> #<ISAAC:0x40208aa0>
irb(main):002:0> r.srand [234,546,7868,98]
=> [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
irb(main):003:0> r.rand32
=> 413434623
irb(main):004:0> r.rand32
=> 1012446849
irb(main):005:0> r.rand32
=> 3846288904

The input (and output) of #srand is an array of up to 16 longs used to
seed the generator.

Also in the next version: float output, distributions as in the Rand.rb
that someone pointed out, better namespace, etc.

Initialization is much faster with size 16 instead of 256, and it
consumes less memory, and it is less secure, but the number of
instructions to produce a value remains the same. If you're using
millions of values, it's unclear that it's faster.
 
J

Joel VanderWerf

Bob said:
Initialization is much faster with size 16 instead of 256, and it
consumes less memory, and it is less secure, but the number of
instructions to produce a value remains the same. If you're using
millions of values, it's unclear that it's faster.

Good point. The generation time appears to be linear in the size, so
over the long term, there's probably no difference in speed, unless
there are cache effects. Still, I think the 16 size is worthwhile as an
option if you have lots of generators, some of which may only be used to
produce a small sequence of numbers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top