postchain-client 1.19.0 → 1.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17503,7 +17503,7 @@ var browserifyRsa = crt$2;
17503
17503
  var elliptic$2 = {};
17504
17504
 
17505
17505
  var name = "elliptic";
17506
- var version = "6.5.4";
17506
+ var version = "6.6.0";
17507
17507
  var description = "EC cryptography";
17508
17508
  var main = "lib/elliptic.js";
17509
17509
  var files = [
@@ -17653,12 +17653,15 @@ var utils$k = {};
17653
17653
  // Represent num in a w-NAF form
17654
17654
  function getNAF(num, w, bits) {
17655
17655
  var naf = new Array(Math.max(num.bitLength(), bits) + 1);
17656
- naf.fill(0);
17656
+ var i;
17657
+ for (i = 0; i < naf.length; i += 1) {
17658
+ naf[i] = 0;
17659
+ }
17657
17660
 
17658
17661
  var ws = 1 << (w + 1);
17659
17662
  var k = num.clone();
17660
17663
 
17661
- for (var i = 0; i < naf.length; i++) {
17664
+ for (i = 0; i < naf.length; i++) {
17662
17665
  var z;
17663
17666
  var mod = k.andln(ws - 1);
17664
17667
  if (k.isOdd()) {
@@ -22129,8 +22132,8 @@ KeyPair$2.prototype.sign = function sign(msg, enc, options) {
22129
22132
  return this.ec.sign(msg, this, enc, options);
22130
22133
  };
22131
22134
 
22132
- KeyPair$2.prototype.verify = function verify(msg, signature) {
22133
- return this.ec.verify(msg, signature, this);
22135
+ KeyPair$2.prototype.verify = function verify(msg, signature, options) {
22136
+ return this.ec.verify(msg, signature, this, undefined, options);
22134
22137
  };
22135
22138
 
22136
22139
  KeyPair$2.prototype.inspect = function inspect() {
@@ -22176,6 +22179,10 @@ function getLength(buf, p) {
22176
22179
  return false;
22177
22180
  }
22178
22181
 
22182
+ if(buf[p.place] === 0x00) {
22183
+ return false;
22184
+ }
22185
+
22179
22186
  var val = 0;
22180
22187
  for (var i = 0, off = p.place; i < octetLen; i++, off++) {
22181
22188
  val <<= 8;
@@ -22224,6 +22231,9 @@ Signature$2.prototype._importDER = function _importDER(data, enc) {
22224
22231
  if (rlen === false) {
22225
22232
  return false;
22226
22233
  }
22234
+ if ((data[p.place] & 128) !== 0) {
22235
+ return false;
22236
+ }
22227
22237
  var r = data.slice(p.place, rlen + p.place);
22228
22238
  p.place += rlen;
22229
22239
  if (data[p.place++] !== 0x02) {
@@ -22236,6 +22246,9 @@ Signature$2.prototype._importDER = function _importDER(data, enc) {
22236
22246
  if (data.length !== slen + p.place) {
22237
22247
  return false;
22238
22248
  }
22249
+ if ((data[p.place] & 128) !== 0) {
22250
+ return false;
22251
+ }
22239
22252
  var s = data.slice(p.place, slen + p.place);
22240
22253
  if (r[0] === 0) {
22241
22254
  if (r[1] & 0x80) {
@@ -22388,8 +22401,27 @@ function requireEc () {
22388
22401
  }
22389
22402
  };
22390
22403
 
22391
- EC.prototype._truncateToN = function _truncateToN(msg, truncOnly) {
22392
- var delta = msg.byteLength() * 8 - this.n.bitLength();
22404
+ EC.prototype._truncateToN = function _truncateToN(msg, truncOnly, bitLength) {
22405
+ var byteLength;
22406
+ if (BN.isBN(msg) || typeof msg === 'number') {
22407
+ msg = new BN(msg, 16);
22408
+ byteLength = msg.byteLength();
22409
+ } else if (typeof msg === 'object') {
22410
+ // BN assumes an array-like input and asserts length
22411
+ byteLength = msg.length;
22412
+ msg = new BN(msg, 16);
22413
+ } else {
22414
+ // BN converts the value to string
22415
+ var str = msg.toString();
22416
+ // HEX encoding
22417
+ byteLength = (str.length + 1) >>> 1;
22418
+ msg = new BN(str, 16);
22419
+ }
22420
+ // Allow overriding
22421
+ if (typeof bitLength !== 'number') {
22422
+ bitLength = byteLength * 8;
22423
+ }
22424
+ var delta = bitLength - this.n.bitLength();
22393
22425
  if (delta > 0)
22394
22426
  msg = msg.ushrn(delta);
22395
22427
  if (!truncOnly && msg.cmp(this.n) >= 0)
@@ -22407,7 +22439,7 @@ function requireEc () {
22407
22439
  options = {};
22408
22440
 
22409
22441
  key = this.keyFromPrivate(key, enc);
22410
- msg = this._truncateToN(new BN(msg, 16));
22442
+ msg = this._truncateToN(msg, false, options.msgBitLength);
22411
22443
 
22412
22444
  // Zero-extend key to provide enough entropy
22413
22445
  var bytes = this.n.byteLength();
@@ -22463,8 +22495,11 @@ function requireEc () {
22463
22495
  }
22464
22496
  };
22465
22497
 
22466
- EC.prototype.verify = function verify(msg, signature, key, enc) {
22467
- msg = this._truncateToN(new BN(msg, 16));
22498
+ EC.prototype.verify = function verify(msg, signature, key, enc, options) {
22499
+ if (!options)
22500
+ options = {};
22501
+
22502
+ msg = this._truncateToN(msg, false, options.msgBitLength);
22468
22503
  key = this.keyFromPublic(key, enc);
22469
22504
  signature = new Signature(signature, 'hex');
22470
22505
 
@@ -22669,6 +22704,7 @@ function Signature$1(eddsa, sig) {
22669
22704
  sig = parseBytes$1(sig);
22670
22705
 
22671
22706
  if (Array.isArray(sig)) {
22707
+ assert$3(sig.length === eddsa.encodingLength * 2, 'Signature has invalid size');
22672
22708
  sig = {
22673
22709
  R: sig.slice(0, eddsa.encodingLength),
22674
22710
  S: sig.slice(eddsa.encodingLength),
@@ -22764,6 +22800,9 @@ EDDSA.prototype.sign = function sign(message, secret) {
22764
22800
  EDDSA.prototype.verify = function verify(message, sig, pub) {
22765
22801
  message = parseBytes(message);
22766
22802
  sig = this.makeSignature(sig);
22803
+ if (sig.S().gte(sig.eddsa.curve.n) || sig.S().isNeg()) {
22804
+ return false;
22805
+ }
22767
22806
  var key = this.keyFromPublic(pub);
22768
22807
  var h = this.hashInt(sig.Rencoded(), key.pubBytes(), message);
22769
22808
  var SG = this.g.mul(sig.S());
@@ -29694,6 +29733,10 @@ function loadCompressedPublicKey (first, xbuf) {
29694
29733
  let y = x.redSqr().redIMul(x).redIAdd(ecparams.b).redSqrt();
29695
29734
  if ((first === 0x03) !== y.isOdd()) y = y.redNeg();
29696
29735
 
29736
+ // x*x*x + b = y*y
29737
+ const x3 = x.redSqr().redIMul(x);
29738
+ if (!y.redSqr().redISub(x3.redIAdd(ecparams.b)).isZero()) return null
29739
+
29697
29740
  return ec.keyPair({ pub: { x: x, y: y } })
29698
29741
  }
29699
29742