Jabba

a program to

Display the Distribution of PRNGs

Intro

Jabba is a PRNG distribution test program. This is the gif of its test run on java.security.SecureRandom and java.Math.random.

Note that my Netscape doesn't handle it, try xv(1) instead.

Analysis by Author

The author, James Maitland of JCP, wrote:

Find attached my jabba.prng package of files. If you compile these and run:

java jabba.prng.prngApp 250000
You'll see my test images for both the java.security.SecureRandom and the java.lang.Math.random() method. If you don't want to go through that, here's my synopsis:

SecureRandom is around 4 times slower than Math.random();

It doesn't generate what my mate Tal describes as the right sort of pattern; It seems to be a 'better' version of the linear congruential generator used in Math.random() (which I imagine is just like the standard C lib's rand() function), but in no way could I call it a cryptographically secure generator- check out the corners (= 0.0 or 1.0 on the distribution) vs. the centre (= 0.5)!

The app, as far as I know, has only one flaw- it generates monochrome images. The mapping of the random number range to the display space domain is fine, so I have to suggest that SecureRandom is nothing but a tweaked Random. Hmm.

Check it out and let me know what you think.

Cheers,

James.

Response

David Hopwood responded:

No, the method it uses is mentioned in a draft of one of the P1363 appendices (I seem to remember it comes from some X*.* standard, but I can't remember which one):

    # + a cryptographically strong hash function (such as SHA-1) computed over a
    #   true-random seed value concatenated with a counter which is incremented
    #   for each operation. [For example, one could have 256 bits of true-random
    #   seed and a 64-bit counter, all hashed by SHA to yield 160 bits of output,
    #   from which only 64 are used -- with the counter incremented by 1 for each
    #   output batch.]

SecureRandom only uses 160 bits of seed, but otherwise it is identical to this description.

The output is exactly as expected for a uniformly distributed PRNG, given the following method that chooses the shade of each plotted point:

    Color generateColour(Point point1, Point point2)
    {
        double d1 = Math.sqrt((double)(square(point1.x - point2.x) +
            square(point1.y - point2.y)));
        Dimension dimension = getSize();
        double d2 = Math.sqrt((double)(square(dimension.width) +
            square(dimension.height)));
        float f = Math.round(d1 / d2);
        return new Color(f, f, f);
    }

Clearly if point1 (the point to be plotted) is near the corners of the plot, point2 is less likely to be close to it, so given a uniform, independent distribution for both point1 and point2, areas closer to the corners will on average be displayed in a lighter shade.


Cryptix Copyright © 1997 Systemics Ltd
on behalf of the Cryptix Development Team.
All rights reserved.
Cryptix is a trademark of Systemics Ltd.