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

Missing infinity point encoding #218

Open
catenacyber opened this issue Feb 21, 2020 · 0 comments · May be fixed by #219
Open

Missing infinity point encoding #218

catenacyber opened this issue Feb 21, 2020 · 0 comments · May be fixed by #219

Comments

@catenacyber
Copy link

I have been doing differential fuzzing of elliptic curve libraries.
And I found one inconsistency with this javascript library.

Reproducer code is

var EC = require('elliptic').ec;
var utils = require('elliptic').utils;

var ec = new EC(process.argv[2]);
var pt1 = ec.curve.decodePoint(process.argv[3], "hex")
var sc = utils.toArray(process.argv[4], "hex")
var pt2 = pt1.mul(sc)
console.log(pt2.encode('hex'));

Reproducer command with this code named elliptic.js is
node elliptic.js p224 04fffffffffffffffffffffffff6fefffeffffffffffffffffffff52fa456dccc33f1d634106fda91244bf704f3dab9650616d0ac30bc05650 ffffffffffffffffffffffffffff16a2e0b8f03e13dd29455c5c2a3d

I get the following stack trace

elliptic/lib/elliptic/curve/short.js:415
  return this.x.fromRed();
                ^

TypeError: Cannot read property 'fromRed' of null
    at Point.getX (elliptic/lib/elliptic/curve/short.js:415:17)
    at Point._encode (elliptic/lib/elliptic/curve/base.js:295:16)
    at Point.encode (elliptic/lib/elliptic/curve/base.js:304:28)
    at Object.<anonymous> (ecfuzzer/modules/elliptic.js:8:17)
    at Module._compile (internal/modules/cjs/loader.js:774:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
    at Module.load (internal/modules/cjs/loader.js:641:32)
    at Function.Module._load (internal/modules/cjs/loader.js:556:12)
    at Function.Module.runMain (internal/modules/cjs/loader.js:837:10)
    at internal/main/run_main_module.js:17:11

Expected output is simply 00 aka infinity point encoding

@catenacyber catenacyber linked a pull request Feb 21, 2020 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants
@catenacyber and others