|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.fasteasytrade.JRandTest.Algo.Cipher com.fasteasytrade.JRandTest.Algo.MicaliSchnorrPrng
Micali-Schnorr Prng algorithm.
Implements algorithm directly from public published book.
The following program implements and tests the Micali-Schnorr random bits generator. The test suite is according to FIPS 140-1. See "Handbook of Applied Cryptography" by Alfred J. Menezes et al Section 5.4.4 pages 181 - 183 and 5.37 Algorithm page 186.
Field Summary | |
(package private) int |
bit_length
n's length/num of bits |
(package private) BigInteger |
e
e is a random exponent we calculate on generation (in setup method) |
(package private) int |
k
nLength = r + k k is the number of low bits we will use in the prng |
(package private) BigInteger |
n
n = p * q, and calculations are done mod n. |
(package private) int |
nLength
nLength is length of n |
(package private) BigInteger |
p
prime (with probability < 2 ** -100) |
(package private) BigInteger |
q
prime (with probability < 2 ** -100) |
(package private) int |
r
nLength = r + k r is the number of high bits we will use in the prng |
(package private) BigInteger |
x
x is the "state" of the prng. |
(package private) BigInteger |
x0
x0 is the "initial state" of the prng. |
Constructor Summary | |
(package private) |
MicaliSchnorrPrng()
|
(package private) |
MicaliSchnorrPrng(BigInteger n,
BigInteger p,
BigInteger q)
|
(package private) |
MicaliSchnorrPrng(BigInteger n,
BigInteger p,
BigInteger q,
BigInteger x)
|
(package private) |
MicaliSchnorrPrng(int x)
|
Method Summary | |
BigInteger |
getE()
|
int |
getK()
|
BigInteger |
getN()
Public key. |
void |
getNextBits(byte[] result)
calculate x**e mod n and returns lowest k bits, k/8 bytes, in result buffer. |
int |
getNLength()
|
BigInteger |
getP()
Secret key. |
BigInteger |
getQ()
Secret key (need only one of p or q). |
int |
getR()
|
BigInteger |
getX()
Encryption: you need to get last x and write it to cipher output stream. |
void |
reset()
Reset "state" of prng by setting x to x0 (initial x). |
(package private) boolean |
setup(int l)
Generate the key and seed for Micali Schnorr 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 |
final int bit_length
BigInteger n
BigInteger p
BigInteger q
BigInteger x
x = take r high bits of ( x**e mod n ).
returns k random bits from k low bits of ( x**e mod n ).
BigInteger x0
reset method set x to x0.
BigInteger e
int nLength
int k
k is the number of low bits we will use in the prng
int r
r is the number of high bits we will use in the prng
Constructor Detail |
MicaliSchnorrPrng()
MicaliSchnorrPrng(int x)
MicaliSchnorrPrng(BigInteger n, BigInteger p, BigInteger q)
MicaliSchnorrPrng(BigInteger n, BigInteger p, BigInteger q, BigInteger x)
Method Detail |
boolean setup(int l)
Select random p, q, n=p*q, x (mod n).
l
- length of n, num of bits.public void getNextBits(byte[] result)
public BigInteger getP()
public BigInteger getQ()
public BigInteger getN()
public BigInteger getE()
public BigInteger getX()
Decryption: you need to read "last x" from input stream, and calculate X0, the first x based on n (public key), p and q (secret key/keys).
public int getNLength()
public int getK()
public int getR()
public void reset()
|
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |