Java Randomness Test Suite

JRandTest at SourceForge

com.fasteasytrade.JRandTest.Algo
Class QuadraticResidue2Prng

java.lang.Object
  extended bycom.fasteasytrade.JRandTest.Algo.Cipher
      extended bycom.fasteasytrade.JRandTest.Algo.QuadraticResidue2Prng

public class QuadraticResidue2Prng
extends Cipher

QuadraidResidue2 Prng algorithm from NIST test package

Fix random p, prime, length 512 bits.

Fix random g, prime, length 512 bits. g < p.

Each prng iteration calculate g = g*(2g + 3) + 1 mod p.
The lowest 64 bits of g are the prng result.

Author:
Zur Aougav

Field Summary
(package private)  BigInteger BI3
           
 int bit_length
          n's length/num of bits
(package private)  BigInteger g
          Initial g is a random prime (with probability < 2 ** -100) Length of g is bit_length = 512 bits = 64 bytes.
(package private)  BigInteger g0
          g0 is the "initial state" of the prng.
(package private)  BigInteger p
          prime (with probability < 2 ** -100).
 
Constructor Summary
(package private) QuadraticResidue2Prng()
           
(package private) QuadraticResidue2Prng(BigInteger p, BigInteger g)
           
(package private) QuadraticResidue2Prng(BigInteger p, BigInteger g, BigInteger g0)
           
(package private) QuadraticResidue2Prng(int x)
           
 
Method Summary
 BigInteger getG()
          Secret key
 BigInteger getP()
          Public key.
 long nextLong()
          calculate g = g*(2g + 3) + 1 mod p and returns lowest 64 bits, long.
 void reset()
          Reset "state" of prng by setting g to g0 (initial g).
(package private)  void setup(int len)
          Generate the key and seed for Quadratic Residue Prng.
 
Methods inherited from class com.fasteasytrade.JRandTest.Algo.Cipher
compareBytes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bit_length

public final int bit_length
n's length/num of bits

See Also:
Constant Field Values

p

BigInteger p
prime (with probability < 2 ** -100).

Length of p is bit_length = 512 bits = 64 bytes.


g

BigInteger g
Initial g is a random prime (with probability < 2 ** -100)

Length of g is bit_length = 512 bits = 64 bytes.

g is the "state" of the prng.

g = take 64 lowr bits of ( g**2 mod n ).


g0

BigInteger g0
g0 is the "initial state" of the prng.

reset method set g to g0.


BI3

final BigInteger BI3
Constructor Detail

QuadraticResidue2Prng

QuadraticResidue2Prng()

QuadraticResidue2Prng

QuadraticResidue2Prng(int x)

QuadraticResidue2Prng

QuadraticResidue2Prng(BigInteger p,
                      BigInteger g)

QuadraticResidue2Prng

QuadraticResidue2Prng(BigInteger p,
                      BigInteger g,
                      BigInteger g0)
Method Detail

setup

void setup(int len)
Generate the key and seed for Quadratic Residue Prng.

Select random primes - p, g. g < p.

Parameters:
len - length of p and g, num of bits.

nextLong

public long nextLong()
calculate g = g*(2g + 3) + 1 mod p and returns lowest 64 bits, long.


getP

public BigInteger getP()
Public key.

Returns:
p prime (with probability < 2 ** -100)

getG

public BigInteger getG()
Secret key

Returns:
g prime (with probability < 2 ** -100)

reset

public void reset()
Reset "state" of prng by setting g to g0 (initial g).


Java Randomness Test Suite

JRandTest at SourceForge

JRandTest at SourceForge
Copyright © 2005 Zur Aougav. All Rights Reserved.