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

Fix prettier tests #16

Merged
merged 1 commit into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/run-tests-and-lint-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,4 @@ jobs:
run: npm install

- name: Run checks
if: always()
run: ${{ matrix.checks }}
16 changes: 8 additions & 8 deletions lib/elliptic.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';
"use strict";

var elliptic = exports;

elliptic.version = require('../package.json').version;
elliptic.utils = require('./elliptic/utils');
elliptic.rand = require('brorand');
elliptic.curve = require('./elliptic/curve');
elliptic.curves = require('./elliptic/curves');
elliptic.version = require("../package.json").version;
elliptic.utils = require("./elliptic/utils");
elliptic.rand = require("brorand");
elliptic.curve = require("./elliptic/curve");
elliptic.curves = require("./elliptic/curves");

// Protocols
elliptic.ec = require('./elliptic/ec');
elliptic.eddsa = require('./elliptic/eddsa');
elliptic.ec = require("./elliptic/ec");
elliptic.eddsa = require("./elliptic/eddsa");
34 changes: 17 additions & 17 deletions lib/elliptic/curve/base.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict';
"use strict";

var BN = require('bn.js');
var utils = require('../utils');
var BN = require("bn.js");
var utils = require("../utils");
var getNAF = utils.getNAF;
var getJSF = utils.getJSF;
var assert = utils.assert;
Expand Down Expand Up @@ -42,11 +42,11 @@ function BaseCurve(type, conf) {
module.exports = BaseCurve;

BaseCurve.prototype.point = function point() {
throw new Error('Not implemented');
throw new Error("Not implemented");
};

BaseCurve.prototype.validate = function validate() {
throw new Error('Not implemented');
throw new Error("Not implemented");
};

BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
Expand Down Expand Up @@ -102,7 +102,7 @@ BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
if (i < 0) break;
var z = naf[i];
assert(z !== 0);
if (p.type === 'affine') {
if (p.type === "affine") {
// J +- P
if (z > 0) acc = acc.mixedAdd(wnd[(z - 1) >> 1]);
else acc = acc.mixedAdd(wnd[(-z - 1) >> 1].neg());
Expand All @@ -112,15 +112,15 @@ BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
else acc = acc.add(wnd[(-z - 1) >> 1].neg());
}
}
return p.type === 'affine' ? acc.toP() : acc;
return p.type === "affine" ? acc.toP() : acc;
};

BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(
defW,
points,
coeffs,
len,
jacobianResult,
jacobianResult
) {
var wndWidth = this._wnafT1;
var wnd = this._wnafT2;
Expand Down Expand Up @@ -214,7 +214,7 @@ BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(
else if (z > 0) p = wnd[j][(z - 1) >> 1];
else if (z < 0) p = wnd[j][(-z - 1) >> 1].neg();

if (p.type === 'affine') acc = acc.mixedAdd(p);
if (p.type === "affine") acc = acc.mixedAdd(p);
else acc = acc.add(p);
}
}
Expand All @@ -233,7 +233,7 @@ function BasePoint(curve, type) {
BaseCurve.BasePoint = BasePoint;

BasePoint.prototype.eq = function eq(/*other*/) {
throw new Error('Not implemented');
throw new Error("Not implemented");
};

BasePoint.prototype.validate = function validate() {
Expand All @@ -255,7 +255,7 @@ BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {

var res = this.point(
bytes.slice(1, 1 + len),
bytes.slice(1 + len, 1 + 2 * len),
bytes.slice(1 + len, 1 + 2 * len)
);

return res;
Expand All @@ -265,7 +265,7 @@ BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
) {
return this.pointFromX(bytes.slice(1, 1 + len), bytes[0] === 0x03);
}
throw new Error('Unknown point format');
throw new Error("Unknown point format");
};

BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {
Expand All @@ -274,11 +274,11 @@ BasePoint.prototype.encodeCompressed = function encodeCompressed(enc) {

BasePoint.prototype._encode = function _encode(compact) {
var len = this.curve.p.byteLength();
var x = this.getX().toArray('be', len);
var x = this.getX().toArray("be", len);

if (compact) return [ this.getY().isEven() ? 0x02 : 0x03 ].concat(x);
if (compact) return [this.getY().isEven() ? 0x02 : 0x03].concat(x);

return [ 0x04 ].concat(x, this.getY().toArray('be', len));
return [0x04].concat(x, this.getY().toArray("be", len));
};

BasePoint.prototype.encode = function encode(enc, compact) {
Expand Down Expand Up @@ -314,7 +314,7 @@ BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
if (this.precomputed && this.precomputed.doubles)
return this.precomputed.doubles;

var doubles = [ this ];
var doubles = [this];
var acc = this;
for (var i = 0; i < power; i += step) {
for (var j = 0; j < step; j++) acc = acc.dbl();
Expand All @@ -329,7 +329,7 @@ BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
if (this.precomputed && this.precomputed.naf) return this.precomputed.naf;

var res = [ this ];
var res = [this];
var max = (1 << wnd) - 1;
var dbl = max === 1 ? null : this.dbl();
for (var i = 1; i < max; i++) res[i] = res[i - 1].add(dbl);
Expand Down
36 changes: 18 additions & 18 deletions lib/elliptic/curve/edwards.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict';
"use strict";

var utils = require('../utils');
var BN = require('bn.js');
var inherits = require('inherits');
var Base = require('./base');
var utils = require("../utils");
var BN = require("bn.js");
var inherits = require("inherits");
var Base = require("./base");

var assert = utils.assert;

Expand All @@ -13,7 +13,7 @@ function EdwardsCurve(conf) {
this.mOneA = this.twisted && (conf.a | 0) === -1;
this.extended = this.mOneA;

Base.call(this, 'edwards', conf);
Base.call(this, "edwards", conf);

this.a = new BN(conf.a, 16).umod(this.red.m);
this.a = this.a.toRed(this.red);
Expand Down Expand Up @@ -54,7 +54,7 @@ EdwardsCurve.prototype.pointFromX = function pointFromX(x, odd) {
var y2 = rhs.redMul(lhs.redInvm());
var y = y2.redSqrt();
if (y.redSqr().redSub(y2).cmp(this.zero) !== 0)
throw new Error('invalid point');
throw new Error("invalid point");

var isOdd = y.fromRed().isOdd();
if ((odd && !isOdd) || (!odd && isOdd)) y = y.redNeg();
Expand All @@ -73,13 +73,13 @@ EdwardsCurve.prototype.pointFromY = function pointFromY(y, odd) {
var x2 = lhs.redMul(rhs.redInvm());

if (x2.cmp(this.zero) === 0) {
if (odd) throw new Error('invalid point');
if (odd) throw new Error("invalid point");
else return this.point(this.zero, y);
}

var x = x2.redSqrt();
if (x.redSqr().redSub(x2).cmp(this.zero) !== 0)
throw new Error('invalid point');
throw new Error("invalid point");

if (x.fromRed().isOdd() !== odd) x = x.redNeg();

Expand All @@ -101,7 +101,7 @@ EdwardsCurve.prototype.validate = function validate(point) {
};

function Point(curve, x, y, z, t) {
Base.BasePoint.call(this, curve, 'projective');
Base.BasePoint.call(this, curve, "projective");
if (x === null && y === null && z === null) {
this.x = this.curve.zero;
this.y = this.curve.one;
Expand Down Expand Up @@ -141,15 +141,15 @@ Point.fromJSON = function fromJSON(curve, obj) {
};

Point.prototype.inspect = function inspect() {
if (this.isInfinity()) return '<EC Point Infinity>';
if (this.isInfinity()) return "<EC Point Infinity>";
return (
'<EC Point x: ' +
"<EC Point x: " +
this.x.fromRed().toString(16, 2) +
' y: ' +
" y: " +
this.y.fromRed().toString(16, 2) +
' z: ' +
" z: " +
this.z.fromRed().toString(16, 2) +
'>'
">"
);
};

Expand Down Expand Up @@ -348,11 +348,11 @@ Point.prototype.mul = function mul(k) {
};

Point.prototype.mulAdd = function mulAdd(k1, p, k2) {
return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, false);
return this.curve._wnafMulAdd(1, [this, p], [k1, k2], 2, false);
};

Point.prototype.jmulAdd = function jmulAdd(k1, p, k2) {
return this.curve._wnafMulAdd(1, [ this, p ], [ k1, k2 ], 2, true);
return this.curve._wnafMulAdd(1, [this, p], [k1, k2], 2, true);
};

Point.prototype.normalize = function normalize() {
Expand All @@ -373,7 +373,7 @@ Point.prototype.neg = function neg() {
this.x.redNeg(),
this.y,
this.z,
this.t && this.t.redNeg(),
this.t && this.t.redNeg()
);
};

Expand Down
10 changes: 5 additions & 5 deletions lib/elliptic/curve/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use strict';
"use strict";

var curve = exports;

curve.base = require('./base');
curve.short = require('./short');
curve.mont = require('./mont');
curve.edwards = require('./edwards');
curve.base = require("./base");
curve.short = require("./short");
curve.mont = require("./mont");
curve.edwards = require("./edwards");
30 changes: 15 additions & 15 deletions lib/elliptic/curve/mont.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
'use strict';
"use strict";

var BN = require('bn.js');
var inherits = require('inherits');
var Base = require('./base');
var BN = require("bn.js");
var inherits = require("inherits");
var Base = require("./base");

var utils = require('../utils');
var utils = require("../utils");

function MontCurve(conf) {
Base.call(this, 'mont', conf);
Base.call(this, "mont", conf);

this.a = new BN(conf.a, 16).toRed(this.red);
this.b = new BN(conf.b, 16).toRed(this.red);
Expand All @@ -28,7 +28,7 @@ MontCurve.prototype.validate = function validate(point) {
};

function Point(curve, x, z) {
Base.BasePoint.call(this, curve, 'projective');
Base.BasePoint.call(this, curve, "projective");
if (x === null && z === null) {
this.x = this.curve.one;
this.z = this.curve.zero;
Expand Down Expand Up @@ -58,21 +58,21 @@ Point.prototype.precompute = function precompute() {
};

Point.prototype._encode = function _encode() {
return this.getX().toArray('be', this.curve.p.byteLength());
return this.getX().toArray("be", this.curve.p.byteLength());
};

Point.fromJSON = function fromJSON(curve, obj) {
return new Point(curve, obj[0], obj[1] || curve.one);
};

Point.prototype.inspect = function inspect() {
if (this.isInfinity()) return '<EC Point Infinity>';
if (this.isInfinity()) return "<EC Point Infinity>";
return (
'<EC Point x: ' +
"<EC Point x: " +
this.x.fromRed().toString(16, 2) +
' z: ' +
" z: " +
this.z.fromRed().toString(16, 2) +
'>'
">"
);
};

Expand Down Expand Up @@ -103,7 +103,7 @@ Point.prototype.dbl = function dbl() {
};

Point.prototype.add = function add() {
throw new Error('Not supported on Montgomery curve');
throw new Error("Not supported on Montgomery curve");
};

Point.prototype.diffAdd = function diffAdd(p, diff) {
Expand Down Expand Up @@ -154,11 +154,11 @@ Point.prototype.mul = function mul(k) {
};

Point.prototype.mulAdd = function mulAdd() {
throw new Error('Not supported on Montgomery curve');
throw new Error("Not supported on Montgomery curve");
};

Point.prototype.jumlAdd = function jumlAdd() {
throw new Error('Not supported on Montgomery curve');
throw new Error("Not supported on Montgomery curve");
};

Point.prototype.eq = function eq(other) {
Expand Down
Loading