This repository was archived by the owner on Dec 23, 2025. It is now read-only.

Description
PROBLEM: The if condition in the following function (crypto/KeyTools.java) seems incorrect. Comparing the bitLength() of two values should not be the criterion to do a modulo.
private static ECPoint getPublicPointFromPrivate(BigInteger privateKeyPoint) {
if (privateKeyPoint.bitLength() > CURVE.getN().bitLength()) {
privateKeyPoint = privateKeyPoint.mod(CURVE.getN());
}
return new FixedPointCombMultiplier().multiply(CURVE.getG(), privateKeyPoint);
}
SOLUTION: Instead of comparing the bitLength(), one should compare the actual values. In fact, one could throw an error if the input is larger than CURVE.N. Since this function is used to generate a public key from a private key, one should also do some extra checks on the input such as the input is 1) positive 2) not equal to 0. @nickcen @iantanwx