Skip to content

Commit

Permalink
6.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
indutny committed Nov 22, 2019
1 parent 9984964 commit 6048941
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 25 deletions.
37 changes: 19 additions & 18 deletions dist/elliptic.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function BaseCurve(type, conf) {
this._wnafT3 = new Array(4);
this._wnafT4 = new Array(4);

this._bitLength = this.n ? this.n.bitLength() : 0;

// Generalized Greg Maxwell's trick
var adjustCount = this.n && this.p.div(this.n);
if (!adjustCount || adjustCount.cmpn(100) > 0) {
Expand All @@ -67,7 +69,7 @@ BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
assert(p.precomputed);
var doubles = p._getDoubles();

var naf = getNAF(k, 1);
var naf = getNAF(k, 1, this._bitLength);
var I = (1 << (doubles.step + 1)) - (doubles.step % 2 === 0 ? 2 : 1);
I /= 3;

Expand Down Expand Up @@ -104,7 +106,7 @@ BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
var wnd = nafPoints.points;

// Get NAF form
var naf = getNAF(k, w);
var naf = getNAF(k, w, this._bitLength);

// Add `this`*(N+1) for every w-NAF index
var acc = this.jpoint(null, null, null);
Expand Down Expand Up @@ -160,8 +162,8 @@ BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
var a = i - 1;
var b = i;
if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
naf[a] = getNAF(coeffs[a], wndWidth[a]);
naf[b] = getNAF(coeffs[b], wndWidth[b]);
naf[a] = getNAF(coeffs[a], wndWidth[a], this._bitLength);
naf[b] = getNAF(coeffs[b], wndWidth[b], this._bitLength);
max = Math.max(naf[a].length, max);
max = Math.max(naf[b].length, max);
continue;
Expand Down Expand Up @@ -3740,14 +3742,17 @@ utils.toHex = minUtils.toHex;
utils.encode = minUtils.encode;

// Represent num in a w-NAF form
function getNAF(num, w) {
var naf = [];
function getNAF(num, w, bits) {
var naf = new Array(Math.max(num.bitLength(), bits) + 1);
naf.fill(0);

var ws = 1 << (w + 1);
var k = num.clone();
while (k.cmpn(1) >= 0) {

for (var i = 0; i < naf.length; i++) {
var z;
var mod = k.andln(ws - 1);
if (k.isOdd()) {
var mod = k.andln(ws - 1);
if (mod > (ws >> 1) - 1)
z = (ws >> 1) - mod;
else
Expand All @@ -3756,13 +3761,9 @@ function getNAF(num, w) {
} else {
z = 0;
}
naf.push(z);

// Optimization, shift by word if possible
var shift = (k.cmpn(0) !== 0 && k.andln(ws - 1) === 0) ? (w + 1) : 1;
for (var i = 1; i < shift; i++)
naf.push(0);
k.iushrn(shift);
naf[i] = z;
k.iushrn(1);
}

return naf;
Expand Down Expand Up @@ -8797,7 +8798,7 @@ utils.encode = function encode(arr, enc) {
},{}],35:[function(require,module,exports){
module.exports={
"name": "elliptic",
"version": "6.5.1",
"version": "6.5.2",
"description": "EC cryptography",
"main": "lib/elliptic.js",
"files": [
Expand Down Expand Up @@ -8829,7 +8830,7 @@ module.exports={
"homepage": "https://github.com/indutny/elliptic",
"devDependencies": {
"brfs": "^1.4.3",
"coveralls": "^3.0.4",
"coveralls": "^3.0.8",
"grunt": "^1.0.4",
"grunt-browserify": "^5.0.0",
"grunt-cli": "^1.2.0",
Expand All @@ -8840,8 +8841,8 @@ module.exports={
"grunt-saucelabs": "^9.0.1",
"istanbul": "^0.4.2",
"jscs": "^3.0.7",
"jshint": "^2.6.0",
"mocha": "^6.1.4"
"jshint": "^2.10.3",
"mocha": "^6.2.2"
},
"dependencies": {
"bn.js": "^4.4.0",
Expand Down
10 changes: 5 additions & 5 deletions dist/elliptic.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "elliptic",
"version": "6.5.1",
"version": "6.5.2",
"description": "EC cryptography",
"main": "lib/elliptic.js",
"files": [
Expand Down

0 comments on commit 6048941

Please sign in to comment.