Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue with publicPointFromPrivate() function #3

Open
AmritKumar opened this issue Apr 2, 2019 · 1 comment
Open

Issue with publicPointFromPrivate() function #3

AmritKumar opened this issue Apr 2, 2019 · 1 comment

Comments

@AmritKumar
Copy link

AmritKumar commented Apr 2, 2019

PROBLEM: The following function in ECKeyPair.cs allows one to obtain the public key from an input private key.

public static ECPoint publicPointFromPrivate(BigInteger privKey)
        {
            /*
             * TODO: FixedPointCombMultiplier currently doesn't support scalars longer than the group
             * order, but that could change in future versions.
             */
            if (privKey.BitLength > CURVE.N.BitLength)
            {
                privKey = privKey.Mod(CURVE.N);
            }
            return new FixedPointCombMultiplier().Multiply(CURVE.G, privKey);
}

If the input privKey has a bit length that is larger than the bit length of the group order N, then privKey is reduced modulo N. There are couple of issues here: 1) Any input privKey that does not fall between 1 and N-1 (both inclusive) should be outright rejected. 2) Comparing the bit length of N and privKey is not correct. One should rather compare their values directly.

SOLUTION: Replace the if condition by instead checking whether the input privKey is valid or not. A valid privKey is simply a scalar value that is between 1 and N-1. If privKey is invalid, then the function should simply throw an error instead of reducing privKey modulo N.

@neeboo @yanbin007

yanbin007 added a commit that referenced this issue Apr 18, 2019
@yanbin007
Copy link
Contributor

Thanks,I have fixed it.

iantanwx added a commit to iantanwx/LaksaCsharp that referenced this issue May 30, 2019
This addresses issue FireStack-Lab#3. Bit length comparisions are incorrect.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants