Skip to content

Commit

Permalink
fix Point.prototype.toJSON for short curves
Browse files Browse the repository at this point in the history
  • Loading branch information
mvayngrib committed Aug 13, 2019
1 parent 421fa23 commit 2eccb6e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions lib/elliptic/curve/short.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ Point.prototype._getBeta = function _getBeta() {

Point.prototype.toJSON = function toJSON() {
if (!this.precomputed)
return [ this.x, this.y ];
return [ this.x.fromRed(), this.y.fromRed() ];

return [ this.x, this.y, this.precomputed && {
return [ this.x.fromRed(), this.y.fromRed(), this.precomputed && {
doubles: this.precomputed.doubles && {
step: this.precomputed.doubles.step,
points: this.precomputed.doubles.points.slice(1)
Expand Down
2 changes: 1 addition & 1 deletion test/toJSON-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ function exportPoint (p) {
}

describe('toJSON <-> pointFromJSON symmetry', function() {
it('toJSON matches pointFromJSON', function () {
it('toJSON is the inverse of pointFromJSON', function () {
for (var key in curves) {
if (key === 'PresetCurve') continue;

Expand Down

0 comments on commit 2eccb6e

Please sign in to comment.