Could you tell me if I am right? I want to generate p
in DSA
algorithm. I don't understaand that: || pTemp.bitLength() != l
in the do while
statement, because it means I am looking only for 1
digit prime which is 2,5,7? It is nonsense.
private BigInteger generateP(BigInteger q, int l) {
if (l % 64 != 0) {
throw new IllegalArgumentException("L value is wrong");
}
BigInteger pTemp;
BigInteger pTemp2;
int i = 0;
do {
//pTemp = new BigInteger(l, primeCenterie, rand); <--- this is useless also?
pTemp = new BigInteger(l, rand);
pTemp2 = pTemp.subtract(BigInteger.ONE);
pTemp = pTemp.subtract(pTemp2.remainder(q));
System.out.println("1 " + i++);
} while (!pTemp.isProbablePrime(primeCenterie) || pTemp.bitLength() != l);
return pTemp;
}
IT is not 1(one) but l(L) everything was okay. I was doing it 2 months ago and didn't understand it now.