@t2000/cli 5.16.0 → 5.18.0

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.
package/dist/index.js CHANGED
@@ -3702,8 +3702,8 @@ var require_bn = __commonJS({
3702
3702
  limbLen--;
3703
3703
  limbPow = limbPow / base | 0;
3704
3704
  var total = number.length - start;
3705
- var mod2 = total % limbLen;
3706
- var end = Math.min(total, total - mod2) + start;
3705
+ var mod3 = total % limbLen;
3706
+ var end = Math.min(total, total - mod3) + start;
3707
3707
  var word = 0;
3708
3708
  for (var i = start; i < end; i += limbLen) {
3709
3709
  word = parseBase(number, i, i + limbLen, base);
@@ -3714,10 +3714,10 @@ var require_bn = __commonJS({
3714
3714
  this._iaddn(word);
3715
3715
  }
3716
3716
  }
3717
- if (mod2 !== 0) {
3717
+ if (mod3 !== 0) {
3718
3718
  var pow = 1;
3719
3719
  word = parseBase(number, i, number.length, base);
3720
- for (i = 0; i < mod2; i++) {
3720
+ for (i = 0; i < mod3; i++) {
3721
3721
  pow *= base;
3722
3722
  }
3723
3723
  this.imuln(pow);
@@ -5499,21 +5499,21 @@ var require_bn = __commonJS({
5499
5499
  mod: new BN2(0)
5500
5500
  };
5501
5501
  }
5502
- var div, mod2, res;
5502
+ var div, mod3, res;
5503
5503
  if (this.negative !== 0 && num.negative === 0) {
5504
5504
  res = this.neg().divmod(num, mode);
5505
5505
  if (mode !== "mod") {
5506
5506
  div = res.div.neg();
5507
5507
  }
5508
5508
  if (mode !== "div") {
5509
- mod2 = res.mod.neg();
5510
- if (positive && mod2.negative !== 0) {
5511
- mod2.iadd(num);
5509
+ mod3 = res.mod.neg();
5510
+ if (positive && mod3.negative !== 0) {
5511
+ mod3.iadd(num);
5512
5512
  }
5513
5513
  }
5514
5514
  return {
5515
5515
  div,
5516
- mod: mod2
5516
+ mod: mod3
5517
5517
  };
5518
5518
  }
5519
5519
  if (this.negative === 0 && num.negative !== 0) {
@@ -5529,14 +5529,14 @@ var require_bn = __commonJS({
5529
5529
  if ((this.negative & num.negative) !== 0) {
5530
5530
  res = this.neg().divmod(num.neg(), mode);
5531
5531
  if (mode !== "div") {
5532
- mod2 = res.mod.neg();
5533
- if (positive && mod2.negative !== 0) {
5534
- mod2.isub(num);
5532
+ mod3 = res.mod.neg();
5533
+ if (positive && mod3.negative !== 0) {
5534
+ mod3.isub(num);
5535
5535
  }
5536
5536
  }
5537
5537
  return {
5538
5538
  div: res.div,
5539
- mod: mod2
5539
+ mod: mod3
5540
5540
  };
5541
5541
  }
5542
5542
  if (num.length > this.length || this.cmp(num) < 0) {
@@ -5568,7 +5568,7 @@ var require_bn = __commonJS({
5568
5568
  BN2.prototype.div = function div(num) {
5569
5569
  return this.divmod(num, "div", false).div;
5570
5570
  };
5571
- BN2.prototype.mod = function mod2(num) {
5571
+ BN2.prototype.mod = function mod3(num) {
5572
5572
  return this.divmod(num, "mod", false).mod;
5573
5573
  };
5574
5574
  BN2.prototype.umod = function umod(num) {
@@ -5577,10 +5577,10 @@ var require_bn = __commonJS({
5577
5577
  BN2.prototype.divRound = function divRound(num) {
5578
5578
  var dm = this.divmod(num);
5579
5579
  if (dm.mod.isZero()) return dm.div;
5580
- var mod2 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
5580
+ var mod3 = dm.div.negative !== 0 ? dm.mod.isub(num) : dm.mod;
5581
5581
  var half = num.ushrn(1);
5582
5582
  var r2 = num.andln(1);
5583
- var cmp = mod2.cmp(half);
5583
+ var cmp = mod3.cmp(half);
5584
5584
  if (cmp < 0 || r2 === 1 && cmp === 0) return dm.div;
5585
5585
  return dm.div.negative !== 0 ? dm.div.isubn(1) : dm.div.iaddn(1);
5586
5586
  };
@@ -8132,8 +8132,8 @@ var require_match = __commonJS({
8132
8132
  var require_ascii = __commonJS({
8133
8133
  "../../node_modules/.pnpm/chardet@2.1.1/node_modules/chardet/lib/encoding/ascii.js"(exports) {
8134
8134
  "use strict";
8135
- var __importDefault = exports && exports.__importDefault || function(mod2) {
8136
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
8135
+ var __importDefault = exports && exports.__importDefault || function(mod3) {
8136
+ return mod3 && mod3.__esModule ? mod3 : { "default": mod3 };
8137
8137
  };
8138
8138
  Object.defineProperty(exports, "__esModule", { value: true });
8139
8139
  var match_1 = __importDefault(require_match());
@@ -8160,8 +8160,8 @@ var require_ascii = __commonJS({
8160
8160
  var require_utf8 = __commonJS({
8161
8161
  "../../node_modules/.pnpm/chardet@2.1.1/node_modules/chardet/lib/encoding/utf8.js"(exports) {
8162
8162
  "use strict";
8163
- var __importDefault = exports && exports.__importDefault || function(mod2) {
8164
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
8163
+ var __importDefault = exports && exports.__importDefault || function(mod3) {
8164
+ return mod3 && mod3.__esModule ? mod3 : { "default": mod3 };
8165
8165
  };
8166
8166
  Object.defineProperty(exports, "__esModule", { value: true });
8167
8167
  var match_1 = __importDefault(require_match());
@@ -8231,8 +8231,8 @@ var require_utf8 = __commonJS({
8231
8231
  var require_unicode = __commonJS({
8232
8232
  "../../node_modules/.pnpm/chardet@2.1.1/node_modules/chardet/lib/encoding/unicode.js"(exports) {
8233
8233
  "use strict";
8234
- var __importDefault = exports && exports.__importDefault || function(mod2) {
8235
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
8234
+ var __importDefault = exports && exports.__importDefault || function(mod3) {
8235
+ return mod3 && mod3.__esModule ? mod3 : { "default": mod3 };
8236
8236
  };
8237
8237
  Object.defineProperty(exports, "__esModule", { value: true });
8238
8238
  exports.UTF_32LE = exports.UTF_32BE = exports.UTF_16LE = exports.UTF_16BE = void 0;
@@ -8330,8 +8330,8 @@ var require_unicode = __commonJS({
8330
8330
  var require_mbcs = __commonJS({
8331
8331
  "../../node_modules/.pnpm/chardet@2.1.1/node_modules/chardet/lib/encoding/mbcs.js"(exports) {
8332
8332
  "use strict";
8333
- var __importDefault = exports && exports.__importDefault || function(mod2) {
8334
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
8333
+ var __importDefault = exports && exports.__importDefault || function(mod3) {
8334
+ return mod3 && mod3.__esModule ? mod3 : { "default": mod3 };
8335
8335
  };
8336
8336
  Object.defineProperty(exports, "__esModule", { value: true });
8337
8337
  exports.gb_18030 = exports.euc_kr = exports.euc_jp = exports.big5 = exports.sjis = void 0;
@@ -9075,8 +9075,8 @@ var require_mbcs = __commonJS({
9075
9075
  var require_sbcs = __commonJS({
9076
9076
  "../../node_modules/.pnpm/chardet@2.1.1/node_modules/chardet/lib/encoding/sbcs.js"(exports) {
9077
9077
  "use strict";
9078
- var __importDefault = exports && exports.__importDefault || function(mod2) {
9079
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
9078
+ var __importDefault = exports && exports.__importDefault || function(mod3) {
9079
+ return mod3 && mod3.__esModule ? mod3 : { "default": mod3 };
9080
9080
  };
9081
9081
  Object.defineProperty(exports, "__esModule", { value: true });
9082
9082
  exports.KOI8_R = exports.windows_1256 = exports.windows_1251 = exports.ISO_8859_9 = exports.ISO_8859_8 = exports.ISO_8859_7 = exports.ISO_8859_6 = exports.ISO_8859_5 = exports.ISO_8859_2 = exports.ISO_8859_1 = void 0;
@@ -13426,8 +13426,8 @@ var require_sbcs = __commonJS({
13426
13426
  var require_iso2022 = __commonJS({
13427
13427
  "../../node_modules/.pnpm/chardet@2.1.1/node_modules/chardet/lib/encoding/iso2022.js"(exports) {
13428
13428
  "use strict";
13429
- var __importDefault = exports && exports.__importDefault || function(mod2) {
13430
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
13429
+ var __importDefault = exports && exports.__importDefault || function(mod3) {
13430
+ return mod3 && mod3.__esModule ? mod3 : { "default": mod3 };
13431
13431
  };
13432
13432
  Object.defineProperty(exports, "__esModule", { value: true });
13433
13433
  exports.ISO_2022_CN = exports.ISO_2022_KR = exports.ISO_2022_JP = void 0;
@@ -13587,18 +13587,18 @@ var require_lib2 = __commonJS({
13587
13587
  };
13588
13588
  return ownKeys(o);
13589
13589
  };
13590
- return function(mod2) {
13591
- if (mod2 && mod2.__esModule) return mod2;
13590
+ return function(mod3) {
13591
+ if (mod3 && mod3.__esModule) return mod3;
13592
13592
  var result = {};
13593
- if (mod2 != null) {
13594
- for (var k = ownKeys(mod2), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod2, k[i]);
13593
+ if (mod3 != null) {
13594
+ for (var k = ownKeys(mod3), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod3, k[i]);
13595
13595
  }
13596
- __setModuleDefault(result, mod2);
13596
+ __setModuleDefault(result, mod3);
13597
13597
  return result;
13598
13598
  };
13599
13599
  })();
13600
- var __importDefault = exports && exports.__importDefault || function(mod2) {
13601
- return mod2 && mod2.__esModule ? mod2 : { "default": mod2 };
13600
+ var __importDefault = exports && exports.__importDefault || function(mod3) {
13601
+ return mod3 && mod3.__esModule ? mod3 : { "default": mod3 };
13602
13602
  };
13603
13603
  Object.defineProperty(exports, "__esModule", { value: true });
13604
13604
  exports.detectFileSync = exports.detectFile = exports.analyse = exports.detect = void 0;
@@ -18326,7 +18326,7 @@ var require_polynomial = __commonJS({
18326
18326
  }
18327
18327
  return coeff;
18328
18328
  };
18329
- exports.mod = function mod2(divident, divisor) {
18329
+ exports.mod = function mod3(divident, divisor) {
18330
18330
  let result = new Uint8Array(divident);
18331
18331
  while (result.length - divisor.length >= 0) {
18332
18332
  const coeff = result[0];
@@ -19156,34 +19156,34 @@ var require_qrcode = __commonJS({
19156
19156
  function setupVersionInfo(matrix, version) {
19157
19157
  const size = matrix.size;
19158
19158
  const bits = Version.getEncodedBits(version);
19159
- let row, col, mod2;
19159
+ let row, col, mod3;
19160
19160
  for (let i = 0; i < 18; i++) {
19161
19161
  row = Math.floor(i / 3);
19162
19162
  col = i % 3 + size - 8 - 3;
19163
- mod2 = (bits >> i & 1) === 1;
19164
- matrix.set(row, col, mod2, true);
19165
- matrix.set(col, row, mod2, true);
19163
+ mod3 = (bits >> i & 1) === 1;
19164
+ matrix.set(row, col, mod3, true);
19165
+ matrix.set(col, row, mod3, true);
19166
19166
  }
19167
19167
  }
19168
19168
  function setupFormatInfo(matrix, errorCorrectionLevel, maskPattern) {
19169
19169
  const size = matrix.size;
19170
19170
  const bits = FormatInfo.getEncodedBits(errorCorrectionLevel, maskPattern);
19171
- let i, mod2;
19171
+ let i, mod3;
19172
19172
  for (i = 0; i < 15; i++) {
19173
- mod2 = (bits >> i & 1) === 1;
19173
+ mod3 = (bits >> i & 1) === 1;
19174
19174
  if (i < 6) {
19175
- matrix.set(i, 8, mod2, true);
19175
+ matrix.set(i, 8, mod3, true);
19176
19176
  } else if (i < 8) {
19177
- matrix.set(i + 1, 8, mod2, true);
19177
+ matrix.set(i + 1, 8, mod3, true);
19178
19178
  } else {
19179
- matrix.set(size - 15 + i, 8, mod2, true);
19179
+ matrix.set(size - 15 + i, 8, mod3, true);
19180
19180
  }
19181
19181
  if (i < 8) {
19182
- matrix.set(8, size - i - 1, mod2, true);
19182
+ matrix.set(8, size - i - 1, mod3, true);
19183
19183
  } else if (i < 9) {
19184
- matrix.set(8, 15 - i - 1 + 1, mod2, true);
19184
+ matrix.set(8, 15 - i - 1 + 1, mod3, true);
19185
19185
  } else {
19186
- matrix.set(8, 15 - i - 1, mod2, true);
19186
+ matrix.set(8, 15 - i - 1, mod3, true);
19187
19187
  }
19188
19188
  }
19189
19189
  matrix.set(size - 8, 8, 1, true);
@@ -25955,7 +25955,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
25955
25955
  });
25956
25956
  const { prehash } = eddsaOpts;
25957
25957
  const { BASE, Fp, Fn } = Point;
25958
- const randomBytes2 = eddsaOpts.randomBytes || randomBytes;
25958
+ const randomBytes3 = eddsaOpts.randomBytes || randomBytes;
25959
25959
  const adjustScalarBytes2 = eddsaOpts.adjustScalarBytes || ((bytes) => bytes);
25960
25960
  const domain = eddsaOpts.domain || ((data, ctx, phflag) => {
25961
25961
  abool(phflag, "phflag");
@@ -26037,7 +26037,7 @@ function eddsa(Point, cHash, eddsaOpts = {}) {
26037
26037
  signature: 2 * _size,
26038
26038
  seed: _size
26039
26039
  };
26040
- function randomSecretKey(seed = randomBytes2(lengths.seed)) {
26040
+ function randomSecretKey(seed = randomBytes3(lengths.seed)) {
26041
26041
  return abytes(seed, lengths.seed, "seed");
26042
26042
  }
26043
26043
  function isValidSecretKey(key) {
@@ -26594,6 +26594,2318 @@ var Ed25519Keypair = class Ed25519Keypair2 extends Keypair {
26594
26594
  import { access, mkdir, writeFile, readFile } from "fs/promises";
26595
26595
  import { join as join2, dirname, resolve } from "path";
26596
26596
  import { homedir } from "os";
26597
+
26598
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/cryptoNode.js
26599
+ import * as nc from "crypto";
26600
+ var crypto2 = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && "randomBytes" in nc ? nc : void 0;
26601
+
26602
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/utils.js
26603
+ function isBytes2(a) {
26604
+ return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
26605
+ }
26606
+ function anumber2(n) {
26607
+ if (!Number.isSafeInteger(n) || n < 0)
26608
+ throw new Error("positive integer expected, got " + n);
26609
+ }
26610
+ function abytes2(b, ...lengths) {
26611
+ if (!isBytes2(b))
26612
+ throw new Error("Uint8Array expected");
26613
+ if (lengths.length > 0 && !lengths.includes(b.length))
26614
+ throw new Error("Uint8Array expected of length " + lengths + ", got length=" + b.length);
26615
+ }
26616
+ function ahash2(h) {
26617
+ if (typeof h !== "function" || typeof h.create !== "function")
26618
+ throw new Error("Hash should be wrapped by utils.createHasher");
26619
+ anumber2(h.outputLen);
26620
+ anumber2(h.blockLen);
26621
+ }
26622
+ function aexists2(instance, checkFinished = true) {
26623
+ if (instance.destroyed)
26624
+ throw new Error("Hash instance has been destroyed");
26625
+ if (checkFinished && instance.finished)
26626
+ throw new Error("Hash#digest() has already been called");
26627
+ }
26628
+ function aoutput(out, instance) {
26629
+ abytes2(out);
26630
+ const min = instance.outputLen;
26631
+ if (out.length < min) {
26632
+ throw new Error("digestInto() expects output buffer of length at least " + min);
26633
+ }
26634
+ }
26635
+ function clean2(...arrays) {
26636
+ for (let i = 0; i < arrays.length; i++) {
26637
+ arrays[i].fill(0);
26638
+ }
26639
+ }
26640
+ function createView2(arr) {
26641
+ return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
26642
+ }
26643
+ function rotr2(word, shift) {
26644
+ return word << 32 - shift | word >>> shift;
26645
+ }
26646
+ var hasHexBuiltin = /* @__PURE__ */ (() => (
26647
+ // @ts-ignore
26648
+ typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function"
26649
+ ))();
26650
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
26651
+ function bytesToHex2(bytes) {
26652
+ abytes2(bytes);
26653
+ if (hasHexBuiltin)
26654
+ return bytes.toHex();
26655
+ let hex = "";
26656
+ for (let i = 0; i < bytes.length; i++) {
26657
+ hex += hexes[bytes[i]];
26658
+ }
26659
+ return hex;
26660
+ }
26661
+ var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
26662
+ function asciiToBase16(ch) {
26663
+ if (ch >= asciis._0 && ch <= asciis._9)
26664
+ return ch - asciis._0;
26665
+ if (ch >= asciis.A && ch <= asciis.F)
26666
+ return ch - (asciis.A - 10);
26667
+ if (ch >= asciis.a && ch <= asciis.f)
26668
+ return ch - (asciis.a - 10);
26669
+ return;
26670
+ }
26671
+ function hexToBytes2(hex) {
26672
+ if (typeof hex !== "string")
26673
+ throw new Error("hex string expected, got " + typeof hex);
26674
+ if (hasHexBuiltin)
26675
+ return Uint8Array.fromHex(hex);
26676
+ const hl = hex.length;
26677
+ const al = hl / 2;
26678
+ if (hl % 2)
26679
+ throw new Error("hex string expected, got unpadded hex of length " + hl);
26680
+ const array = new Uint8Array(al);
26681
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
26682
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
26683
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
26684
+ if (n1 === void 0 || n2 === void 0) {
26685
+ const char = hex[hi] + hex[hi + 1];
26686
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
26687
+ }
26688
+ array[ai] = n1 * 16 + n2;
26689
+ }
26690
+ return array;
26691
+ }
26692
+ function utf8ToBytes(str) {
26693
+ if (typeof str !== "string")
26694
+ throw new Error("string expected");
26695
+ return new Uint8Array(new TextEncoder().encode(str));
26696
+ }
26697
+ function toBytes(data) {
26698
+ if (typeof data === "string")
26699
+ data = utf8ToBytes(data);
26700
+ abytes2(data);
26701
+ return data;
26702
+ }
26703
+ function concatBytes2(...arrays) {
26704
+ let sum = 0;
26705
+ for (let i = 0; i < arrays.length; i++) {
26706
+ const a = arrays[i];
26707
+ abytes2(a);
26708
+ sum += a.length;
26709
+ }
26710
+ const res = new Uint8Array(sum);
26711
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
26712
+ const a = arrays[i];
26713
+ res.set(a, pad);
26714
+ pad += a.length;
26715
+ }
26716
+ return res;
26717
+ }
26718
+ var Hash = class {
26719
+ };
26720
+ function createHasher2(hashCons) {
26721
+ const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
26722
+ const tmp = hashCons();
26723
+ hashC.outputLen = tmp.outputLen;
26724
+ hashC.blockLen = tmp.blockLen;
26725
+ hashC.create = () => hashCons();
26726
+ return hashC;
26727
+ }
26728
+ function randomBytes2(bytesLength = 32) {
26729
+ if (crypto2 && typeof crypto2.getRandomValues === "function") {
26730
+ return crypto2.getRandomValues(new Uint8Array(bytesLength));
26731
+ }
26732
+ if (crypto2 && typeof crypto2.randomBytes === "function") {
26733
+ return Uint8Array.from(crypto2.randomBytes(bytesLength));
26734
+ }
26735
+ throw new Error("crypto.getRandomValues must be defined");
26736
+ }
26737
+
26738
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/_md.js
26739
+ function setBigUint64(view, byteOffset, value, isLE) {
26740
+ if (typeof view.setBigUint64 === "function")
26741
+ return view.setBigUint64(byteOffset, value, isLE);
26742
+ const _32n = BigInt(32);
26743
+ const _u32_max = BigInt(4294967295);
26744
+ const wh = Number(value >> _32n & _u32_max);
26745
+ const wl = Number(value & _u32_max);
26746
+ const h = isLE ? 4 : 0;
26747
+ const l = isLE ? 0 : 4;
26748
+ view.setUint32(byteOffset + h, wh, isLE);
26749
+ view.setUint32(byteOffset + l, wl, isLE);
26750
+ }
26751
+ function Chi2(a, b, c) {
26752
+ return a & b ^ ~a & c;
26753
+ }
26754
+ function Maj2(a, b, c) {
26755
+ return a & b ^ a & c ^ b & c;
26756
+ }
26757
+ var HashMD2 = class extends Hash {
26758
+ constructor(blockLen, outputLen, padOffset, isLE) {
26759
+ super();
26760
+ this.finished = false;
26761
+ this.length = 0;
26762
+ this.pos = 0;
26763
+ this.destroyed = false;
26764
+ this.blockLen = blockLen;
26765
+ this.outputLen = outputLen;
26766
+ this.padOffset = padOffset;
26767
+ this.isLE = isLE;
26768
+ this.buffer = new Uint8Array(blockLen);
26769
+ this.view = createView2(this.buffer);
26770
+ }
26771
+ update(data) {
26772
+ aexists2(this);
26773
+ data = toBytes(data);
26774
+ abytes2(data);
26775
+ const { view, buffer, blockLen } = this;
26776
+ const len = data.length;
26777
+ for (let pos = 0; pos < len; ) {
26778
+ const take = Math.min(blockLen - this.pos, len - pos);
26779
+ if (take === blockLen) {
26780
+ const dataView = createView2(data);
26781
+ for (; blockLen <= len - pos; pos += blockLen)
26782
+ this.process(dataView, pos);
26783
+ continue;
26784
+ }
26785
+ buffer.set(data.subarray(pos, pos + take), this.pos);
26786
+ this.pos += take;
26787
+ pos += take;
26788
+ if (this.pos === blockLen) {
26789
+ this.process(view, 0);
26790
+ this.pos = 0;
26791
+ }
26792
+ }
26793
+ this.length += data.length;
26794
+ this.roundClean();
26795
+ return this;
26796
+ }
26797
+ digestInto(out) {
26798
+ aexists2(this);
26799
+ aoutput(out, this);
26800
+ this.finished = true;
26801
+ const { buffer, view, blockLen, isLE } = this;
26802
+ let { pos } = this;
26803
+ buffer[pos++] = 128;
26804
+ clean2(this.buffer.subarray(pos));
26805
+ if (this.padOffset > blockLen - pos) {
26806
+ this.process(view, 0);
26807
+ pos = 0;
26808
+ }
26809
+ for (let i = pos; i < blockLen; i++)
26810
+ buffer[i] = 0;
26811
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
26812
+ this.process(view, 0);
26813
+ const oview = createView2(out);
26814
+ const len = this.outputLen;
26815
+ if (len % 4)
26816
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
26817
+ const outLen = len / 4;
26818
+ const state = this.get();
26819
+ if (outLen > state.length)
26820
+ throw new Error("_sha2: outputLen bigger than state");
26821
+ for (let i = 0; i < outLen; i++)
26822
+ oview.setUint32(4 * i, state[i], isLE);
26823
+ }
26824
+ digest() {
26825
+ const { buffer, outputLen } = this;
26826
+ this.digestInto(buffer);
26827
+ const res = buffer.slice(0, outputLen);
26828
+ this.destroy();
26829
+ return res;
26830
+ }
26831
+ _cloneInto(to) {
26832
+ to || (to = new this.constructor());
26833
+ to.set(...this.get());
26834
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
26835
+ to.destroyed = destroyed;
26836
+ to.finished = finished;
26837
+ to.length = length;
26838
+ to.pos = pos;
26839
+ if (length % blockLen)
26840
+ to.buffer.set(buffer);
26841
+ return to;
26842
+ }
26843
+ clone() {
26844
+ return this._cloneInto();
26845
+ }
26846
+ };
26847
+ var SHA256_IV2 = /* @__PURE__ */ Uint32Array.from([
26848
+ 1779033703,
26849
+ 3144134277,
26850
+ 1013904242,
26851
+ 2773480762,
26852
+ 1359893119,
26853
+ 2600822924,
26854
+ 528734635,
26855
+ 1541459225
26856
+ ]);
26857
+
26858
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha2.js
26859
+ var SHA256_K = /* @__PURE__ */ Uint32Array.from([
26860
+ 1116352408,
26861
+ 1899447441,
26862
+ 3049323471,
26863
+ 3921009573,
26864
+ 961987163,
26865
+ 1508970993,
26866
+ 2453635748,
26867
+ 2870763221,
26868
+ 3624381080,
26869
+ 310598401,
26870
+ 607225278,
26871
+ 1426881987,
26872
+ 1925078388,
26873
+ 2162078206,
26874
+ 2614888103,
26875
+ 3248222580,
26876
+ 3835390401,
26877
+ 4022224774,
26878
+ 264347078,
26879
+ 604807628,
26880
+ 770255983,
26881
+ 1249150122,
26882
+ 1555081692,
26883
+ 1996064986,
26884
+ 2554220882,
26885
+ 2821834349,
26886
+ 2952996808,
26887
+ 3210313671,
26888
+ 3336571891,
26889
+ 3584528711,
26890
+ 113926993,
26891
+ 338241895,
26892
+ 666307205,
26893
+ 773529912,
26894
+ 1294757372,
26895
+ 1396182291,
26896
+ 1695183700,
26897
+ 1986661051,
26898
+ 2177026350,
26899
+ 2456956037,
26900
+ 2730485921,
26901
+ 2820302411,
26902
+ 3259730800,
26903
+ 3345764771,
26904
+ 3516065817,
26905
+ 3600352804,
26906
+ 4094571909,
26907
+ 275423344,
26908
+ 430227734,
26909
+ 506948616,
26910
+ 659060556,
26911
+ 883997877,
26912
+ 958139571,
26913
+ 1322822218,
26914
+ 1537002063,
26915
+ 1747873779,
26916
+ 1955562222,
26917
+ 2024104815,
26918
+ 2227730452,
26919
+ 2361852424,
26920
+ 2428436474,
26921
+ 2756734187,
26922
+ 3204031479,
26923
+ 3329325298
26924
+ ]);
26925
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
26926
+ var SHA256 = class extends HashMD2 {
26927
+ constructor(outputLen = 32) {
26928
+ super(64, outputLen, 8, false);
26929
+ this.A = SHA256_IV2[0] | 0;
26930
+ this.B = SHA256_IV2[1] | 0;
26931
+ this.C = SHA256_IV2[2] | 0;
26932
+ this.D = SHA256_IV2[3] | 0;
26933
+ this.E = SHA256_IV2[4] | 0;
26934
+ this.F = SHA256_IV2[5] | 0;
26935
+ this.G = SHA256_IV2[6] | 0;
26936
+ this.H = SHA256_IV2[7] | 0;
26937
+ }
26938
+ get() {
26939
+ const { A, B, C, D, E, F, G, H } = this;
26940
+ return [A, B, C, D, E, F, G, H];
26941
+ }
26942
+ // prettier-ignore
26943
+ set(A, B, C, D, E, F, G, H) {
26944
+ this.A = A | 0;
26945
+ this.B = B | 0;
26946
+ this.C = C | 0;
26947
+ this.D = D | 0;
26948
+ this.E = E | 0;
26949
+ this.F = F | 0;
26950
+ this.G = G | 0;
26951
+ this.H = H | 0;
26952
+ }
26953
+ process(view, offset) {
26954
+ for (let i = 0; i < 16; i++, offset += 4)
26955
+ SHA256_W[i] = view.getUint32(offset, false);
26956
+ for (let i = 16; i < 64; i++) {
26957
+ const W15 = SHA256_W[i - 15];
26958
+ const W2 = SHA256_W[i - 2];
26959
+ const s0 = rotr2(W15, 7) ^ rotr2(W15, 18) ^ W15 >>> 3;
26960
+ const s1 = rotr2(W2, 17) ^ rotr2(W2, 19) ^ W2 >>> 10;
26961
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
26962
+ }
26963
+ let { A, B, C, D, E, F, G, H } = this;
26964
+ for (let i = 0; i < 64; i++) {
26965
+ const sigma1 = rotr2(E, 6) ^ rotr2(E, 11) ^ rotr2(E, 25);
26966
+ const T1 = H + sigma1 + Chi2(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
26967
+ const sigma0 = rotr2(A, 2) ^ rotr2(A, 13) ^ rotr2(A, 22);
26968
+ const T2 = sigma0 + Maj2(A, B, C) | 0;
26969
+ H = G;
26970
+ G = F;
26971
+ F = E;
26972
+ E = D + T1 | 0;
26973
+ D = C;
26974
+ C = B;
26975
+ B = A;
26976
+ A = T1 + T2 | 0;
26977
+ }
26978
+ A = A + this.A | 0;
26979
+ B = B + this.B | 0;
26980
+ C = C + this.C | 0;
26981
+ D = D + this.D | 0;
26982
+ E = E + this.E | 0;
26983
+ F = F + this.F | 0;
26984
+ G = G + this.G | 0;
26985
+ H = H + this.H | 0;
26986
+ this.set(A, B, C, D, E, F, G, H);
26987
+ }
26988
+ roundClean() {
26989
+ clean2(SHA256_W);
26990
+ }
26991
+ destroy() {
26992
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
26993
+ clean2(this.buffer);
26994
+ }
26995
+ };
26996
+ var sha2562 = /* @__PURE__ */ createHasher2(() => new SHA256());
26997
+
26998
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/hmac.js
26999
+ var HMAC = class extends Hash {
27000
+ constructor(hash, _key) {
27001
+ super();
27002
+ this.finished = false;
27003
+ this.destroyed = false;
27004
+ ahash2(hash);
27005
+ const key = toBytes(_key);
27006
+ this.iHash = hash.create();
27007
+ if (typeof this.iHash.update !== "function")
27008
+ throw new Error("Expected instance of class which extends utils.Hash");
27009
+ this.blockLen = this.iHash.blockLen;
27010
+ this.outputLen = this.iHash.outputLen;
27011
+ const blockLen = this.blockLen;
27012
+ const pad = new Uint8Array(blockLen);
27013
+ pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
27014
+ for (let i = 0; i < pad.length; i++)
27015
+ pad[i] ^= 54;
27016
+ this.iHash.update(pad);
27017
+ this.oHash = hash.create();
27018
+ for (let i = 0; i < pad.length; i++)
27019
+ pad[i] ^= 54 ^ 92;
27020
+ this.oHash.update(pad);
27021
+ clean2(pad);
27022
+ }
27023
+ update(buf) {
27024
+ aexists2(this);
27025
+ this.iHash.update(buf);
27026
+ return this;
27027
+ }
27028
+ digestInto(out) {
27029
+ aexists2(this);
27030
+ abytes2(out, this.outputLen);
27031
+ this.finished = true;
27032
+ this.iHash.digestInto(out);
27033
+ this.oHash.update(out);
27034
+ this.oHash.digestInto(out);
27035
+ this.destroy();
27036
+ }
27037
+ digest() {
27038
+ const out = new Uint8Array(this.oHash.outputLen);
27039
+ this.digestInto(out);
27040
+ return out;
27041
+ }
27042
+ _cloneInto(to) {
27043
+ to || (to = Object.create(Object.getPrototypeOf(this), {}));
27044
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
27045
+ to = to;
27046
+ to.finished = finished;
27047
+ to.destroyed = destroyed;
27048
+ to.blockLen = blockLen;
27049
+ to.outputLen = outputLen;
27050
+ to.oHash = oHash._cloneInto(to.oHash);
27051
+ to.iHash = iHash._cloneInto(to.iHash);
27052
+ return to;
27053
+ }
27054
+ clone() {
27055
+ return this._cloneInto();
27056
+ }
27057
+ destroy() {
27058
+ this.destroyed = true;
27059
+ this.oHash.destroy();
27060
+ this.iHash.destroy();
27061
+ }
27062
+ };
27063
+ var hmac2 = (hash, key, message) => new HMAC(hash, key).update(message).digest();
27064
+ hmac2.create = (hash, key) => new HMAC(hash, key);
27065
+
27066
+ // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/utils.js
27067
+ var _0n5 = /* @__PURE__ */ BigInt(0);
27068
+ var _1n6 = /* @__PURE__ */ BigInt(1);
27069
+ function _abool2(value, title = "") {
27070
+ if (typeof value !== "boolean") {
27071
+ const prefix = title && `"${title}"`;
27072
+ throw new Error(prefix + "expected boolean, got type=" + typeof value);
27073
+ }
27074
+ return value;
27075
+ }
27076
+ function _abytes2(value, length, title = "") {
27077
+ const bytes = isBytes2(value);
27078
+ const len = value?.length;
27079
+ const needsLen = length !== void 0;
27080
+ if (!bytes || needsLen && len !== length) {
27081
+ const prefix = title && `"${title}" `;
27082
+ const ofLen = needsLen ? ` of length ${length}` : "";
27083
+ const got = bytes ? `length=${len}` : `type=${typeof value}`;
27084
+ throw new Error(prefix + "expected Uint8Array" + ofLen + ", got " + got);
27085
+ }
27086
+ return value;
27087
+ }
27088
+ function numberToHexUnpadded(num) {
27089
+ const hex = num.toString(16);
27090
+ return hex.length & 1 ? "0" + hex : hex;
27091
+ }
27092
+ function hexToNumber2(hex) {
27093
+ if (typeof hex !== "string")
27094
+ throw new Error("hex string expected, got " + typeof hex);
27095
+ return hex === "" ? _0n5 : BigInt("0x" + hex);
27096
+ }
27097
+ function bytesToNumberBE2(bytes) {
27098
+ return hexToNumber2(bytesToHex2(bytes));
27099
+ }
27100
+ function bytesToNumberLE2(bytes) {
27101
+ abytes2(bytes);
27102
+ return hexToNumber2(bytesToHex2(Uint8Array.from(bytes).reverse()));
27103
+ }
27104
+ function numberToBytesBE2(n, len) {
27105
+ return hexToBytes2(n.toString(16).padStart(len * 2, "0"));
27106
+ }
27107
+ function numberToBytesLE2(n, len) {
27108
+ return numberToBytesBE2(n, len).reverse();
27109
+ }
27110
+ function ensureBytes(title, hex, expectedLength) {
27111
+ let res;
27112
+ if (typeof hex === "string") {
27113
+ try {
27114
+ res = hexToBytes2(hex);
27115
+ } catch (e) {
27116
+ throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
27117
+ }
27118
+ } else if (isBytes2(hex)) {
27119
+ res = Uint8Array.from(hex);
27120
+ } else {
27121
+ throw new Error(title + " must be hex string or Uint8Array");
27122
+ }
27123
+ const len = res.length;
27124
+ if (typeof expectedLength === "number" && len !== expectedLength)
27125
+ throw new Error(title + " of length " + expectedLength + " expected, got " + len);
27126
+ return res;
27127
+ }
27128
+ var isPosBig2 = (n) => typeof n === "bigint" && _0n5 <= n;
27129
+ function inRange2(n, min, max) {
27130
+ return isPosBig2(n) && isPosBig2(min) && isPosBig2(max) && min <= n && n < max;
27131
+ }
27132
+ function aInRange2(title, n, min, max) {
27133
+ if (!inRange2(n, min, max))
27134
+ throw new Error("expected valid " + title + ": " + min + " <= n < " + max + ", got " + n);
27135
+ }
27136
+ function bitLen2(n) {
27137
+ let len;
27138
+ for (len = 0; n > _0n5; n >>= _1n6, len += 1)
27139
+ ;
27140
+ return len;
27141
+ }
27142
+ var bitMask2 = (n) => (_1n6 << BigInt(n)) - _1n6;
27143
+ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
27144
+ if (typeof hashLen !== "number" || hashLen < 2)
27145
+ throw new Error("hashLen must be a number");
27146
+ if (typeof qByteLen !== "number" || qByteLen < 2)
27147
+ throw new Error("qByteLen must be a number");
27148
+ if (typeof hmacFn !== "function")
27149
+ throw new Error("hmacFn must be a function");
27150
+ const u8n = (len) => new Uint8Array(len);
27151
+ const u8of = (byte) => Uint8Array.of(byte);
27152
+ let v = u8n(hashLen);
27153
+ let k = u8n(hashLen);
27154
+ let i = 0;
27155
+ const reset = () => {
27156
+ v.fill(1);
27157
+ k.fill(0);
27158
+ i = 0;
27159
+ };
27160
+ const h = (...b) => hmacFn(k, v, ...b);
27161
+ const reseed = (seed = u8n(0)) => {
27162
+ k = h(u8of(0), seed);
27163
+ v = h();
27164
+ if (seed.length === 0)
27165
+ return;
27166
+ k = h(u8of(1), seed);
27167
+ v = h();
27168
+ };
27169
+ const gen = () => {
27170
+ if (i++ >= 1e3)
27171
+ throw new Error("drbg: tried 1000 values");
27172
+ let len = 0;
27173
+ const out = [];
27174
+ while (len < qByteLen) {
27175
+ v = h();
27176
+ const sl = v.slice();
27177
+ out.push(sl);
27178
+ len += v.length;
27179
+ }
27180
+ return concatBytes2(...out);
27181
+ };
27182
+ const genUntil = (seed, pred) => {
27183
+ reset();
27184
+ reseed(seed);
27185
+ let res = void 0;
27186
+ while (!(res = pred(gen())))
27187
+ reseed();
27188
+ reset();
27189
+ return res;
27190
+ };
27191
+ return genUntil;
27192
+ }
27193
+ function _validateObject(object, fields, optFields = {}) {
27194
+ if (!object || typeof object !== "object")
27195
+ throw new Error("expected valid options object");
27196
+ function checkField(fieldName, expectedType, isOpt) {
27197
+ const val = object[fieldName];
27198
+ if (isOpt && val === void 0)
27199
+ return;
27200
+ const current = typeof val;
27201
+ if (current !== expectedType || val === null)
27202
+ throw new Error(`param "${fieldName}" is invalid: expected ${expectedType}, got ${current}`);
27203
+ }
27204
+ Object.entries(fields).forEach(([k, v]) => checkField(k, v, false));
27205
+ Object.entries(optFields).forEach(([k, v]) => checkField(k, v, true));
27206
+ }
27207
+ function memoized2(fn) {
27208
+ const map = /* @__PURE__ */ new WeakMap();
27209
+ return (arg, ...args) => {
27210
+ const val = map.get(arg);
27211
+ if (val !== void 0)
27212
+ return val;
27213
+ const computed = fn(arg, ...args);
27214
+ map.set(arg, computed);
27215
+ return computed;
27216
+ };
27217
+ }
27218
+
27219
+ // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/modular.js
27220
+ var _0n6 = BigInt(0);
27221
+ var _1n7 = BigInt(1);
27222
+ var _2n4 = /* @__PURE__ */ BigInt(2);
27223
+ var _3n2 = /* @__PURE__ */ BigInt(3);
27224
+ var _4n2 = /* @__PURE__ */ BigInt(4);
27225
+ var _5n3 = /* @__PURE__ */ BigInt(5);
27226
+ var _7n2 = /* @__PURE__ */ BigInt(7);
27227
+ var _8n4 = /* @__PURE__ */ BigInt(8);
27228
+ var _9n2 = /* @__PURE__ */ BigInt(9);
27229
+ var _16n2 = /* @__PURE__ */ BigInt(16);
27230
+ function mod2(a, b) {
27231
+ const result = a % b;
27232
+ return result >= _0n6 ? result : b + result;
27233
+ }
27234
+ function pow22(x, power, modulo) {
27235
+ let res = x;
27236
+ while (power-- > _0n6) {
27237
+ res *= res;
27238
+ res %= modulo;
27239
+ }
27240
+ return res;
27241
+ }
27242
+ function invert2(number, modulo) {
27243
+ if (number === _0n6)
27244
+ throw new Error("invert: expected non-zero number");
27245
+ if (modulo <= _0n6)
27246
+ throw new Error("invert: expected positive modulus, got " + modulo);
27247
+ let a = mod2(number, modulo);
27248
+ let b = modulo;
27249
+ let x = _0n6, y = _1n7, u = _1n7, v = _0n6;
27250
+ while (a !== _0n6) {
27251
+ const q = b / a;
27252
+ const r = b % a;
27253
+ const m = x - u * q;
27254
+ const n = y - v * q;
27255
+ b = a, a = r, x = u, y = v, u = m, v = n;
27256
+ }
27257
+ const gcd = b;
27258
+ if (gcd !== _1n7)
27259
+ throw new Error("invert: does not exist");
27260
+ return mod2(x, modulo);
27261
+ }
27262
+ function assertIsSquare2(Fp, root, n) {
27263
+ if (!Fp.eql(Fp.sqr(root), n))
27264
+ throw new Error("Cannot find square root");
27265
+ }
27266
+ function sqrt3mod42(Fp, n) {
27267
+ const p1div4 = (Fp.ORDER + _1n7) / _4n2;
27268
+ const root = Fp.pow(n, p1div4);
27269
+ assertIsSquare2(Fp, root, n);
27270
+ return root;
27271
+ }
27272
+ function sqrt5mod82(Fp, n) {
27273
+ const p5div8 = (Fp.ORDER - _5n3) / _8n4;
27274
+ const n2 = Fp.mul(n, _2n4);
27275
+ const v = Fp.pow(n2, p5div8);
27276
+ const nv = Fp.mul(n, v);
27277
+ const i = Fp.mul(Fp.mul(nv, _2n4), v);
27278
+ const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
27279
+ assertIsSquare2(Fp, root, n);
27280
+ return root;
27281
+ }
27282
+ function sqrt9mod162(P) {
27283
+ const Fp_ = Field2(P);
27284
+ const tn = tonelliShanks2(P);
27285
+ const c1 = tn(Fp_, Fp_.neg(Fp_.ONE));
27286
+ const c2 = tn(Fp_, c1);
27287
+ const c3 = tn(Fp_, Fp_.neg(c1));
27288
+ const c4 = (P + _7n2) / _16n2;
27289
+ return (Fp, n) => {
27290
+ let tv1 = Fp.pow(n, c4);
27291
+ let tv2 = Fp.mul(tv1, c1);
27292
+ const tv3 = Fp.mul(tv1, c2);
27293
+ const tv4 = Fp.mul(tv1, c3);
27294
+ const e1 = Fp.eql(Fp.sqr(tv2), n);
27295
+ const e2 = Fp.eql(Fp.sqr(tv3), n);
27296
+ tv1 = Fp.cmov(tv1, tv2, e1);
27297
+ tv2 = Fp.cmov(tv4, tv3, e2);
27298
+ const e3 = Fp.eql(Fp.sqr(tv2), n);
27299
+ const root = Fp.cmov(tv1, tv2, e3);
27300
+ assertIsSquare2(Fp, root, n);
27301
+ return root;
27302
+ };
27303
+ }
27304
+ function tonelliShanks2(P) {
27305
+ if (P < _3n2)
27306
+ throw new Error("sqrt is not defined for small field");
27307
+ let Q = P - _1n7;
27308
+ let S = 0;
27309
+ while (Q % _2n4 === _0n6) {
27310
+ Q /= _2n4;
27311
+ S++;
27312
+ }
27313
+ let Z = _2n4;
27314
+ const _Fp = Field2(P);
27315
+ while (FpLegendre2(_Fp, Z) === 1) {
27316
+ if (Z++ > 1e3)
27317
+ throw new Error("Cannot find square root: probably non-prime P");
27318
+ }
27319
+ if (S === 1)
27320
+ return sqrt3mod42;
27321
+ let cc = _Fp.pow(Z, Q);
27322
+ const Q1div2 = (Q + _1n7) / _2n4;
27323
+ return function tonelliSlow(Fp, n) {
27324
+ if (Fp.is0(n))
27325
+ return n;
27326
+ if (FpLegendre2(Fp, n) !== 1)
27327
+ throw new Error("Cannot find square root");
27328
+ let M = S;
27329
+ let c = Fp.mul(Fp.ONE, cc);
27330
+ let t = Fp.pow(n, Q);
27331
+ let R = Fp.pow(n, Q1div2);
27332
+ while (!Fp.eql(t, Fp.ONE)) {
27333
+ if (Fp.is0(t))
27334
+ return Fp.ZERO;
27335
+ let i = 1;
27336
+ let t_tmp = Fp.sqr(t);
27337
+ while (!Fp.eql(t_tmp, Fp.ONE)) {
27338
+ i++;
27339
+ t_tmp = Fp.sqr(t_tmp);
27340
+ if (i === M)
27341
+ throw new Error("Cannot find square root");
27342
+ }
27343
+ const exponent = _1n7 << BigInt(M - i - 1);
27344
+ const b = Fp.pow(c, exponent);
27345
+ M = i;
27346
+ c = Fp.sqr(b);
27347
+ t = Fp.mul(t, c);
27348
+ R = Fp.mul(R, b);
27349
+ }
27350
+ return R;
27351
+ };
27352
+ }
27353
+ function FpSqrt2(P) {
27354
+ if (P % _4n2 === _3n2)
27355
+ return sqrt3mod42;
27356
+ if (P % _8n4 === _5n3)
27357
+ return sqrt5mod82;
27358
+ if (P % _16n2 === _9n2)
27359
+ return sqrt9mod162(P);
27360
+ return tonelliShanks2(P);
27361
+ }
27362
+ var FIELD_FIELDS2 = [
27363
+ "create",
27364
+ "isValid",
27365
+ "is0",
27366
+ "neg",
27367
+ "inv",
27368
+ "sqrt",
27369
+ "sqr",
27370
+ "eql",
27371
+ "add",
27372
+ "sub",
27373
+ "mul",
27374
+ "pow",
27375
+ "div",
27376
+ "addN",
27377
+ "subN",
27378
+ "mulN",
27379
+ "sqrN"
27380
+ ];
27381
+ function validateField2(field) {
27382
+ const initial = {
27383
+ ORDER: "bigint",
27384
+ MASK: "bigint",
27385
+ BYTES: "number",
27386
+ BITS: "number"
27387
+ };
27388
+ const opts = FIELD_FIELDS2.reduce((map, val) => {
27389
+ map[val] = "function";
27390
+ return map;
27391
+ }, initial);
27392
+ _validateObject(field, opts);
27393
+ return field;
27394
+ }
27395
+ function FpPow2(Fp, num, power) {
27396
+ if (power < _0n6)
27397
+ throw new Error("invalid exponent, negatives unsupported");
27398
+ if (power === _0n6)
27399
+ return Fp.ONE;
27400
+ if (power === _1n7)
27401
+ return num;
27402
+ let p = Fp.ONE;
27403
+ let d = num;
27404
+ while (power > _0n6) {
27405
+ if (power & _1n7)
27406
+ p = Fp.mul(p, d);
27407
+ d = Fp.sqr(d);
27408
+ power >>= _1n7;
27409
+ }
27410
+ return p;
27411
+ }
27412
+ function FpInvertBatch2(Fp, nums, passZero = false) {
27413
+ const inverted = new Array(nums.length).fill(passZero ? Fp.ZERO : void 0);
27414
+ const multipliedAcc = nums.reduce((acc, num, i) => {
27415
+ if (Fp.is0(num))
27416
+ return acc;
27417
+ inverted[i] = acc;
27418
+ return Fp.mul(acc, num);
27419
+ }, Fp.ONE);
27420
+ const invertedAcc = Fp.inv(multipliedAcc);
27421
+ nums.reduceRight((acc, num, i) => {
27422
+ if (Fp.is0(num))
27423
+ return acc;
27424
+ inverted[i] = Fp.mul(acc, inverted[i]);
27425
+ return Fp.mul(acc, num);
27426
+ }, invertedAcc);
27427
+ return inverted;
27428
+ }
27429
+ function FpLegendre2(Fp, n) {
27430
+ const p1mod2 = (Fp.ORDER - _1n7) / _2n4;
27431
+ const powered = Fp.pow(n, p1mod2);
27432
+ const yes = Fp.eql(powered, Fp.ONE);
27433
+ const zero = Fp.eql(powered, Fp.ZERO);
27434
+ const no = Fp.eql(powered, Fp.neg(Fp.ONE));
27435
+ if (!yes && !zero && !no)
27436
+ throw new Error("invalid Legendre symbol result");
27437
+ return yes ? 1 : zero ? 0 : -1;
27438
+ }
27439
+ function nLength2(n, nBitLength) {
27440
+ if (nBitLength !== void 0)
27441
+ anumber2(nBitLength);
27442
+ const _nBitLength = nBitLength !== void 0 ? nBitLength : n.toString(2).length;
27443
+ const nByteLength = Math.ceil(_nBitLength / 8);
27444
+ return { nBitLength: _nBitLength, nByteLength };
27445
+ }
27446
+ function Field2(ORDER, bitLenOrOpts, isLE = false, opts = {}) {
27447
+ if (ORDER <= _0n6)
27448
+ throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
27449
+ let _nbitLength = void 0;
27450
+ let _sqrt = void 0;
27451
+ let modFromBytes = false;
27452
+ let allowedLengths = void 0;
27453
+ if (typeof bitLenOrOpts === "object" && bitLenOrOpts != null) {
27454
+ if (opts.sqrt || isLE)
27455
+ throw new Error("cannot specify opts in two arguments");
27456
+ const _opts = bitLenOrOpts;
27457
+ if (_opts.BITS)
27458
+ _nbitLength = _opts.BITS;
27459
+ if (_opts.sqrt)
27460
+ _sqrt = _opts.sqrt;
27461
+ if (typeof _opts.isLE === "boolean")
27462
+ isLE = _opts.isLE;
27463
+ if (typeof _opts.modFromBytes === "boolean")
27464
+ modFromBytes = _opts.modFromBytes;
27465
+ allowedLengths = _opts.allowedLengths;
27466
+ } else {
27467
+ if (typeof bitLenOrOpts === "number")
27468
+ _nbitLength = bitLenOrOpts;
27469
+ if (opts.sqrt)
27470
+ _sqrt = opts.sqrt;
27471
+ }
27472
+ const { nBitLength: BITS, nByteLength: BYTES } = nLength2(ORDER, _nbitLength);
27473
+ if (BYTES > 2048)
27474
+ throw new Error("invalid field: expected ORDER of <= 2048 bytes");
27475
+ let sqrtP;
27476
+ const f = Object.freeze({
27477
+ ORDER,
27478
+ isLE,
27479
+ BITS,
27480
+ BYTES,
27481
+ MASK: bitMask2(BITS),
27482
+ ZERO: _0n6,
27483
+ ONE: _1n7,
27484
+ allowedLengths,
27485
+ create: (num) => mod2(num, ORDER),
27486
+ isValid: (num) => {
27487
+ if (typeof num !== "bigint")
27488
+ throw new Error("invalid field element: expected bigint, got " + typeof num);
27489
+ return _0n6 <= num && num < ORDER;
27490
+ },
27491
+ is0: (num) => num === _0n6,
27492
+ // is valid and invertible
27493
+ isValidNot0: (num) => !f.is0(num) && f.isValid(num),
27494
+ isOdd: (num) => (num & _1n7) === _1n7,
27495
+ neg: (num) => mod2(-num, ORDER),
27496
+ eql: (lhs, rhs) => lhs === rhs,
27497
+ sqr: (num) => mod2(num * num, ORDER),
27498
+ add: (lhs, rhs) => mod2(lhs + rhs, ORDER),
27499
+ sub: (lhs, rhs) => mod2(lhs - rhs, ORDER),
27500
+ mul: (lhs, rhs) => mod2(lhs * rhs, ORDER),
27501
+ pow: (num, power) => FpPow2(f, num, power),
27502
+ div: (lhs, rhs) => mod2(lhs * invert2(rhs, ORDER), ORDER),
27503
+ // Same as above, but doesn't normalize
27504
+ sqrN: (num) => num * num,
27505
+ addN: (lhs, rhs) => lhs + rhs,
27506
+ subN: (lhs, rhs) => lhs - rhs,
27507
+ mulN: (lhs, rhs) => lhs * rhs,
27508
+ inv: (num) => invert2(num, ORDER),
27509
+ sqrt: _sqrt || ((n) => {
27510
+ if (!sqrtP)
27511
+ sqrtP = FpSqrt2(ORDER);
27512
+ return sqrtP(f, n);
27513
+ }),
27514
+ toBytes: (num) => isLE ? numberToBytesLE2(num, BYTES) : numberToBytesBE2(num, BYTES),
27515
+ fromBytes: (bytes, skipValidation = true) => {
27516
+ if (allowedLengths) {
27517
+ if (!allowedLengths.includes(bytes.length) || bytes.length > BYTES) {
27518
+ throw new Error("Field.fromBytes: expected " + allowedLengths + " bytes, got " + bytes.length);
27519
+ }
27520
+ const padded = new Uint8Array(BYTES);
27521
+ padded.set(bytes, isLE ? 0 : padded.length - bytes.length);
27522
+ bytes = padded;
27523
+ }
27524
+ if (bytes.length !== BYTES)
27525
+ throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
27526
+ let scalar = isLE ? bytesToNumberLE2(bytes) : bytesToNumberBE2(bytes);
27527
+ if (modFromBytes)
27528
+ scalar = mod2(scalar, ORDER);
27529
+ if (!skipValidation) {
27530
+ if (!f.isValid(scalar))
27531
+ throw new Error("invalid field element: outside of range 0..ORDER");
27532
+ }
27533
+ return scalar;
27534
+ },
27535
+ // TODO: we don't need it here, move out to separate fn
27536
+ invertBatch: (lst) => FpInvertBatch2(f, lst),
27537
+ // We can't move this out because Fp6, Fp12 implement it
27538
+ // and it's unclear what to return in there.
27539
+ cmov: (a, b, c) => c ? b : a
27540
+ });
27541
+ return Object.freeze(f);
27542
+ }
27543
+ function getFieldBytesLength(fieldOrder) {
27544
+ if (typeof fieldOrder !== "bigint")
27545
+ throw new Error("field order must be bigint");
27546
+ const bitLength = fieldOrder.toString(2).length;
27547
+ return Math.ceil(bitLength / 8);
27548
+ }
27549
+ function getMinHashLength(fieldOrder) {
27550
+ const length = getFieldBytesLength(fieldOrder);
27551
+ return length + Math.ceil(length / 2);
27552
+ }
27553
+ function mapHashToField(key, fieldOrder, isLE = false) {
27554
+ const len = key.length;
27555
+ const fieldLen = getFieldBytesLength(fieldOrder);
27556
+ const minLen = getMinHashLength(fieldOrder);
27557
+ if (len < 16 || len < minLen || len > 1024)
27558
+ throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
27559
+ const num = isLE ? bytesToNumberLE2(key) : bytesToNumberBE2(key);
27560
+ const reduced = mod2(num, fieldOrder - _1n7) + _1n7;
27561
+ return isLE ? numberToBytesLE2(reduced, fieldLen) : numberToBytesBE2(reduced, fieldLen);
27562
+ }
27563
+
27564
+ // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/curve.js
27565
+ var _0n7 = BigInt(0);
27566
+ var _1n8 = BigInt(1);
27567
+ function negateCt2(condition, item) {
27568
+ const neg = item.negate();
27569
+ return condition ? neg : item;
27570
+ }
27571
+ function normalizeZ2(c, points) {
27572
+ const invertedZs = FpInvertBatch2(c.Fp, points.map((p) => p.Z));
27573
+ return points.map((p, i) => c.fromAffine(p.toAffine(invertedZs[i])));
27574
+ }
27575
+ function validateW2(W, bits) {
27576
+ if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
27577
+ throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W);
27578
+ }
27579
+ function calcWOpts2(W, scalarBits) {
27580
+ validateW2(W, scalarBits);
27581
+ const windows = Math.ceil(scalarBits / W) + 1;
27582
+ const windowSize = 2 ** (W - 1);
27583
+ const maxNumber = 2 ** W;
27584
+ const mask = bitMask2(W);
27585
+ const shiftBy = BigInt(W);
27586
+ return { windows, windowSize, mask, maxNumber, shiftBy };
27587
+ }
27588
+ function calcOffsets2(n, window2, wOpts) {
27589
+ const { windowSize, mask, maxNumber, shiftBy } = wOpts;
27590
+ let wbits = Number(n & mask);
27591
+ let nextN = n >> shiftBy;
27592
+ if (wbits > windowSize) {
27593
+ wbits -= maxNumber;
27594
+ nextN += _1n8;
27595
+ }
27596
+ const offsetStart = window2 * windowSize;
27597
+ const offset = offsetStart + Math.abs(wbits) - 1;
27598
+ const isZero = wbits === 0;
27599
+ const isNeg = wbits < 0;
27600
+ const isNegF = window2 % 2 !== 0;
27601
+ const offsetF = offsetStart;
27602
+ return { nextN, offset, isZero, isNeg, isNegF, offsetF };
27603
+ }
27604
+ function validateMSMPoints(points, c) {
27605
+ if (!Array.isArray(points))
27606
+ throw new Error("array expected");
27607
+ points.forEach((p, i) => {
27608
+ if (!(p instanceof c))
27609
+ throw new Error("invalid point at index " + i);
27610
+ });
27611
+ }
27612
+ function validateMSMScalars(scalars, field) {
27613
+ if (!Array.isArray(scalars))
27614
+ throw new Error("array of scalars expected");
27615
+ scalars.forEach((s, i) => {
27616
+ if (!field.isValid(s))
27617
+ throw new Error("invalid scalar at index " + i);
27618
+ });
27619
+ }
27620
+ var pointPrecomputes2 = /* @__PURE__ */ new WeakMap();
27621
+ var pointWindowSizes2 = /* @__PURE__ */ new WeakMap();
27622
+ function getW2(P) {
27623
+ return pointWindowSizes2.get(P) || 1;
27624
+ }
27625
+ function assert02(n) {
27626
+ if (n !== _0n7)
27627
+ throw new Error("invalid wNAF");
27628
+ }
27629
+ var wNAF2 = class {
27630
+ // Parametrized with a given Point class (not individual point)
27631
+ constructor(Point, bits) {
27632
+ this.BASE = Point.BASE;
27633
+ this.ZERO = Point.ZERO;
27634
+ this.Fn = Point.Fn;
27635
+ this.bits = bits;
27636
+ }
27637
+ // non-const time multiplication ladder
27638
+ _unsafeLadder(elm, n, p = this.ZERO) {
27639
+ let d = elm;
27640
+ while (n > _0n7) {
27641
+ if (n & _1n8)
27642
+ p = p.add(d);
27643
+ d = d.double();
27644
+ n >>= _1n8;
27645
+ }
27646
+ return p;
27647
+ }
27648
+ /**
27649
+ * Creates a wNAF precomputation window. Used for caching.
27650
+ * Default window size is set by `utils.precompute()` and is equal to 8.
27651
+ * Number of precomputed points depends on the curve size:
27652
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
27653
+ * - 𝑊 is the window size
27654
+ * - 𝑛 is the bitlength of the curve order.
27655
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
27656
+ * @param point Point instance
27657
+ * @param W window size
27658
+ * @returns precomputed point tables flattened to a single array
27659
+ */
27660
+ precomputeWindow(point, W) {
27661
+ const { windows, windowSize } = calcWOpts2(W, this.bits);
27662
+ const points = [];
27663
+ let p = point;
27664
+ let base = p;
27665
+ for (let window2 = 0; window2 < windows; window2++) {
27666
+ base = p;
27667
+ points.push(base);
27668
+ for (let i = 1; i < windowSize; i++) {
27669
+ base = base.add(p);
27670
+ points.push(base);
27671
+ }
27672
+ p = base.double();
27673
+ }
27674
+ return points;
27675
+ }
27676
+ /**
27677
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
27678
+ * More compact implementation:
27679
+ * https://github.com/paulmillr/noble-secp256k1/blob/47cb1669b6e506ad66b35fe7d76132ae97465da2/index.ts#L502-L541
27680
+ * @returns real and fake (for const-time) points
27681
+ */
27682
+ wNAF(W, precomputes, n) {
27683
+ if (!this.Fn.isValid(n))
27684
+ throw new Error("invalid scalar");
27685
+ let p = this.ZERO;
27686
+ let f = this.BASE;
27687
+ const wo = calcWOpts2(W, this.bits);
27688
+ for (let window2 = 0; window2 < wo.windows; window2++) {
27689
+ const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets2(n, window2, wo);
27690
+ n = nextN;
27691
+ if (isZero) {
27692
+ f = f.add(negateCt2(isNegF, precomputes[offsetF]));
27693
+ } else {
27694
+ p = p.add(negateCt2(isNeg, precomputes[offset]));
27695
+ }
27696
+ }
27697
+ assert02(n);
27698
+ return { p, f };
27699
+ }
27700
+ /**
27701
+ * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
27702
+ * @param acc accumulator point to add result of multiplication
27703
+ * @returns point
27704
+ */
27705
+ wNAFUnsafe(W, precomputes, n, acc = this.ZERO) {
27706
+ const wo = calcWOpts2(W, this.bits);
27707
+ for (let window2 = 0; window2 < wo.windows; window2++) {
27708
+ if (n === _0n7)
27709
+ break;
27710
+ const { nextN, offset, isZero, isNeg } = calcOffsets2(n, window2, wo);
27711
+ n = nextN;
27712
+ if (isZero) {
27713
+ continue;
27714
+ } else {
27715
+ const item = precomputes[offset];
27716
+ acc = acc.add(isNeg ? item.negate() : item);
27717
+ }
27718
+ }
27719
+ assert02(n);
27720
+ return acc;
27721
+ }
27722
+ getPrecomputes(W, point, transform) {
27723
+ let comp = pointPrecomputes2.get(point);
27724
+ if (!comp) {
27725
+ comp = this.precomputeWindow(point, W);
27726
+ if (W !== 1) {
27727
+ if (typeof transform === "function")
27728
+ comp = transform(comp);
27729
+ pointPrecomputes2.set(point, comp);
27730
+ }
27731
+ }
27732
+ return comp;
27733
+ }
27734
+ cached(point, scalar, transform) {
27735
+ const W = getW2(point);
27736
+ return this.wNAF(W, this.getPrecomputes(W, point, transform), scalar);
27737
+ }
27738
+ unsafe(point, scalar, transform, prev) {
27739
+ const W = getW2(point);
27740
+ if (W === 1)
27741
+ return this._unsafeLadder(point, scalar, prev);
27742
+ return this.wNAFUnsafe(W, this.getPrecomputes(W, point, transform), scalar, prev);
27743
+ }
27744
+ // We calculate precomputes for elliptic curve point multiplication
27745
+ // using windowed method. This specifies window size and
27746
+ // stores precomputed values. Usually only base point would be precomputed.
27747
+ createCache(P, W) {
27748
+ validateW2(W, this.bits);
27749
+ pointWindowSizes2.set(P, W);
27750
+ pointPrecomputes2.delete(P);
27751
+ }
27752
+ hasCache(elm) {
27753
+ return getW2(elm) !== 1;
27754
+ }
27755
+ };
27756
+ function mulEndoUnsafe(Point, point, k1, k2) {
27757
+ let acc = point;
27758
+ let p1 = Point.ZERO;
27759
+ let p2 = Point.ZERO;
27760
+ while (k1 > _0n7 || k2 > _0n7) {
27761
+ if (k1 & _1n8)
27762
+ p1 = p1.add(acc);
27763
+ if (k2 & _1n8)
27764
+ p2 = p2.add(acc);
27765
+ acc = acc.double();
27766
+ k1 >>= _1n8;
27767
+ k2 >>= _1n8;
27768
+ }
27769
+ return { p1, p2 };
27770
+ }
27771
+ function pippenger(c, fieldN, points, scalars) {
27772
+ validateMSMPoints(points, c);
27773
+ validateMSMScalars(scalars, fieldN);
27774
+ const plength = points.length;
27775
+ const slength = scalars.length;
27776
+ if (plength !== slength)
27777
+ throw new Error("arrays of points and scalars must have equal length");
27778
+ const zero = c.ZERO;
27779
+ const wbits = bitLen2(BigInt(plength));
27780
+ let windowSize = 1;
27781
+ if (wbits > 12)
27782
+ windowSize = wbits - 3;
27783
+ else if (wbits > 4)
27784
+ windowSize = wbits - 2;
27785
+ else if (wbits > 0)
27786
+ windowSize = 2;
27787
+ const MASK = bitMask2(windowSize);
27788
+ const buckets = new Array(Number(MASK) + 1).fill(zero);
27789
+ const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
27790
+ let sum = zero;
27791
+ for (let i = lastBits; i >= 0; i -= windowSize) {
27792
+ buckets.fill(zero);
27793
+ for (let j = 0; j < slength; j++) {
27794
+ const scalar = scalars[j];
27795
+ const wbits2 = Number(scalar >> BigInt(i) & MASK);
27796
+ buckets[wbits2] = buckets[wbits2].add(points[j]);
27797
+ }
27798
+ let resI = zero;
27799
+ for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {
27800
+ sumI = sumI.add(buckets[j]);
27801
+ resI = resI.add(sumI);
27802
+ }
27803
+ sum = sum.add(resI);
27804
+ if (i !== 0)
27805
+ for (let j = 0; j < windowSize; j++)
27806
+ sum = sum.double();
27807
+ }
27808
+ return sum;
27809
+ }
27810
+ function createField2(order, field, isLE) {
27811
+ if (field) {
27812
+ if (field.ORDER !== order)
27813
+ throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
27814
+ validateField2(field);
27815
+ return field;
27816
+ } else {
27817
+ return Field2(order, { isLE });
27818
+ }
27819
+ }
27820
+ function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
27821
+ if (FpFnLE === void 0)
27822
+ FpFnLE = type === "edwards";
27823
+ if (!CURVE || typeof CURVE !== "object")
27824
+ throw new Error(`expected valid ${type} CURVE object`);
27825
+ for (const p of ["p", "n", "h"]) {
27826
+ const val = CURVE[p];
27827
+ if (!(typeof val === "bigint" && val > _0n7))
27828
+ throw new Error(`CURVE.${p} must be positive bigint`);
27829
+ }
27830
+ const Fp = createField2(CURVE.p, curveOpts.Fp, FpFnLE);
27831
+ const Fn = createField2(CURVE.n, curveOpts.Fn, FpFnLE);
27832
+ const _b = type === "weierstrass" ? "b" : "d";
27833
+ const params = ["Gx", "Gy", "a", _b];
27834
+ for (const p of params) {
27835
+ if (!Fp.isValid(CURVE[p]))
27836
+ throw new Error(`CURVE.${p} must be valid field element of CURVE.Fp`);
27837
+ }
27838
+ CURVE = Object.freeze(Object.assign({}, CURVE));
27839
+ return { CURVE, Fp, Fn };
27840
+ }
27841
+
27842
+ // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/weierstrass.js
27843
+ var divNearest = (num, den) => (num + (num >= 0 ? den : -den) / _2n5) / den;
27844
+ function _splitEndoScalar(k, basis, n) {
27845
+ const [[a1, b1], [a2, b2]] = basis;
27846
+ const c1 = divNearest(b2 * k, n);
27847
+ const c2 = divNearest(-b1 * k, n);
27848
+ let k1 = k - c1 * a1 - c2 * a2;
27849
+ let k2 = -c1 * b1 - c2 * b2;
27850
+ const k1neg = k1 < _0n8;
27851
+ const k2neg = k2 < _0n8;
27852
+ if (k1neg)
27853
+ k1 = -k1;
27854
+ if (k2neg)
27855
+ k2 = -k2;
27856
+ const MAX_NUM = bitMask2(Math.ceil(bitLen2(n) / 2)) + _1n9;
27857
+ if (k1 < _0n8 || k1 >= MAX_NUM || k2 < _0n8 || k2 >= MAX_NUM) {
27858
+ throw new Error("splitScalar (endomorphism): failed, k=" + k);
27859
+ }
27860
+ return { k1neg, k1, k2neg, k2 };
27861
+ }
27862
+ function validateSigFormat(format) {
27863
+ if (!["compact", "recovered", "der"].includes(format))
27864
+ throw new Error('Signature format must be "compact", "recovered", or "der"');
27865
+ return format;
27866
+ }
27867
+ function validateSigOpts(opts, def) {
27868
+ const optsn = {};
27869
+ for (let optName of Object.keys(def)) {
27870
+ optsn[optName] = opts[optName] === void 0 ? def[optName] : opts[optName];
27871
+ }
27872
+ _abool2(optsn.lowS, "lowS");
27873
+ _abool2(optsn.prehash, "prehash");
27874
+ if (optsn.format !== void 0)
27875
+ validateSigFormat(optsn.format);
27876
+ return optsn;
27877
+ }
27878
+ var DERErr = class extends Error {
27879
+ constructor(m = "") {
27880
+ super(m);
27881
+ }
27882
+ };
27883
+ var DER = {
27884
+ // asn.1 DER encoding utils
27885
+ Err: DERErr,
27886
+ // Basic building block is TLV (Tag-Length-Value)
27887
+ _tlv: {
27888
+ encode: (tag, data) => {
27889
+ const { Err: E } = DER;
27890
+ if (tag < 0 || tag > 256)
27891
+ throw new E("tlv.encode: wrong tag");
27892
+ if (data.length & 1)
27893
+ throw new E("tlv.encode: unpadded data");
27894
+ const dataLen = data.length / 2;
27895
+ const len = numberToHexUnpadded(dataLen);
27896
+ if (len.length / 2 & 128)
27897
+ throw new E("tlv.encode: long form length too big");
27898
+ const lenLen = dataLen > 127 ? numberToHexUnpadded(len.length / 2 | 128) : "";
27899
+ const t = numberToHexUnpadded(tag);
27900
+ return t + lenLen + len + data;
27901
+ },
27902
+ // v - value, l - left bytes (unparsed)
27903
+ decode(tag, data) {
27904
+ const { Err: E } = DER;
27905
+ let pos = 0;
27906
+ if (tag < 0 || tag > 256)
27907
+ throw new E("tlv.encode: wrong tag");
27908
+ if (data.length < 2 || data[pos++] !== tag)
27909
+ throw new E("tlv.decode: wrong tlv");
27910
+ const first = data[pos++];
27911
+ const isLong = !!(first & 128);
27912
+ let length = 0;
27913
+ if (!isLong)
27914
+ length = first;
27915
+ else {
27916
+ const lenLen = first & 127;
27917
+ if (!lenLen)
27918
+ throw new E("tlv.decode(long): indefinite length not supported");
27919
+ if (lenLen > 4)
27920
+ throw new E("tlv.decode(long): byte length is too big");
27921
+ const lengthBytes = data.subarray(pos, pos + lenLen);
27922
+ if (lengthBytes.length !== lenLen)
27923
+ throw new E("tlv.decode: length bytes not complete");
27924
+ if (lengthBytes[0] === 0)
27925
+ throw new E("tlv.decode(long): zero leftmost byte");
27926
+ for (const b of lengthBytes)
27927
+ length = length << 8 | b;
27928
+ pos += lenLen;
27929
+ if (length < 128)
27930
+ throw new E("tlv.decode(long): not minimal encoding");
27931
+ }
27932
+ const v = data.subarray(pos, pos + length);
27933
+ if (v.length !== length)
27934
+ throw new E("tlv.decode: wrong value length");
27935
+ return { v, l: data.subarray(pos + length) };
27936
+ }
27937
+ },
27938
+ // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
27939
+ // since we always use positive integers here. It must always be empty:
27940
+ // - add zero byte if exists
27941
+ // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
27942
+ _int: {
27943
+ encode(num) {
27944
+ const { Err: E } = DER;
27945
+ if (num < _0n8)
27946
+ throw new E("integer: negative integers are not allowed");
27947
+ let hex = numberToHexUnpadded(num);
27948
+ if (Number.parseInt(hex[0], 16) & 8)
27949
+ hex = "00" + hex;
27950
+ if (hex.length & 1)
27951
+ throw new E("unexpected DER parsing assertion: unpadded hex");
27952
+ return hex;
27953
+ },
27954
+ decode(data) {
27955
+ const { Err: E } = DER;
27956
+ if (data[0] & 128)
27957
+ throw new E("invalid signature integer: negative");
27958
+ if (data[0] === 0 && !(data[1] & 128))
27959
+ throw new E("invalid signature integer: unnecessary leading zero");
27960
+ return bytesToNumberBE2(data);
27961
+ }
27962
+ },
27963
+ toSig(hex) {
27964
+ const { Err: E, _int: int, _tlv: tlv } = DER;
27965
+ const data = ensureBytes("signature", hex);
27966
+ const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
27967
+ if (seqLeftBytes.length)
27968
+ throw new E("invalid signature: left bytes after parsing");
27969
+ const { v: rBytes, l: rLeftBytes } = tlv.decode(2, seqBytes);
27970
+ const { v: sBytes, l: sLeftBytes } = tlv.decode(2, rLeftBytes);
27971
+ if (sLeftBytes.length)
27972
+ throw new E("invalid signature: left bytes after parsing");
27973
+ return { r: int.decode(rBytes), s: int.decode(sBytes) };
27974
+ },
27975
+ hexFromSig(sig) {
27976
+ const { _tlv: tlv, _int: int } = DER;
27977
+ const rs = tlv.encode(2, int.encode(sig.r));
27978
+ const ss = tlv.encode(2, int.encode(sig.s));
27979
+ const seq = rs + ss;
27980
+ return tlv.encode(48, seq);
27981
+ }
27982
+ };
27983
+ var _0n8 = BigInt(0);
27984
+ var _1n9 = BigInt(1);
27985
+ var _2n5 = BigInt(2);
27986
+ var _3n3 = BigInt(3);
27987
+ var _4n3 = BigInt(4);
27988
+ function _normFnElement(Fn, key) {
27989
+ const { BYTES: expected } = Fn;
27990
+ let num;
27991
+ if (typeof key === "bigint") {
27992
+ num = key;
27993
+ } else {
27994
+ let bytes = ensureBytes("private key", key);
27995
+ try {
27996
+ num = Fn.fromBytes(bytes);
27997
+ } catch (error) {
27998
+ throw new Error(`invalid private key: expected ui8a of size ${expected}, got ${typeof key}`);
27999
+ }
28000
+ }
28001
+ if (!Fn.isValidNot0(num))
28002
+ throw new Error("invalid private key: out of range [1..N-1]");
28003
+ return num;
28004
+ }
28005
+ function weierstrassN(params, extraOpts = {}) {
28006
+ const validated = _createCurveFields("weierstrass", params, extraOpts);
28007
+ const { Fp, Fn } = validated;
28008
+ let CURVE = validated.CURVE;
28009
+ const { h: cofactor, n: CURVE_ORDER } = CURVE;
28010
+ _validateObject(extraOpts, {}, {
28011
+ allowInfinityPoint: "boolean",
28012
+ clearCofactor: "function",
28013
+ isTorsionFree: "function",
28014
+ fromBytes: "function",
28015
+ toBytes: "function",
28016
+ endo: "object",
28017
+ wrapPrivateKey: "boolean"
28018
+ });
28019
+ const { endo } = extraOpts;
28020
+ if (endo) {
28021
+ if (!Fp.is0(CURVE.a) || typeof endo.beta !== "bigint" || !Array.isArray(endo.basises)) {
28022
+ throw new Error('invalid endo: expected "beta": bigint and "basises": array');
28023
+ }
28024
+ }
28025
+ const lengths = getWLengths(Fp, Fn);
28026
+ function assertCompressionIsSupported() {
28027
+ if (!Fp.isOdd)
28028
+ throw new Error("compression is not supported: Field does not have .isOdd()");
28029
+ }
28030
+ function pointToBytes(_c, point, isCompressed) {
28031
+ const { x, y } = point.toAffine();
28032
+ const bx = Fp.toBytes(x);
28033
+ _abool2(isCompressed, "isCompressed");
28034
+ if (isCompressed) {
28035
+ assertCompressionIsSupported();
28036
+ const hasEvenY = !Fp.isOdd(y);
28037
+ return concatBytes2(pprefix(hasEvenY), bx);
28038
+ } else {
28039
+ return concatBytes2(Uint8Array.of(4), bx, Fp.toBytes(y));
28040
+ }
28041
+ }
28042
+ function pointFromBytes(bytes) {
28043
+ _abytes2(bytes, void 0, "Point");
28044
+ const { publicKey: comp, publicKeyUncompressed: uncomp } = lengths;
28045
+ const length = bytes.length;
28046
+ const head = bytes[0];
28047
+ const tail = bytes.subarray(1);
28048
+ if (length === comp && (head === 2 || head === 3)) {
28049
+ const x = Fp.fromBytes(tail);
28050
+ if (!Fp.isValid(x))
28051
+ throw new Error("bad point: is not on curve, wrong x");
28052
+ const y2 = weierstrassEquation(x);
28053
+ let y;
28054
+ try {
28055
+ y = Fp.sqrt(y2);
28056
+ } catch (sqrtError) {
28057
+ const err = sqrtError instanceof Error ? ": " + sqrtError.message : "";
28058
+ throw new Error("bad point: is not on curve, sqrt error" + err);
28059
+ }
28060
+ assertCompressionIsSupported();
28061
+ const isYOdd = Fp.isOdd(y);
28062
+ const isHeadOdd = (head & 1) === 1;
28063
+ if (isHeadOdd !== isYOdd)
28064
+ y = Fp.neg(y);
28065
+ return { x, y };
28066
+ } else if (length === uncomp && head === 4) {
28067
+ const L = Fp.BYTES;
28068
+ const x = Fp.fromBytes(tail.subarray(0, L));
28069
+ const y = Fp.fromBytes(tail.subarray(L, L * 2));
28070
+ if (!isValidXY(x, y))
28071
+ throw new Error("bad point: is not on curve");
28072
+ return { x, y };
28073
+ } else {
28074
+ throw new Error(`bad point: got length ${length}, expected compressed=${comp} or uncompressed=${uncomp}`);
28075
+ }
28076
+ }
28077
+ const encodePoint = extraOpts.toBytes || pointToBytes;
28078
+ const decodePoint = extraOpts.fromBytes || pointFromBytes;
28079
+ function weierstrassEquation(x) {
28080
+ const x2 = Fp.sqr(x);
28081
+ const x3 = Fp.mul(x2, x);
28082
+ return Fp.add(Fp.add(x3, Fp.mul(x, CURVE.a)), CURVE.b);
28083
+ }
28084
+ function isValidXY(x, y) {
28085
+ const left = Fp.sqr(y);
28086
+ const right = weierstrassEquation(x);
28087
+ return Fp.eql(left, right);
28088
+ }
28089
+ if (!isValidXY(CURVE.Gx, CURVE.Gy))
28090
+ throw new Error("bad curve params: generator point");
28091
+ const _4a3 = Fp.mul(Fp.pow(CURVE.a, _3n3), _4n3);
28092
+ const _27b2 = Fp.mul(Fp.sqr(CURVE.b), BigInt(27));
28093
+ if (Fp.is0(Fp.add(_4a3, _27b2)))
28094
+ throw new Error("bad curve params: a or b");
28095
+ function acoord(title, n, banZero = false) {
28096
+ if (!Fp.isValid(n) || banZero && Fp.is0(n))
28097
+ throw new Error(`bad point coordinate ${title}`);
28098
+ return n;
28099
+ }
28100
+ function aprjpoint(other) {
28101
+ if (!(other instanceof Point))
28102
+ throw new Error("ProjectivePoint expected");
28103
+ }
28104
+ function splitEndoScalarN(k) {
28105
+ if (!endo || !endo.basises)
28106
+ throw new Error("no endo");
28107
+ return _splitEndoScalar(k, endo.basises, Fn.ORDER);
28108
+ }
28109
+ const toAffineMemo = memoized2((p, iz) => {
28110
+ const { X, Y, Z } = p;
28111
+ if (Fp.eql(Z, Fp.ONE))
28112
+ return { x: X, y: Y };
28113
+ const is0 = p.is0();
28114
+ if (iz == null)
28115
+ iz = is0 ? Fp.ONE : Fp.inv(Z);
28116
+ const x = Fp.mul(X, iz);
28117
+ const y = Fp.mul(Y, iz);
28118
+ const zz = Fp.mul(Z, iz);
28119
+ if (is0)
28120
+ return { x: Fp.ZERO, y: Fp.ZERO };
28121
+ if (!Fp.eql(zz, Fp.ONE))
28122
+ throw new Error("invZ was invalid");
28123
+ return { x, y };
28124
+ });
28125
+ const assertValidMemo = memoized2((p) => {
28126
+ if (p.is0()) {
28127
+ if (extraOpts.allowInfinityPoint && !Fp.is0(p.Y))
28128
+ return;
28129
+ throw new Error("bad point: ZERO");
28130
+ }
28131
+ const { x, y } = p.toAffine();
28132
+ if (!Fp.isValid(x) || !Fp.isValid(y))
28133
+ throw new Error("bad point: x or y not field elements");
28134
+ if (!isValidXY(x, y))
28135
+ throw new Error("bad point: equation left != right");
28136
+ if (!p.isTorsionFree())
28137
+ throw new Error("bad point: not in prime-order subgroup");
28138
+ return true;
28139
+ });
28140
+ function finishEndo(endoBeta, k1p, k2p, k1neg, k2neg) {
28141
+ k2p = new Point(Fp.mul(k2p.X, endoBeta), k2p.Y, k2p.Z);
28142
+ k1p = negateCt2(k1neg, k1p);
28143
+ k2p = negateCt2(k2neg, k2p);
28144
+ return k1p.add(k2p);
28145
+ }
28146
+ class Point {
28147
+ /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
28148
+ constructor(X, Y, Z) {
28149
+ this.X = acoord("x", X);
28150
+ this.Y = acoord("y", Y, true);
28151
+ this.Z = acoord("z", Z);
28152
+ Object.freeze(this);
28153
+ }
28154
+ static CURVE() {
28155
+ return CURVE;
28156
+ }
28157
+ /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
28158
+ static fromAffine(p) {
28159
+ const { x, y } = p || {};
28160
+ if (!p || !Fp.isValid(x) || !Fp.isValid(y))
28161
+ throw new Error("invalid affine point");
28162
+ if (p instanceof Point)
28163
+ throw new Error("projective point not allowed");
28164
+ if (Fp.is0(x) && Fp.is0(y))
28165
+ return Point.ZERO;
28166
+ return new Point(x, y, Fp.ONE);
28167
+ }
28168
+ static fromBytes(bytes) {
28169
+ const P = Point.fromAffine(decodePoint(_abytes2(bytes, void 0, "point")));
28170
+ P.assertValidity();
28171
+ return P;
28172
+ }
28173
+ static fromHex(hex) {
28174
+ return Point.fromBytes(ensureBytes("pointHex", hex));
28175
+ }
28176
+ get x() {
28177
+ return this.toAffine().x;
28178
+ }
28179
+ get y() {
28180
+ return this.toAffine().y;
28181
+ }
28182
+ /**
28183
+ *
28184
+ * @param windowSize
28185
+ * @param isLazy true will defer table computation until the first multiplication
28186
+ * @returns
28187
+ */
28188
+ precompute(windowSize = 8, isLazy = true) {
28189
+ wnaf.createCache(this, windowSize);
28190
+ if (!isLazy)
28191
+ this.multiply(_3n3);
28192
+ return this;
28193
+ }
28194
+ // TODO: return `this`
28195
+ /** A point on curve is valid if it conforms to equation. */
28196
+ assertValidity() {
28197
+ assertValidMemo(this);
28198
+ }
28199
+ hasEvenY() {
28200
+ const { y } = this.toAffine();
28201
+ if (!Fp.isOdd)
28202
+ throw new Error("Field doesn't support isOdd");
28203
+ return !Fp.isOdd(y);
28204
+ }
28205
+ /** Compare one point to another. */
28206
+ equals(other) {
28207
+ aprjpoint(other);
28208
+ const { X: X1, Y: Y1, Z: Z1 } = this;
28209
+ const { X: X2, Y: Y2, Z: Z2 } = other;
28210
+ const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));
28211
+ const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));
28212
+ return U1 && U2;
28213
+ }
28214
+ /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
28215
+ negate() {
28216
+ return new Point(this.X, Fp.neg(this.Y), this.Z);
28217
+ }
28218
+ // Renes-Costello-Batina exception-free doubling formula.
28219
+ // There is 30% faster Jacobian formula, but it is not complete.
28220
+ // https://eprint.iacr.org/2015/1060, algorithm 3
28221
+ // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
28222
+ double() {
28223
+ const { a, b } = CURVE;
28224
+ const b3 = Fp.mul(b, _3n3);
28225
+ const { X: X1, Y: Y1, Z: Z1 } = this;
28226
+ let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
28227
+ let t0 = Fp.mul(X1, X1);
28228
+ let t1 = Fp.mul(Y1, Y1);
28229
+ let t2 = Fp.mul(Z1, Z1);
28230
+ let t3 = Fp.mul(X1, Y1);
28231
+ t3 = Fp.add(t3, t3);
28232
+ Z3 = Fp.mul(X1, Z1);
28233
+ Z3 = Fp.add(Z3, Z3);
28234
+ X3 = Fp.mul(a, Z3);
28235
+ Y3 = Fp.mul(b3, t2);
28236
+ Y3 = Fp.add(X3, Y3);
28237
+ X3 = Fp.sub(t1, Y3);
28238
+ Y3 = Fp.add(t1, Y3);
28239
+ Y3 = Fp.mul(X3, Y3);
28240
+ X3 = Fp.mul(t3, X3);
28241
+ Z3 = Fp.mul(b3, Z3);
28242
+ t2 = Fp.mul(a, t2);
28243
+ t3 = Fp.sub(t0, t2);
28244
+ t3 = Fp.mul(a, t3);
28245
+ t3 = Fp.add(t3, Z3);
28246
+ Z3 = Fp.add(t0, t0);
28247
+ t0 = Fp.add(Z3, t0);
28248
+ t0 = Fp.add(t0, t2);
28249
+ t0 = Fp.mul(t0, t3);
28250
+ Y3 = Fp.add(Y3, t0);
28251
+ t2 = Fp.mul(Y1, Z1);
28252
+ t2 = Fp.add(t2, t2);
28253
+ t0 = Fp.mul(t2, t3);
28254
+ X3 = Fp.sub(X3, t0);
28255
+ Z3 = Fp.mul(t2, t1);
28256
+ Z3 = Fp.add(Z3, Z3);
28257
+ Z3 = Fp.add(Z3, Z3);
28258
+ return new Point(X3, Y3, Z3);
28259
+ }
28260
+ // Renes-Costello-Batina exception-free addition formula.
28261
+ // There is 30% faster Jacobian formula, but it is not complete.
28262
+ // https://eprint.iacr.org/2015/1060, algorithm 1
28263
+ // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
28264
+ add(other) {
28265
+ aprjpoint(other);
28266
+ const { X: X1, Y: Y1, Z: Z1 } = this;
28267
+ const { X: X2, Y: Y2, Z: Z2 } = other;
28268
+ let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
28269
+ const a = CURVE.a;
28270
+ const b3 = Fp.mul(CURVE.b, _3n3);
28271
+ let t0 = Fp.mul(X1, X2);
28272
+ let t1 = Fp.mul(Y1, Y2);
28273
+ let t2 = Fp.mul(Z1, Z2);
28274
+ let t3 = Fp.add(X1, Y1);
28275
+ let t4 = Fp.add(X2, Y2);
28276
+ t3 = Fp.mul(t3, t4);
28277
+ t4 = Fp.add(t0, t1);
28278
+ t3 = Fp.sub(t3, t4);
28279
+ t4 = Fp.add(X1, Z1);
28280
+ let t5 = Fp.add(X2, Z2);
28281
+ t4 = Fp.mul(t4, t5);
28282
+ t5 = Fp.add(t0, t2);
28283
+ t4 = Fp.sub(t4, t5);
28284
+ t5 = Fp.add(Y1, Z1);
28285
+ X3 = Fp.add(Y2, Z2);
28286
+ t5 = Fp.mul(t5, X3);
28287
+ X3 = Fp.add(t1, t2);
28288
+ t5 = Fp.sub(t5, X3);
28289
+ Z3 = Fp.mul(a, t4);
28290
+ X3 = Fp.mul(b3, t2);
28291
+ Z3 = Fp.add(X3, Z3);
28292
+ X3 = Fp.sub(t1, Z3);
28293
+ Z3 = Fp.add(t1, Z3);
28294
+ Y3 = Fp.mul(X3, Z3);
28295
+ t1 = Fp.add(t0, t0);
28296
+ t1 = Fp.add(t1, t0);
28297
+ t2 = Fp.mul(a, t2);
28298
+ t4 = Fp.mul(b3, t4);
28299
+ t1 = Fp.add(t1, t2);
28300
+ t2 = Fp.sub(t0, t2);
28301
+ t2 = Fp.mul(a, t2);
28302
+ t4 = Fp.add(t4, t2);
28303
+ t0 = Fp.mul(t1, t4);
28304
+ Y3 = Fp.add(Y3, t0);
28305
+ t0 = Fp.mul(t5, t4);
28306
+ X3 = Fp.mul(t3, X3);
28307
+ X3 = Fp.sub(X3, t0);
28308
+ t0 = Fp.mul(t3, t1);
28309
+ Z3 = Fp.mul(t5, Z3);
28310
+ Z3 = Fp.add(Z3, t0);
28311
+ return new Point(X3, Y3, Z3);
28312
+ }
28313
+ subtract(other) {
28314
+ return this.add(other.negate());
28315
+ }
28316
+ is0() {
28317
+ return this.equals(Point.ZERO);
28318
+ }
28319
+ /**
28320
+ * Constant time multiplication.
28321
+ * Uses wNAF method. Windowed method may be 10% faster,
28322
+ * but takes 2x longer to generate and consumes 2x memory.
28323
+ * Uses precomputes when available.
28324
+ * Uses endomorphism for Koblitz curves.
28325
+ * @param scalar by which the point would be multiplied
28326
+ * @returns New point
28327
+ */
28328
+ multiply(scalar) {
28329
+ const { endo: endo2 } = extraOpts;
28330
+ if (!Fn.isValidNot0(scalar))
28331
+ throw new Error("invalid scalar: out of range");
28332
+ let point, fake;
28333
+ const mul = (n) => wnaf.cached(this, n, (p) => normalizeZ2(Point, p));
28334
+ if (endo2) {
28335
+ const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(scalar);
28336
+ const { p: k1p, f: k1f } = mul(k1);
28337
+ const { p: k2p, f: k2f } = mul(k2);
28338
+ fake = k1f.add(k2f);
28339
+ point = finishEndo(endo2.beta, k1p, k2p, k1neg, k2neg);
28340
+ } else {
28341
+ const { p, f } = mul(scalar);
28342
+ point = p;
28343
+ fake = f;
28344
+ }
28345
+ return normalizeZ2(Point, [point, fake])[0];
28346
+ }
28347
+ /**
28348
+ * Non-constant-time multiplication. Uses double-and-add algorithm.
28349
+ * It's faster, but should only be used when you don't care about
28350
+ * an exposed secret key e.g. sig verification, which works over *public* keys.
28351
+ */
28352
+ multiplyUnsafe(sc) {
28353
+ const { endo: endo2 } = extraOpts;
28354
+ const p = this;
28355
+ if (!Fn.isValid(sc))
28356
+ throw new Error("invalid scalar: out of range");
28357
+ if (sc === _0n8 || p.is0())
28358
+ return Point.ZERO;
28359
+ if (sc === _1n9)
28360
+ return p;
28361
+ if (wnaf.hasCache(this))
28362
+ return this.multiply(sc);
28363
+ if (endo2) {
28364
+ const { k1neg, k1, k2neg, k2 } = splitEndoScalarN(sc);
28365
+ const { p1, p2 } = mulEndoUnsafe(Point, p, k1, k2);
28366
+ return finishEndo(endo2.beta, p1, p2, k1neg, k2neg);
28367
+ } else {
28368
+ return wnaf.unsafe(p, sc);
28369
+ }
28370
+ }
28371
+ multiplyAndAddUnsafe(Q, a, b) {
28372
+ const sum = this.multiplyUnsafe(a).add(Q.multiplyUnsafe(b));
28373
+ return sum.is0() ? void 0 : sum;
28374
+ }
28375
+ /**
28376
+ * Converts Projective point to affine (x, y) coordinates.
28377
+ * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
28378
+ */
28379
+ toAffine(invertedZ) {
28380
+ return toAffineMemo(this, invertedZ);
28381
+ }
28382
+ /**
28383
+ * Checks whether Point is free of torsion elements (is in prime subgroup).
28384
+ * Always torsion-free for cofactor=1 curves.
28385
+ */
28386
+ isTorsionFree() {
28387
+ const { isTorsionFree } = extraOpts;
28388
+ if (cofactor === _1n9)
28389
+ return true;
28390
+ if (isTorsionFree)
28391
+ return isTorsionFree(Point, this);
28392
+ return wnaf.unsafe(this, CURVE_ORDER).is0();
28393
+ }
28394
+ clearCofactor() {
28395
+ const { clearCofactor } = extraOpts;
28396
+ if (cofactor === _1n9)
28397
+ return this;
28398
+ if (clearCofactor)
28399
+ return clearCofactor(Point, this);
28400
+ return this.multiplyUnsafe(cofactor);
28401
+ }
28402
+ isSmallOrder() {
28403
+ return this.multiplyUnsafe(cofactor).is0();
28404
+ }
28405
+ toBytes(isCompressed = true) {
28406
+ _abool2(isCompressed, "isCompressed");
28407
+ this.assertValidity();
28408
+ return encodePoint(Point, this, isCompressed);
28409
+ }
28410
+ toHex(isCompressed = true) {
28411
+ return bytesToHex2(this.toBytes(isCompressed));
28412
+ }
28413
+ toString() {
28414
+ return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
28415
+ }
28416
+ // TODO: remove
28417
+ get px() {
28418
+ return this.X;
28419
+ }
28420
+ get py() {
28421
+ return this.X;
28422
+ }
28423
+ get pz() {
28424
+ return this.Z;
28425
+ }
28426
+ toRawBytes(isCompressed = true) {
28427
+ return this.toBytes(isCompressed);
28428
+ }
28429
+ _setWindowSize(windowSize) {
28430
+ this.precompute(windowSize);
28431
+ }
28432
+ static normalizeZ(points) {
28433
+ return normalizeZ2(Point, points);
28434
+ }
28435
+ static msm(points, scalars) {
28436
+ return pippenger(Point, Fn, points, scalars);
28437
+ }
28438
+ static fromPrivateKey(privateKey) {
28439
+ return Point.BASE.multiply(_normFnElement(Fn, privateKey));
28440
+ }
28441
+ }
28442
+ Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);
28443
+ Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);
28444
+ Point.Fp = Fp;
28445
+ Point.Fn = Fn;
28446
+ const bits = Fn.BITS;
28447
+ const wnaf = new wNAF2(Point, extraOpts.endo ? Math.ceil(bits / 2) : bits);
28448
+ Point.BASE.precompute(8);
28449
+ return Point;
28450
+ }
28451
+ function pprefix(hasEvenY) {
28452
+ return Uint8Array.of(hasEvenY ? 2 : 3);
28453
+ }
28454
+ function getWLengths(Fp, Fn) {
28455
+ return {
28456
+ secretKey: Fn.BYTES,
28457
+ publicKey: 1 + Fp.BYTES,
28458
+ publicKeyUncompressed: 1 + 2 * Fp.BYTES,
28459
+ publicKeyHasPrefix: true,
28460
+ signature: 2 * Fn.BYTES
28461
+ };
28462
+ }
28463
+ function ecdh(Point, ecdhOpts = {}) {
28464
+ const { Fn } = Point;
28465
+ const randomBytes_ = ecdhOpts.randomBytes || randomBytes2;
28466
+ const lengths = Object.assign(getWLengths(Point.Fp, Fn), { seed: getMinHashLength(Fn.ORDER) });
28467
+ function isValidSecretKey(secretKey) {
28468
+ try {
28469
+ return !!_normFnElement(Fn, secretKey);
28470
+ } catch (error) {
28471
+ return false;
28472
+ }
28473
+ }
28474
+ function isValidPublicKey(publicKey, isCompressed) {
28475
+ const { publicKey: comp, publicKeyUncompressed } = lengths;
28476
+ try {
28477
+ const l = publicKey.length;
28478
+ if (isCompressed === true && l !== comp)
28479
+ return false;
28480
+ if (isCompressed === false && l !== publicKeyUncompressed)
28481
+ return false;
28482
+ return !!Point.fromBytes(publicKey);
28483
+ } catch (error) {
28484
+ return false;
28485
+ }
28486
+ }
28487
+ function randomSecretKey(seed = randomBytes_(lengths.seed)) {
28488
+ return mapHashToField(_abytes2(seed, lengths.seed, "seed"), Fn.ORDER);
28489
+ }
28490
+ function getPublicKey(secretKey, isCompressed = true) {
28491
+ return Point.BASE.multiply(_normFnElement(Fn, secretKey)).toBytes(isCompressed);
28492
+ }
28493
+ function keygen(seed) {
28494
+ const secretKey = randomSecretKey(seed);
28495
+ return { secretKey, publicKey: getPublicKey(secretKey) };
28496
+ }
28497
+ function isProbPub(item) {
28498
+ if (typeof item === "bigint")
28499
+ return false;
28500
+ if (item instanceof Point)
28501
+ return true;
28502
+ const { secretKey, publicKey, publicKeyUncompressed } = lengths;
28503
+ if (Fn.allowedLengths || secretKey === publicKey)
28504
+ return void 0;
28505
+ const l = ensureBytes("key", item).length;
28506
+ return l === publicKey || l === publicKeyUncompressed;
28507
+ }
28508
+ function getSharedSecret(secretKeyA, publicKeyB, isCompressed = true) {
28509
+ if (isProbPub(secretKeyA) === true)
28510
+ throw new Error("first arg must be private key");
28511
+ if (isProbPub(publicKeyB) === false)
28512
+ throw new Error("second arg must be public key");
28513
+ const s = _normFnElement(Fn, secretKeyA);
28514
+ const b = Point.fromHex(publicKeyB);
28515
+ return b.multiply(s).toBytes(isCompressed);
28516
+ }
28517
+ const utils = {
28518
+ isValidSecretKey,
28519
+ isValidPublicKey,
28520
+ randomSecretKey,
28521
+ // TODO: remove
28522
+ isValidPrivateKey: isValidSecretKey,
28523
+ randomPrivateKey: randomSecretKey,
28524
+ normPrivateKeyToScalar: (key) => _normFnElement(Fn, key),
28525
+ precompute(windowSize = 8, point = Point.BASE) {
28526
+ return point.precompute(windowSize, false);
28527
+ }
28528
+ };
28529
+ return Object.freeze({ getPublicKey, getSharedSecret, keygen, Point, utils, lengths });
28530
+ }
28531
+ function ecdsa(Point, hash, ecdsaOpts = {}) {
28532
+ ahash2(hash);
28533
+ _validateObject(ecdsaOpts, {}, {
28534
+ hmac: "function",
28535
+ lowS: "boolean",
28536
+ randomBytes: "function",
28537
+ bits2int: "function",
28538
+ bits2int_modN: "function"
28539
+ });
28540
+ const randomBytes3 = ecdsaOpts.randomBytes || randomBytes2;
28541
+ const hmac3 = ecdsaOpts.hmac || ((key, ...msgs) => hmac2(hash, key, concatBytes2(...msgs)));
28542
+ const { Fp, Fn } = Point;
28543
+ const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
28544
+ const { keygen, getPublicKey, getSharedSecret, utils, lengths } = ecdh(Point, ecdsaOpts);
28545
+ const defaultSigOpts = {
28546
+ prehash: false,
28547
+ lowS: typeof ecdsaOpts.lowS === "boolean" ? ecdsaOpts.lowS : false,
28548
+ format: void 0,
28549
+ //'compact' as ECDSASigFormat,
28550
+ extraEntropy: false
28551
+ };
28552
+ const defaultSigOpts_format = "compact";
28553
+ function isBiggerThanHalfOrder(number) {
28554
+ const HALF = CURVE_ORDER >> _1n9;
28555
+ return number > HALF;
28556
+ }
28557
+ function validateRS(title, num) {
28558
+ if (!Fn.isValidNot0(num))
28559
+ throw new Error(`invalid signature ${title}: out of range 1..Point.Fn.ORDER`);
28560
+ return num;
28561
+ }
28562
+ function validateSigLength(bytes, format) {
28563
+ validateSigFormat(format);
28564
+ const size = lengths.signature;
28565
+ const sizer = format === "compact" ? size : format === "recovered" ? size + 1 : void 0;
28566
+ return _abytes2(bytes, sizer, `${format} signature`);
28567
+ }
28568
+ class Signature {
28569
+ constructor(r, s, recovery) {
28570
+ this.r = validateRS("r", r);
28571
+ this.s = validateRS("s", s);
28572
+ if (recovery != null)
28573
+ this.recovery = recovery;
28574
+ Object.freeze(this);
28575
+ }
28576
+ static fromBytes(bytes, format = defaultSigOpts_format) {
28577
+ validateSigLength(bytes, format);
28578
+ let recid;
28579
+ if (format === "der") {
28580
+ const { r: r2, s: s2 } = DER.toSig(_abytes2(bytes));
28581
+ return new Signature(r2, s2);
28582
+ }
28583
+ if (format === "recovered") {
28584
+ recid = bytes[0];
28585
+ format = "compact";
28586
+ bytes = bytes.subarray(1);
28587
+ }
28588
+ const L = Fn.BYTES;
28589
+ const r = bytes.subarray(0, L);
28590
+ const s = bytes.subarray(L, L * 2);
28591
+ return new Signature(Fn.fromBytes(r), Fn.fromBytes(s), recid);
28592
+ }
28593
+ static fromHex(hex, format) {
28594
+ return this.fromBytes(hexToBytes2(hex), format);
28595
+ }
28596
+ addRecoveryBit(recovery) {
28597
+ return new Signature(this.r, this.s, recovery);
28598
+ }
28599
+ recoverPublicKey(messageHash) {
28600
+ const FIELD_ORDER = Fp.ORDER;
28601
+ const { r, s, recovery: rec } = this;
28602
+ if (rec == null || ![0, 1, 2, 3].includes(rec))
28603
+ throw new Error("recovery id invalid");
28604
+ const hasCofactor = CURVE_ORDER * _2n5 < FIELD_ORDER;
28605
+ if (hasCofactor && rec > 1)
28606
+ throw new Error("recovery id is ambiguous for h>1 curve");
28607
+ const radj = rec === 2 || rec === 3 ? r + CURVE_ORDER : r;
28608
+ if (!Fp.isValid(radj))
28609
+ throw new Error("recovery id 2 or 3 invalid");
28610
+ const x = Fp.toBytes(radj);
28611
+ const R = Point.fromBytes(concatBytes2(pprefix((rec & 1) === 0), x));
28612
+ const ir = Fn.inv(radj);
28613
+ const h = bits2int_modN(ensureBytes("msgHash", messageHash));
28614
+ const u1 = Fn.create(-h * ir);
28615
+ const u2 = Fn.create(s * ir);
28616
+ const Q = Point.BASE.multiplyUnsafe(u1).add(R.multiplyUnsafe(u2));
28617
+ if (Q.is0())
28618
+ throw new Error("point at infinify");
28619
+ Q.assertValidity();
28620
+ return Q;
28621
+ }
28622
+ // Signatures should be low-s, to prevent malleability.
28623
+ hasHighS() {
28624
+ return isBiggerThanHalfOrder(this.s);
28625
+ }
28626
+ toBytes(format = defaultSigOpts_format) {
28627
+ validateSigFormat(format);
28628
+ if (format === "der")
28629
+ return hexToBytes2(DER.hexFromSig(this));
28630
+ const r = Fn.toBytes(this.r);
28631
+ const s = Fn.toBytes(this.s);
28632
+ if (format === "recovered") {
28633
+ if (this.recovery == null)
28634
+ throw new Error("recovery bit must be present");
28635
+ return concatBytes2(Uint8Array.of(this.recovery), r, s);
28636
+ }
28637
+ return concatBytes2(r, s);
28638
+ }
28639
+ toHex(format) {
28640
+ return bytesToHex2(this.toBytes(format));
28641
+ }
28642
+ // TODO: remove
28643
+ assertValidity() {
28644
+ }
28645
+ static fromCompact(hex) {
28646
+ return Signature.fromBytes(ensureBytes("sig", hex), "compact");
28647
+ }
28648
+ static fromDER(hex) {
28649
+ return Signature.fromBytes(ensureBytes("sig", hex), "der");
28650
+ }
28651
+ normalizeS() {
28652
+ return this.hasHighS() ? new Signature(this.r, Fn.neg(this.s), this.recovery) : this;
28653
+ }
28654
+ toDERRawBytes() {
28655
+ return this.toBytes("der");
28656
+ }
28657
+ toDERHex() {
28658
+ return bytesToHex2(this.toBytes("der"));
28659
+ }
28660
+ toCompactRawBytes() {
28661
+ return this.toBytes("compact");
28662
+ }
28663
+ toCompactHex() {
28664
+ return bytesToHex2(this.toBytes("compact"));
28665
+ }
28666
+ }
28667
+ const bits2int = ecdsaOpts.bits2int || function bits2int_def(bytes) {
28668
+ if (bytes.length > 8192)
28669
+ throw new Error("input is too large");
28670
+ const num = bytesToNumberBE2(bytes);
28671
+ const delta = bytes.length * 8 - fnBits;
28672
+ return delta > 0 ? num >> BigInt(delta) : num;
28673
+ };
28674
+ const bits2int_modN = ecdsaOpts.bits2int_modN || function bits2int_modN_def(bytes) {
28675
+ return Fn.create(bits2int(bytes));
28676
+ };
28677
+ const ORDER_MASK = bitMask2(fnBits);
28678
+ function int2octets(num) {
28679
+ aInRange2("num < 2^" + fnBits, num, _0n8, ORDER_MASK);
28680
+ return Fn.toBytes(num);
28681
+ }
28682
+ function validateMsgAndHash(message, prehash) {
28683
+ _abytes2(message, void 0, "message");
28684
+ return prehash ? _abytes2(hash(message), void 0, "prehashed message") : message;
28685
+ }
28686
+ function prepSig(message, privateKey, opts) {
28687
+ if (["recovered", "canonical"].some((k) => k in opts))
28688
+ throw new Error("sign() legacy options not supported");
28689
+ const { lowS, prehash, extraEntropy } = validateSigOpts(opts, defaultSigOpts);
28690
+ message = validateMsgAndHash(message, prehash);
28691
+ const h1int = bits2int_modN(message);
28692
+ const d = _normFnElement(Fn, privateKey);
28693
+ const seedArgs = [int2octets(d), int2octets(h1int)];
28694
+ if (extraEntropy != null && extraEntropy !== false) {
28695
+ const e = extraEntropy === true ? randomBytes3(lengths.secretKey) : extraEntropy;
28696
+ seedArgs.push(ensureBytes("extraEntropy", e));
28697
+ }
28698
+ const seed = concatBytes2(...seedArgs);
28699
+ const m = h1int;
28700
+ function k2sig(kBytes) {
28701
+ const k = bits2int(kBytes);
28702
+ if (!Fn.isValidNot0(k))
28703
+ return;
28704
+ const ik = Fn.inv(k);
28705
+ const q = Point.BASE.multiply(k).toAffine();
28706
+ const r = Fn.create(q.x);
28707
+ if (r === _0n8)
28708
+ return;
28709
+ const s = Fn.create(ik * Fn.create(m + r * d));
28710
+ if (s === _0n8)
28711
+ return;
28712
+ let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n9);
28713
+ let normS = s;
28714
+ if (lowS && isBiggerThanHalfOrder(s)) {
28715
+ normS = Fn.neg(s);
28716
+ recovery ^= 1;
28717
+ }
28718
+ return new Signature(r, normS, recovery);
28719
+ }
28720
+ return { seed, k2sig };
28721
+ }
28722
+ function sign(message, secretKey, opts = {}) {
28723
+ message = ensureBytes("message", message);
28724
+ const { seed, k2sig } = prepSig(message, secretKey, opts);
28725
+ const drbg = createHmacDrbg(hash.outputLen, Fn.BYTES, hmac3);
28726
+ const sig = drbg(seed, k2sig);
28727
+ return sig;
28728
+ }
28729
+ function tryParsingSig(sg) {
28730
+ let sig = void 0;
28731
+ const isHex = typeof sg === "string" || isBytes2(sg);
28732
+ const isObj = !isHex && sg !== null && typeof sg === "object" && typeof sg.r === "bigint" && typeof sg.s === "bigint";
28733
+ if (!isHex && !isObj)
28734
+ throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
28735
+ if (isObj) {
28736
+ sig = new Signature(sg.r, sg.s);
28737
+ } else if (isHex) {
28738
+ try {
28739
+ sig = Signature.fromBytes(ensureBytes("sig", sg), "der");
28740
+ } catch (derError) {
28741
+ if (!(derError instanceof DER.Err))
28742
+ throw derError;
28743
+ }
28744
+ if (!sig) {
28745
+ try {
28746
+ sig = Signature.fromBytes(ensureBytes("sig", sg), "compact");
28747
+ } catch (error) {
28748
+ return false;
28749
+ }
28750
+ }
28751
+ }
28752
+ if (!sig)
28753
+ return false;
28754
+ return sig;
28755
+ }
28756
+ function verify(signature, message, publicKey, opts = {}) {
28757
+ const { lowS, prehash, format } = validateSigOpts(opts, defaultSigOpts);
28758
+ publicKey = ensureBytes("publicKey", publicKey);
28759
+ message = validateMsgAndHash(ensureBytes("message", message), prehash);
28760
+ if ("strict" in opts)
28761
+ throw new Error("options.strict was renamed to lowS");
28762
+ const sig = format === void 0 ? tryParsingSig(signature) : Signature.fromBytes(ensureBytes("sig", signature), format);
28763
+ if (sig === false)
28764
+ return false;
28765
+ try {
28766
+ const P = Point.fromBytes(publicKey);
28767
+ if (lowS && sig.hasHighS())
28768
+ return false;
28769
+ const { r, s } = sig;
28770
+ const h = bits2int_modN(message);
28771
+ const is = Fn.inv(s);
28772
+ const u1 = Fn.create(h * is);
28773
+ const u2 = Fn.create(r * is);
28774
+ const R = Point.BASE.multiplyUnsafe(u1).add(P.multiplyUnsafe(u2));
28775
+ if (R.is0())
28776
+ return false;
28777
+ const v = Fn.create(R.x);
28778
+ return v === r;
28779
+ } catch (e) {
28780
+ return false;
28781
+ }
28782
+ }
28783
+ function recoverPublicKey(signature, message, opts = {}) {
28784
+ const { prehash } = validateSigOpts(opts, defaultSigOpts);
28785
+ message = validateMsgAndHash(message, prehash);
28786
+ return Signature.fromBytes(signature, "recovered").recoverPublicKey(message).toBytes();
28787
+ }
28788
+ return Object.freeze({
28789
+ keygen,
28790
+ getPublicKey,
28791
+ getSharedSecret,
28792
+ utils,
28793
+ lengths,
28794
+ Point,
28795
+ sign,
28796
+ verify,
28797
+ recoverPublicKey,
28798
+ Signature,
28799
+ hash
28800
+ });
28801
+ }
28802
+ function _weierstrass_legacy_opts_to_new(c) {
28803
+ const CURVE = {
28804
+ a: c.a,
28805
+ b: c.b,
28806
+ p: c.Fp.ORDER,
28807
+ n: c.n,
28808
+ h: c.h,
28809
+ Gx: c.Gx,
28810
+ Gy: c.Gy
28811
+ };
28812
+ const Fp = c.Fp;
28813
+ let allowedLengths = c.allowedPrivateKeyLengths ? Array.from(new Set(c.allowedPrivateKeyLengths.map((l) => Math.ceil(l / 2)))) : void 0;
28814
+ const Fn = Field2(CURVE.n, {
28815
+ BITS: c.nBitLength,
28816
+ allowedLengths,
28817
+ modFromBytes: c.wrapPrivateKey
28818
+ });
28819
+ const curveOpts = {
28820
+ Fp,
28821
+ Fn,
28822
+ allowInfinityPoint: c.allowInfinityPoint,
28823
+ endo: c.endo,
28824
+ isTorsionFree: c.isTorsionFree,
28825
+ clearCofactor: c.clearCofactor,
28826
+ fromBytes: c.fromBytes,
28827
+ toBytes: c.toBytes
28828
+ };
28829
+ return { CURVE, curveOpts };
28830
+ }
28831
+ function _ecdsa_legacy_opts_to_new(c) {
28832
+ const { CURVE, curveOpts } = _weierstrass_legacy_opts_to_new(c);
28833
+ const ecdsaOpts = {
28834
+ hmac: c.hmac,
28835
+ randomBytes: c.randomBytes,
28836
+ lowS: c.lowS,
28837
+ bits2int: c.bits2int,
28838
+ bits2int_modN: c.bits2int_modN
28839
+ };
28840
+ return { CURVE, curveOpts, hash: c.hash, ecdsaOpts };
28841
+ }
28842
+ function _ecdsa_new_output_to_legacy(c, _ecdsa) {
28843
+ const Point = _ecdsa.Point;
28844
+ return Object.assign({}, _ecdsa, {
28845
+ ProjectivePoint: Point,
28846
+ CURVE: Object.assign({}, c, nLength2(Point.Fn.ORDER, Point.Fn.BITS))
28847
+ });
28848
+ }
28849
+ function weierstrass(c) {
28850
+ const { CURVE, curveOpts, hash, ecdsaOpts } = _ecdsa_legacy_opts_to_new(c);
28851
+ const Point = weierstrassN(CURVE, curveOpts);
28852
+ const signs = ecdsa(Point, hash, ecdsaOpts);
28853
+ return _ecdsa_new_output_to_legacy(c, signs);
28854
+ }
28855
+
28856
+ // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/_shortw_utils.js
28857
+ function createCurve(curveDef, defHash) {
28858
+ const create = (hash) => weierstrass({ ...curveDef, hash });
28859
+ return { ...create(defHash), create };
28860
+ }
28861
+
28862
+ // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/secp256k1.js
28863
+ var secp256k1_CURVE = {
28864
+ p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
28865
+ n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
28866
+ h: BigInt(1),
28867
+ a: BigInt(0),
28868
+ b: BigInt(7),
28869
+ Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
28870
+ Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
28871
+ };
28872
+ var secp256k1_ENDO = {
28873
+ beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
28874
+ basises: [
28875
+ [BigInt("0x3086d221a7d46bcde86c90e49284eb15"), -BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],
28876
+ [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
28877
+ ]
28878
+ };
28879
+ var _2n6 = /* @__PURE__ */ BigInt(2);
28880
+ function sqrtMod(y) {
28881
+ const P = secp256k1_CURVE.p;
28882
+ const _3n4 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
28883
+ const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
28884
+ const b2 = y * y * y % P;
28885
+ const b3 = b2 * b2 * y % P;
28886
+ const b6 = pow22(b3, _3n4, P) * b3 % P;
28887
+ const b9 = pow22(b6, _3n4, P) * b3 % P;
28888
+ const b11 = pow22(b9, _2n6, P) * b2 % P;
28889
+ const b22 = pow22(b11, _11n, P) * b11 % P;
28890
+ const b44 = pow22(b22, _22n, P) * b22 % P;
28891
+ const b88 = pow22(b44, _44n, P) * b44 % P;
28892
+ const b176 = pow22(b88, _88n, P) * b88 % P;
28893
+ const b220 = pow22(b176, _44n, P) * b44 % P;
28894
+ const b223 = pow22(b220, _3n4, P) * b3 % P;
28895
+ const t1 = pow22(b223, _23n, P) * b22 % P;
28896
+ const t2 = pow22(t1, _6n, P) * b2 % P;
28897
+ const root = pow22(t2, _2n6, P);
28898
+ if (!Fpk1.eql(Fpk1.sqr(root), y))
28899
+ throw new Error("Cannot find square root");
28900
+ return root;
28901
+ }
28902
+ var Fpk1 = Field2(secp256k1_CURVE.p, { sqrt: sqrtMod });
28903
+ var secp256k1 = createCurve({ ...secp256k1_CURVE, Fp: Fpk1, lowS: true, endo: secp256k1_ENDO }, sha2562);
28904
+
28905
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha256.js
28906
+ var sha2563 = sha2562;
28907
+
28908
+ // ../sdk/dist/index.js
26597
28909
  import { readFileSync, existsSync, mkdirSync, writeFileSync } from "fs";
26598
28910
  var __defProp = Object.defineProperty;
26599
28911
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -27783,10 +30095,10 @@ async function finalize(response, opts) {
27783
30095
  return { status: response.status, body: body2, paid: opts.paid };
27784
30096
  }
27785
30097
  async function makeGrpcBuildClient(client) {
27786
- const { SuiGrpcClient: SuiGrpcClient2 } = await import("./grpc-OLWNGPHN.js");
30098
+ const { SuiGrpcClient: SuiGrpcClient3 } = await import("./grpc-OLWNGPHN.js");
27787
30099
  const network = client.network === "testnet" ? "testnet" : "mainnet";
27788
30100
  const baseUrl = network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
27789
- return new SuiGrpcClient2({ baseUrl, network });
30101
+ return new SuiGrpcClient3({ baseUrl, network });
27790
30102
  }
27791
30103
  function atomicToHuman(raw, decimals) {
27792
30104
  return Number(raw) / 10 ** decimals;
@@ -28209,10 +30521,10 @@ function recordFromGqlNode(node, address) {
28209
30521
  commandTypes.push("MoveCall");
28210
30522
  const fn = cmd.function;
28211
30523
  const pkg = fn?.module?.package?.address;
28212
- const mod2 = fn?.module?.name;
30524
+ const mod3 = fn?.module?.name;
28213
30525
  const name = fn?.name;
28214
- if (pkg && mod2 && name) {
28215
- moveCallTargets.push(`${pkg}::${mod2}::${name}`);
30526
+ if (pkg && mod3 && name) {
30527
+ moveCallTargets.push(`${pkg}::${mod3}::${name}`);
28216
30528
  }
28217
30529
  } else if (cmd.__typename === "TransferObjectsCommand") {
28218
30530
  commandTypes.push("TransferObjects");
@@ -28436,6 +30748,207 @@ async function listModels(opts) {
28436
30748
  privacy: m.privacy ?? m.privacy_tier
28437
30749
  }));
28438
30750
  }
30751
+ var RECEIPT_ANCHORED_SUFFIX = "::anchor::ReceiptAnchored";
30752
+ function fullnodeUrl(network) {
30753
+ return network === "testnet" ? "https://fullnode.testnet.sui.io" : "https://fullnode.mainnet.sui.io";
30754
+ }
30755
+ function jcs(value) {
30756
+ if (value === null) {
30757
+ return "null";
30758
+ }
30759
+ if (typeof value === "boolean") {
30760
+ return value ? "true" : "false";
30761
+ }
30762
+ if (typeof value === "number") {
30763
+ if (!Number.isInteger(value)) {
30764
+ throw new Error("JCS: non-integer number");
30765
+ }
30766
+ return String(value);
30767
+ }
30768
+ if (typeof value === "string") {
30769
+ return JSON.stringify(value);
30770
+ }
30771
+ if (Array.isArray(value)) {
30772
+ return `[${value.map(jcs).join(",")}]`;
30773
+ }
30774
+ const keys = Object.keys(value).sort();
30775
+ return `{${keys.map((k) => `${JSON.stringify(k)}:${jcs(value[k])}`).join(",")}}`;
30776
+ }
30777
+ function verifyReceiptSignature(receipt, signingKeyHex) {
30778
+ try {
30779
+ const sig = receipt.signature;
30780
+ if (sig?.algo !== "ecdsa-secp256k1" || !sig.value) {
30781
+ return false;
30782
+ }
30783
+ const canonical = {
30784
+ api_version: receipt.api_version ?? "",
30785
+ receipt_id: receipt.receipt_id ?? "",
30786
+ chat_id: receipt.chat_id ?? null,
30787
+ workload_id: receipt.workload_id ?? "",
30788
+ workload_keyset_digest: receipt.workload_keyset_digest ?? "",
30789
+ endpoint: receipt.endpoint ?? "",
30790
+ method: receipt.method ?? "",
30791
+ served_at: receipt.served_at ?? 0,
30792
+ event_log: receipt.event_log ?? [],
30793
+ signature: { algo: sig.algo, key_id: sig.key_id ?? "" }
30794
+ };
30795
+ const prehash = sha2563(new TextEncoder().encode(jcs(canonical)));
30796
+ const sigBytes = hexToBytes2(sig.value);
30797
+ if (sigBytes.length !== 65) {
30798
+ return false;
30799
+ }
30800
+ let v = sigBytes[64];
30801
+ if (v >= 27 && v <= 30) {
30802
+ v -= 27;
30803
+ }
30804
+ if (v > 3) {
30805
+ return false;
30806
+ }
30807
+ const recovered = secp256k1.Signature.fromCompact(sigBytes.slice(0, 64)).addRecoveryBit(v).recoverPublicKey(prehash).toHex(false);
30808
+ const endorsed = bytesToHex2(hexToBytes2(signingKeyHex.replace(/^0x/, "")));
30809
+ return recovered.toLowerCase() === endorsed.toLowerCase();
30810
+ } catch {
30811
+ return false;
30812
+ }
30813
+ }
30814
+ async function verifyReceipt(receiptId, opts = {}) {
30815
+ const base = opts.apiBase ?? DEFAULT_API_BASE;
30816
+ const network = opts.network ?? "mainnet";
30817
+ const checks = [];
30818
+ let receipt = null;
30819
+ try {
30820
+ const res = await fetch(`${base}/aci/receipts/${encodeURIComponent(receiptId)}`);
30821
+ if (res.ok) {
30822
+ receipt = await res.json();
30823
+ }
30824
+ } catch {
30825
+ }
30826
+ if (!receipt?.event_log) {
30827
+ checks.push({
30828
+ name: "Receipt",
30829
+ status: "fail",
30830
+ detail: "receipt not found or malformed",
30831
+ trust: "receipt-asserted"
30832
+ });
30833
+ return { receiptId, verified: false, anchorVerified: false, checks };
30834
+ }
30835
+ const wireHash = receipt.event_log.find((e) => e.type === "response.returned")?.wire_hash;
30836
+ const workloadId = receipt.workload_id;
30837
+ checks.push({
30838
+ name: "Receipt",
30839
+ status: wireHash && workloadId ? "pass" : "fail",
30840
+ detail: wireHash ? `well-formed (${receipt.event_log.length} log entries, workload ${workloadId})` : "missing response wire_hash / workload_id",
30841
+ trust: "receipt-asserted"
30842
+ });
30843
+ const upstreamEv = receipt.event_log.find((e) => e.type === "upstream.verified");
30844
+ const upstreamOk = upstreamEv?.result === "verified";
30845
+ checks.push({
30846
+ name: "Confidential upstream",
30847
+ status: upstreamEv ? upstreamOk ? "pass" : "fail" : "skip",
30848
+ detail: upstreamEv ? `${upstreamEv.provider ?? upstreamEv.upstream_name ?? "upstream"}: ${upstreamEv.result ?? "unknown"}${upstreamEv.tcb_status ? ` (TCB ${upstreamEv.tcb_status})` : ""}` : "no upstream.verified event (routed/non-confidential?)",
30849
+ trust: "receipt-asserted"
30850
+ });
30851
+ let anchorVerified = false;
30852
+ let anchor;
30853
+ let digest;
30854
+ try {
30855
+ const res = await fetch(`${base}/aci/anchor/${encodeURIComponent(receiptId)}`);
30856
+ if (res.ok) {
30857
+ const j = await res.json();
30858
+ digest = j.txDigest;
30859
+ }
30860
+ } catch {
30861
+ }
30862
+ if (!digest) {
30863
+ checks.push({
30864
+ name: "Sui anchor",
30865
+ status: "fail",
30866
+ detail: `no anchor on record \u2014 POST ${base}/aci/anchor/${receiptId} to create one`,
30867
+ trust: "trustless"
30868
+ });
30869
+ } else {
30870
+ try {
30871
+ const client = new SuiGrpcClient({ baseUrl: fullnodeUrl(network), network });
30872
+ const tx = await client.core.getTransaction({
30873
+ digest,
30874
+ include: { events: true }
30875
+ });
30876
+ const txn = tx.$kind === "Transaction" ? tx.Transaction : tx.FailedTransaction;
30877
+ const ev = (txn.events ?? []).find(
30878
+ (e) => e.eventType.endsWith(RECEIPT_ANCHORED_SUFFIX)
30879
+ );
30880
+ const data = ev?.json ?? {};
30881
+ const onChainReceipt = String(data.receipt_id ?? "");
30882
+ const onChainWire = String(data.wire_hash ?? "");
30883
+ const onChainWorkload = String(data.workload_id ?? "");
30884
+ const matches = onChainReceipt === receiptId && onChainWire === wireHash && onChainWorkload === workloadId;
30885
+ anchorVerified = matches;
30886
+ anchor = {
30887
+ txDigest: digest,
30888
+ anchoredAtMs: data.anchored_at_ms ? String(data.anchored_at_ms) : void 0,
30889
+ anchoredBy: data.anchored_by ? String(data.anchored_by) : void 0,
30890
+ explorer: `https://suiscan.xyz/${network}/tx/${digest}`
30891
+ };
30892
+ checks.push({
30893
+ name: "Sui anchor",
30894
+ status: matches ? "pass" : "fail",
30895
+ detail: matches ? `on-chain ReceiptAnchored matches (wire_hash + workload_id), tx ${digest}` : `on-chain event does NOT match the receipt (wire ${onChainWire || "absent"})`,
30896
+ trust: "trustless"
30897
+ });
30898
+ } catch (e) {
30899
+ checks.push({
30900
+ name: "Sui anchor",
30901
+ status: "fail",
30902
+ detail: `could not read anchor tx ${digest}: ${e instanceof Error ? e.message : "error"}`,
30903
+ trust: "trustless"
30904
+ });
30905
+ }
30906
+ }
30907
+ let signatureForged = false;
30908
+ let sigStatus = "skip";
30909
+ let sigDetail = "no signature on receipt";
30910
+ if (receipt.signature?.value) {
30911
+ try {
30912
+ const model = opts.model ?? "phala/glm-5.2";
30913
+ const res = await fetch(
30914
+ `${base}/aci/attestation?model=${encodeURIComponent(model)}`
30915
+ );
30916
+ const att = res.ok ? await res.json() : null;
30917
+ if (!att?.signingKey) {
30918
+ sigDetail = "could not fetch the attested keyset to check the signature";
30919
+ } else if (att.workloadId && att.workloadId !== workloadId) {
30920
+ sigDetail = `attested keyset is for a different workload \u2014 pass --model for ${workloadId}`;
30921
+ } else {
30922
+ const ok = verifyReceiptSignature(receipt, att.signingKey);
30923
+ sigStatus = ok ? "pass" : "fail";
30924
+ signatureForged = !ok;
30925
+ sigDetail = ok ? `signed by the attested receipt key (${receipt.signature.key_id ?? "key"})` : "signature does NOT recover the attested receipt key \u2014 forged/altered";
30926
+ }
30927
+ } catch {
30928
+ sigDetail = "signature check errored";
30929
+ }
30930
+ }
30931
+ checks.push({
30932
+ name: "Receipt signature",
30933
+ status: sigStatus,
30934
+ detail: sigDetail,
30935
+ trust: sigStatus === "skip" ? "roadmap" : "trustless"
30936
+ });
30937
+ return {
30938
+ receiptId,
30939
+ verified: Boolean(wireHash && workloadId) && anchorVerified && !signatureForged,
30940
+ anchorVerified,
30941
+ checks,
30942
+ wireHash,
30943
+ workloadId,
30944
+ upstream: upstreamEv ? {
30945
+ provider: upstreamEv.provider ?? upstreamEv.upstream_name,
30946
+ result: upstreamEv.result,
30947
+ tcbStatus: upstreamEv.tcb_status
30948
+ } : void 0,
30949
+ anchor
30950
+ };
30951
+ }
28439
30952
  var DEFAULT_CONFIG_DIR = join2(homedir(), ".t2000");
28440
30953
  function resolveConfigPath(configDir) {
28441
30954
  return join2(configDir ?? DEFAULT_CONFIG_DIR, "config.json");
@@ -28717,6 +31230,11 @@ var T2000 = class _T2000 extends import_index2.default {
28717
31230
  async models(opts) {
28718
31231
  return listModels(opts);
28719
31232
  }
31233
+ /** Verify a confidential response by receipt id — checks the signed receipt
31234
+ * + its trustless on-chain Sui anchor. Fails closed on any mismatch. */
31235
+ async verify(receiptId, opts) {
31236
+ return verifyReceipt(receiptId, opts);
31237
+ }
28720
31238
  // -- Swap --
28721
31239
  async swap(params) {
28722
31240
  this.limits.assert({
@@ -32473,8 +34991,80 @@ function registerChat(program3) {
32473
34991
  });
32474
34992
  }
32475
34993
 
32476
- // src/commands/services/search.ts
34994
+ // src/commands/verify.ts
32477
34995
  var import_picocolors10 = __toESM(require_picocolors(), 1);
34996
+ function mark(check2) {
34997
+ if (check2.status === "pass") {
34998
+ return import_picocolors10.default.green("\u2713");
34999
+ }
35000
+ if (check2.status === "fail") {
35001
+ return import_picocolors10.default.red("\u2717");
35002
+ }
35003
+ return import_picocolors10.default.dim("\u2022");
35004
+ }
35005
+ function trustTag(check2) {
35006
+ if (check2.trust === "trustless") {
35007
+ return import_picocolors10.default.green(" (trustless)");
35008
+ }
35009
+ if (check2.trust === "roadmap") {
35010
+ return import_picocolors10.default.dim(" (roadmap)");
35011
+ }
35012
+ return import_picocolors10.default.dim(" (in signed receipt)");
35013
+ }
35014
+ function registerVerify(program3) {
35015
+ program3.command("verify").argument("<receipt-id>", "A confidential receipt id (rcpt-\u2026)").description(
35016
+ "Verify a confidential response by receipt id \u2014 checks the signed receipt + its trustless on-chain Sui anchor. Fails closed on any mismatch."
35017
+ ).option("--api <url>", "API base URL (default https://api.t2000.ai/v1)").option("--model <id>", "Confidential model for the attested key (default phala/glm-5.2)").option("--testnet", "Read the anchor from Sui testnet (default mainnet)").action(
35018
+ async (receiptId, opts) => {
35019
+ try {
35020
+ const result = await verifyReceipt(receiptId, {
35021
+ apiBase: opts.api,
35022
+ model: opts.model,
35023
+ network: opts.testnet ? "testnet" : "mainnet"
35024
+ });
35025
+ if (isJsonMode()) {
35026
+ printJson(result);
35027
+ if (!result.verified) {
35028
+ process.exitCode = 1;
35029
+ }
35030
+ return;
35031
+ }
35032
+ printBlank();
35033
+ printLine(import_picocolors10.default.bold(`Verifying ${receiptId}`));
35034
+ printBlank();
35035
+ for (const check2 of result.checks) {
35036
+ printLine(` ${mark(check2)} ${import_picocolors10.default.bold(check2.name)}${trustTag(check2)}`);
35037
+ printLine(` ${import_picocolors10.default.dim(check2.detail)}`);
35038
+ }
35039
+ printBlank();
35040
+ if (result.anchor) {
35041
+ printLine(import_picocolors10.default.dim(` anchor: ${result.anchor.explorer}`));
35042
+ }
35043
+ if (result.verified) {
35044
+ printLine(
35045
+ import_picocolors10.default.green(
35046
+ " RESULT: \u2713 verified \u2014 TEE-signed receipt + tamper-evident Sui anchor."
35047
+ )
35048
+ );
35049
+ printLine(
35050
+ import_picocolors10.default.dim(
35051
+ " Local DCAP-quote re-verification (dcap-qvl) = roadmap (full no-trust)."
35052
+ )
35053
+ );
35054
+ } else {
35055
+ printLine(import_picocolors10.default.red(" RESULT: \u2717 NOT verified \u2014 see the failed check above."));
35056
+ process.exitCode = 1;
35057
+ }
35058
+ printBlank();
35059
+ } catch (error) {
35060
+ handleError(error);
35061
+ }
35062
+ }
35063
+ );
35064
+ }
35065
+
35066
+ // src/commands/services/search.ts
35067
+ var import_picocolors11 = __toESM(require_picocolors(), 1);
32478
35068
 
32479
35069
  // src/commands/services/catalog.ts
32480
35070
  var DEFAULT_GATEWAY_URL = "https://mpp.t2000.ai";
@@ -32576,9 +35166,9 @@ Examples:
32576
35166
  }
32577
35167
  function renderServiceLine(svc) {
32578
35168
  const minPrice = cheapestEndpointPrice(svc);
32579
- const priceTag = minPrice !== null ? import_picocolors10.default.green(`from $${minPrice}`) : import_picocolors10.default.dim("no pricing");
32580
- const catTag = svc.categories.length > 0 ? import_picocolors10.default.dim(`[${svc.categories.join(", ")}]`) : "";
32581
- printKeyValue(import_picocolors10.default.bold(svc.name), `${priceTag} ${catTag}`);
35169
+ const priceTag = minPrice !== null ? import_picocolors11.default.green(`from $${minPrice}`) : import_picocolors11.default.dim("no pricing");
35170
+ const catTag = svc.categories.length > 0 ? import_picocolors11.default.dim(`[${svc.categories.join(", ")}]`) : "";
35171
+ printKeyValue(import_picocolors11.default.bold(svc.name), `${priceTag} ${catTag}`);
32582
35172
  printKeyValue(" url", svc.serviceUrl);
32583
35173
  printKeyValue(" about", svc.description);
32584
35174
  printBlank();
@@ -32592,7 +35182,7 @@ function cheapestEndpointPrice(svc) {
32592
35182
  }
32593
35183
 
32594
35184
  // src/commands/services/inspect.ts
32595
- var import_picocolors11 = __toESM(require_picocolors(), 1);
35185
+ var import_picocolors12 = __toESM(require_picocolors(), 1);
32596
35186
  function registerServicesInspect(parent) {
32597
35187
  parent.command("inspect").description("Show pricing + endpoints for an MPP service or endpoint URL").argument("<url>", "Service base URL or endpoint URL").option("--gateway <url>", "Override gateway base URL (default: https://mpp.t2000.ai)").addHelpText(
32598
35188
  "after",
@@ -32629,7 +35219,7 @@ Examples:
32629
35219
  return;
32630
35220
  }
32631
35221
  printBlank();
32632
- printKeyValue("Service", import_picocolors11.default.bold(service.name));
35222
+ printKeyValue("Service", import_picocolors12.default.bold(service.name));
32633
35223
  printKeyValue("URL", service.serviceUrl);
32634
35224
  printKeyValue("About", service.description);
32635
35225
  if (service.categories.length > 0) {
@@ -32659,7 +35249,7 @@ Examples:
32659
35249
  function renderEndpoint(ep, serviceUrl) {
32660
35250
  const price = `$${ep.price}`;
32661
35251
  const label = `${ep.method} ${ep.path}`.padEnd(40);
32662
- printKeyValue(label, `${import_picocolors11.default.green(price)} ${import_picocolors11.default.dim(ep.description)}`);
35252
+ printKeyValue(label, `${import_picocolors12.default.green(price)} ${import_picocolors12.default.dim(ep.description)}`);
32663
35253
  printKeyValue(" url", `${serviceUrl}${ep.path}`);
32664
35254
  printBlank();
32665
35255
  }
@@ -32682,7 +35272,7 @@ T2000_GATEWAY_URL or --gateway <url> for local development.
32682
35272
  }
32683
35273
 
32684
35274
  // src/commands/limit/show.ts
32685
- var import_picocolors12 = __toESM(require_picocolors(), 1);
35275
+ var import_picocolors13 = __toESM(require_picocolors(), 1);
32686
35276
  function registerLimitShow(parent) {
32687
35277
  parent.command("show").description("Show current spending limits").action(async (opts) => {
32688
35278
  try {
@@ -32705,10 +35295,10 @@ function registerLimitShow(parent) {
32705
35295
  }
32706
35296
  printBlank();
32707
35297
  if (limits.perTxUsd !== void 0) {
32708
- printKeyValue("Per-transaction", import_picocolors12.default.green(`$${limits.perTxUsd}`));
35298
+ printKeyValue("Per-transaction", import_picocolors13.default.green(`$${limits.perTxUsd}`));
32709
35299
  }
32710
35300
  if (limits.dailyUsd !== void 0) {
32711
- printKeyValue("Daily (cumulative)", import_picocolors12.default.green(`$${limits.dailyUsd}`));
35301
+ printKeyValue("Daily (cumulative)", import_picocolors13.default.green(`$${limits.dailyUsd}`));
32712
35302
  }
32713
35303
  printBlank();
32714
35304
  printInfo("Use `--force` on `t2 send` / `t2 swap` / `t2 pay` to override per-call.");
@@ -32720,7 +35310,7 @@ function registerLimitShow(parent) {
32720
35310
  }
32721
35311
 
32722
35312
  // src/commands/limit/set.ts
32723
- var import_picocolors13 = __toESM(require_picocolors(), 1);
35313
+ var import_picocolors14 = __toESM(require_picocolors(), 1);
32724
35314
  function parseLimitSetArgs(opts) {
32725
35315
  const perTx = opts.perTx !== void 0 ? parseUsdFlag("--per-tx", opts.perTx) : void 0;
32726
35316
  const daily = opts.daily !== void 0 ? parseUsdFlag("--daily", opts.daily) : void 0;
@@ -32762,10 +35352,10 @@ Examples:
32762
35352
  printBlank();
32763
35353
  printSuccess("Spending limits updated.");
32764
35354
  if (next?.perTxUsd !== void 0) {
32765
- printKeyValue("Per-transaction", import_picocolors13.default.green(`$${next.perTxUsd}`));
35355
+ printKeyValue("Per-transaction", import_picocolors14.default.green(`$${next.perTxUsd}`));
32766
35356
  }
32767
35357
  if (next?.dailyUsd !== void 0) {
32768
- printKeyValue("Daily (cumulative)", import_picocolors13.default.green(`$${next.dailyUsd}`));
35358
+ printKeyValue("Daily (cumulative)", import_picocolors14.default.green(`$${next.dailyUsd}`));
32769
35359
  }
32770
35360
  printBlank();
32771
35361
  printInfo("Use `t2 limit show` to view; `t2 limit reset` to clear.");
@@ -32825,14 +35415,14 @@ Subcommands:
32825
35415
  // src/commands/mcp/start.ts
32826
35416
  function registerMcpStart(parent) {
32827
35417
  parent.command("start", { isDefault: true }).description("Start MCP server (stdio transport \u2014 for AI client integration)").option("--key <path>", "Custom wallet path (default ~/.t2000/wallet.key)").action(async (opts) => {
32828
- let mod2;
35418
+ let mod3;
32829
35419
  try {
32830
- mod2 = await import("./dist-UPUBYGXT.js");
35420
+ mod3 = await import("./dist-QHCQQBPF.js");
32831
35421
  } catch {
32832
35422
  console.error("MCP server not installed. Run:\n npm install -g @t2000/mcp");
32833
35423
  process.exit(1);
32834
35424
  }
32835
- await mod2.startMcpServer({ keyPath: opts.key });
35425
+ await mod3.startMcpServer({ keyPath: opts.key });
32836
35426
  });
32837
35427
  }
32838
35428
 
@@ -33790,6 +36380,7 @@ Examples:
33790
36380
  registerSwap(program3);
33791
36381
  registerPay(program3);
33792
36382
  registerChat(program3);
36383
+ registerVerify(program3);
33793
36384
  registerServices(program3);
33794
36385
  registerLimit(program3);
33795
36386
  registerMcp(program3);
@@ -33815,9 +36406,18 @@ program2.parse();
33815
36406
  @noble/curves/abstract/curve.js:
33816
36407
  @noble/curves/abstract/edwards.js:
33817
36408
  @noble/curves/ed25519.js:
36409
+ @noble/curves/esm/utils.js:
36410
+ @noble/curves/esm/abstract/modular.js:
36411
+ @noble/curves/esm/abstract/curve.js:
36412
+ @noble/curves/esm/abstract/weierstrass.js:
36413
+ @noble/curves/esm/_shortw_utils.js:
36414
+ @noble/curves/esm/secp256k1.js:
33818
36415
  (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
33819
36416
 
33820
36417
  @scure/bip39/index.js:
33821
36418
  (*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
36419
+
36420
+ @noble/hashes/esm/utils.js:
36421
+ (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
33822
36422
  */
33823
36423
  //# sourceMappingURL=index.js.map