Fermat's primality test vs. Miller-Rabin
Sidney Markowitz
sidney at sidney.com
Sat Dec 3 09:41:54 EST 2005
Joseph Ashwood wrote:
> byte [] rawBytes = new byte[lenNum/8];
> rand.nextBytes(rawBytes);
> curNum = new BigInteger(rawBytes);
I haven't thought through why it would produce non-primes, but it
doesn't seem to do what you want. That produces a 512 bit
twos-complement number, which gives you a 511 bit positive integer, not
512 bit. It also is unnecessarily complicated compared to this form of
the BigInteger constructor and the or method (see the javadoc):
curNum = BigInteger.ONE.or(new BigInteger(512, rand));
-- Sidney Markowitz
http://www.sidney.com
---------------------------------------------------------------------
The Cryptography Mailing List
Unsubscribe by sending "unsubscribe cryptography" to majordomo at metzdowd.com
More information about the cryptography
mailing list