mirror of
https://github.com/pgpainless/pgpainless.git
synced 2024-11-26 14:22:05 +01:00
Improve ElGamal validation by refraining from biginteger for loop variable
This commit is contained in:
parent
bfbaa30e4c
commit
6a5c6c5509
1 changed files with 5 additions and 4 deletions
|
@ -265,14 +265,15 @@ public class PublicKeyParameterValidationUtil {
|
||||||
|
|
||||||
// check g^i mod p != 1 for i < threshold
|
// check g^i mod p != 1 for i < threshold
|
||||||
BigInteger res = g;
|
BigInteger res = g;
|
||||||
BigInteger i = BigInteger.valueOf(1);
|
// 262144
|
||||||
BigInteger threshold = BigInteger.valueOf(2).shiftLeft(17);
|
int threshold = 2 << 17;
|
||||||
while (i.compareTo(threshold) < 0) {
|
int i = 1;
|
||||||
|
while (i < threshold) {
|
||||||
res = res.multiply(g).mod(p);
|
res = res.multiply(g).mod(p);
|
||||||
if (res.equals(one)) {
|
if (res.equals(one)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
i = i.add(one);
|
i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// blinded exponentiation to check y = g^(r*(p-1)+x) mod p
|
// blinded exponentiation to check y = g^(r*(p-1)+x) mod p
|
||||||
|
|
Loading…
Reference in a new issue