@zoralabs/protocol-deployments 0.4.0-DEV.0 → 0.4.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.
@@ -1,21 +1,99 @@
1
- import {
2
- Hash,
3
- bytes,
4
- concatBytes,
5
- createView,
6
- exists,
7
- hash,
8
- output,
9
- randomBytes,
10
- rotr,
11
- toBytes,
12
- wrapConstructor
13
- } from "./chunk-FJ2PMLO3.js";
14
1
  import {
15
2
  __export
16
3
  } from "./chunk-3EJPJMEH.js";
17
4
 
18
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_md.js
5
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/_assert.js
6
+ function anumber(n) {
7
+ if (!Number.isSafeInteger(n) || n < 0)
8
+ throw new Error("positive integer expected, got " + n);
9
+ }
10
+ function isBytes(a) {
11
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
12
+ }
13
+ function abytes(b, ...lengths) {
14
+ if (!isBytes(b))
15
+ throw new Error("Uint8Array expected");
16
+ if (lengths.length > 0 && !lengths.includes(b.length))
17
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
18
+ }
19
+ function ahash(h) {
20
+ if (typeof h !== "function" || typeof h.create !== "function")
21
+ throw new Error("Hash should be wrapped by utils.wrapConstructor");
22
+ anumber(h.outputLen);
23
+ anumber(h.blockLen);
24
+ }
25
+ function aexists(instance, checkFinished = true) {
26
+ if (instance.destroyed)
27
+ throw new Error("Hash instance has been destroyed");
28
+ if (checkFinished && instance.finished)
29
+ throw new Error("Hash#digest() has already been called");
30
+ }
31
+ function aoutput(out, instance) {
32
+ abytes(out);
33
+ const min = instance.outputLen;
34
+ if (out.length < min) {
35
+ throw new Error("digestInto() expects output buffer of length at least " + min);
36
+ }
37
+ }
38
+
39
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/cryptoNode.js
40
+ import * as nc from "crypto";
41
+ var crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
42
+
43
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/utils.js
44
+ var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
45
+ var rotr = (word, shift) => word << 32 - shift | word >>> shift;
46
+ function utf8ToBytes(str) {
47
+ if (typeof str !== "string")
48
+ throw new Error("utf8ToBytes expected string, got " + typeof str);
49
+ return new Uint8Array(new TextEncoder().encode(str));
50
+ }
51
+ function toBytes(data) {
52
+ if (typeof data === "string")
53
+ data = utf8ToBytes(data);
54
+ abytes(data);
55
+ return data;
56
+ }
57
+ function concatBytes(...arrays) {
58
+ let sum = 0;
59
+ for (let i = 0; i < arrays.length; i++) {
60
+ const a = arrays[i];
61
+ abytes(a);
62
+ sum += a.length;
63
+ }
64
+ const res = new Uint8Array(sum);
65
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
66
+ const a = arrays[i];
67
+ res.set(a, pad);
68
+ pad += a.length;
69
+ }
70
+ return res;
71
+ }
72
+ var Hash = class {
73
+ // Safe version that clones internal state
74
+ clone() {
75
+ return this._cloneInto();
76
+ }
77
+ };
78
+ function wrapConstructor(hashCons) {
79
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
80
+ const tmp = hashCons();
81
+ hashC.outputLen = tmp.outputLen;
82
+ hashC.blockLen = tmp.blockLen;
83
+ hashC.create = () => hashCons();
84
+ return hashC;
85
+ }
86
+ function randomBytes(bytesLength = 32) {
87
+ if (crypto && typeof crypto.getRandomValues === "function") {
88
+ return crypto.getRandomValues(new Uint8Array(bytesLength));
89
+ }
90
+ if (crypto && typeof crypto.randomBytes === "function") {
91
+ return crypto.randomBytes(bytesLength);
92
+ }
93
+ throw new Error("crypto.getRandomValues must be defined");
94
+ }
95
+
96
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/_md.js
19
97
  function setBigUint64(view, byteOffset, value, isLE) {
20
98
  if (typeof view.setBigUint64 === "function")
21
99
  return view.setBigUint64(byteOffset, value, isLE);
@@ -45,7 +123,7 @@ var HashMD = class extends Hash {
45
123
  this.view = createView(this.buffer);
46
124
  }
47
125
  update(data) {
48
- exists(this);
126
+ aexists(this);
49
127
  const { view, buffer, blockLen } = this;
50
128
  data = toBytes(data);
51
129
  const len = data.length;
@@ -70,8 +148,8 @@ var HashMD = class extends Hash {
70
148
  return this;
71
149
  }
72
150
  digestInto(out) {
73
- exists(this);
74
- output(out, this);
151
+ aexists(this);
152
+ aoutput(out, this);
75
153
  this.finished = true;
76
154
  const { buffer, view, blockLen, isLE } = this;
77
155
  let { pos } = this;
@@ -117,7 +195,7 @@ var HashMD = class extends Hash {
117
195
  }
118
196
  };
119
197
 
120
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/sha256.js
198
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/sha256.js
121
199
  var SHA256_K = /* @__PURE__ */ new Uint32Array([
122
200
  1116352408,
123
201
  1899447441,
@@ -267,39 +345,39 @@ var SHA256 = class extends HashMD {
267
345
  };
268
346
  var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
269
347
 
270
- // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/hmac.js
348
+ // ../../node_modules/.pnpm/@noble+hashes@1.6.0/node_modules/@noble/hashes/esm/hmac.js
271
349
  var HMAC = class extends Hash {
272
- constructor(hash2, _key) {
350
+ constructor(hash, _key) {
273
351
  super();
274
352
  this.finished = false;
275
353
  this.destroyed = false;
276
- hash(hash2);
354
+ ahash(hash);
277
355
  const key = toBytes(_key);
278
- this.iHash = hash2.create();
356
+ this.iHash = hash.create();
279
357
  if (typeof this.iHash.update !== "function")
280
358
  throw new Error("Expected instance of class which extends utils.Hash");
281
359
  this.blockLen = this.iHash.blockLen;
282
360
  this.outputLen = this.iHash.outputLen;
283
361
  const blockLen = this.blockLen;
284
362
  const pad = new Uint8Array(blockLen);
285
- pad.set(key.length > blockLen ? hash2.create().update(key).digest() : key);
363
+ pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
286
364
  for (let i = 0; i < pad.length; i++)
287
365
  pad[i] ^= 54;
288
366
  this.iHash.update(pad);
289
- this.oHash = hash2.create();
367
+ this.oHash = hash.create();
290
368
  for (let i = 0; i < pad.length; i++)
291
369
  pad[i] ^= 54 ^ 92;
292
370
  this.oHash.update(pad);
293
371
  pad.fill(0);
294
372
  }
295
373
  update(buf) {
296
- exists(this);
374
+ aexists(this);
297
375
  this.iHash.update(buf);
298
376
  return this;
299
377
  }
300
378
  digestInto(out) {
301
- exists(this);
302
- bytes(out, this.outputLen);
379
+ aexists(this);
380
+ abytes(out, this.outputLen);
303
381
  this.finished = true;
304
382
  this.iHash.digestInto(out);
305
383
  this.oHash.update(out);
@@ -329,15 +407,15 @@ var HMAC = class extends Hash {
329
407
  this.iHash.destroy();
330
408
  }
331
409
  };
332
- var hmac = (hash2, key, message) => new HMAC(hash2, key).update(message).digest();
333
- hmac.create = (hash2, key) => new HMAC(hash2, key);
410
+ var hmac = (hash, key, message) => new HMAC(hash, key).update(message).digest();
411
+ hmac.create = (hash, key) => new HMAC(hash, key);
334
412
 
335
- // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/utils.js
413
+ // ../../node_modules/.pnpm/@noble+curves@1.7.0/node_modules/@noble/curves/esm/abstract/utils.js
336
414
  var utils_exports = {};
337
415
  __export(utils_exports, {
338
416
  aInRange: () => aInRange,
339
417
  abool: () => abool,
340
- abytes: () => abytes,
418
+ abytes: () => abytes2,
341
419
  bitGet: () => bitGet,
342
420
  bitLen: () => bitLen,
343
421
  bitMask: () => bitMask,
@@ -352,56 +430,56 @@ __export(utils_exports, {
352
430
  hexToBytes: () => hexToBytes,
353
431
  hexToNumber: () => hexToNumber,
354
432
  inRange: () => inRange,
355
- isBytes: () => isBytes,
433
+ isBytes: () => isBytes2,
356
434
  memoized: () => memoized,
357
435
  notImplemented: () => notImplemented,
358
436
  numberToBytesBE: () => numberToBytesBE,
359
437
  numberToBytesLE: () => numberToBytesLE,
360
438
  numberToHexUnpadded: () => numberToHexUnpadded,
361
439
  numberToVarBytesBE: () => numberToVarBytesBE,
362
- utf8ToBytes: () => utf8ToBytes,
440
+ utf8ToBytes: () => utf8ToBytes2,
363
441
  validateObject: () => validateObject
364
442
  });
365
443
  var _0n = /* @__PURE__ */ BigInt(0);
366
444
  var _1n = /* @__PURE__ */ BigInt(1);
367
445
  var _2n = /* @__PURE__ */ BigInt(2);
368
- function isBytes(a) {
369
- return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
446
+ function isBytes2(a) {
447
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
370
448
  }
371
- function abytes(item) {
372
- if (!isBytes(item))
449
+ function abytes2(item) {
450
+ if (!isBytes2(item))
373
451
  throw new Error("Uint8Array expected");
374
452
  }
375
453
  function abool(title, value) {
376
454
  if (typeof value !== "boolean")
377
- throw new Error(`${title} must be valid boolean, got "${value}".`);
455
+ throw new Error(title + " boolean expected, got " + value);
378
456
  }
379
457
  var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
380
- function bytesToHex(bytes2) {
381
- abytes(bytes2);
458
+ function bytesToHex(bytes) {
459
+ abytes2(bytes);
382
460
  let hex = "";
383
- for (let i = 0; i < bytes2.length; i++) {
384
- hex += hexes[bytes2[i]];
461
+ for (let i = 0; i < bytes.length; i++) {
462
+ hex += hexes[bytes[i]];
385
463
  }
386
464
  return hex;
387
465
  }
388
466
  function numberToHexUnpadded(num2) {
389
467
  const hex = num2.toString(16);
390
- return hex.length & 1 ? `0${hex}` : hex;
468
+ return hex.length & 1 ? "0" + hex : hex;
391
469
  }
392
470
  function hexToNumber(hex) {
393
471
  if (typeof hex !== "string")
394
472
  throw new Error("hex string expected, got " + typeof hex);
395
- return BigInt(hex === "" ? "0" : `0x${hex}`);
396
- }
397
- var asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
398
- function asciiToBase16(char) {
399
- if (char >= asciis._0 && char <= asciis._9)
400
- return char - asciis._0;
401
- if (char >= asciis._A && char <= asciis._F)
402
- return char - (asciis._A - 10);
403
- if (char >= asciis._a && char <= asciis._f)
404
- return char - (asciis._a - 10);
473
+ return hex === "" ? _0n : BigInt("0x" + hex);
474
+ }
475
+ var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
476
+ function asciiToBase16(ch) {
477
+ if (ch >= asciis._0 && ch <= asciis._9)
478
+ return ch - asciis._0;
479
+ if (ch >= asciis.A && ch <= asciis.F)
480
+ return ch - (asciis.A - 10);
481
+ if (ch >= asciis.a && ch <= asciis.f)
482
+ return ch - (asciis.a - 10);
405
483
  return;
406
484
  }
407
485
  function hexToBytes(hex) {
@@ -410,7 +488,7 @@ function hexToBytes(hex) {
410
488
  const hl = hex.length;
411
489
  const al = hl / 2;
412
490
  if (hl % 2)
413
- throw new Error("padded hex string expected, got unpadded hex of length " + hl);
491
+ throw new Error("hex string expected, got unpadded hex of length " + hl);
414
492
  const array = new Uint8Array(al);
415
493
  for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
416
494
  const n1 = asciiToBase16(hex.charCodeAt(hi));
@@ -423,12 +501,12 @@ function hexToBytes(hex) {
423
501
  }
424
502
  return array;
425
503
  }
426
- function bytesToNumberBE(bytes2) {
427
- return hexToNumber(bytesToHex(bytes2));
504
+ function bytesToNumberBE(bytes) {
505
+ return hexToNumber(bytesToHex(bytes));
428
506
  }
429
- function bytesToNumberLE(bytes2) {
430
- abytes(bytes2);
431
- return hexToNumber(bytesToHex(Uint8Array.from(bytes2).reverse()));
507
+ function bytesToNumberLE(bytes) {
508
+ abytes2(bytes);
509
+ return hexToNumber(bytesToHex(Uint8Array.from(bytes).reverse()));
432
510
  }
433
511
  function numberToBytesBE(n, len) {
434
512
  return hexToBytes(n.toString(16).padStart(len * 2, "0"));
@@ -445,23 +523,23 @@ function ensureBytes(title, hex, expectedLength) {
445
523
  try {
446
524
  res = hexToBytes(hex);
447
525
  } catch (e) {
448
- throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
526
+ throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
449
527
  }
450
- } else if (isBytes(hex)) {
528
+ } else if (isBytes2(hex)) {
451
529
  res = Uint8Array.from(hex);
452
530
  } else {
453
- throw new Error(`${title} must be hex string or Uint8Array`);
531
+ throw new Error(title + " must be hex string or Uint8Array");
454
532
  }
455
533
  const len = res.length;
456
534
  if (typeof expectedLength === "number" && len !== expectedLength)
457
- throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`);
535
+ throw new Error(title + " of length " + expectedLength + " expected, got " + len);
458
536
  return res;
459
537
  }
460
538
  function concatBytes2(...arrays) {
461
539
  let sum = 0;
462
540
  for (let i = 0; i < arrays.length; i++) {
463
541
  const a = arrays[i];
464
- abytes(a);
542
+ abytes2(a);
465
543
  sum += a.length;
466
544
  }
467
545
  const res = new Uint8Array(sum);
@@ -480,9 +558,9 @@ function equalBytes(a, b) {
480
558
  diff |= a[i] ^ b[i];
481
559
  return diff === 0;
482
560
  }
483
- function utf8ToBytes(str) {
561
+ function utf8ToBytes2(str) {
484
562
  if (typeof str !== "string")
485
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
563
+ throw new Error("string expected");
486
564
  return new Uint8Array(new TextEncoder().encode(str));
487
565
  }
488
566
  var isPosBig = (n) => typeof n === "bigint" && _0n <= n;
@@ -491,7 +569,7 @@ function inRange(n, min, max) {
491
569
  }
492
570
  function aInRange(title, n, min, max) {
493
571
  if (!inRange(n, min, max))
494
- throw new Error(`expected valid ${title}: ${min} <= n < ${max}, got ${typeof n} ${n}`);
572
+ throw new Error("expected valid " + title + ": " + min + " <= n < " + max + ", got " + n);
495
573
  }
496
574
  function bitLen(n) {
497
575
  let len;
@@ -561,7 +639,7 @@ var validatorFns = {
561
639
  function: (val) => typeof val === "function",
562
640
  boolean: (val) => typeof val === "boolean",
563
641
  string: (val) => typeof val === "string",
564
- stringOrUint8Array: (val) => typeof val === "string" || isBytes(val),
642
+ stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
565
643
  isSafeInteger: (val) => Number.isSafeInteger(val),
566
644
  array: (val) => Array.isArray(val),
567
645
  field: (val, object) => object.Fp.isValid(val),
@@ -571,12 +649,12 @@ function validateObject(object, validators, optValidators = {}) {
571
649
  const checkField = (fieldName, type, isOptional) => {
572
650
  const checkVal = validatorFns[type];
573
651
  if (typeof checkVal !== "function")
574
- throw new Error(`Invalid validator "${type}", expected function`);
652
+ throw new Error("invalid validator function");
575
653
  const val = object[fieldName];
576
654
  if (isOptional && val === void 0)
577
655
  return;
578
656
  if (!checkVal(val, object)) {
579
- throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}`);
657
+ throw new Error("param " + String(fieldName) + " is invalid. Expected " + type + ", got " + val);
580
658
  }
581
659
  };
582
660
  for (const [fieldName, type] of Object.entries(validators))
@@ -600,23 +678,25 @@ function memoized(fn) {
600
678
  };
601
679
  }
602
680
 
603
- // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/modular.js
681
+ // ../../node_modules/.pnpm/@noble+curves@1.7.0/node_modules/@noble/curves/esm/abstract/modular.js
604
682
  var _0n2 = BigInt(0);
605
683
  var _1n2 = BigInt(1);
606
- var _2n2 = BigInt(2);
607
- var _3n = BigInt(3);
608
- var _4n = BigInt(4);
609
- var _5n = BigInt(5);
610
- var _8n = BigInt(8);
611
- var _9n = BigInt(9);
612
- var _16n = BigInt(16);
684
+ var _2n2 = /* @__PURE__ */ BigInt(2);
685
+ var _3n = /* @__PURE__ */ BigInt(3);
686
+ var _4n = /* @__PURE__ */ BigInt(4);
687
+ var _5n = /* @__PURE__ */ BigInt(5);
688
+ var _8n = /* @__PURE__ */ BigInt(8);
689
+ var _9n = /* @__PURE__ */ BigInt(9);
690
+ var _16n = /* @__PURE__ */ BigInt(16);
613
691
  function mod(a, b) {
614
692
  const result = a % b;
615
693
  return result >= _0n2 ? result : b + result;
616
694
  }
617
695
  function pow(num2, power, modulo) {
618
- if (modulo <= _0n2 || power < _0n2)
619
- throw new Error("Expected power/modulo > 0");
696
+ if (power < _0n2)
697
+ throw new Error("invalid exponent, negatives unsupported");
698
+ if (modulo <= _0n2)
699
+ throw new Error("invalid modulus");
620
700
  if (modulo === _1n2)
621
701
  return _0n2;
622
702
  let res = _1n2;
@@ -637,9 +717,10 @@ function pow2(x, power, modulo) {
637
717
  return res;
638
718
  }
639
719
  function invert(number, modulo) {
640
- if (number === _0n2 || modulo <= _0n2) {
641
- throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);
642
- }
720
+ if (number === _0n2)
721
+ throw new Error("invert: expected non-zero number");
722
+ if (modulo <= _0n2)
723
+ throw new Error("invert: expected positive modulus, got " + modulo);
643
724
  let a = mod(number, modulo);
644
725
  let b = modulo;
645
726
  let x = _0n2, y = _1n2, u = _1n2, v = _0n2;
@@ -660,38 +741,40 @@ function tonelliShanks(P) {
660
741
  let Q, S, Z;
661
742
  for (Q = P - _1n2, S = 0; Q % _2n2 === _0n2; Q /= _2n2, S++)
662
743
  ;
663
- for (Z = _2n2; Z < P && pow(Z, legendreC, P) !== P - _1n2; Z++)
664
- ;
744
+ for (Z = _2n2; Z < P && pow(Z, legendreC, P) !== P - _1n2; Z++) {
745
+ if (Z > 1e3)
746
+ throw new Error("Cannot find square root: likely non-prime P");
747
+ }
665
748
  if (S === 1) {
666
749
  const p1div4 = (P + _1n2) / _4n;
667
- return function tonelliFast(Fp2, n) {
668
- const root = Fp2.pow(n, p1div4);
669
- if (!Fp2.eql(Fp2.sqr(root), n))
750
+ return function tonelliFast(Fp, n) {
751
+ const root = Fp.pow(n, p1div4);
752
+ if (!Fp.eql(Fp.sqr(root), n))
670
753
  throw new Error("Cannot find square root");
671
754
  return root;
672
755
  };
673
756
  }
674
757
  const Q1div2 = (Q + _1n2) / _2n2;
675
- return function tonelliSlow(Fp2, n) {
676
- if (Fp2.pow(n, legendreC) === Fp2.neg(Fp2.ONE))
758
+ return function tonelliSlow(Fp, n) {
759
+ if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE))
677
760
  throw new Error("Cannot find square root");
678
761
  let r = S;
679
- let g = Fp2.pow(Fp2.mul(Fp2.ONE, Z), Q);
680
- let x = Fp2.pow(n, Q1div2);
681
- let b = Fp2.pow(n, Q);
682
- while (!Fp2.eql(b, Fp2.ONE)) {
683
- if (Fp2.eql(b, Fp2.ZERO))
684
- return Fp2.ZERO;
762
+ let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q);
763
+ let x = Fp.pow(n, Q1div2);
764
+ let b = Fp.pow(n, Q);
765
+ while (!Fp.eql(b, Fp.ONE)) {
766
+ if (Fp.eql(b, Fp.ZERO))
767
+ return Fp.ZERO;
685
768
  let m = 1;
686
- for (let t2 = Fp2.sqr(b); m < r; m++) {
687
- if (Fp2.eql(t2, Fp2.ONE))
769
+ for (let t2 = Fp.sqr(b); m < r; m++) {
770
+ if (Fp.eql(t2, Fp.ONE))
688
771
  break;
689
- t2 = Fp2.sqr(t2);
772
+ t2 = Fp.sqr(t2);
690
773
  }
691
- const ge = Fp2.pow(g, _1n2 << BigInt(r - m - 1));
692
- g = Fp2.sqr(ge);
693
- x = Fp2.mul(x, ge);
694
- b = Fp2.mul(b, g);
774
+ const ge = Fp.pow(g, _1n2 << BigInt(r - m - 1));
775
+ g = Fp.sqr(ge);
776
+ x = Fp.mul(x, ge);
777
+ b = Fp.mul(b, g);
695
778
  r = m;
696
779
  }
697
780
  return x;
@@ -700,22 +783,22 @@ function tonelliShanks(P) {
700
783
  function FpSqrt(P) {
701
784
  if (P % _4n === _3n) {
702
785
  const p1div4 = (P + _1n2) / _4n;
703
- return function sqrt3mod4(Fp2, n) {
704
- const root = Fp2.pow(n, p1div4);
705
- if (!Fp2.eql(Fp2.sqr(root), n))
786
+ return function sqrt3mod4(Fp, n) {
787
+ const root = Fp.pow(n, p1div4);
788
+ if (!Fp.eql(Fp.sqr(root), n))
706
789
  throw new Error("Cannot find square root");
707
790
  return root;
708
791
  };
709
792
  }
710
793
  if (P % _8n === _5n) {
711
794
  const c1 = (P - _5n) / _8n;
712
- return function sqrt5mod8(Fp2, n) {
713
- const n2 = Fp2.mul(n, _2n2);
714
- const v = Fp2.pow(n2, c1);
715
- const nv = Fp2.mul(n, v);
716
- const i = Fp2.mul(Fp2.mul(nv, _2n2), v);
717
- const root = Fp2.mul(nv, Fp2.sub(i, Fp2.ONE));
718
- if (!Fp2.eql(Fp2.sqr(root), n))
795
+ return function sqrt5mod8(Fp, n) {
796
+ const n2 = Fp.mul(n, _2n2);
797
+ const v = Fp.pow(n2, c1);
798
+ const nv = Fp.mul(n, v);
799
+ const i = Fp.mul(Fp.mul(nv, _2n2), v);
800
+ const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
801
+ if (!Fp.eql(Fp.sqr(root), n))
719
802
  throw new Error("Cannot find square root");
720
803
  return root;
721
804
  };
@@ -758,7 +841,7 @@ function validateField(field) {
758
841
  }
759
842
  function FpPow(f, num2, power) {
760
843
  if (power < _0n2)
761
- throw new Error("Expected power > 0");
844
+ throw new Error("invalid exponent, negatives unsupported");
762
845
  if (power === _0n2)
763
846
  return f.ONE;
764
847
  if (power === _1n2)
@@ -797,11 +880,11 @@ function nLength(n, nBitLength) {
797
880
  }
798
881
  function Field(ORDER, bitLen2, isLE = false, redef = {}) {
799
882
  if (ORDER <= _0n2)
800
- throw new Error(`Expected Field ORDER > 0, got ${ORDER}`);
883
+ throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
801
884
  const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
802
885
  if (BYTES > 2048)
803
- throw new Error("Field lengths over 2048 bytes are not supported");
804
- const sqrtP = FpSqrt(ORDER);
886
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
887
+ let sqrtP;
805
888
  const f = Object.freeze({
806
889
  ORDER,
807
890
  BITS,
@@ -812,7 +895,7 @@ function Field(ORDER, bitLen2, isLE = false, redef = {}) {
812
895
  create: (num2) => mod(num2, ORDER),
813
896
  isValid: (num2) => {
814
897
  if (typeof num2 !== "bigint")
815
- throw new Error(`Invalid field element: expected bigint, got ${typeof num2}`);
898
+ throw new Error("invalid field element: expected bigint, got " + typeof num2);
816
899
  return _0n2 <= num2 && num2 < ORDER;
817
900
  },
818
901
  is0: (num2) => num2 === _0n2,
@@ -831,16 +914,20 @@ function Field(ORDER, bitLen2, isLE = false, redef = {}) {
831
914
  subN: (lhs, rhs) => lhs - rhs,
832
915
  mulN: (lhs, rhs) => lhs * rhs,
833
916
  inv: (num2) => invert(num2, ORDER),
834
- sqrt: redef.sqrt || ((n) => sqrtP(f, n)),
917
+ sqrt: redef.sqrt || ((n) => {
918
+ if (!sqrtP)
919
+ sqrtP = FpSqrt(ORDER);
920
+ return sqrtP(f, n);
921
+ }),
835
922
  invertBatch: (lst) => FpInvertBatch(f, lst),
836
923
  // TODO: do we really need constant cmov?
837
924
  // We don't have const-time bigints anyway, so probably will be not very useful
838
925
  cmov: (a, b, c) => c ? b : a,
839
926
  toBytes: (num2) => isLE ? numberToBytesLE(num2, BYTES) : numberToBytesBE(num2, BYTES),
840
- fromBytes: (bytes2) => {
841
- if (bytes2.length !== BYTES)
842
- throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes2.length}`);
843
- return isLE ? bytesToNumberLE(bytes2) : bytesToNumberBE(bytes2);
927
+ fromBytes: (bytes) => {
928
+ if (bytes.length !== BYTES)
929
+ throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
930
+ return isLE ? bytesToNumberLE(bytes) : bytesToNumberBE(bytes);
844
931
  }
845
932
  });
846
933
  return Object.freeze(f);
@@ -860,37 +947,58 @@ function mapHashToField(key, fieldOrder, isLE = false) {
860
947
  const fieldLen = getFieldBytesLength(fieldOrder);
861
948
  const minLen = getMinHashLength(fieldOrder);
862
949
  if (len < 16 || len < minLen || len > 1024)
863
- throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
950
+ throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
864
951
  const num2 = isLE ? bytesToNumberBE(key) : bytesToNumberLE(key);
865
952
  const reduced = mod(num2, fieldOrder - _1n2) + _1n2;
866
953
  return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
867
954
  }
868
955
 
869
- // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/curve.js
956
+ // ../../node_modules/.pnpm/@noble+curves@1.7.0/node_modules/@noble/curves/esm/abstract/curve.js
870
957
  var _0n3 = BigInt(0);
871
958
  var _1n3 = BigInt(1);
959
+ function constTimeNegate(condition, item) {
960
+ const neg = item.negate();
961
+ return condition ? neg : item;
962
+ }
963
+ function validateW(W, bits) {
964
+ if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
965
+ throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W);
966
+ }
967
+ function calcWOpts(W, bits) {
968
+ validateW(W, bits);
969
+ const windows = Math.ceil(bits / W) + 1;
970
+ const windowSize = 2 ** (W - 1);
971
+ return { windows, windowSize };
972
+ }
973
+ function validateMSMPoints(points, c) {
974
+ if (!Array.isArray(points))
975
+ throw new Error("array expected");
976
+ points.forEach((p, i) => {
977
+ if (!(p instanceof c))
978
+ throw new Error("invalid point at index " + i);
979
+ });
980
+ }
981
+ function validateMSMScalars(scalars, field) {
982
+ if (!Array.isArray(scalars))
983
+ throw new Error("array of scalars expected");
984
+ scalars.forEach((s, i) => {
985
+ if (!field.isValid(s))
986
+ throw new Error("invalid scalar at index " + i);
987
+ });
988
+ }
872
989
  var pointPrecomputes = /* @__PURE__ */ new WeakMap();
873
990
  var pointWindowSizes = /* @__PURE__ */ new WeakMap();
991
+ function getW(P) {
992
+ return pointWindowSizes.get(P) || 1;
993
+ }
874
994
  function wNAF(c, bits) {
875
- const constTimeNegate = (condition, item) => {
876
- const neg = item.negate();
877
- return condition ? neg : item;
878
- };
879
- const validateW = (W) => {
880
- if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
881
- throw new Error(`Wrong window size=${W}, should be [1..${bits}]`);
882
- };
883
- const opts = (W) => {
884
- validateW(W);
885
- const windows = Math.ceil(bits / W) + 1;
886
- const windowSize = 2 ** (W - 1);
887
- return { windows, windowSize };
888
- };
889
995
  return {
890
996
  constTimeNegate,
997
+ hasPrecomputes(elm) {
998
+ return getW(elm) !== 1;
999
+ },
891
1000
  // non-const time multiplication ladder
892
- unsafeLadder(elm, n) {
893
- let p = c.ZERO;
1001
+ unsafeLadder(elm, n, p = c.ZERO) {
894
1002
  let d = elm;
895
1003
  while (n > _0n3) {
896
1004
  if (n & _1n3)
@@ -908,10 +1016,12 @@ function wNAF(c, bits) {
908
1016
  * - 𝑊 is the window size
909
1017
  * - 𝑛 is the bitlength of the curve order.
910
1018
  * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
1019
+ * @param elm Point instance
1020
+ * @param W window size
911
1021
  * @returns precomputed point tables flattened to a single array
912
1022
  */
913
1023
  precomputeWindow(elm, W) {
914
- const { windows, windowSize } = opts(W);
1024
+ const { windows, windowSize } = calcWOpts(W, bits);
915
1025
  const points = [];
916
1026
  let p = elm;
917
1027
  let base = p;
@@ -934,7 +1044,7 @@ function wNAF(c, bits) {
934
1044
  * @returns real and fake (for const-time) points
935
1045
  */
936
1046
  wNAF(W, precomputes, n) {
937
- const { windows, windowSize } = opts(W);
1047
+ const { windows, windowSize } = calcWOpts(W, bits);
938
1048
  let p = c.ZERO;
939
1049
  let f = c.BASE;
940
1050
  const mask = BigInt(2 ** W - 1);
@@ -960,52 +1070,88 @@ function wNAF(c, bits) {
960
1070
  }
961
1071
  return { p, f };
962
1072
  },
963
- wNAFCached(P, n, transform) {
964
- const W = pointWindowSizes.get(P) || 1;
1073
+ /**
1074
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
1075
+ * @param W window size
1076
+ * @param precomputes precomputed tables
1077
+ * @param n scalar (we don't check here, but should be less than curve order)
1078
+ * @param acc accumulator point to add result of multiplication
1079
+ * @returns point
1080
+ */
1081
+ wNAFUnsafe(W, precomputes, n, acc = c.ZERO) {
1082
+ const { windows, windowSize } = calcWOpts(W, bits);
1083
+ const mask = BigInt(2 ** W - 1);
1084
+ const maxNumber = 2 ** W;
1085
+ const shiftBy = BigInt(W);
1086
+ for (let window = 0; window < windows; window++) {
1087
+ const offset = window * windowSize;
1088
+ if (n === _0n3)
1089
+ break;
1090
+ let wbits = Number(n & mask);
1091
+ n >>= shiftBy;
1092
+ if (wbits > windowSize) {
1093
+ wbits -= maxNumber;
1094
+ n += _1n3;
1095
+ }
1096
+ if (wbits === 0)
1097
+ continue;
1098
+ let curr = precomputes[offset + Math.abs(wbits) - 1];
1099
+ if (wbits < 0)
1100
+ curr = curr.negate();
1101
+ acc = acc.add(curr);
1102
+ }
1103
+ return acc;
1104
+ },
1105
+ getPrecomputes(W, P, transform) {
965
1106
  let comp = pointPrecomputes.get(P);
966
1107
  if (!comp) {
967
1108
  comp = this.precomputeWindow(P, W);
968
1109
  if (W !== 1)
969
1110
  pointPrecomputes.set(P, transform(comp));
970
1111
  }
971
- return this.wNAF(W, comp, n);
1112
+ return comp;
1113
+ },
1114
+ wNAFCached(P, n, transform) {
1115
+ const W = getW(P);
1116
+ return this.wNAF(W, this.getPrecomputes(W, P, transform), n);
1117
+ },
1118
+ wNAFCachedUnsafe(P, n, transform, prev) {
1119
+ const W = getW(P);
1120
+ if (W === 1)
1121
+ return this.unsafeLadder(P, n, prev);
1122
+ return this.wNAFUnsafe(W, this.getPrecomputes(W, P, transform), n, prev);
972
1123
  },
973
1124
  // We calculate precomputes for elliptic curve point multiplication
974
1125
  // using windowed method. This specifies window size and
975
1126
  // stores precomputed values. Usually only base point would be precomputed.
976
1127
  setWindowSize(P, W) {
977
- validateW(W);
1128
+ validateW(W, bits);
978
1129
  pointWindowSizes.set(P, W);
979
1130
  pointPrecomputes.delete(P);
980
1131
  }
981
1132
  };
982
1133
  }
983
- function pippenger(c, field, points, scalars) {
984
- if (!Array.isArray(points) || !Array.isArray(scalars) || scalars.length !== points.length)
1134
+ function pippenger(c, fieldN, points, scalars) {
1135
+ validateMSMPoints(points, c);
1136
+ validateMSMScalars(scalars, fieldN);
1137
+ if (points.length !== scalars.length)
985
1138
  throw new Error("arrays of points and scalars must have equal length");
986
- scalars.forEach((s, i) => {
987
- if (!field.isValid(s))
988
- throw new Error(`wrong scalar at index ${i}`);
989
- });
990
- points.forEach((p, i) => {
991
- if (!(p instanceof c))
992
- throw new Error(`wrong point at index ${i}`);
993
- });
1139
+ const zero = c.ZERO;
994
1140
  const wbits = bitLen(BigInt(points.length));
995
1141
  const windowSize = wbits > 12 ? wbits - 3 : wbits > 4 ? wbits - 2 : wbits ? 2 : 1;
996
1142
  const MASK = (1 << windowSize) - 1;
997
- const buckets = new Array(MASK + 1).fill(c.ZERO);
998
- const lastBits = Math.floor((field.BITS - 1) / windowSize) * windowSize;
999
- let sum = c.ZERO;
1143
+ const buckets = new Array(MASK + 1).fill(zero);
1144
+ const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
1145
+ let sum = zero;
1000
1146
  for (let i = lastBits; i >= 0; i -= windowSize) {
1001
- buckets.fill(c.ZERO);
1147
+ buckets.fill(zero);
1002
1148
  for (let j = 0; j < scalars.length; j++) {
1003
1149
  const scalar = scalars[j];
1004
1150
  const wbits2 = Number(scalar >> BigInt(i) & BigInt(MASK));
1005
1151
  buckets[wbits2] = buckets[wbits2].add(points[j]);
1006
1152
  }
1007
- let resI = c.ZERO;
1008
- for (let j = buckets.length - 1, sumI = c.ZERO; j > 0; j--) {
1153
+ let resI = zero;
1154
+ for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {
1009
1155
  sumI = sumI.add(buckets[j]);
1010
1156
  resI = resI.add(sumI);
1011
1157
  }
@@ -1034,7 +1180,7 @@ function validateBasic(curve) {
1034
1180
  });
1035
1181
  }
1036
1182
 
1037
- // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/weierstrass.js
1183
+ // ../../node_modules/.pnpm/@noble+curves@1.7.0/node_modules/@noble/curves/esm/abstract/weierstrass.js
1038
1184
  function validateSigVerOpts(opts) {
1039
1185
  if (opts.lowS !== void 0)
1040
1186
  abool("lowS", opts.lowS);
@@ -1055,13 +1201,13 @@ function validatePointOpts(curve) {
1055
1201
  fromBytes: "function",
1056
1202
  toBytes: "function"
1057
1203
  });
1058
- const { endo, Fp: Fp2, a } = opts;
1204
+ const { endo, Fp, a } = opts;
1059
1205
  if (endo) {
1060
- if (!Fp2.eql(a, Fp2.ZERO)) {
1061
- throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");
1206
+ if (!Fp.eql(a, Fp.ZERO)) {
1207
+ throw new Error("invalid endomorphism, can only be defined for Koblitz curves that have a=0");
1062
1208
  }
1063
1209
  if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
1064
- throw new Error("Expected endomorphism with beta: bigint and splitScalar: function");
1210
+ throw new Error("invalid endomorphism, expected beta: bigint and splitScalar: function");
1065
1211
  }
1066
1212
  }
1067
1213
  return Object.freeze({ ...opts });
@@ -1087,7 +1233,8 @@ var DER = {
1087
1233
  if (len.length / 2 & 128)
1088
1234
  throw new E("tlv.encode: long form length too big");
1089
1235
  const lenLen = dataLen > 127 ? numberToHexUnpadded(len.length / 2 | 128) : "";
1090
- return `${numberToHexUnpadded(tag)}${lenLen}${len}${data}`;
1236
+ const t = numberToHexUnpadded(tag);
1237
+ return t + lenLen + len + data;
1091
1238
  },
1092
1239
  // v - value, l - left bytes (unparsed)
1093
1240
  decode(tag, data) {
@@ -1138,34 +1285,36 @@ var DER = {
1138
1285
  if (Number.parseInt(hex[0], 16) & 8)
1139
1286
  hex = "00" + hex;
1140
1287
  if (hex.length & 1)
1141
- throw new E("unexpected assertion");
1288
+ throw new E("unexpected DER parsing assertion: unpadded hex");
1142
1289
  return hex;
1143
1290
  },
1144
1291
  decode(data) {
1145
1292
  const { Err: E } = DER;
1146
1293
  if (data[0] & 128)
1147
- throw new E("Invalid signature integer: negative");
1294
+ throw new E("invalid signature integer: negative");
1148
1295
  if (data[0] === 0 && !(data[1] & 128))
1149
- throw new E("Invalid signature integer: unnecessary leading zero");
1296
+ throw new E("invalid signature integer: unnecessary leading zero");
1150
1297
  return b2n(data);
1151
1298
  }
1152
1299
  },
1153
1300
  toSig(hex) {
1154
1301
  const { Err: E, _int: int, _tlv: tlv } = DER;
1155
1302
  const data = typeof hex === "string" ? h2b(hex) : hex;
1156
- abytes(data);
1303
+ abytes2(data);
1157
1304
  const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
1158
1305
  if (seqLeftBytes.length)
1159
- throw new E("Invalid signature: left bytes after parsing");
1306
+ throw new E("invalid signature: left bytes after parsing");
1160
1307
  const { v: rBytes, l: rLeftBytes } = tlv.decode(2, seqBytes);
1161
1308
  const { v: sBytes, l: sLeftBytes } = tlv.decode(2, rLeftBytes);
1162
1309
  if (sLeftBytes.length)
1163
- throw new E("Invalid signature: left bytes after parsing");
1310
+ throw new E("invalid signature: left bytes after parsing");
1164
1311
  return { r: int.decode(rBytes), s: int.decode(sBytes) };
1165
1312
  },
1166
1313
  hexFromSig(sig) {
1167
1314
  const { _tlv: tlv, _int: int } = DER;
1168
- const seq = `${tlv.encode(2, int.encode(sig.r))}${tlv.encode(2, int.encode(sig.s))}`;
1315
+ const rs = tlv.encode(2, int.encode(sig.r));
1316
+ const ss = tlv.encode(2, int.encode(sig.s));
1317
+ const seq = rs + ss;
1169
1318
  return tlv.encode(48, seq);
1170
1319
  }
1171
1320
  };
@@ -1176,25 +1325,25 @@ var _3n2 = BigInt(3);
1176
1325
  var _4n2 = BigInt(4);
1177
1326
  function weierstrassPoints(opts) {
1178
1327
  const CURVE = validatePointOpts(opts);
1179
- const { Fp: Fp2 } = CURVE;
1328
+ const { Fp } = CURVE;
1180
1329
  const Fn = Field(CURVE.n, CURVE.nBitLength);
1181
1330
  const toBytes2 = CURVE.toBytes || ((_c, point, _isCompressed) => {
1182
1331
  const a = point.toAffine();
1183
- return concatBytes2(Uint8Array.from([4]), Fp2.toBytes(a.x), Fp2.toBytes(a.y));
1332
+ return concatBytes2(Uint8Array.from([4]), Fp.toBytes(a.x), Fp.toBytes(a.y));
1184
1333
  });
1185
- const fromBytes = CURVE.fromBytes || ((bytes2) => {
1186
- const tail = bytes2.subarray(1);
1187
- const x = Fp2.fromBytes(tail.subarray(0, Fp2.BYTES));
1188
- const y = Fp2.fromBytes(tail.subarray(Fp2.BYTES, 2 * Fp2.BYTES));
1334
+ const fromBytes = CURVE.fromBytes || ((bytes) => {
1335
+ const tail = bytes.subarray(1);
1336
+ const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
1337
+ const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
1189
1338
  return { x, y };
1190
1339
  });
1191
1340
  function weierstrassEquation(x) {
1192
1341
  const { a, b } = CURVE;
1193
- const x2 = Fp2.sqr(x);
1194
- const x3 = Fp2.mul(x2, x);
1195
- return Fp2.add(Fp2.add(x3, Fp2.mul(x, a)), b);
1342
+ const x2 = Fp.sqr(x);
1343
+ const x3 = Fp.mul(x2, x);
1344
+ return Fp.add(Fp.add(x3, Fp.mul(x, a)), b);
1196
1345
  }
1197
- if (!Fp2.eql(Fp2.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))
1346
+ if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))
1198
1347
  throw new Error("bad generator point: equation left != right");
1199
1348
  function isWithinCurveOrder(num2) {
1200
1349
  return inRange(num2, _1n4, CURVE.n);
@@ -1202,17 +1351,17 @@ function weierstrassPoints(opts) {
1202
1351
  function normPrivateKeyToScalar(key) {
1203
1352
  const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;
1204
1353
  if (lengths && typeof key !== "bigint") {
1205
- if (isBytes(key))
1354
+ if (isBytes2(key))
1206
1355
  key = bytesToHex(key);
1207
1356
  if (typeof key !== "string" || !lengths.includes(key.length))
1208
- throw new Error("Invalid key");
1357
+ throw new Error("invalid private key");
1209
1358
  key = key.padStart(nByteLength * 2, "0");
1210
1359
  }
1211
1360
  let num2;
1212
1361
  try {
1213
1362
  num2 = typeof key === "bigint" ? key : bytesToNumberBE(ensureBytes("private key", key, nByteLength));
1214
1363
  } catch (error) {
1215
- throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
1364
+ throw new Error("invalid private key, expected hex or " + nByteLength + " bytes, got " + typeof key);
1216
1365
  }
1217
1366
  if (wrapPrivateKey)
1218
1367
  num2 = mod(num2, N);
@@ -1225,32 +1374,32 @@ function weierstrassPoints(opts) {
1225
1374
  }
1226
1375
  const toAffineMemo = memoized((p, iz) => {
1227
1376
  const { px: x, py: y, pz: z } = p;
1228
- if (Fp2.eql(z, Fp2.ONE))
1377
+ if (Fp.eql(z, Fp.ONE))
1229
1378
  return { x, y };
1230
1379
  const is0 = p.is0();
1231
1380
  if (iz == null)
1232
- iz = is0 ? Fp2.ONE : Fp2.inv(z);
1233
- const ax = Fp2.mul(x, iz);
1234
- const ay = Fp2.mul(y, iz);
1235
- const zz = Fp2.mul(z, iz);
1381
+ iz = is0 ? Fp.ONE : Fp.inv(z);
1382
+ const ax = Fp.mul(x, iz);
1383
+ const ay = Fp.mul(y, iz);
1384
+ const zz = Fp.mul(z, iz);
1236
1385
  if (is0)
1237
- return { x: Fp2.ZERO, y: Fp2.ZERO };
1238
- if (!Fp2.eql(zz, Fp2.ONE))
1386
+ return { x: Fp.ZERO, y: Fp.ZERO };
1387
+ if (!Fp.eql(zz, Fp.ONE))
1239
1388
  throw new Error("invZ was invalid");
1240
1389
  return { x: ax, y: ay };
1241
1390
  });
1242
1391
  const assertValidMemo = memoized((p) => {
1243
1392
  if (p.is0()) {
1244
- if (CURVE.allowInfinityPoint && !Fp2.is0(p.py))
1393
+ if (CURVE.allowInfinityPoint && !Fp.is0(p.py))
1245
1394
  return;
1246
1395
  throw new Error("bad point: ZERO");
1247
1396
  }
1248
1397
  const { x, y } = p.toAffine();
1249
- if (!Fp2.isValid(x) || !Fp2.isValid(y))
1398
+ if (!Fp.isValid(x) || !Fp.isValid(y))
1250
1399
  throw new Error("bad point: x or y not FE");
1251
- const left = Fp2.sqr(y);
1400
+ const left = Fp.sqr(y);
1252
1401
  const right = weierstrassEquation(x);
1253
- if (!Fp2.eql(left, right))
1402
+ if (!Fp.eql(left, right))
1254
1403
  throw new Error("bad point: equation left != right");
1255
1404
  if (!p.isTorsionFree())
1256
1405
  throw new Error("bad point: not in prime-order subgroup");
@@ -1261,11 +1410,11 @@ function weierstrassPoints(opts) {
1261
1410
  this.px = px;
1262
1411
  this.py = py;
1263
1412
  this.pz = pz;
1264
- if (px == null || !Fp2.isValid(px))
1413
+ if (px == null || !Fp.isValid(px))
1265
1414
  throw new Error("x required");
1266
- if (py == null || !Fp2.isValid(py))
1415
+ if (py == null || !Fp.isValid(py))
1267
1416
  throw new Error("y required");
1268
- if (pz == null || !Fp2.isValid(pz))
1417
+ if (pz == null || !Fp.isValid(pz))
1269
1418
  throw new Error("z required");
1270
1419
  Object.freeze(this);
1271
1420
  }
@@ -1273,14 +1422,14 @@ function weierstrassPoints(opts) {
1273
1422
  // Use fromHex instead, or call assertValidity() later.
1274
1423
  static fromAffine(p) {
1275
1424
  const { x, y } = p || {};
1276
- if (!p || !Fp2.isValid(x) || !Fp2.isValid(y))
1425
+ if (!p || !Fp.isValid(x) || !Fp.isValid(y))
1277
1426
  throw new Error("invalid affine point");
1278
1427
  if (p instanceof Point2)
1279
1428
  throw new Error("projective point not allowed");
1280
- const is0 = (i) => Fp2.eql(i, Fp2.ZERO);
1429
+ const is0 = (i) => Fp.eql(i, Fp.ZERO);
1281
1430
  if (is0(x) && is0(y))
1282
1431
  return Point2.ZERO;
1283
- return new Point2(x, y, Fp2.ONE);
1432
+ return new Point2(x, y, Fp.ONE);
1284
1433
  }
1285
1434
  get x() {
1286
1435
  return this.toAffine().x;
@@ -1295,7 +1444,7 @@ function weierstrassPoints(opts) {
1295
1444
  * Optimization: converts a list of projective points to a list of identical points with Z=1.
1296
1445
  */
1297
1446
  static normalizeZ(points) {
1298
- const toInv = Fp2.invertBatch(points.map((p) => p.pz));
1447
+ const toInv = Fp.invertBatch(points.map((p) => p.pz));
1299
1448
  return points.map((p, i) => p.toAffine(toInv[i])).map(Point2.fromAffine);
1300
1449
  }
1301
1450
  /**
@@ -1325,8 +1474,8 @@ function weierstrassPoints(opts) {
1325
1474
  }
1326
1475
  hasEvenY() {
1327
1476
  const { y } = this.toAffine();
1328
- if (Fp2.isOdd)
1329
- return !Fp2.isOdd(y);
1477
+ if (Fp.isOdd)
1478
+ return !Fp.isOdd(y);
1330
1479
  throw new Error("Field doesn't support isOdd");
1331
1480
  }
1332
1481
  /**
@@ -1336,15 +1485,15 @@ function weierstrassPoints(opts) {
1336
1485
  assertPrjPoint(other);
1337
1486
  const { px: X1, py: Y1, pz: Z1 } = this;
1338
1487
  const { px: X2, py: Y2, pz: Z2 } = other;
1339
- const U1 = Fp2.eql(Fp2.mul(X1, Z2), Fp2.mul(X2, Z1));
1340
- const U2 = Fp2.eql(Fp2.mul(Y1, Z2), Fp2.mul(Y2, Z1));
1488
+ const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));
1489
+ const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));
1341
1490
  return U1 && U2;
1342
1491
  }
1343
1492
  /**
1344
1493
  * Flips point to one corresponding to (x, -y) in Affine coordinates.
1345
1494
  */
1346
1495
  negate() {
1347
- return new Point2(this.px, Fp2.neg(this.py), this.pz);
1496
+ return new Point2(this.px, Fp.neg(this.py), this.pz);
1348
1497
  }
1349
1498
  // Renes-Costello-Batina exception-free doubling formula.
1350
1499
  // There is 30% faster Jacobian formula, but it is not complete.
@@ -1352,40 +1501,40 @@ function weierstrassPoints(opts) {
1352
1501
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
1353
1502
  double() {
1354
1503
  const { a, b } = CURVE;
1355
- const b3 = Fp2.mul(b, _3n2);
1504
+ const b3 = Fp.mul(b, _3n2);
1356
1505
  const { px: X1, py: Y1, pz: Z1 } = this;
1357
- let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
1358
- let t0 = Fp2.mul(X1, X1);
1359
- let t1 = Fp2.mul(Y1, Y1);
1360
- let t2 = Fp2.mul(Z1, Z1);
1361
- let t3 = Fp2.mul(X1, Y1);
1362
- t3 = Fp2.add(t3, t3);
1363
- Z3 = Fp2.mul(X1, Z1);
1364
- Z3 = Fp2.add(Z3, Z3);
1365
- X3 = Fp2.mul(a, Z3);
1366
- Y3 = Fp2.mul(b3, t2);
1367
- Y3 = Fp2.add(X3, Y3);
1368
- X3 = Fp2.sub(t1, Y3);
1369
- Y3 = Fp2.add(t1, Y3);
1370
- Y3 = Fp2.mul(X3, Y3);
1371
- X3 = Fp2.mul(t3, X3);
1372
- Z3 = Fp2.mul(b3, Z3);
1373
- t2 = Fp2.mul(a, t2);
1374
- t3 = Fp2.sub(t0, t2);
1375
- t3 = Fp2.mul(a, t3);
1376
- t3 = Fp2.add(t3, Z3);
1377
- Z3 = Fp2.add(t0, t0);
1378
- t0 = Fp2.add(Z3, t0);
1379
- t0 = Fp2.add(t0, t2);
1380
- t0 = Fp2.mul(t0, t3);
1381
- Y3 = Fp2.add(Y3, t0);
1382
- t2 = Fp2.mul(Y1, Z1);
1383
- t2 = Fp2.add(t2, t2);
1384
- t0 = Fp2.mul(t2, t3);
1385
- X3 = Fp2.sub(X3, t0);
1386
- Z3 = Fp2.mul(t2, t1);
1387
- Z3 = Fp2.add(Z3, Z3);
1388
- Z3 = Fp2.add(Z3, Z3);
1506
+ let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
1507
+ let t0 = Fp.mul(X1, X1);
1508
+ let t1 = Fp.mul(Y1, Y1);
1509
+ let t2 = Fp.mul(Z1, Z1);
1510
+ let t3 = Fp.mul(X1, Y1);
1511
+ t3 = Fp.add(t3, t3);
1512
+ Z3 = Fp.mul(X1, Z1);
1513
+ Z3 = Fp.add(Z3, Z3);
1514
+ X3 = Fp.mul(a, Z3);
1515
+ Y3 = Fp.mul(b3, t2);
1516
+ Y3 = Fp.add(X3, Y3);
1517
+ X3 = Fp.sub(t1, Y3);
1518
+ Y3 = Fp.add(t1, Y3);
1519
+ Y3 = Fp.mul(X3, Y3);
1520
+ X3 = Fp.mul(t3, X3);
1521
+ Z3 = Fp.mul(b3, Z3);
1522
+ t2 = Fp.mul(a, t2);
1523
+ t3 = Fp.sub(t0, t2);
1524
+ t3 = Fp.mul(a, t3);
1525
+ t3 = Fp.add(t3, Z3);
1526
+ Z3 = Fp.add(t0, t0);
1527
+ t0 = Fp.add(Z3, t0);
1528
+ t0 = Fp.add(t0, t2);
1529
+ t0 = Fp.mul(t0, t3);
1530
+ Y3 = Fp.add(Y3, t0);
1531
+ t2 = Fp.mul(Y1, Z1);
1532
+ t2 = Fp.add(t2, t2);
1533
+ t0 = Fp.mul(t2, t3);
1534
+ X3 = Fp.sub(X3, t0);
1535
+ Z3 = Fp.mul(t2, t1);
1536
+ Z3 = Fp.add(Z3, Z3);
1537
+ Z3 = Fp.add(Z3, Z3);
1389
1538
  return new Point2(X3, Y3, Z3);
1390
1539
  }
1391
1540
  // Renes-Costello-Batina exception-free addition formula.
@@ -1396,49 +1545,49 @@ function weierstrassPoints(opts) {
1396
1545
  assertPrjPoint(other);
1397
1546
  const { px: X1, py: Y1, pz: Z1 } = this;
1398
1547
  const { px: X2, py: Y2, pz: Z2 } = other;
1399
- let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
1548
+ let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
1400
1549
  const a = CURVE.a;
1401
- const b3 = Fp2.mul(CURVE.b, _3n2);
1402
- let t0 = Fp2.mul(X1, X2);
1403
- let t1 = Fp2.mul(Y1, Y2);
1404
- let t2 = Fp2.mul(Z1, Z2);
1405
- let t3 = Fp2.add(X1, Y1);
1406
- let t4 = Fp2.add(X2, Y2);
1407
- t3 = Fp2.mul(t3, t4);
1408
- t4 = Fp2.add(t0, t1);
1409
- t3 = Fp2.sub(t3, t4);
1410
- t4 = Fp2.add(X1, Z1);
1411
- let t5 = Fp2.add(X2, Z2);
1412
- t4 = Fp2.mul(t4, t5);
1413
- t5 = Fp2.add(t0, t2);
1414
- t4 = Fp2.sub(t4, t5);
1415
- t5 = Fp2.add(Y1, Z1);
1416
- X3 = Fp2.add(Y2, Z2);
1417
- t5 = Fp2.mul(t5, X3);
1418
- X3 = Fp2.add(t1, t2);
1419
- t5 = Fp2.sub(t5, X3);
1420
- Z3 = Fp2.mul(a, t4);
1421
- X3 = Fp2.mul(b3, t2);
1422
- Z3 = Fp2.add(X3, Z3);
1423
- X3 = Fp2.sub(t1, Z3);
1424
- Z3 = Fp2.add(t1, Z3);
1425
- Y3 = Fp2.mul(X3, Z3);
1426
- t1 = Fp2.add(t0, t0);
1427
- t1 = Fp2.add(t1, t0);
1428
- t2 = Fp2.mul(a, t2);
1429
- t4 = Fp2.mul(b3, t4);
1430
- t1 = Fp2.add(t1, t2);
1431
- t2 = Fp2.sub(t0, t2);
1432
- t2 = Fp2.mul(a, t2);
1433
- t4 = Fp2.add(t4, t2);
1434
- t0 = Fp2.mul(t1, t4);
1435
- Y3 = Fp2.add(Y3, t0);
1436
- t0 = Fp2.mul(t5, t4);
1437
- X3 = Fp2.mul(t3, X3);
1438
- X3 = Fp2.sub(X3, t0);
1439
- t0 = Fp2.mul(t3, t1);
1440
- Z3 = Fp2.mul(t5, Z3);
1441
- Z3 = Fp2.add(Z3, t0);
1550
+ const b3 = Fp.mul(CURVE.b, _3n2);
1551
+ let t0 = Fp.mul(X1, X2);
1552
+ let t1 = Fp.mul(Y1, Y2);
1553
+ let t2 = Fp.mul(Z1, Z2);
1554
+ let t3 = Fp.add(X1, Y1);
1555
+ let t4 = Fp.add(X2, Y2);
1556
+ t3 = Fp.mul(t3, t4);
1557
+ t4 = Fp.add(t0, t1);
1558
+ t3 = Fp.sub(t3, t4);
1559
+ t4 = Fp.add(X1, Z1);
1560
+ let t5 = Fp.add(X2, Z2);
1561
+ t4 = Fp.mul(t4, t5);
1562
+ t5 = Fp.add(t0, t2);
1563
+ t4 = Fp.sub(t4, t5);
1564
+ t5 = Fp.add(Y1, Z1);
1565
+ X3 = Fp.add(Y2, Z2);
1566
+ t5 = Fp.mul(t5, X3);
1567
+ X3 = Fp.add(t1, t2);
1568
+ t5 = Fp.sub(t5, X3);
1569
+ Z3 = Fp.mul(a, t4);
1570
+ X3 = Fp.mul(b3, t2);
1571
+ Z3 = Fp.add(X3, Z3);
1572
+ X3 = Fp.sub(t1, Z3);
1573
+ Z3 = Fp.add(t1, Z3);
1574
+ Y3 = Fp.mul(X3, Z3);
1575
+ t1 = Fp.add(t0, t0);
1576
+ t1 = Fp.add(t1, t0);
1577
+ t2 = Fp.mul(a, t2);
1578
+ t4 = Fp.mul(b3, t4);
1579
+ t1 = Fp.add(t1, t2);
1580
+ t2 = Fp.sub(t0, t2);
1581
+ t2 = Fp.mul(a, t2);
1582
+ t4 = Fp.add(t4, t2);
1583
+ t0 = Fp.mul(t1, t4);
1584
+ Y3 = Fp.add(Y3, t0);
1585
+ t0 = Fp.mul(t5, t4);
1586
+ X3 = Fp.mul(t3, X3);
1587
+ X3 = Fp.sub(X3, t0);
1588
+ t0 = Fp.mul(t3, t1);
1589
+ Z3 = Fp.mul(t5, Z3);
1590
+ Z3 = Fp.add(Z3, t0);
1442
1591
  return new Point2(X3, Y3, Z3);
1443
1592
  }
1444
1593
  subtract(other) {
@@ -1456,15 +1605,15 @@ function weierstrassPoints(opts) {
1456
1605
  * an exposed private key e.g. sig verification, which works over *public* keys.
1457
1606
  */
1458
1607
  multiplyUnsafe(sc) {
1459
- aInRange("scalar", sc, _0n4, CURVE.n);
1608
+ const { endo, n: N } = CURVE;
1609
+ aInRange("scalar", sc, _0n4, N);
1460
1610
  const I = Point2.ZERO;
1461
1611
  if (sc === _0n4)
1462
1612
  return I;
1463
- if (sc === _1n4)
1613
+ if (this.is0() || sc === _1n4)
1464
1614
  return this;
1465
- const { endo } = CURVE;
1466
- if (!endo)
1467
- return wnaf.unsafeLadder(this, sc);
1615
+ if (!endo || wnaf.hasPrecomputes(this))
1616
+ return wnaf.wNAFCachedUnsafe(this, sc, Point2.normalizeZ);
1468
1617
  let { k1neg, k1, k2neg, k2 } = endo.splitScalar(sc);
1469
1618
  let k1p = I;
1470
1619
  let k2p = I;
@@ -1482,7 +1631,7 @@ function weierstrassPoints(opts) {
1482
1631
  k1p = k1p.negate();
1483
1632
  if (k2neg)
1484
1633
  k2p = k2p.negate();
1485
- k2p = new Point2(Fp2.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
1634
+ k2p = new Point2(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
1486
1635
  return k1p.add(k2p);
1487
1636
  }
1488
1637
  /**
@@ -1504,7 +1653,7 @@ function weierstrassPoints(opts) {
1504
1653
  let { p: k2p, f: f2p } = this.wNAF(k2);
1505
1654
  k1p = wnaf.constTimeNegate(k1neg, k1p);
1506
1655
  k2p = wnaf.constTimeNegate(k2neg, k2p);
1507
- k2p = new Point2(Fp2.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
1656
+ k2p = new Point2(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
1508
1657
  point = k1p.add(k2p);
1509
1658
  fake = f1p.add(f2p);
1510
1659
  } else {
@@ -1558,8 +1707,8 @@ function weierstrassPoints(opts) {
1558
1707
  return bytesToHex(this.toRawBytes(isCompressed));
1559
1708
  }
1560
1709
  }
1561
- Point2.BASE = new Point2(CURVE.Gx, CURVE.Gy, Fp2.ONE);
1562
- Point2.ZERO = new Point2(Fp2.ZERO, Fp2.ONE, Fp2.ZERO);
1710
+ Point2.BASE = new Point2(CURVE.Gx, CURVE.Gy, Fp.ONE);
1711
+ Point2.ZERO = new Point2(Fp.ZERO, Fp.ONE, Fp.ZERO);
1563
1712
  const _bits = CURVE.nBitLength;
1564
1713
  const wnaf = wNAF(Point2, CURVE.endo ? Math.ceil(_bits / 2) : _bits);
1565
1714
  return {
@@ -1585,9 +1734,9 @@ function validateOpts(curve) {
1585
1734
  }
1586
1735
  function weierstrass(curveDef) {
1587
1736
  const CURVE = validateOpts(curveDef);
1588
- const { Fp: Fp2, n: CURVE_ORDER } = CURVE;
1589
- const compressedLen = Fp2.BYTES + 1;
1590
- const uncompressedLen = 2 * Fp2.BYTES + 1;
1737
+ const { Fp, n: CURVE_ORDER } = CURVE;
1738
+ const compressedLen = Fp.BYTES + 1;
1739
+ const uncompressedLen = 2 * Fp.BYTES + 1;
1591
1740
  function modN2(a) {
1592
1741
  return mod(a, CURVE_ORDER);
1593
1742
  }
@@ -1598,27 +1747,27 @@ function weierstrass(curveDef) {
1598
1747
  ...CURVE,
1599
1748
  toBytes(_c, point, isCompressed) {
1600
1749
  const a = point.toAffine();
1601
- const x = Fp2.toBytes(a.x);
1750
+ const x = Fp.toBytes(a.x);
1602
1751
  const cat = concatBytes2;
1603
1752
  abool("isCompressed", isCompressed);
1604
1753
  if (isCompressed) {
1605
1754
  return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
1606
1755
  } else {
1607
- return cat(Uint8Array.from([4]), x, Fp2.toBytes(a.y));
1756
+ return cat(Uint8Array.from([4]), x, Fp.toBytes(a.y));
1608
1757
  }
1609
1758
  },
1610
- fromBytes(bytes2) {
1611
- const len = bytes2.length;
1612
- const head = bytes2[0];
1613
- const tail = bytes2.subarray(1);
1759
+ fromBytes(bytes) {
1760
+ const len = bytes.length;
1761
+ const head = bytes[0];
1762
+ const tail = bytes.subarray(1);
1614
1763
  if (len === compressedLen && (head === 2 || head === 3)) {
1615
1764
  const x = bytesToNumberBE(tail);
1616
- if (!inRange(x, _1n4, Fp2.ORDER))
1765
+ if (!inRange(x, _1n4, Fp.ORDER))
1617
1766
  throw new Error("Point is not on curve");
1618
1767
  const y2 = weierstrassEquation(x);
1619
1768
  let y;
1620
1769
  try {
1621
- y = Fp2.sqrt(y2);
1770
+ y = Fp.sqrt(y2);
1622
1771
  } catch (sqrtError) {
1623
1772
  const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
1624
1773
  throw new Error("Point is not on curve" + suffix);
@@ -1626,14 +1775,16 @@ function weierstrass(curveDef) {
1626
1775
  const isYOdd = (y & _1n4) === _1n4;
1627
1776
  const isHeadOdd = (head & 1) === 1;
1628
1777
  if (isHeadOdd !== isYOdd)
1629
- y = Fp2.neg(y);
1778
+ y = Fp.neg(y);
1630
1779
  return { x, y };
1631
1780
  } else if (len === uncompressedLen && head === 4) {
1632
- const x = Fp2.fromBytes(tail.subarray(0, Fp2.BYTES));
1633
- const y = Fp2.fromBytes(tail.subarray(Fp2.BYTES, 2 * Fp2.BYTES));
1781
+ const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
1782
+ const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
1634
1783
  return { x, y };
1635
1784
  } else {
1636
- throw new Error(`Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes`);
1785
+ const cl = compressedLen;
1786
+ const ul = uncompressedLen;
1787
+ throw new Error("invalid Point, expected length of " + cl + ", or uncompressed " + ul + ", got " + len);
1637
1788
  }
1638
1789
  }
1639
1790
  });
@@ -1678,7 +1829,7 @@ function weierstrass(curveDef) {
1678
1829
  if (rec == null || ![0, 1, 2, 3].includes(rec))
1679
1830
  throw new Error("recovery id invalid");
1680
1831
  const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;
1681
- if (radj >= Fp2.ORDER)
1832
+ if (radj >= Fp.ORDER)
1682
1833
  throw new Error("recovery id 2 or 3 invalid");
1683
1834
  const prefix = (rec & 1) === 0 ? "02" : "03";
1684
1835
  const R = Point2.fromHex(prefix + numToNByteStr(radj));
@@ -1749,7 +1900,7 @@ function weierstrass(curveDef) {
1749
1900
  return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
1750
1901
  }
1751
1902
  function isProbPub(item) {
1752
- const arr = isBytes(item);
1903
+ const arr = isBytes2(item);
1753
1904
  const str = typeof item === "string";
1754
1905
  const len = (arr || str) && item.length;
1755
1906
  if (arr)
@@ -1768,35 +1919,37 @@ function weierstrass(curveDef) {
1768
1919
  const b = Point2.fromHex(publicB);
1769
1920
  return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
1770
1921
  }
1771
- const bits2int = CURVE.bits2int || function(bytes2) {
1772
- const num2 = bytesToNumberBE(bytes2);
1773
- const delta = bytes2.length * 8 - CURVE.nBitLength;
1922
+ const bits2int = CURVE.bits2int || function(bytes) {
1923
+ if (bytes.length > 8192)
1924
+ throw new Error("input is too large");
1925
+ const num2 = bytesToNumberBE(bytes);
1926
+ const delta = bytes.length * 8 - CURVE.nBitLength;
1774
1927
  return delta > 0 ? num2 >> BigInt(delta) : num2;
1775
1928
  };
1776
- const bits2int_modN = CURVE.bits2int_modN || function(bytes2) {
1777
- return modN2(bits2int(bytes2));
1929
+ const bits2int_modN = CURVE.bits2int_modN || function(bytes) {
1930
+ return modN2(bits2int(bytes));
1778
1931
  };
1779
1932
  const ORDER_MASK = bitMask(CURVE.nBitLength);
1780
1933
  function int2octets(num2) {
1781
- aInRange(`num < 2^${CURVE.nBitLength}`, num2, _0n4, ORDER_MASK);
1934
+ aInRange("num < 2^" + CURVE.nBitLength, num2, _0n4, ORDER_MASK);
1782
1935
  return numberToBytesBE(num2, CURVE.nByteLength);
1783
1936
  }
1784
1937
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
1785
1938
  if (["recovered", "canonical"].some((k) => k in opts))
1786
1939
  throw new Error("sign() legacy options not supported");
1787
- const { hash: hash2, randomBytes: randomBytes2 } = CURVE;
1940
+ const { hash, randomBytes: randomBytes2 } = CURVE;
1788
1941
  let { lowS, prehash, extraEntropy: ent } = opts;
1789
1942
  if (lowS == null)
1790
1943
  lowS = true;
1791
1944
  msgHash = ensureBytes("msgHash", msgHash);
1792
1945
  validateSigVerOpts(opts);
1793
1946
  if (prehash)
1794
- msgHash = ensureBytes("prehashed msgHash", hash2(msgHash));
1947
+ msgHash = ensureBytes("prehashed msgHash", hash(msgHash));
1795
1948
  const h1int = bits2int_modN(msgHash);
1796
1949
  const d = normPrivateKeyToScalar(privateKey);
1797
1950
  const seedArgs = [int2octets(d), int2octets(h1int)];
1798
1951
  if (ent != null && ent !== false) {
1799
- const e = ent === true ? randomBytes2(Fp2.BYTES) : ent;
1952
+ const e = ent === true ? randomBytes2(Fp.BYTES) : ent;
1800
1953
  seedArgs.push(ensureBytes("extraEntropy", e));
1801
1954
  }
1802
1955
  const seed = concatBytes2(...seedArgs);
@@ -1836,33 +1989,38 @@ function weierstrass(curveDef) {
1836
1989
  const sg = signature;
1837
1990
  msgHash = ensureBytes("msgHash", msgHash);
1838
1991
  publicKey = ensureBytes("publicKey", publicKey);
1992
+ const { lowS, prehash, format } = opts;
1993
+ validateSigVerOpts(opts);
1839
1994
  if ("strict" in opts)
1840
1995
  throw new Error("options.strict was renamed to lowS");
1841
- validateSigVerOpts(opts);
1842
- const { lowS, prehash } = opts;
1996
+ if (format !== void 0 && format !== "compact" && format !== "der")
1997
+ throw new Error("format must be compact or der");
1998
+ const isHex = typeof sg === "string" || isBytes2(sg);
1999
+ const isObj = !isHex && !format && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
2000
+ if (!isHex && !isObj)
2001
+ throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
1843
2002
  let _sig = void 0;
1844
2003
  let P;
1845
2004
  try {
1846
- if (typeof sg === "string" || isBytes(sg)) {
2005
+ if (isObj)
2006
+ _sig = new Signature(sg.r, sg.s);
2007
+ if (isHex) {
1847
2008
  try {
1848
- _sig = Signature.fromDER(sg);
2009
+ if (format !== "compact")
2010
+ _sig = Signature.fromDER(sg);
1849
2011
  } catch (derError) {
1850
2012
  if (!(derError instanceof DER.Err))
1851
2013
  throw derError;
1852
- _sig = Signature.fromCompact(sg);
1853
2014
  }
1854
- } else if (typeof sg === "object" && typeof sg.r === "bigint" && typeof sg.s === "bigint") {
1855
- const { r: r2, s: s2 } = sg;
1856
- _sig = new Signature(r2, s2);
1857
- } else {
1858
- throw new Error("PARSE");
2015
+ if (!_sig && format !== "der")
2016
+ _sig = Signature.fromCompact(sg);
1859
2017
  }
1860
2018
  P = Point2.fromHex(publicKey);
1861
2019
  } catch (error) {
1862
- if (error.message === "PARSE")
1863
- throw new Error(`signature must be Signature instance, Uint8Array or hex string`);
1864
2020
  return false;
1865
2021
  }
2022
+ if (!_sig)
2023
+ return false;
1866
2024
  if (lowS && _sig.hasHighS())
1867
2025
  return false;
1868
2026
  if (prehash)
@@ -1889,8 +2047,8 @@ function weierstrass(curveDef) {
1889
2047
  utils
1890
2048
  };
1891
2049
  }
1892
- function SWUFpSqrtRatio(Fp2, Z) {
1893
- const q = Fp2.ORDER;
2050
+ function SWUFpSqrtRatio(Fp, Z) {
2051
+ const q = Fp.ORDER;
1894
2052
  let l = _0n4;
1895
2053
  for (let o = q - _1n4; o % _2n3 === _0n4; o /= _2n3)
1896
2054
  l += _1n4;
@@ -1901,115 +2059,114 @@ function SWUFpSqrtRatio(Fp2, Z) {
1901
2059
  const c3 = (c2 - _1n4) / _2n3;
1902
2060
  const c4 = _2n_pow_c1 - _1n4;
1903
2061
  const c5 = _2n_pow_c1_1;
1904
- const c6 = Fp2.pow(Z, c2);
1905
- const c7 = Fp2.pow(Z, (c2 + _1n4) / _2n3);
2062
+ const c6 = Fp.pow(Z, c2);
2063
+ const c7 = Fp.pow(Z, (c2 + _1n4) / _2n3);
1906
2064
  let sqrtRatio = (u, v) => {
1907
2065
  let tv1 = c6;
1908
- let tv2 = Fp2.pow(v, c4);
1909
- let tv3 = Fp2.sqr(tv2);
1910
- tv3 = Fp2.mul(tv3, v);
1911
- let tv5 = Fp2.mul(u, tv3);
1912
- tv5 = Fp2.pow(tv5, c3);
1913
- tv5 = Fp2.mul(tv5, tv2);
1914
- tv2 = Fp2.mul(tv5, v);
1915
- tv3 = Fp2.mul(tv5, u);
1916
- let tv4 = Fp2.mul(tv3, tv2);
1917
- tv5 = Fp2.pow(tv4, c5);
1918
- let isQR = Fp2.eql(tv5, Fp2.ONE);
1919
- tv2 = Fp2.mul(tv3, c7);
1920
- tv5 = Fp2.mul(tv4, tv1);
1921
- tv3 = Fp2.cmov(tv2, tv3, isQR);
1922
- tv4 = Fp2.cmov(tv5, tv4, isQR);
2066
+ let tv2 = Fp.pow(v, c4);
2067
+ let tv3 = Fp.sqr(tv2);
2068
+ tv3 = Fp.mul(tv3, v);
2069
+ let tv5 = Fp.mul(u, tv3);
2070
+ tv5 = Fp.pow(tv5, c3);
2071
+ tv5 = Fp.mul(tv5, tv2);
2072
+ tv2 = Fp.mul(tv5, v);
2073
+ tv3 = Fp.mul(tv5, u);
2074
+ let tv4 = Fp.mul(tv3, tv2);
2075
+ tv5 = Fp.pow(tv4, c5);
2076
+ let isQR = Fp.eql(tv5, Fp.ONE);
2077
+ tv2 = Fp.mul(tv3, c7);
2078
+ tv5 = Fp.mul(tv4, tv1);
2079
+ tv3 = Fp.cmov(tv2, tv3, isQR);
2080
+ tv4 = Fp.cmov(tv5, tv4, isQR);
1923
2081
  for (let i = c1; i > _1n4; i--) {
1924
2082
  let tv52 = i - _2n3;
1925
2083
  tv52 = _2n3 << tv52 - _1n4;
1926
- let tvv5 = Fp2.pow(tv4, tv52);
1927
- const e1 = Fp2.eql(tvv5, Fp2.ONE);
1928
- tv2 = Fp2.mul(tv3, tv1);
1929
- tv1 = Fp2.mul(tv1, tv1);
1930
- tvv5 = Fp2.mul(tv4, tv1);
1931
- tv3 = Fp2.cmov(tv2, tv3, e1);
1932
- tv4 = Fp2.cmov(tvv5, tv4, e1);
2084
+ let tvv5 = Fp.pow(tv4, tv52);
2085
+ const e1 = Fp.eql(tvv5, Fp.ONE);
2086
+ tv2 = Fp.mul(tv3, tv1);
2087
+ tv1 = Fp.mul(tv1, tv1);
2088
+ tvv5 = Fp.mul(tv4, tv1);
2089
+ tv3 = Fp.cmov(tv2, tv3, e1);
2090
+ tv4 = Fp.cmov(tvv5, tv4, e1);
1933
2091
  }
1934
2092
  return { isValid: isQR, value: tv3 };
1935
2093
  };
1936
- if (Fp2.ORDER % _4n2 === _3n2) {
1937
- const c12 = (Fp2.ORDER - _3n2) / _4n2;
1938
- const c22 = Fp2.sqrt(Fp2.neg(Z));
2094
+ if (Fp.ORDER % _4n2 === _3n2) {
2095
+ const c12 = (Fp.ORDER - _3n2) / _4n2;
2096
+ const c22 = Fp.sqrt(Fp.neg(Z));
1939
2097
  sqrtRatio = (u, v) => {
1940
- let tv1 = Fp2.sqr(v);
1941
- const tv2 = Fp2.mul(u, v);
1942
- tv1 = Fp2.mul(tv1, tv2);
1943
- let y1 = Fp2.pow(tv1, c12);
1944
- y1 = Fp2.mul(y1, tv2);
1945
- const y2 = Fp2.mul(y1, c22);
1946
- const tv3 = Fp2.mul(Fp2.sqr(y1), v);
1947
- const isQR = Fp2.eql(tv3, u);
1948
- let y = Fp2.cmov(y2, y1, isQR);
2098
+ let tv1 = Fp.sqr(v);
2099
+ const tv2 = Fp.mul(u, v);
2100
+ tv1 = Fp.mul(tv1, tv2);
2101
+ let y1 = Fp.pow(tv1, c12);
2102
+ y1 = Fp.mul(y1, tv2);
2103
+ const y2 = Fp.mul(y1, c22);
2104
+ const tv3 = Fp.mul(Fp.sqr(y1), v);
2105
+ const isQR = Fp.eql(tv3, u);
2106
+ let y = Fp.cmov(y2, y1, isQR);
1949
2107
  return { isValid: isQR, value: y };
1950
2108
  };
1951
2109
  }
1952
2110
  return sqrtRatio;
1953
2111
  }
1954
- function mapToCurveSimpleSWU(Fp2, opts) {
1955
- validateField(Fp2);
1956
- if (!Fp2.isValid(opts.A) || !Fp2.isValid(opts.B) || !Fp2.isValid(opts.Z))
2112
+ function mapToCurveSimpleSWU(Fp, opts) {
2113
+ validateField(Fp);
2114
+ if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))
1957
2115
  throw new Error("mapToCurveSimpleSWU: invalid opts");
1958
- const sqrtRatio = SWUFpSqrtRatio(Fp2, opts.Z);
1959
- if (!Fp2.isOdd)
2116
+ const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);
2117
+ if (!Fp.isOdd)
1960
2118
  throw new Error("Fp.isOdd is not implemented!");
1961
2119
  return (u) => {
1962
2120
  let tv1, tv2, tv3, tv4, tv5, tv6, x, y;
1963
- tv1 = Fp2.sqr(u);
1964
- tv1 = Fp2.mul(tv1, opts.Z);
1965
- tv2 = Fp2.sqr(tv1);
1966
- tv2 = Fp2.add(tv2, tv1);
1967
- tv3 = Fp2.add(tv2, Fp2.ONE);
1968
- tv3 = Fp2.mul(tv3, opts.B);
1969
- tv4 = Fp2.cmov(opts.Z, Fp2.neg(tv2), !Fp2.eql(tv2, Fp2.ZERO));
1970
- tv4 = Fp2.mul(tv4, opts.A);
1971
- tv2 = Fp2.sqr(tv3);
1972
- tv6 = Fp2.sqr(tv4);
1973
- tv5 = Fp2.mul(tv6, opts.A);
1974
- tv2 = Fp2.add(tv2, tv5);
1975
- tv2 = Fp2.mul(tv2, tv3);
1976
- tv6 = Fp2.mul(tv6, tv4);
1977
- tv5 = Fp2.mul(tv6, opts.B);
1978
- tv2 = Fp2.add(tv2, tv5);
1979
- x = Fp2.mul(tv1, tv3);
2121
+ tv1 = Fp.sqr(u);
2122
+ tv1 = Fp.mul(tv1, opts.Z);
2123
+ tv2 = Fp.sqr(tv1);
2124
+ tv2 = Fp.add(tv2, tv1);
2125
+ tv3 = Fp.add(tv2, Fp.ONE);
2126
+ tv3 = Fp.mul(tv3, opts.B);
2127
+ tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO));
2128
+ tv4 = Fp.mul(tv4, opts.A);
2129
+ tv2 = Fp.sqr(tv3);
2130
+ tv6 = Fp.sqr(tv4);
2131
+ tv5 = Fp.mul(tv6, opts.A);
2132
+ tv2 = Fp.add(tv2, tv5);
2133
+ tv2 = Fp.mul(tv2, tv3);
2134
+ tv6 = Fp.mul(tv6, tv4);
2135
+ tv5 = Fp.mul(tv6, opts.B);
2136
+ tv2 = Fp.add(tv2, tv5);
2137
+ x = Fp.mul(tv1, tv3);
1980
2138
  const { isValid, value } = sqrtRatio(tv2, tv6);
1981
- y = Fp2.mul(tv1, u);
1982
- y = Fp2.mul(y, value);
1983
- x = Fp2.cmov(x, tv3, isValid);
1984
- y = Fp2.cmov(y, value, isValid);
1985
- const e1 = Fp2.isOdd(u) === Fp2.isOdd(y);
1986
- y = Fp2.cmov(Fp2.neg(y), y, e1);
1987
- x = Fp2.div(x, tv4);
2139
+ y = Fp.mul(tv1, u);
2140
+ y = Fp.mul(y, value);
2141
+ x = Fp.cmov(x, tv3, isValid);
2142
+ y = Fp.cmov(y, value, isValid);
2143
+ const e1 = Fp.isOdd(u) === Fp.isOdd(y);
2144
+ y = Fp.cmov(Fp.neg(y), y, e1);
2145
+ x = Fp.div(x, tv4);
1988
2146
  return { x, y };
1989
2147
  };
1990
2148
  }
1991
2149
 
1992
- // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/_shortw_utils.js
1993
- function getHash(hash2) {
2150
+ // ../../node_modules/.pnpm/@noble+curves@1.7.0/node_modules/@noble/curves/esm/_shortw_utils.js
2151
+ function getHash(hash) {
1994
2152
  return {
1995
- hash: hash2,
1996
- hmac: (key, ...msgs) => hmac(hash2, key, concatBytes(...msgs)),
2153
+ hash,
2154
+ hmac: (key, ...msgs) => hmac(hash, key, concatBytes(...msgs)),
1997
2155
  randomBytes
1998
2156
  };
1999
2157
  }
2000
2158
  function createCurve(curveDef, defHash) {
2001
- const create = (hash2) => weierstrass({ ...curveDef, ...getHash(hash2) });
2159
+ const create = (hash) => weierstrass({ ...curveDef, ...getHash(hash) });
2002
2160
  return Object.freeze({ ...create(defHash), create });
2003
2161
  }
2004
2162
 
2005
- // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
2163
+ // ../../node_modules/.pnpm/@noble+curves@1.7.0/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
2006
2164
  var os2ip = bytesToNumberBE;
2007
2165
  function i2osp(value, length) {
2008
2166
  anum(value);
2009
2167
  anum(length);
2010
- if (value < 0 || value >= 1 << 8 * length) {
2011
- throw new Error(`bad I2OSP call: value=${value} length=${length}`);
2012
- }
2168
+ if (value < 0 || value >= 1 << 8 * length)
2169
+ throw new Error("invalid I2OSP input: " + value);
2013
2170
  const res = Array.from({ length }).fill(0);
2014
2171
  for (let i = length - 1; i >= 0; i--) {
2015
2172
  res[i] = value & 255;
@@ -2029,11 +2186,11 @@ function anum(item) {
2029
2186
  throw new Error("number expected");
2030
2187
  }
2031
2188
  function expand_message_xmd(msg, DST, lenInBytes, H) {
2032
- abytes(msg);
2033
- abytes(DST);
2189
+ abytes2(msg);
2190
+ abytes2(DST);
2034
2191
  anum(lenInBytes);
2035
2192
  if (DST.length > 255)
2036
- DST = H(concatBytes2(utf8ToBytes("H2C-OVERSIZE-DST-"), DST));
2193
+ DST = H(concatBytes2(utf8ToBytes2("H2C-OVERSIZE-DST-"), DST));
2037
2194
  const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
2038
2195
  const ell = Math.ceil(lenInBytes / b_in_bytes);
2039
2196
  if (lenInBytes > 65535 || ell > 255)
@@ -2052,12 +2209,12 @@ function expand_message_xmd(msg, DST, lenInBytes, H) {
2052
2209
  return pseudo_random_bytes.slice(0, lenInBytes);
2053
2210
  }
2054
2211
  function expand_message_xof(msg, DST, lenInBytes, k, H) {
2055
- abytes(msg);
2056
- abytes(DST);
2212
+ abytes2(msg);
2213
+ abytes2(DST);
2057
2214
  anum(lenInBytes);
2058
2215
  if (DST.length > 255) {
2059
2216
  const dkLen = Math.ceil(2 * k / 8);
2060
- DST = H.create({ dkLen }).update(utf8ToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
2217
+ DST = H.create({ dkLen }).update(utf8ToBytes2("H2C-OVERSIZE-DST-")).update(DST).digest();
2061
2218
  }
2062
2219
  if (lenInBytes > 65535 || DST.length > 255)
2063
2220
  throw new Error("expand_message_xof: invalid lenInBytes");
@@ -2071,18 +2228,18 @@ function hash_to_field(msg, count, options) {
2071
2228
  k: "isSafeInteger",
2072
2229
  hash: "hash"
2073
2230
  });
2074
- const { p, k, m, hash: hash2, expand, DST: _DST } = options;
2075
- abytes(msg);
2231
+ const { p, k, m, hash, expand, DST: _DST } = options;
2232
+ abytes2(msg);
2076
2233
  anum(count);
2077
- const DST = typeof _DST === "string" ? utf8ToBytes(_DST) : _DST;
2234
+ const DST = typeof _DST === "string" ? utf8ToBytes2(_DST) : _DST;
2078
2235
  const log2p = p.toString(2).length;
2079
2236
  const L = Math.ceil((log2p + k) / 8);
2080
2237
  const len_in_bytes = count * m * L;
2081
2238
  let prb;
2082
2239
  if (expand === "xmd") {
2083
- prb = expand_message_xmd(msg, DST, len_in_bytes, hash2);
2240
+ prb = expand_message_xmd(msg, DST, len_in_bytes, hash);
2084
2241
  } else if (expand === "xof") {
2085
- prb = expand_message_xof(msg, DST, len_in_bytes, k, hash2);
2242
+ prb = expand_message_xof(msg, DST, len_in_bytes, k, hash);
2086
2243
  } else if (expand === "_internal_pass") {
2087
2244
  prb = msg;
2088
2245
  } else {
@@ -2137,7 +2294,7 @@ function createHasher(Point2, mapToCurve, def) {
2137
2294
  throw new Error("mapToCurve: expected array of bigints");
2138
2295
  for (const i of scalars)
2139
2296
  if (typeof i !== "bigint")
2140
- throw new Error(`mapToCurve: expected array of bigints, got ${i} in array`);
2297
+ throw new Error("mapToCurve: expected array of bigints");
2141
2298
  const P = Point2.fromAffine(mapToCurve(scalars)).clearCofactor();
2142
2299
  P.assertValidity();
2143
2300
  return P;
@@ -2145,7 +2302,7 @@ function createHasher(Point2, mapToCurve, def) {
2145
2302
  };
2146
2303
  }
2147
2304
 
2148
- // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/secp256k1.js
2305
+ // ../../node_modules/.pnpm/@noble+curves@1.7.0/node_modules/@noble/curves/esm/secp256k1.js
2149
2306
  var secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
2150
2307
  var secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
2151
2308
  var _1n5 = BigInt(1);
@@ -2169,17 +2326,17 @@ function sqrtMod(y) {
2169
2326
  const t1 = pow2(b223, _23n, P) * b22 % P;
2170
2327
  const t2 = pow2(t1, _6n, P) * b2 % P;
2171
2328
  const root = pow2(t2, _2n4, P);
2172
- if (!Fp.eql(Fp.sqr(root), y))
2329
+ if (!Fpk1.eql(Fpk1.sqr(root), y))
2173
2330
  throw new Error("Cannot find square root");
2174
2331
  return root;
2175
2332
  }
2176
- var Fp = Field(secp256k1P, void 0, void 0, { sqrt: sqrtMod });
2333
+ var Fpk1 = Field(secp256k1P, void 0, void 0, { sqrt: sqrtMod });
2177
2334
  var secp256k1 = createCurve({
2178
2335
  a: BigInt(0),
2179
2336
  // equation params: a, b
2180
2337
  b: BigInt(7),
2181
2338
  // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975
2182
- Fp,
2339
+ Fp: Fpk1,
2183
2340
  // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n
2184
2341
  n: secp256k1N,
2185
2342
  // Curve order, total count of valid points in the field
@@ -2316,7 +2473,7 @@ var schnorr = /* @__PURE__ */ (() => ({
2316
2473
  mod
2317
2474
  }
2318
2475
  }))();
2319
- var isoMap = /* @__PURE__ */ (() => isogenyMap(Fp, [
2476
+ var isoMap = /* @__PURE__ */ (() => isogenyMap(Fpk1, [
2320
2477
  // xNum
2321
2478
  [
2322
2479
  "0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7",
@@ -2347,18 +2504,18 @@ var isoMap = /* @__PURE__ */ (() => isogenyMap(Fp, [
2347
2504
  // LAST 1
2348
2505
  ]
2349
2506
  ].map((i) => i.map((j) => BigInt(j)))))();
2350
- var mapSWU = /* @__PURE__ */ (() => mapToCurveSimpleSWU(Fp, {
2507
+ var mapSWU = /* @__PURE__ */ (() => mapToCurveSimpleSWU(Fpk1, {
2351
2508
  A: BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),
2352
2509
  B: BigInt("1771"),
2353
- Z: Fp.create(BigInt("-11"))
2510
+ Z: Fpk1.create(BigInt("-11"))
2354
2511
  }))();
2355
2512
  var htf = /* @__PURE__ */ (() => createHasher(secp256k1.ProjectivePoint, (scalars) => {
2356
- const { x, y } = mapSWU(Fp.create(scalars[0]));
2513
+ const { x, y } = mapSWU(Fpk1.create(scalars[0]));
2357
2514
  return isoMap(x, y);
2358
2515
  }, {
2359
2516
  DST: "secp256k1_XMD:SHA-256_SSWU_RO_",
2360
2517
  encodeDST: "secp256k1_XMD:SHA-256_SSWU_NU_",
2361
- p: Fp.ORDER,
2518
+ p: Fpk1.ORDER,
2362
2519
  m: 1,
2363
2520
  k: 128,
2364
2521
  expand: "xmd",
@@ -2374,6 +2531,9 @@ export {
2374
2531
  };
2375
2532
  /*! Bundled license information:
2376
2533
 
2534
+ @noble/hashes/esm/utils.js:
2535
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2536
+
2377
2537
  @noble/curves/esm/abstract/utils.js:
2378
2538
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2379
2539
 
@@ -2392,4 +2552,4 @@ export {
2392
2552
  @noble/curves/esm/secp256k1.js:
2393
2553
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2394
2554
  */
2395
- //# sourceMappingURL=secp256k1-NJATWSDZ.js.map
2555
+ //# sourceMappingURL=secp256k1-DTX2GS77.js.map