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

Possible issue in KeyTools #8

@AmritKumar

Description

@AmritKumar

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions