Compare commits

...

5 Commits

Author SHA1 Message Date
Richard Moore
bd5e39edf8 Updated changelog. 2021-07-19 23:25:19 -04:00
Richard Moore
9e94c03d01 Updated elliptic library (#1439, #1782). 2021-07-19 23:22:02 -04:00
Richard Moore
278b388307 Added publishConfig to specify dist-tag. 2020-08-25 10:54:52 -04:00
Richard Moore
106f8a2109 Updated changelog. 2020-08-24 20:12:49 -04:00
Richard Moore
f79c9655bd Bumped elliptic version for security updates. 2020-08-24 15:47:06 -04:00
11 changed files with 1198 additions and 1579 deletions

View File

@@ -1,6 +1,16 @@
CHANGELOG
=========
ethers/v4.0.49 (2021-07-19 23:23)
---------------------------------
- Updated elliptic library. ([#1439](https://github.com/ethers-io/ethers.js/issues/1439), [#1782](https://github.com/ethers-io/ethers.js/issues/1782); [9e94c03](https://github.com/ethers-io/ethers.js/commit/9e94c03d01ba51ef9b7b0cec060cb5077dd1b2e7))
ethers/v4.0.48 (2020-08-24 15:44)
---------------------------------
- Bumped elliptic version for security updates. ([f79c965](https://github.com/ethers-io/ethers.js/commit/f79c9655bdd13ada834a6af9f66f93851740a9ab))
ethers/v4.0.47 (2020-04-21 23:15)
---------------------------------

2
_version.d.ts vendored
View File

@@ -1 +1 @@
export declare const version = "4.0.47";
export declare const version = "4.0.49";

View File

@@ -1,3 +1,3 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "4.0.47";
exports.version = "4.0.49";

438
dist/ethers.js vendored
View File

@@ -1,7 +1,7 @@
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ethers = f()}})(function(){var define,module,exports;return (function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.version = "4.0.47";
exports.version = "4.0.49";
},{}],2:[function(require,module,exports){
"use strict";
@@ -1849,7 +1849,11 @@ __export(require("./ethers"));
var Buffer;
try {
Buffer = require('buffer').Buffer;
if (typeof window !== 'undefined' && typeof window.Buffer !== 'undefined') {
Buffer = window.Buffer;
} else {
Buffer = require('buffer').Buffer;
}
} catch (e) {
}
@@ -1890,23 +1894,19 @@ __export(require("./ethers"));
var start = 0;
if (number[0] === '-') {
start++;
}
if (base === 16) {
this._parseHex(number, start);
} else {
this._parseBase(number, base, start);
}
if (number[0] === '-') {
this.negative = 1;
}
this.strip();
if (endian !== 'le') return;
this._initArray(this.toArray(), base, endian);
if (start < number.length) {
if (base === 16) {
this._parseHex(number, start, endian);
} else {
this._parseBase(number, base, start);
if (endian === 'le') {
this._initArray(this.toArray(), base, endian);
}
}
}
};
BN.prototype._initNumber = function _initNumber (number, base, endian) {
@@ -1982,31 +1982,29 @@ __export(require("./ethers"));
return this.strip();
};
function parseHex (str, start, end) {
var r = 0;
var len = Math.min(str.length, end);
for (var i = start; i < len; i++) {
var c = str.charCodeAt(i) - 48;
function parseHex4Bits (string, index) {
var c = string.charCodeAt(index);
// 'A' - 'F'
if (c >= 65 && c <= 70) {
return c - 55;
// 'a' - 'f'
} else if (c >= 97 && c <= 102) {
return c - 87;
// '0' - '9'
} else {
return (c - 48) & 0xf;
}
}
r <<= 4;
// 'a' - 'f'
if (c >= 49 && c <= 54) {
r |= c - 49 + 0xa;
// 'A' - 'F'
} else if (c >= 17 && c <= 22) {
r |= c - 17 + 0xa;
// '0' - '9'
} else {
r |= c & 0xf;
}
function parseHexByte (string, lowerBound, index) {
var r = parseHex4Bits(string, index);
if (index - 1 >= lowerBound) {
r |= parseHex4Bits(string, index - 1) << 4;
}
return r;
}
BN.prototype._parseHex = function _parseHex (number, start) {
BN.prototype._parseHex = function _parseHex (number, start, endian) {
// Create possibly bigger array to ensure that it fits the number
this.length = Math.ceil((number.length - start) / 6);
this.words = new Array(this.length);
@@ -2014,25 +2012,38 @@ __export(require("./ethers"));
this.words[i] = 0;
}
var j, w;
// Scan 24-bit chunks and add them to the number
// 24-bits chunks
var off = 0;
for (i = number.length - 6, j = 0; i >= start; i -= 6) {
w = parseHex(number, i, i + 6);
this.words[j] |= (w << off) & 0x3ffffff;
// NOTE: `0x3fffff` is intentional here, 26bits max shift + 24bit hex limb
this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
off += 24;
if (off >= 26) {
off -= 26;
j++;
var j = 0;
var w;
if (endian === 'be') {
for (i = number.length - 1; i >= start; i -= 2) {
w = parseHexByte(number, start, i) << off;
this.words[j] |= w & 0x3ffffff;
if (off >= 18) {
off -= 18;
j += 1;
this.words[j] |= w >>> 26;
} else {
off += 8;
}
}
} else {
var parseLength = number.length - start;
for (i = parseLength % 2 === 0 ? start + 1 : start; i < number.length; i += 2) {
w = parseHexByte(number, start, i) << off;
this.words[j] |= w & 0x3ffffff;
if (off >= 18) {
off -= 18;
j += 1;
this.words[j] |= w >>> 26;
} else {
off += 8;
}
}
}
if (i + 6 !== start) {
w = parseHex(number, start, i + 6);
this.words[j] |= (w << off) & 0x3ffffff;
this.words[j + 1] |= w >>> (26 - off) & 0x3fffff;
}
this.strip();
};
@@ -2103,6 +2114,8 @@ __export(require("./ethers"));
this._iaddn(word);
}
}
this.strip();
};
BN.prototype.copy = function copy (dest) {
@@ -4771,7 +4784,13 @@ __export(require("./ethers"));
} else if (cmp > 0) {
r.isub(this.p);
} else {
r.strip();
if (r.strip !== undefined) {
// r is BN v4 instance
r.strip();
} else {
// r is BN v5 instance
r._strip();
}
}
return r;
@@ -5226,9 +5245,9 @@ __export(require("./ethers"));
})(typeof module === 'undefined' || module, this);
},{"buffer":11}],10:[function(require,module,exports){
(function (global){
(function (global){(function (){
module.exports = function(length) { var result = new Uint8Array(length); (global.crypto || global.msCrypto).getRandomValues(result); return result; }
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],11:[function(require,module,exports){
},{}],12:[function(require,module,exports){
@@ -5308,18 +5327,20 @@ BaseCurve.prototype._fixedNafMul = function _fixedNafMul(p, k) {
// Translate into more windowed form
var repr = [];
for (var j = 0; j < naf.length; j += doubles.step) {
var nafW = 0;
for (var k = j + doubles.step - 1; k >= j; k--)
nafW = (nafW << 1) + naf[k];
var j;
var nafW;
for (j = 0; j < naf.length; j += doubles.step) {
nafW = 0;
for (var l = j + doubles.step - 1; l >= j; l--)
nafW = (nafW << 1) + naf[l];
repr.push(nafW);
}
var a = this.jpoint(null, null, null);
var b = this.jpoint(null, null, null);
for (var i = I; i > 0; i--) {
for (var j = 0; j < repr.length; j++) {
var nafW = repr[j];
for (j = 0; j < repr.length; j++) {
nafW = repr[j];
if (nafW === i)
b = b.mixedAdd(doubles.points[j]);
else if (nafW === -i)
@@ -5345,11 +5366,11 @@ BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
var acc = this.jpoint(null, null, null);
for (var i = naf.length - 1; i >= 0; i--) {
// Count zeroes
for (var k = 0; i >= 0 && naf[i] === 0; i--)
k++;
for (var l = 0; i >= 0 && naf[i] === 0; i--)
l++;
if (i >= 0)
k++;
acc = acc.dblp(k);
l++;
acc = acc.dblp(l);
if (i < 0)
break;
@@ -5373,25 +5394,28 @@ BaseCurve.prototype._wnafMul = function _wnafMul(p, k) {
};
BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
points,
coeffs,
len,
jacobianResult) {
points,
coeffs,
len,
jacobianResult) {
var wndWidth = this._wnafT1;
var wnd = this._wnafT2;
var naf = this._wnafT3;
// Fill all arrays
var max = 0;
for (var i = 0; i < len; i++) {
var p = points[i];
var i;
var j;
var p;
for (i = 0; i < len; i++) {
p = points[i];
var nafPoints = p._getNAFPoints(defW);
wndWidth[i] = nafPoints.wnd;
wnd[i] = nafPoints.points;
}
// Comb small window NAFs
for (var i = len - 1; i >= 1; i -= 2) {
for (i = len - 1; i >= 1; i -= 2) {
var a = i - 1;
var b = i;
if (wndWidth[a] !== 1 || wndWidth[b] !== 1) {
@@ -5406,7 +5430,7 @@ BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
points[a], /* 1 */
null, /* 3 */
null, /* 5 */
points[b] /* 7 */
points[b], /* 7 */
];
// Try to avoid Projective points, if possible
@@ -5430,14 +5454,14 @@ BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
7, /* 0 1 */
5, /* 1 -1 */
1, /* 1 0 */
3 /* 1 1 */
3, /* 1 1 */
];
var jsf = getJSF(coeffs[a], coeffs[b]);
max = Math.max(jsf[0].length, max);
naf[a] = new Array(max);
naf[b] = new Array(max);
for (var j = 0; j < max; j++) {
for (j = 0; j < max; j++) {
var ja = jsf[0][j] | 0;
var jb = jsf[1][j] | 0;
@@ -5449,12 +5473,12 @@ BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
var acc = this.jpoint(null, null, null);
var tmp = this._wnafT4;
for (var i = max; i >= 0; i--) {
for (i = max; i >= 0; i--) {
var k = 0;
while (i >= 0) {
var zero = true;
for (var j = 0; j < len; j++) {
for (j = 0; j < len; j++) {
tmp[j] = naf[j][i] | 0;
if (tmp[j] !== 0)
zero = false;
@@ -5470,9 +5494,9 @@ BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
if (i < 0)
break;
for (var j = 0; j < len; j++) {
for (j = 0; j < len; j++) {
var z = tmp[j];
var p;
p;
if (z === 0)
continue;
else if (z > 0)
@@ -5487,7 +5511,7 @@ BaseCurve.prototype._wnafMulAdd = function _wnafMulAdd(defW,
}
}
// Zeroify references
for (var i = 0; i < len; i++)
for (i = 0; i < len; i++)
wnd[i] = null;
if (jacobianResult)
@@ -5525,7 +5549,7 @@ BaseCurve.prototype.decodePoint = function decodePoint(bytes, enc) {
assert(bytes[bytes.length - 1] % 2 === 1);
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;
} else if ((bytes[0] === 0x02 || bytes[0] === 0x03) &&
@@ -5546,7 +5570,7 @@ BasePoint.prototype._encode = function _encode(compact) {
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) {
@@ -5560,7 +5584,7 @@ BasePoint.prototype.precompute = function precompute(power) {
var precomputed = {
doubles: null,
naf: null,
beta: null
beta: null,
};
precomputed.naf = this._getNAFPoints(8);
precomputed.doubles = this._getDoubles(4, power);
@@ -5594,7 +5618,7 @@ BasePoint.prototype._getDoubles = function _getDoubles(step, power) {
}
return {
step: step,
points: doubles
points: doubles,
};
};
@@ -5609,7 +5633,7 @@ BasePoint.prototype._getNAFPoints = function _getNAFPoints(wnd) {
res[i] = res[i - 1].add(dbl);
return {
wnd: wnd,
points: res
points: res,
};
};
@@ -5701,7 +5725,7 @@ ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
basis = conf.basis.map(function(vec) {
return {
a: new BN(vec.a, 16),
b: new BN(vec.b, 16)
b: new BN(vec.b, 16),
};
});
} else {
@@ -5711,7 +5735,7 @@ ShortCurve.prototype._getEndomorphism = function _getEndomorphism(conf) {
return {
beta: beta,
lambda: lambda,
basis: basis
basis: basis,
};
};
@@ -5802,7 +5826,7 @@ ShortCurve.prototype._getEndoBasis = function _getEndoBasis(lambda) {
return [
{ a: a1, b: b1 },
{ a: a2, b: b2 }
{ a: a2, b: b2 },
];
};
@@ -5858,36 +5882,36 @@ ShortCurve.prototype.validate = function validate(point) {
ShortCurve.prototype._endoWnafMulAdd =
function _endoWnafMulAdd(points, coeffs, jacobianResult) {
var npoints = this._endoWnafT1;
var ncoeffs = this._endoWnafT2;
for (var i = 0; i < points.length; i++) {
var split = this._endoSplit(coeffs[i]);
var p = points[i];
var beta = p._getBeta();
var npoints = this._endoWnafT1;
var ncoeffs = this._endoWnafT2;
for (var i = 0; i < points.length; i++) {
var split = this._endoSplit(coeffs[i]);
var p = points[i];
var beta = p._getBeta();
if (split.k1.negative) {
split.k1.ineg();
p = p.neg(true);
}
if (split.k2.negative) {
split.k2.ineg();
beta = beta.neg(true);
}
if (split.k1.negative) {
split.k1.ineg();
p = p.neg(true);
}
if (split.k2.negative) {
split.k2.ineg();
beta = beta.neg(true);
}
npoints[i * 2] = p;
npoints[i * 2 + 1] = beta;
ncoeffs[i * 2] = split.k1;
ncoeffs[i * 2 + 1] = split.k2;
}
var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
npoints[i * 2] = p;
npoints[i * 2 + 1] = beta;
ncoeffs[i * 2] = split.k1;
ncoeffs[i * 2 + 1] = split.k2;
}
var res = this._wnafMulAdd(1, npoints, ncoeffs, i * 2, jacobianResult);
// Clean-up references to points and coefficients
for (var j = 0; j < i * 2; j++) {
npoints[j] = null;
ncoeffs[j] = null;
}
return res;
};
// Clean-up references to points and coefficients
for (var j = 0; j < i * 2; j++) {
npoints[j] = null;
ncoeffs[j] = null;
}
return res;
};
function Point(curve, x, y, isRed) {
Base.BasePoint.call(this, curve, 'affine');
@@ -5939,12 +5963,12 @@ Point.prototype._getBeta = function _getBeta() {
beta: null,
naf: pre.naf && {
wnd: pre.naf.wnd,
points: pre.naf.points.map(endoMul)
points: pre.naf.points.map(endoMul),
},
doubles: pre.doubles && {
step: pre.doubles.step,
points: pre.doubles.points.map(endoMul)
}
points: pre.doubles.points.map(endoMul),
},
};
}
return beta;
@@ -5957,12 +5981,12 @@ Point.prototype.toJSON = function toJSON() {
return [ this.x, this.y, this.precomputed && {
doubles: this.precomputed.doubles && {
step: this.precomputed.doubles.step,
points: this.precomputed.doubles.points.slice(1)
points: this.precomputed.doubles.points.slice(1),
},
naf: this.precomputed.naf && {
wnd: this.precomputed.naf.wnd,
points: this.precomputed.naf.points.slice(1)
}
points: this.precomputed.naf.points.slice(1),
},
} ];
};
@@ -5982,12 +6006,12 @@ Point.fromJSON = function fromJSON(curve, obj, red) {
beta: null,
doubles: pre.doubles && {
step: pre.doubles.step,
points: [ res ].concat(pre.doubles.points.map(obj2point))
points: [ res ].concat(pre.doubles.points.map(obj2point)),
},
naf: pre.naf && {
wnd: pre.naf.wnd,
points: [ res ].concat(pre.naf.points.map(obj2point))
}
points: [ res ].concat(pre.naf.points.map(obj2point)),
},
};
return res;
};
@@ -6109,12 +6133,12 @@ Point.prototype.neg = function neg(_precompute) {
res.precomputed = {
naf: pre.naf && {
wnd: pre.naf.wnd,
points: pre.naf.points.map(negate)
points: pre.naf.points.map(negate),
},
doubles: pre.doubles && {
step: pre.doubles.step,
points: pre.doubles.points.map(negate)
}
points: pre.doubles.points.map(negate),
},
};
}
return res;
@@ -6251,9 +6275,10 @@ JPoint.prototype.dblp = function dblp(pow) {
if (!pow)
return this.dbl();
var i;
if (this.curve.zeroA || this.curve.threeA) {
var r = this;
for (var i = 0; i < pow; i++)
for (i = 0; i < pow; i++)
r = r.dbl();
return r;
}
@@ -6270,7 +6295,7 @@ JPoint.prototype.dblp = function dblp(pow) {
// Reuse results
var jyd = jy.redAdd(jy);
for (var i = 0; i < pow; i++) {
for (i = 0; i < pow; i++) {
var jx2 = jx.redSqr();
var jyd2 = jyd.redSqr();
var jyd4 = jyd2.redSqr();
@@ -6613,10 +6638,10 @@ function defineCurve(name, options) {
Object.defineProperty(curves, name, {
configurable: true,
enumerable: true,
value: curve
value: curve,
});
return curve;
}
},
});
}
@@ -6631,8 +6656,8 @@ defineCurve('p192', {
gRed: false,
g: [
'188da80e b03090f6 7cbf20eb 43a18800 f4ff0afd 82ff1012',
'07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811'
]
'07192b95 ffc8da78 631011ed 6b24cdd5 73f977a1 1e794811',
],
});
defineCurve('p224', {
@@ -6646,8 +6671,8 @@ defineCurve('p224', {
gRed: false,
g: [
'b70e0cbd 6bb4bf7f 321390b9 4a03c1d3 56c21122 343280d6 115c1d21',
'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34'
]
'bd376388 b5f723fb 4c22dfe6 cd4375a0 5a074764 44d58199 85007e34',
],
});
defineCurve('p256', {
@@ -6661,8 +6686,8 @@ defineCurve('p256', {
gRed: false,
g: [
'6b17d1f2 e12c4247 f8bce6e5 63a440f2 77037d81 2deb33a0 f4a13945 d898c296',
'4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5'
]
'4fe342e2 fe1a7f9b 8ee7eb4a 7c0f9e16 2bce3357 6b315ece cbb64068 37bf51f5',
],
});
defineCurve('p384', {
@@ -6682,8 +6707,8 @@ defineCurve('p384', {
'aa87ca22 be8b0537 8eb1c71e f320ad74 6e1d3b62 8ba79b98 59f741e0 82542a38 ' +
'5502f25d bf55296c 3a545e38 72760ab7',
'3617de4a 96262c6f 5d9e98bf 9292dc29 f8f41dbd 289a147c e9da3113 b5f0b8c0 ' +
'0a60b1ce 1d7e819d 7a431d7c 90ea0e5f'
]
'0a60b1ce 1d7e819d 7a431d7c 90ea0e5f',
],
});
defineCurve('p521', {
@@ -6709,8 +6734,8 @@ defineCurve('p521', {
'a2ffa8de 3348b3c1 856a429b f97e7e31 c2e5bd66',
'00000118 39296a78 9a3bc004 5c8a5fb4 2c7d1bd9 98f54449 ' +
'579b4468 17afbd17 273e662c 97ee7299 5ef42640 c550b901 ' +
'3fad0761 353c7086 a272c240 88be9476 9fd16650'
]
'3fad0761 353c7086 a272c240 88be9476 9fd16650',
],
});
defineCurve('curve25519', {
@@ -6723,8 +6748,8 @@ defineCurve('curve25519', {
hash: hash.sha256,
gRed: false,
g: [
'9'
]
'9',
],
});
defineCurve('ed25519', {
@@ -6742,8 +6767,8 @@ defineCurve('ed25519', {
'216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a',
// 4/5
'6666666666666666666666666666666666666666666666666666666666666658'
]
'6666666666666666666666666666666666666666666666666666666666666658',
],
});
var pre;
@@ -6769,20 +6794,20 @@ defineCurve('secp256k1', {
basis: [
{
a: '3086d221a7d46bcde86c90e49284eb15',
b: '-e4437ed6010e88286f547fa90abfe4c3'
b: '-e4437ed6010e88286f547fa90abfe4c3',
},
{
a: '114ca50f7a8e2f3f657c1108d9d44cfd8',
b: '3086d221a7d46bcde86c90e49284eb15'
}
b: '3086d221a7d46bcde86c90e49284eb15',
},
],
gRed: false,
g: [
'79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798',
'483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8',
pre
]
pre,
],
});
},{"./curve":15,"./precomputed/secp256k1":23,"./utils":24,"hash.js":26}],19:[function(require,module,exports){
@@ -6804,7 +6829,8 @@ function EC(options) {
// Shortcut `elliptic.ec(curve-name)`
if (typeof options === 'string') {
assert(curves.hasOwnProperty(options), 'Unknown curve ' + options);
assert(Object.prototype.hasOwnProperty.call(curves, options),
'Unknown curve ' + options);
options = curves[options];
}
@@ -6850,22 +6876,22 @@ EC.prototype.genKeyPair = function genKeyPair(options) {
persEnc: options.persEnc || 'utf8',
entropy: options.entropy || rand(this.hash.hmacStrength),
entropyEnc: options.entropy && options.entropyEnc || 'utf8',
nonce: this.n.toArray()
nonce: this.n.toArray(),
});
var bytes = this.n.byteLength();
var ns2 = this.n.sub(new BN(2));
do {
for (;;) {
var priv = new BN(drbg.generate(bytes));
if (priv.cmp(ns2) > 0)
continue;
priv.iaddn(1);
return this.keyFromPrivate(priv);
} while (true);
}
};
EC.prototype._truncateToN = function truncateToN(msg, truncOnly) {
EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {
var delta = msg.byteLength() * 8 - this.n.bitLength();
if (delta > 0)
msg = msg.ushrn(delta);
@@ -6899,16 +6925,16 @@ EC.prototype.sign = function sign(msg, key, enc, options) {
entropy: bkey,
nonce: nonce,
pers: options.pers,
persEnc: options.persEnc || 'utf8'
persEnc: options.persEnc || 'utf8',
});
// Number of bytes to generate
var ns1 = this.n.sub(new BN(1));
for (var iter = 0; true; iter++) {
for (var iter = 0; ; iter++) {
var k = options.k ?
options.k(iter) :
new BN(drbg.generate(this.n.byteLength()));
options.k(iter) :
new BN(drbg.generate(this.n.byteLength()));
k = this._truncateToN(k, true);
if (k.cmpn(1) <= 0 || k.cmp(ns1) >= 0)
continue;
@@ -6957,9 +6983,10 @@ EC.prototype.verify = function verify(msg, signature, key, enc) {
var sinv = s.invm(this.n);
var u1 = sinv.mul(msg).umod(this.n);
var u2 = sinv.mul(r).umod(this.n);
var p;
if (!this.curve._maxwellTrick) {
var p = this.g.mulAdd(u1, key.getPublic(), u2);
p = this.g.mulAdd(u1, key.getPublic(), u2);
if (p.isInfinity())
return false;
@@ -6969,7 +6996,7 @@ EC.prototype.verify = function verify(msg, signature, key, enc) {
// NOTE: Greg Maxwell's trick, inspired by:
// https://git.io/vad3K
var p = this.g.jmulAdd(u1, key.getPublic(), u2);
p = this.g.jmulAdd(u1, key.getPublic(), u2);
if (p.isInfinity())
return false;
@@ -7054,7 +7081,7 @@ KeyPair.fromPublic = function fromPublic(ec, pub, enc) {
return new KeyPair(ec, {
pub: pub,
pubEnc: enc
pubEnc: enc,
});
};
@@ -7064,7 +7091,7 @@ KeyPair.fromPrivate = function fromPrivate(ec, priv, enc) {
return new KeyPair(ec, {
priv: priv,
privEnc: enc
privEnc: enc,
});
};
@@ -7131,6 +7158,9 @@ KeyPair.prototype._importPublic = function _importPublic(key, enc) {
// ECDH
KeyPair.prototype.derive = function derive(pub) {
if(!pub.validate()) {
assert(pub.validate(), 'public point not validated');
}
return pub.mul(this.priv).getX();
};
@@ -7183,11 +7213,24 @@ function getLength(buf, p) {
return initial;
}
var octetLen = initial & 0xf;
// Indefinite length or overflow
if (octetLen === 0 || octetLen > 4) {
return false;
}
var val = 0;
for (var i = 0, off = p.place; i < octetLen; i++, off++) {
val <<= 8;
val |= buf[off];
val >>>= 0;
}
// Leading zeroes
if (val <= 0x7f) {
return false;
}
p.place = off;
return val;
}
@@ -7211,6 +7254,9 @@ Signature.prototype._importDER = function _importDER(data, enc) {
return false;
}
var len = getLength(data, p);
if (len === false) {
return false;
}
if ((len + p.place) !== data.length) {
return false;
}
@@ -7218,21 +7264,37 @@ Signature.prototype._importDER = function _importDER(data, enc) {
return false;
}
var rlen = getLength(data, p);
if (rlen === false) {
return false;
}
var r = data.slice(p.place, rlen + p.place);
p.place += rlen;
if (data[p.place++] !== 0x02) {
return false;
}
var slen = getLength(data, p);
if (slen === false) {
return false;
}
if (data.length !== slen + p.place) {
return false;
}
var s = data.slice(p.place, slen + p.place);
if (r[0] === 0 && (r[1] & 0x80)) {
r = r.slice(1);
if (r[0] === 0) {
if (r[1] & 0x80) {
r = r.slice(1);
} else {
// Leading zeroes
return false;
}
}
if (s[0] === 0 && (s[1] & 0x80)) {
s = s.slice(1);
if (s[0] === 0) {
if (s[1] & 0x80) {
s = s.slice(1);
} else {
// Leading zeroes
return false;
}
}
this.r = new BN(r);
@@ -7335,15 +7397,15 @@ utils.getNAF = getNAF;
function getJSF(k1, k2) {
var jsf = [
[],
[]
[],
];
k1 = k1.clone();
k2 = k2.clone();
var d1 = 0;
var d2 = 0;
var m8;
while (k1.cmpn(-d1) > 0 || k2.cmpn(-d2) > 0) {
// First phase
var m14 = (k1.andln(3) + d1) & 3;
var m24 = (k2.andln(3) + d2) & 3;
@@ -7355,7 +7417,7 @@ function getJSF(k1, k2) {
if ((m14 & 1) === 0) {
u1 = 0;
} else {
var m8 = (k1.andln(7) + d1) & 7;
m8 = (k1.andln(7) + d1) & 7;
if ((m8 === 3 || m8 === 5) && m24 === 2)
u1 = -m14;
else
@@ -7367,7 +7429,7 @@ function getJSF(k1, k2) {
if ((m24 & 1) === 0) {
u2 = 0;
} else {
var m8 = (k2.andln(7) + d2) & 7;
m8 = (k2.andln(7) + d2) & 7;
if ((m8 === 3 || m8 === 5) && m14 === 2)
u2 = -m24;
else
@@ -7392,14 +7454,14 @@ function cachedProperty(obj, name, computer) {
var key = '_' + name;
obj.prototype[name] = function cachedProperty() {
return this[key] !== undefined ? this[key] :
this[key] = computer.call(this);
this[key] = computer.call(this);
};
}
utils.cachedProperty = cachedProperty;
function parseBytes(bytes) {
return typeof bytes === 'string' ? utils.toArray(bytes, 'hex') :
bytes;
bytes;
}
utils.parseBytes = parseBytes;
@@ -7410,7 +7472,7 @@ utils.intFromLE = intFromLE;
},{"bn.js":9,"minimalistic-assert":41,"minimalistic-crypto-utils":42}],25:[function(require,module,exports){
module.exports={"version":"6.5.2"}
module.exports={"version":"6.5.4"}
},{}],26:[function(require,module,exports){
var hash = exports;
@@ -8624,7 +8686,7 @@ if (typeof Object.create === 'function') {
}
},{}],40:[function(require,module,exports){
(function (process,global){
(function (process,global){(function (){
/**
* [js-sha3]{@link https://github.com/emn178/js-sha3}
*
@@ -9101,7 +9163,7 @@ if (typeof Object.create === 'function') {
}
})();
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"_process":43}],41:[function(require,module,exports){
module.exports = assert;
@@ -9178,7 +9240,7 @@ utils.encode = function encode(arr, enc) {
},{}],43:[function(require,module,exports){
module.exports = { browser: true };
},{}],44:[function(require,module,exports){
(function (setImmediate){
(function (setImmediate){(function (){
"use strict";
(function(root) {
@@ -9634,9 +9696,9 @@ module.exports = { browser: true };
})(this);
}).call(this,require("timers").setImmediate)
}).call(this)}).call(this,require("timers").setImmediate)
},{"timers":46}],45:[function(require,module,exports){
(function (process,global,clearImmediate){
(function (process,global,clearImmediate){(function (){
(function (global, undefined) {
"use strict";
@@ -9813,13 +9875,13 @@ module.exports = { browser: true };
attachTo.clearImmediate = clearImmediate;
}(typeof self === "undefined" ? typeof global === "undefined" ? this : global : self));
}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").clearImmediate)
}).call(this)}).call(this,require('_process'),typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {},require("timers").clearImmediate)
},{"_process":43,"timers":46}],46:[function(require,module,exports){
(function (global){
(function (global){(function (){
module.exports = { setImmediate: global.setImmediate };
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],47:[function(require,module,exports){
(function (global){
(function (global){(function (){
var rng;
@@ -9852,7 +9914,7 @@ if (!rng) {
module.exports = rng;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{}],48:[function(require,module,exports){
// uuid.js
//
@@ -15442,7 +15504,7 @@ function inheritable(parent) {
exports.inheritable = inheritable;
},{"../errors":5}],75:[function(require,module,exports){
(function (global){
(function (global){(function (){
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
var bytes_1 = require("../utils/bytes");
@@ -15481,7 +15543,7 @@ if (crypto._weakCrypto === true) {
properties_1.defineReadOnly(randomBytes, '_weakCrypto', true);
}
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../utils/bytes":64,"../utils/properties":74}],76:[function(require,module,exports){
"use strict";
//See: https://github.com/ethereum/wiki/wiki/RLP
@@ -17069,7 +17131,7 @@ function poll(func, options) {
exports.poll = poll;
},{"../errors":5,"./base64":61,"./properties":74,"./utf8":85,"xmlhttprequest":49}],87:[function(require,module,exports){
(function (global){
(function (global){(function (){
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// This gets overriddenby gulp during bip39-XX
@@ -17124,7 +17186,7 @@ function register(lang, name) {
}
exports.register = register;
}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"../utils/hash":65,"../utils/properties":74}],88:[function(require,module,exports){
'use strict';
var __extends = (this && this.__extends) || (function () {

2
dist/ethers.min.js vendored

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -266,7 +266,7 @@ declare module 'ethers/utils/shims' {
}
declare module 'ethers/_version' {
export const version = "4.0.47";
export const version = "4.0.49";
}
declare module 'ethers/utils/bignumber' {

2
dist/shims.js vendored

File diff suppressed because one or more lines are too long

2301
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,10 @@
{
"name": "ethers",
"version": "4.0.47",
"version": "4.0.49",
"publishConfig": {
"access": "public",
"tag": "legacy"
},
"description": "Ethereum wallet library.",
"main": "./index.js",
"types": "./index.d.ts",
@@ -20,8 +24,8 @@
},
"dependencies": {
"aes-js": "3.0.0",
"bn.js": "^4.4.0",
"elliptic": "6.5.2",
"bn.js": "^4.11.9",
"elliptic": "6.5.4",
"hash.js": "1.1.3",
"js-sha3": "0.5.7",
"scrypt-js": "2.0.4",
@@ -30,7 +34,7 @@
"xmlhttprequest": "1.8.0"
},
"devDependencies": {
"@types/node": "^10.3.2",
"@types/node": "10.17.28",
"browserify": "^16.2.3",
"browserify-zlib": "^0.2.0",
"dts-bundle": "^0.7.3",
@@ -45,7 +49,7 @@
"gulp-uglify": "^3.0.0",
"mocha": "^5.2.0",
"mocha-phantomjs-core": "2.1.2",
"solc": "0.4.20",
"solc": "^0.7.0",
"tsify": "^4.0.0",
"tslint": "^5.10.0",
"typescript": "^2.9.1",

View File

@@ -1 +1 @@
export const version = "4.0.47";
export const version = "4.0.49";