@settlemint/sdk-cli 2.1.1-prc71cad32 → 2.1.1-prcb1d9c8d

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.
Files changed (3) hide show
  1. package/dist/cli.js +703 -627
  2. package/dist/cli.js.map +28 -26
  3. package/package.json +3 -3
package/dist/cli.js CHANGED
@@ -837,7 +837,7 @@ var require_dist2 = __commonJS((exports) => {
837
837
  // ../../node_modules/@dotenvx/dotenvx/package.json
838
838
  var require_package = __commonJS((exports, module) => {
839
839
  module.exports = {
840
- version: "1.39.1",
840
+ version: "1.40.1",
841
841
  name: "@dotenvx/dotenvx",
842
842
  description: "a better dotenv–from the creator of `dotenv`",
843
843
  author: "@motdotla",
@@ -4232,7 +4232,7 @@ var require_utils4 = __commonJS((exports) => {
4232
4232
  exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
4233
4233
  exports.randomBytes = randomBytes;
4234
4234
  var crypto_1 = require_cryptoNode2();
4235
- var _assert_js_1 = require__assert2();
4235
+ var _assert_ts_1 = require__assert2();
4236
4236
  function isBytes(a) {
4237
4237
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
4238
4238
  }
@@ -4261,9 +4261,12 @@ var require_utils4 = __commonJS((exports) => {
4261
4261
  arr[i] = byteSwap(arr[i]);
4262
4262
  }
4263
4263
  }
4264
+ var hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
4264
4265
  var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
4265
4266
  function bytesToHex(bytes) {
4266
- (0, _assert_js_1.abytes)(bytes);
4267
+ (0, _assert_ts_1.abytes)(bytes);
4268
+ if (hasHexBuiltin)
4269
+ return bytes.toHex();
4267
4270
  let hex = "";
4268
4271
  for (let i = 0;i < bytes.length; i++) {
4269
4272
  hex += hexes[bytes[i]];
@@ -4283,6 +4286,8 @@ var require_utils4 = __commonJS((exports) => {
4283
4286
  function hexToBytes(hex) {
4284
4287
  if (typeof hex !== "string")
4285
4288
  throw new Error("hex string expected, got " + typeof hex);
4289
+ if (hasHexBuiltin)
4290
+ return Uint8Array.fromHex(hex);
4286
4291
  const hl = hex.length;
4287
4292
  const al = hl / 2;
4288
4293
  if (hl % 2)
@@ -4320,14 +4325,14 @@ var require_utils4 = __commonJS((exports) => {
4320
4325
  function toBytes(data) {
4321
4326
  if (typeof data === "string")
4322
4327
  data = utf8ToBytes(data);
4323
- (0, _assert_js_1.abytes)(data);
4328
+ (0, _assert_ts_1.abytes)(data);
4324
4329
  return data;
4325
4330
  }
4326
4331
  function concatBytes(...arrays) {
4327
4332
  let sum = 0;
4328
4333
  for (let i = 0;i < arrays.length; i++) {
4329
4334
  const a = arrays[i];
4330
- (0, _assert_js_1.abytes)(a);
4335
+ (0, _assert_ts_1.abytes)(a);
4331
4336
  sum += a.length;
4332
4337
  }
4333
4338
  const res = new Uint8Array(sum);
@@ -4380,7 +4385,7 @@ var require_utils4 = __commonJS((exports) => {
4380
4385
  return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
4381
4386
  }
4382
4387
  if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") {
4383
- return crypto_1.crypto.randomBytes(bytesLength);
4388
+ return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
4384
4389
  }
4385
4390
  throw new Error("crypto.getRandomValues must be defined");
4386
4391
  }
@@ -4393,8 +4398,8 @@ var require__md = __commonJS((exports) => {
4393
4398
  exports.setBigUint64 = setBigUint64;
4394
4399
  exports.Chi = Chi;
4395
4400
  exports.Maj = Maj;
4396
- var _assert_js_1 = require__assert2();
4397
- var utils_js_1 = require_utils4();
4401
+ var _assert_ts_1 = require__assert2();
4402
+ var utils_ts_1 = require_utils4();
4398
4403
  function setBigUint64(view, byteOffset, value, isLE) {
4399
4404
  if (typeof view.setBigUint64 === "function")
4400
4405
  return view.setBigUint64(byteOffset, value, isLE);
@@ -4414,29 +4419,29 @@ var require__md = __commonJS((exports) => {
4414
4419
  return a & b ^ a & c ^ b & c;
4415
4420
  }
4416
4421
 
4417
- class HashMD extends utils_js_1.Hash {
4422
+ class HashMD extends utils_ts_1.Hash {
4418
4423
  constructor(blockLen, outputLen, padOffset, isLE) {
4419
4424
  super();
4420
- this.blockLen = blockLen;
4421
- this.outputLen = outputLen;
4422
- this.padOffset = padOffset;
4423
- this.isLE = isLE;
4424
4425
  this.finished = false;
4425
4426
  this.length = 0;
4426
4427
  this.pos = 0;
4427
4428
  this.destroyed = false;
4429
+ this.blockLen = blockLen;
4430
+ this.outputLen = outputLen;
4431
+ this.padOffset = padOffset;
4432
+ this.isLE = isLE;
4428
4433
  this.buffer = new Uint8Array(blockLen);
4429
- this.view = (0, utils_js_1.createView)(this.buffer);
4434
+ this.view = (0, utils_ts_1.createView)(this.buffer);
4430
4435
  }
4431
4436
  update(data) {
4432
- (0, _assert_js_1.aexists)(this);
4437
+ (0, _assert_ts_1.aexists)(this);
4433
4438
  const { view, buffer, blockLen } = this;
4434
- data = (0, utils_js_1.toBytes)(data);
4439
+ data = (0, utils_ts_1.toBytes)(data);
4435
4440
  const len = data.length;
4436
4441
  for (let pos = 0;pos < len; ) {
4437
4442
  const take = Math.min(blockLen - this.pos, len - pos);
4438
4443
  if (take === blockLen) {
4439
- const dataView = (0, utils_js_1.createView)(data);
4444
+ const dataView = (0, utils_ts_1.createView)(data);
4440
4445
  for (;blockLen <= len - pos; pos += blockLen)
4441
4446
  this.process(dataView, pos);
4442
4447
  continue;
@@ -4454,8 +4459,8 @@ var require__md = __commonJS((exports) => {
4454
4459
  return this;
4455
4460
  }
4456
4461
  digestInto(out) {
4457
- (0, _assert_js_1.aexists)(this);
4458
- (0, _assert_js_1.aoutput)(out, this);
4462
+ (0, _assert_ts_1.aexists)(this);
4463
+ (0, _assert_ts_1.aoutput)(out, this);
4459
4464
  this.finished = true;
4460
4465
  const { buffer, view, blockLen, isLE } = this;
4461
4466
  let { pos } = this;
@@ -4469,7 +4474,7 @@ var require__md = __commonJS((exports) => {
4469
4474
  buffer[i] = 0;
4470
4475
  setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
4471
4476
  this.process(view, 0);
4472
- const oview = (0, utils_js_1.createView)(out);
4477
+ const oview = (0, utils_ts_1.createView)(out);
4473
4478
  const len = this.outputLen;
4474
4479
  if (len % 4)
4475
4480
  throw new Error("_sha2: outputLen should be aligned to 32bit");
@@ -4503,6 +4508,178 @@ var require__md = __commonJS((exports) => {
4503
4508
  exports.HashMD = HashMD;
4504
4509
  });
4505
4510
 
4511
+ // ../../node_modules/@noble/hashes/sha256.js
4512
+ var require_sha256 = __commonJS((exports) => {
4513
+ Object.defineProperty(exports, "__esModule", { value: true });
4514
+ exports.sha224 = exports.sha256 = exports.SHA256 = undefined;
4515
+ var _md_ts_1 = require__md();
4516
+ var utils_ts_1 = require_utils4();
4517
+ var SHA256_K = /* @__PURE__ */ new Uint32Array([
4518
+ 1116352408,
4519
+ 1899447441,
4520
+ 3049323471,
4521
+ 3921009573,
4522
+ 961987163,
4523
+ 1508970993,
4524
+ 2453635748,
4525
+ 2870763221,
4526
+ 3624381080,
4527
+ 310598401,
4528
+ 607225278,
4529
+ 1426881987,
4530
+ 1925078388,
4531
+ 2162078206,
4532
+ 2614888103,
4533
+ 3248222580,
4534
+ 3835390401,
4535
+ 4022224774,
4536
+ 264347078,
4537
+ 604807628,
4538
+ 770255983,
4539
+ 1249150122,
4540
+ 1555081692,
4541
+ 1996064986,
4542
+ 2554220882,
4543
+ 2821834349,
4544
+ 2952996808,
4545
+ 3210313671,
4546
+ 3336571891,
4547
+ 3584528711,
4548
+ 113926993,
4549
+ 338241895,
4550
+ 666307205,
4551
+ 773529912,
4552
+ 1294757372,
4553
+ 1396182291,
4554
+ 1695183700,
4555
+ 1986661051,
4556
+ 2177026350,
4557
+ 2456956037,
4558
+ 2730485921,
4559
+ 2820302411,
4560
+ 3259730800,
4561
+ 3345764771,
4562
+ 3516065817,
4563
+ 3600352804,
4564
+ 4094571909,
4565
+ 275423344,
4566
+ 430227734,
4567
+ 506948616,
4568
+ 659060556,
4569
+ 883997877,
4570
+ 958139571,
4571
+ 1322822218,
4572
+ 1537002063,
4573
+ 1747873779,
4574
+ 1955562222,
4575
+ 2024104815,
4576
+ 2227730452,
4577
+ 2361852424,
4578
+ 2428436474,
4579
+ 2756734187,
4580
+ 3204031479,
4581
+ 3329325298
4582
+ ]);
4583
+ var SHA256_IV = /* @__PURE__ */ new Uint32Array([
4584
+ 1779033703,
4585
+ 3144134277,
4586
+ 1013904242,
4587
+ 2773480762,
4588
+ 1359893119,
4589
+ 2600822924,
4590
+ 528734635,
4591
+ 1541459225
4592
+ ]);
4593
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
4594
+
4595
+ class SHA256 extends _md_ts_1.HashMD {
4596
+ constructor(outputLen = 32) {
4597
+ super(64, outputLen, 8, false);
4598
+ this.A = SHA256_IV[0] | 0;
4599
+ this.B = SHA256_IV[1] | 0;
4600
+ this.C = SHA256_IV[2] | 0;
4601
+ this.D = SHA256_IV[3] | 0;
4602
+ this.E = SHA256_IV[4] | 0;
4603
+ this.F = SHA256_IV[5] | 0;
4604
+ this.G = SHA256_IV[6] | 0;
4605
+ this.H = SHA256_IV[7] | 0;
4606
+ }
4607
+ get() {
4608
+ const { A, B, C, D, E, F, G, H } = this;
4609
+ return [A, B, C, D, E, F, G, H];
4610
+ }
4611
+ set(A, B, C, D, E, F, G, H) {
4612
+ this.A = A | 0;
4613
+ this.B = B | 0;
4614
+ this.C = C | 0;
4615
+ this.D = D | 0;
4616
+ this.E = E | 0;
4617
+ this.F = F | 0;
4618
+ this.G = G | 0;
4619
+ this.H = H | 0;
4620
+ }
4621
+ process(view, offset) {
4622
+ for (let i = 0;i < 16; i++, offset += 4)
4623
+ SHA256_W[i] = view.getUint32(offset, false);
4624
+ for (let i = 16;i < 64; i++) {
4625
+ const W15 = SHA256_W[i - 15];
4626
+ const W2 = SHA256_W[i - 2];
4627
+ const s0 = (0, utils_ts_1.rotr)(W15, 7) ^ (0, utils_ts_1.rotr)(W15, 18) ^ W15 >>> 3;
4628
+ const s1 = (0, utils_ts_1.rotr)(W2, 17) ^ (0, utils_ts_1.rotr)(W2, 19) ^ W2 >>> 10;
4629
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
4630
+ }
4631
+ let { A, B, C, D, E, F, G, H } = this;
4632
+ for (let i = 0;i < 64; i++) {
4633
+ const sigma1 = (0, utils_ts_1.rotr)(E, 6) ^ (0, utils_ts_1.rotr)(E, 11) ^ (0, utils_ts_1.rotr)(E, 25);
4634
+ const T1 = H + sigma1 + (0, _md_ts_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
4635
+ const sigma0 = (0, utils_ts_1.rotr)(A, 2) ^ (0, utils_ts_1.rotr)(A, 13) ^ (0, utils_ts_1.rotr)(A, 22);
4636
+ const T2 = sigma0 + (0, _md_ts_1.Maj)(A, B, C) | 0;
4637
+ H = G;
4638
+ G = F;
4639
+ F = E;
4640
+ E = D + T1 | 0;
4641
+ D = C;
4642
+ C = B;
4643
+ B = A;
4644
+ A = T1 + T2 | 0;
4645
+ }
4646
+ A = A + this.A | 0;
4647
+ B = B + this.B | 0;
4648
+ C = C + this.C | 0;
4649
+ D = D + this.D | 0;
4650
+ E = E + this.E | 0;
4651
+ F = F + this.F | 0;
4652
+ G = G + this.G | 0;
4653
+ H = H + this.H | 0;
4654
+ this.set(A, B, C, D, E, F, G, H);
4655
+ }
4656
+ roundClean() {
4657
+ SHA256_W.fill(0);
4658
+ }
4659
+ destroy() {
4660
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
4661
+ this.buffer.fill(0);
4662
+ }
4663
+ }
4664
+ exports.SHA256 = SHA256;
4665
+
4666
+ class SHA224 extends SHA256 {
4667
+ constructor() {
4668
+ super(28);
4669
+ this.A = 3238371032 | 0;
4670
+ this.B = 914150663 | 0;
4671
+ this.C = 812702999 | 0;
4672
+ this.D = 4144912697 | 0;
4673
+ this.E = 4290775857 | 0;
4674
+ this.F = 1750603025 | 0;
4675
+ this.G = 1694076839 | 0;
4676
+ this.H = 3204075428 | 0;
4677
+ }
4678
+ }
4679
+ exports.sha256 = (0, utils_ts_1.wrapConstructor)(() => new SHA256);
4680
+ exports.sha224 = (0, utils_ts_1.wrapConstructor)(() => new SHA224);
4681
+ });
4682
+
4506
4683
  // ../../node_modules/@noble/hashes/_u64.js
4507
4684
  var require__u64 = __commonJS((exports) => {
4508
4685
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -4599,10 +4776,10 @@ var require__u64 = __commonJS((exports) => {
4599
4776
  var require_sha512 = __commonJS((exports) => {
4600
4777
  Object.defineProperty(exports, "__esModule", { value: true });
4601
4778
  exports.sha384 = exports.sha512_256 = exports.sha512_224 = exports.sha512 = exports.SHA384 = exports.SHA512_256 = exports.SHA512_224 = exports.SHA512 = undefined;
4602
- var _md_js_1 = require__md();
4603
- var _u64_js_1 = require__u64();
4604
- var utils_js_1 = require_utils4();
4605
- var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => _u64_js_1.default.split([
4779
+ var _md_ts_1 = require__md();
4780
+ var _u64_ts_1 = require__u64();
4781
+ var utils_ts_1 = require_utils4();
4782
+ var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => _u64_ts_1.default.split([
4606
4783
  "0x428a2f98d728ae22",
4607
4784
  "0x7137449123ef65cd",
4608
4785
  "0xb5c0fbcfec4d3b2f",
@@ -4687,9 +4864,9 @@ var require_sha512 = __commonJS((exports) => {
4687
4864
  var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
4688
4865
  var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
4689
4866
 
4690
- class SHA512 extends _md_js_1.HashMD {
4691
- constructor() {
4692
- super(128, 64, 16, false);
4867
+ class SHA512 extends _md_ts_1.HashMD {
4868
+ constructor(outputLen = 64) {
4869
+ super(128, outputLen, 16, false);
4693
4870
  this.Ah = 1779033703 | 0;
4694
4871
  this.Al = 4089235720 | 0;
4695
4872
  this.Bh = 3144134277 | 0;
@@ -4737,28 +4914,28 @@ var require_sha512 = __commonJS((exports) => {
4737
4914
  for (let i = 16;i < 80; i++) {
4738
4915
  const W15h = SHA512_W_H[i - 15] | 0;
4739
4916
  const W15l = SHA512_W_L[i - 15] | 0;
4740
- const s0h = _u64_js_1.default.rotrSH(W15h, W15l, 1) ^ _u64_js_1.default.rotrSH(W15h, W15l, 8) ^ _u64_js_1.default.shrSH(W15h, W15l, 7);
4741
- const s0l = _u64_js_1.default.rotrSL(W15h, W15l, 1) ^ _u64_js_1.default.rotrSL(W15h, W15l, 8) ^ _u64_js_1.default.shrSL(W15h, W15l, 7);
4917
+ const s0h = _u64_ts_1.default.rotrSH(W15h, W15l, 1) ^ _u64_ts_1.default.rotrSH(W15h, W15l, 8) ^ _u64_ts_1.default.shrSH(W15h, W15l, 7);
4918
+ const s0l = _u64_ts_1.default.rotrSL(W15h, W15l, 1) ^ _u64_ts_1.default.rotrSL(W15h, W15l, 8) ^ _u64_ts_1.default.shrSL(W15h, W15l, 7);
4742
4919
  const W2h = SHA512_W_H[i - 2] | 0;
4743
4920
  const W2l = SHA512_W_L[i - 2] | 0;
4744
- const s1h = _u64_js_1.default.rotrSH(W2h, W2l, 19) ^ _u64_js_1.default.rotrBH(W2h, W2l, 61) ^ _u64_js_1.default.shrSH(W2h, W2l, 6);
4745
- const s1l = _u64_js_1.default.rotrSL(W2h, W2l, 19) ^ _u64_js_1.default.rotrBL(W2h, W2l, 61) ^ _u64_js_1.default.shrSL(W2h, W2l, 6);
4746
- const SUMl = _u64_js_1.default.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
4747
- const SUMh = _u64_js_1.default.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
4921
+ const s1h = _u64_ts_1.default.rotrSH(W2h, W2l, 19) ^ _u64_ts_1.default.rotrBH(W2h, W2l, 61) ^ _u64_ts_1.default.shrSH(W2h, W2l, 6);
4922
+ const s1l = _u64_ts_1.default.rotrSL(W2h, W2l, 19) ^ _u64_ts_1.default.rotrBL(W2h, W2l, 61) ^ _u64_ts_1.default.shrSL(W2h, W2l, 6);
4923
+ const SUMl = _u64_ts_1.default.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
4924
+ const SUMh = _u64_ts_1.default.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
4748
4925
  SHA512_W_H[i] = SUMh | 0;
4749
4926
  SHA512_W_L[i] = SUMl | 0;
4750
4927
  }
4751
4928
  let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
4752
4929
  for (let i = 0;i < 80; i++) {
4753
- const sigma1h = _u64_js_1.default.rotrSH(Eh, El, 14) ^ _u64_js_1.default.rotrSH(Eh, El, 18) ^ _u64_js_1.default.rotrBH(Eh, El, 41);
4754
- const sigma1l = _u64_js_1.default.rotrSL(Eh, El, 14) ^ _u64_js_1.default.rotrSL(Eh, El, 18) ^ _u64_js_1.default.rotrBL(Eh, El, 41);
4930
+ const sigma1h = _u64_ts_1.default.rotrSH(Eh, El, 14) ^ _u64_ts_1.default.rotrSH(Eh, El, 18) ^ _u64_ts_1.default.rotrBH(Eh, El, 41);
4931
+ const sigma1l = _u64_ts_1.default.rotrSL(Eh, El, 14) ^ _u64_ts_1.default.rotrSL(Eh, El, 18) ^ _u64_ts_1.default.rotrBL(Eh, El, 41);
4755
4932
  const CHIh = Eh & Fh ^ ~Eh & Gh;
4756
4933
  const CHIl = El & Fl ^ ~El & Gl;
4757
- const T1ll = _u64_js_1.default.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
4758
- const T1h = _u64_js_1.default.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
4934
+ const T1ll = _u64_ts_1.default.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
4935
+ const T1h = _u64_ts_1.default.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
4759
4936
  const T1l = T1ll | 0;
4760
- const sigma0h = _u64_js_1.default.rotrSH(Ah, Al, 28) ^ _u64_js_1.default.rotrBH(Ah, Al, 34) ^ _u64_js_1.default.rotrBH(Ah, Al, 39);
4761
- const sigma0l = _u64_js_1.default.rotrSL(Ah, Al, 28) ^ _u64_js_1.default.rotrBL(Ah, Al, 34) ^ _u64_js_1.default.rotrBL(Ah, Al, 39);
4937
+ const sigma0h = _u64_ts_1.default.rotrSH(Ah, Al, 28) ^ _u64_ts_1.default.rotrBH(Ah, Al, 34) ^ _u64_ts_1.default.rotrBH(Ah, Al, 39);
4938
+ const sigma0l = _u64_ts_1.default.rotrSL(Ah, Al, 28) ^ _u64_ts_1.default.rotrBL(Ah, Al, 34) ^ _u64_ts_1.default.rotrBL(Ah, Al, 39);
4762
4939
  const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
4763
4940
  const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
4764
4941
  Hh = Gh | 0;
@@ -4767,25 +4944,25 @@ var require_sha512 = __commonJS((exports) => {
4767
4944
  Gl = Fl | 0;
4768
4945
  Fh = Eh | 0;
4769
4946
  Fl = El | 0;
4770
- ({ h: Eh, l: El } = _u64_js_1.default.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
4947
+ ({ h: Eh, l: El } = _u64_ts_1.default.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
4771
4948
  Dh = Ch | 0;
4772
4949
  Dl = Cl | 0;
4773
4950
  Ch = Bh | 0;
4774
4951
  Cl = Bl | 0;
4775
4952
  Bh = Ah | 0;
4776
4953
  Bl = Al | 0;
4777
- const All = _u64_js_1.default.add3L(T1l, sigma0l, MAJl);
4778
- Ah = _u64_js_1.default.add3H(All, T1h, sigma0h, MAJh);
4954
+ const All = _u64_ts_1.default.add3L(T1l, sigma0l, MAJl);
4955
+ Ah = _u64_ts_1.default.add3H(All, T1h, sigma0h, MAJh);
4779
4956
  Al = All | 0;
4780
4957
  }
4781
- ({ h: Ah, l: Al } = _u64_js_1.default.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
4782
- ({ h: Bh, l: Bl } = _u64_js_1.default.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
4783
- ({ h: Ch, l: Cl } = _u64_js_1.default.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
4784
- ({ h: Dh, l: Dl } = _u64_js_1.default.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
4785
- ({ h: Eh, l: El } = _u64_js_1.default.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
4786
- ({ h: Fh, l: Fl } = _u64_js_1.default.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
4787
- ({ h: Gh, l: Gl } = _u64_js_1.default.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
4788
- ({ h: Hh, l: Hl } = _u64_js_1.default.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
4958
+ ({ h: Ah, l: Al } = _u64_ts_1.default.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
4959
+ ({ h: Bh, l: Bl } = _u64_ts_1.default.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
4960
+ ({ h: Ch, l: Cl } = _u64_ts_1.default.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
4961
+ ({ h: Dh, l: Dl } = _u64_ts_1.default.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
4962
+ ({ h: Eh, l: El } = _u64_ts_1.default.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
4963
+ ({ h: Fh, l: Fl } = _u64_ts_1.default.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
4964
+ ({ h: Gh, l: Gl } = _u64_ts_1.default.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
4965
+ ({ h: Hh, l: Hl } = _u64_ts_1.default.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
4789
4966
  this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
4790
4967
  }
4791
4968
  roundClean() {
@@ -4801,7 +4978,7 @@ var require_sha512 = __commonJS((exports) => {
4801
4978
 
4802
4979
  class SHA512_224 extends SHA512 {
4803
4980
  constructor() {
4804
- super();
4981
+ super(28);
4805
4982
  this.Ah = 2352822216 | 0;
4806
4983
  this.Al = 424955298 | 0;
4807
4984
  this.Bh = 1944164710 | 0;
@@ -4818,14 +4995,13 @@ var require_sha512 = __commonJS((exports) => {
4818
4995
  this.Gl = 1780299464 | 0;
4819
4996
  this.Hh = 286451373 | 0;
4820
4997
  this.Hl = 2446758561 | 0;
4821
- this.outputLen = 28;
4822
4998
  }
4823
4999
  }
4824
5000
  exports.SHA512_224 = SHA512_224;
4825
5001
 
4826
5002
  class SHA512_256 extends SHA512 {
4827
5003
  constructor() {
4828
- super();
5004
+ super(32);
4829
5005
  this.Ah = 573645204 | 0;
4830
5006
  this.Al = 4230739756 | 0;
4831
5007
  this.Bh = 2673172387 | 0;
@@ -4842,14 +5018,13 @@ var require_sha512 = __commonJS((exports) => {
4842
5018
  this.Gl = 746961066 | 0;
4843
5019
  this.Hh = 246885852 | 0;
4844
5020
  this.Hl = 2177182882 | 0;
4845
- this.outputLen = 32;
4846
5021
  }
4847
5022
  }
4848
5023
  exports.SHA512_256 = SHA512_256;
4849
5024
 
4850
5025
  class SHA384 extends SHA512 {
4851
5026
  constructor() {
4852
- super();
5027
+ super(48);
4853
5028
  this.Ah = 3418070365 | 0;
4854
5029
  this.Al = 3238371032 | 0;
4855
5030
  this.Bh = 1654270250 | 0;
@@ -4866,14 +5041,39 @@ var require_sha512 = __commonJS((exports) => {
4866
5041
  this.Gl = 1694076839 | 0;
4867
5042
  this.Hh = 1203062813 | 0;
4868
5043
  this.Hl = 3204075428 | 0;
4869
- this.outputLen = 48;
4870
5044
  }
4871
5045
  }
4872
5046
  exports.SHA384 = SHA384;
4873
- exports.sha512 = (0, utils_js_1.wrapConstructor)(() => new SHA512);
4874
- exports.sha512_224 = (0, utils_js_1.wrapConstructor)(() => new SHA512_224);
4875
- exports.sha512_256 = (0, utils_js_1.wrapConstructor)(() => new SHA512_256);
4876
- exports.sha384 = (0, utils_js_1.wrapConstructor)(() => new SHA384);
5047
+ exports.sha512 = (0, utils_ts_1.wrapConstructor)(() => new SHA512);
5048
+ exports.sha512_224 = (0, utils_ts_1.wrapConstructor)(() => new SHA512_224);
5049
+ exports.sha512_256 = (0, utils_ts_1.wrapConstructor)(() => new SHA512_256);
5050
+ exports.sha384 = (0, utils_ts_1.wrapConstructor)(() => new SHA384);
5051
+ });
5052
+
5053
+ // ../../node_modules/@noble/hashes/sha2.js
5054
+ var require_sha2 = __commonJS((exports) => {
5055
+ Object.defineProperty(exports, "__esModule", { value: true });
5056
+ exports.sha512_256 = exports.sha512_224 = exports.sha512 = exports.sha384 = exports.sha256 = exports.sha224 = undefined;
5057
+ var sha256_ts_1 = require_sha256();
5058
+ Object.defineProperty(exports, "sha224", { enumerable: true, get: function() {
5059
+ return sha256_ts_1.sha224;
5060
+ } });
5061
+ Object.defineProperty(exports, "sha256", { enumerable: true, get: function() {
5062
+ return sha256_ts_1.sha256;
5063
+ } });
5064
+ var sha512_ts_1 = require_sha512();
5065
+ Object.defineProperty(exports, "sha384", { enumerable: true, get: function() {
5066
+ return sha512_ts_1.sha384;
5067
+ } });
5068
+ Object.defineProperty(exports, "sha512", { enumerable: true, get: function() {
5069
+ return sha512_ts_1.sha512;
5070
+ } });
5071
+ Object.defineProperty(exports, "sha512_224", { enumerable: true, get: function() {
5072
+ return sha512_ts_1.sha512_224;
5073
+ } });
5074
+ Object.defineProperty(exports, "sha512_256", { enumerable: true, get: function() {
5075
+ return sha512_ts_1.sha512_256;
5076
+ } });
4877
5077
  });
4878
5078
 
4879
5079
  // ../../node_modules/@noble/curves/abstract/utils.js
@@ -4884,9 +5084,9 @@ var require_utils5 = __commonJS((exports) => {
4884
5084
  exports.isBytes = isBytes;
4885
5085
  exports.abytes = abytes;
4886
5086
  exports.abool = abool;
4887
- exports.bytesToHex = bytesToHex;
4888
5087
  exports.numberToHexUnpadded = numberToHexUnpadded;
4889
5088
  exports.hexToNumber = hexToNumber;
5089
+ exports.bytesToHex = bytesToHex;
4890
5090
  exports.hexToBytes = hexToBytes;
4891
5091
  exports.bytesToNumberBE = bytesToNumberBE;
4892
5092
  exports.bytesToNumberLE = bytesToNumberLE;
@@ -4907,7 +5107,6 @@ var require_utils5 = __commonJS((exports) => {
4907
5107
  exports.memoized = memoized;
4908
5108
  var _0n = /* @__PURE__ */ BigInt(0);
4909
5109
  var _1n = /* @__PURE__ */ BigInt(1);
4910
- var _2n = /* @__PURE__ */ BigInt(2);
4911
5110
  function isBytes(a) {
4912
5111
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
4913
5112
  }
@@ -4919,15 +5118,6 @@ var require_utils5 = __commonJS((exports) => {
4919
5118
  if (typeof value !== "boolean")
4920
5119
  throw new Error(title + " boolean expected, got " + value);
4921
5120
  }
4922
- var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
4923
- function bytesToHex(bytes) {
4924
- abytes(bytes);
4925
- let hex = "";
4926
- for (let i = 0;i < bytes.length; i++) {
4927
- hex += hexes[bytes[i]];
4928
- }
4929
- return hex;
4930
- }
4931
5121
  function numberToHexUnpadded(num) {
4932
5122
  const hex = num.toString(16);
4933
5123
  return hex.length & 1 ? "0" + hex : hex;
@@ -4937,6 +5127,18 @@ var require_utils5 = __commonJS((exports) => {
4937
5127
  throw new Error("hex string expected, got " + typeof hex);
4938
5128
  return hex === "" ? _0n : BigInt("0x" + hex);
4939
5129
  }
5130
+ var hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
5131
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
5132
+ function bytesToHex(bytes) {
5133
+ abytes(bytes);
5134
+ if (hasHexBuiltin)
5135
+ return bytes.toHex();
5136
+ let hex = "";
5137
+ for (let i = 0;i < bytes.length; i++) {
5138
+ hex += hexes[bytes[i]];
5139
+ }
5140
+ return hex;
5141
+ }
4940
5142
  var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
4941
5143
  function asciiToBase16(ch) {
4942
5144
  if (ch >= asciis._0 && ch <= asciis._9)
@@ -4950,6 +5152,8 @@ var require_utils5 = __commonJS((exports) => {
4950
5152
  function hexToBytes(hex) {
4951
5153
  if (typeof hex !== "string")
4952
5154
  throw new Error("hex string expected, got " + typeof hex);
5155
+ if (hasHexBuiltin)
5156
+ return Uint8Array.fromHex(hex);
4953
5157
  const hl = hex.length;
4954
5158
  const al = hl / 2;
4955
5159
  if (hl % 2)
@@ -5048,9 +5252,9 @@ var require_utils5 = __commonJS((exports) => {
5048
5252
  function bitSet(n, pos, value) {
5049
5253
  return n | (value ? _1n : _0n) << BigInt(pos);
5050
5254
  }
5051
- var bitMask = (n) => (_2n << BigInt(n - 1)) - _1n;
5255
+ var bitMask = (n) => (_1n << BigInt(n)) - _1n;
5052
5256
  exports.bitMask = bitMask;
5053
- var u8n = (data) => new Uint8Array(data);
5257
+ var u8n = (len) => new Uint8Array(len);
5054
5258
  var u8fr = (arr) => Uint8Array.from(arr);
5055
5259
  function createHmacDrbg(hashLen, qByteLen, hmacFn) {
5056
5260
  if (typeof hashLen !== "number" || hashLen < 2)
@@ -5068,7 +5272,7 @@ var require_utils5 = __commonJS((exports) => {
5068
5272
  i = 0;
5069
5273
  };
5070
5274
  const h = (...b) => hmacFn(k, v, ...b);
5071
- const reseed = (seed = u8n()) => {
5275
+ const reseed = (seed = u8n(0)) => {
5072
5276
  k = h(u8fr([0]), seed);
5073
5277
  v = h();
5074
5278
  if (seed.length === 0)
@@ -5171,7 +5375,7 @@ var require_modular = __commonJS((exports) => {
5171
5375
  exports.getMinHashLength = getMinHashLength;
5172
5376
  exports.mapHashToField = mapHashToField;
5173
5377
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5174
- var utils_js_1 = require_utils5();
5378
+ var utils_ts_1 = require_utils5();
5175
5379
  var _0n = BigInt(0);
5176
5380
  var _1n = BigInt(1);
5177
5381
  var _2n = /* @__PURE__ */ BigInt(2);
@@ -5331,7 +5535,7 @@ var require_modular = __commonJS((exports) => {
5331
5535
  map[val] = "function";
5332
5536
  return map;
5333
5537
  }, initial);
5334
- return (0, utils_js_1.validateObject)(field, opts);
5538
+ return (0, utils_ts_1.validateObject)(field, opts);
5335
5539
  }
5336
5540
  function FpPow(f, num, power) {
5337
5541
  if (power < _0n)
@@ -5398,7 +5602,7 @@ var require_modular = __commonJS((exports) => {
5398
5602
  isLE,
5399
5603
  BITS,
5400
5604
  BYTES,
5401
- MASK: (0, utils_js_1.bitMask)(BITS),
5605
+ MASK: (0, utils_ts_1.bitMask)(BITS),
5402
5606
  ZERO: _0n,
5403
5607
  ONE: _1n,
5404
5608
  create: (num) => mod(num, ORDER),
@@ -5429,11 +5633,11 @@ var require_modular = __commonJS((exports) => {
5429
5633
  }),
5430
5634
  invertBatch: (lst) => FpInvertBatch(f, lst),
5431
5635
  cmov: (a, b, c) => c ? b : a,
5432
- toBytes: (num) => isLE ? (0, utils_js_1.numberToBytesLE)(num, BYTES) : (0, utils_js_1.numberToBytesBE)(num, BYTES),
5636
+ toBytes: (num) => isLE ? (0, utils_ts_1.numberToBytesLE)(num, BYTES) : (0, utils_ts_1.numberToBytesBE)(num, BYTES),
5433
5637
  fromBytes: (bytes) => {
5434
5638
  if (bytes.length !== BYTES)
5435
5639
  throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
5436
- return isLE ? (0, utils_js_1.bytesToNumberLE)(bytes) : (0, utils_js_1.bytesToNumberBE)(bytes);
5640
+ return isLE ? (0, utils_ts_1.bytesToNumberLE)(bytes) : (0, utils_ts_1.bytesToNumberBE)(bytes);
5437
5641
  }
5438
5642
  });
5439
5643
  return Object.freeze(f);
@@ -5451,12 +5655,12 @@ var require_modular = __commonJS((exports) => {
5451
5655
  return Fp.isOdd(root) ? Fp.neg(root) : root;
5452
5656
  }
5453
5657
  function hashToPrivateScalar(hash, groupOrder, isLE = false) {
5454
- hash = (0, utils_js_1.ensureBytes)("privateHash", hash);
5658
+ hash = (0, utils_ts_1.ensureBytes)("privateHash", hash);
5455
5659
  const hashLen = hash.length;
5456
5660
  const minLen = nLength(groupOrder).nByteLength + 8;
5457
5661
  if (minLen < 24 || hashLen < minLen || hashLen > 1024)
5458
5662
  throw new Error("hashToPrivateScalar: expected " + minLen + "-1024 bytes of input, got " + hashLen);
5459
- const num = isLE ? (0, utils_js_1.bytesToNumberLE)(hash) : (0, utils_js_1.bytesToNumberBE)(hash);
5663
+ const num = isLE ? (0, utils_ts_1.bytesToNumberLE)(hash) : (0, utils_ts_1.bytesToNumberBE)(hash);
5460
5664
  return mod(num, groupOrder - _1n) + _1n;
5461
5665
  }
5462
5666
  function getFieldBytesLength(fieldOrder) {
@@ -5475,9 +5679,9 @@ var require_modular = __commonJS((exports) => {
5475
5679
  const minLen = getMinHashLength(fieldOrder);
5476
5680
  if (len < 16 || len < minLen || len > 1024)
5477
5681
  throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
5478
- const num = isLE ? (0, utils_js_1.bytesToNumberLE)(key) : (0, utils_js_1.bytesToNumberBE)(key);
5682
+ const num = isLE ? (0, utils_ts_1.bytesToNumberLE)(key) : (0, utils_ts_1.bytesToNumberBE)(key);
5479
5683
  const reduced = mod(num, fieldOrder - _1n) + _1n;
5480
- return isLE ? (0, utils_js_1.numberToBytesLE)(reduced, fieldLen) : (0, utils_js_1.numberToBytesBE)(reduced, fieldLen);
5684
+ return isLE ? (0, utils_ts_1.numberToBytesLE)(reduced, fieldLen) : (0, utils_ts_1.numberToBytesBE)(reduced, fieldLen);
5481
5685
  }
5482
5686
  });
5483
5687
 
@@ -5489,8 +5693,8 @@ var require_curve = __commonJS((exports) => {
5489
5693
  exports.precomputeMSMUnsafe = precomputeMSMUnsafe;
5490
5694
  exports.validateBasic = validateBasic;
5491
5695
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5492
- var modular_js_1 = require_modular();
5493
- var utils_js_1 = require_utils5();
5696
+ var modular_ts_1 = require_modular();
5697
+ var utils_ts_1 = require_utils5();
5494
5698
  var _0n = BigInt(0);
5495
5699
  var _1n = BigInt(1);
5496
5700
  function constTimeNegate(condition, item) {
@@ -5501,11 +5705,30 @@ var require_curve = __commonJS((exports) => {
5501
5705
  if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
5502
5706
  throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W);
5503
5707
  }
5504
- function calcWOpts(W, bits) {
5505
- validateW(W, bits);
5506
- const windows = Math.ceil(bits / W) + 1;
5708
+ function calcWOpts(W, scalarBits) {
5709
+ validateW(W, scalarBits);
5710
+ const windows = Math.ceil(scalarBits / W) + 1;
5507
5711
  const windowSize = 2 ** (W - 1);
5508
- return { windows, windowSize };
5712
+ const maxNumber = 2 ** W;
5713
+ const mask = (0, utils_ts_1.bitMask)(W);
5714
+ const shiftBy = BigInt(W);
5715
+ return { windows, windowSize, mask, maxNumber, shiftBy };
5716
+ }
5717
+ function calcOffsets(n, window2, wOpts) {
5718
+ const { windowSize, mask, maxNumber, shiftBy } = wOpts;
5719
+ let wbits = Number(n & mask);
5720
+ let nextN = n >> shiftBy;
5721
+ if (wbits > windowSize) {
5722
+ wbits -= maxNumber;
5723
+ nextN += _1n;
5724
+ }
5725
+ const offsetStart = window2 * windowSize;
5726
+ const offset = offsetStart + Math.abs(wbits) - 1;
5727
+ const isZero = wbits === 0;
5728
+ const isNeg = wbits < 0;
5729
+ const isNegF = window2 % 2 !== 0;
5730
+ const offsetF = offsetStart;
5731
+ return { nextN, offset, isZero, isNeg, isNegF, offsetF };
5509
5732
  }
5510
5733
  function validateMSMPoints(points, c) {
5511
5734
  if (!Array.isArray(points))
@@ -5561,53 +5784,33 @@ var require_curve = __commonJS((exports) => {
5561
5784
  return points;
5562
5785
  },
5563
5786
  wNAF(W, precomputes, n) {
5564
- const { windows, windowSize } = calcWOpts(W, bits);
5565
5787
  let p = c.ZERO;
5566
5788
  let f = c.BASE;
5567
- const mask = BigInt(2 ** W - 1);
5568
- const maxNumber = 2 ** W;
5569
- const shiftBy = BigInt(W);
5570
- for (let window2 = 0;window2 < windows; window2++) {
5571
- const offset = window2 * windowSize;
5572
- let wbits = Number(n & mask);
5573
- n >>= shiftBy;
5574
- if (wbits > windowSize) {
5575
- wbits -= maxNumber;
5576
- n += _1n;
5577
- }
5578
- const offset1 = offset;
5579
- const offset2 = offset + Math.abs(wbits) - 1;
5580
- const cond1 = window2 % 2 !== 0;
5581
- const cond2 = wbits < 0;
5582
- if (wbits === 0) {
5583
- f = f.add(constTimeNegate(cond1, precomputes[offset1]));
5789
+ const wo = calcWOpts(W, bits);
5790
+ for (let window2 = 0;window2 < wo.windows; window2++) {
5791
+ const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n, window2, wo);
5792
+ n = nextN;
5793
+ if (isZero) {
5794
+ f = f.add(constTimeNegate(isNegF, precomputes[offsetF]));
5584
5795
  } else {
5585
- p = p.add(constTimeNegate(cond2, precomputes[offset2]));
5796
+ p = p.add(constTimeNegate(isNeg, precomputes[offset]));
5586
5797
  }
5587
5798
  }
5588
5799
  return { p, f };
5589
5800
  },
5590
5801
  wNAFUnsafe(W, precomputes, n, acc = c.ZERO) {
5591
- const { windows, windowSize } = calcWOpts(W, bits);
5592
- const mask = BigInt(2 ** W - 1);
5593
- const maxNumber = 2 ** W;
5594
- const shiftBy = BigInt(W);
5595
- for (let window2 = 0;window2 < windows; window2++) {
5596
- const offset = window2 * windowSize;
5802
+ const wo = calcWOpts(W, bits);
5803
+ for (let window2 = 0;window2 < wo.windows; window2++) {
5597
5804
  if (n === _0n)
5598
5805
  break;
5599
- let wbits = Number(n & mask);
5600
- n >>= shiftBy;
5601
- if (wbits > windowSize) {
5602
- wbits -= maxNumber;
5603
- n += _1n;
5604
- }
5605
- if (wbits === 0)
5806
+ const { nextN, offset, isZero, isNeg } = calcOffsets(n, window2, wo);
5807
+ n = nextN;
5808
+ if (isZero) {
5606
5809
  continue;
5607
- let curr = precomputes[offset + Math.abs(wbits) - 1];
5608
- if (wbits < 0)
5609
- curr = curr.negate();
5610
- acc = acc.add(curr);
5810
+ } else {
5811
+ const item = precomputes[offset];
5812
+ acc = acc.add(isNeg ? item.negate() : item);
5813
+ }
5611
5814
  }
5612
5815
  return acc;
5613
5816
  },
@@ -5643,17 +5846,17 @@ var require_curve = __commonJS((exports) => {
5643
5846
  if (points.length !== scalars.length)
5644
5847
  throw new Error("arrays of points and scalars must have equal length");
5645
5848
  const zero = c.ZERO;
5646
- const wbits = (0, utils_js_1.bitLen)(BigInt(points.length));
5849
+ const wbits = (0, utils_ts_1.bitLen)(BigInt(points.length));
5647
5850
  const windowSize = wbits > 12 ? wbits - 3 : wbits > 4 ? wbits - 2 : wbits ? 2 : 1;
5648
- const MASK = (1 << windowSize) - 1;
5649
- const buckets = new Array(MASK + 1).fill(zero);
5851
+ const MASK = (0, utils_ts_1.bitMask)(windowSize);
5852
+ const buckets = new Array(Number(MASK) + 1).fill(zero);
5650
5853
  const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
5651
5854
  let sum = zero;
5652
5855
  for (let i = lastBits;i >= 0; i -= windowSize) {
5653
5856
  buckets.fill(zero);
5654
5857
  for (let j = 0;j < scalars.length; j++) {
5655
5858
  const scalar = scalars[j];
5656
- const wbits2 = Number(scalar >> BigInt(i) & BigInt(MASK));
5859
+ const wbits2 = Number(scalar >> BigInt(i) & MASK);
5657
5860
  buckets[wbits2] = buckets[wbits2].add(points[j]);
5658
5861
  }
5659
5862
  let resI = zero;
@@ -5674,7 +5877,7 @@ var require_curve = __commonJS((exports) => {
5674
5877
  const zero = c.ZERO;
5675
5878
  const tableSize = 2 ** windowSize - 1;
5676
5879
  const chunks = Math.ceil(fieldN.BITS / windowSize);
5677
- const MASK = BigInt((1 << windowSize) - 1);
5880
+ const MASK = (0, utils_ts_1.bitMask)(windowSize);
5678
5881
  const tables = points.map((p) => {
5679
5882
  const res = [];
5680
5883
  for (let i = 0, acc = p;i < tableSize; i++) {
@@ -5705,8 +5908,8 @@ var require_curve = __commonJS((exports) => {
5705
5908
  };
5706
5909
  }
5707
5910
  function validateBasic(curve) {
5708
- (0, modular_js_1.validateField)(curve.Fp);
5709
- (0, utils_js_1.validateObject)(curve, {
5911
+ (0, modular_ts_1.validateField)(curve.Fp);
5912
+ (0, utils_ts_1.validateObject)(curve, {
5710
5913
  n: "bigint",
5711
5914
  h: "bigint",
5712
5915
  Gx: "field",
@@ -5716,7 +5919,7 @@ var require_curve = __commonJS((exports) => {
5716
5919
  nByteLength: "isSafeInteger"
5717
5920
  });
5718
5921
  return Object.freeze({
5719
- ...(0, modular_js_1.nLength)(curve.n, curve.nBitLength),
5922
+ ...(0, modular_ts_1.nLength)(curve.n, curve.nBitLength),
5720
5923
  ...curve,
5721
5924
  ...{ p: curve.Fp.ORDER }
5722
5925
  });
@@ -5728,18 +5931,17 @@ var require_edwards = __commonJS((exports) => {
5728
5931
  Object.defineProperty(exports, "__esModule", { value: true });
5729
5932
  exports.twistedEdwards = twistedEdwards;
5730
5933
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
5731
- var curve_js_1 = require_curve();
5732
- var modular_js_1 = require_modular();
5733
- var ut = require_utils5();
5734
- var utils_js_1 = require_utils5();
5934
+ var curve_ts_1 = require_curve();
5935
+ var modular_ts_1 = require_modular();
5936
+ var utils_ts_1 = require_utils5();
5735
5937
  var _0n = BigInt(0);
5736
5938
  var _1n = BigInt(1);
5737
5939
  var _2n = BigInt(2);
5738
5940
  var _8n = BigInt(8);
5739
5941
  var VERIFY_DEFAULT = { zip215: true };
5740
5942
  function validateOpts(curve) {
5741
- const opts = (0, curve_js_1.validateBasic)(curve);
5742
- ut.validateObject(curve, {
5943
+ const opts = (0, curve_ts_1.validateBasic)(curve);
5944
+ (0, utils_ts_1.validateObject)(curve, {
5743
5945
  hash: "function",
5744
5946
  a: "bigint",
5745
5947
  d: "bigint",
@@ -5757,7 +5959,7 @@ var require_edwards = __commonJS((exports) => {
5757
5959
  const { Fp, n: CURVE_ORDER, prehash, hash: cHash, randomBytes, nByteLength, h: cofactor } = CURVE;
5758
5960
  const MASK = _2n << BigInt(nByteLength * 8) - _1n;
5759
5961
  const modP = Fp.create;
5760
- const Fn = (0, modular_js_1.Field)(CURVE.n, CURVE.nBitLength);
5962
+ const Fn = (0, modular_ts_1.Field)(CURVE.n, CURVE.nBitLength);
5761
5963
  const uvRatio = CURVE.uvRatio || ((u, v) => {
5762
5964
  try {
5763
5965
  return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) };
@@ -5767,19 +5969,20 @@ var require_edwards = __commonJS((exports) => {
5767
5969
  });
5768
5970
  const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes);
5769
5971
  const domain = CURVE.domain || ((data, ctx, phflag) => {
5770
- (0, utils_js_1.abool)("phflag", phflag);
5972
+ (0, utils_ts_1.abool)("phflag", phflag);
5771
5973
  if (ctx.length || phflag)
5772
5974
  throw new Error("Contexts/pre-hash are not supported");
5773
5975
  return data;
5774
5976
  });
5775
- function aCoordinate(title, n) {
5776
- ut.aInRange("coordinate " + title, n, _0n, MASK);
5977
+ function aCoordinate(title, n, banZero = false) {
5978
+ const min = banZero ? _1n : _0n;
5979
+ (0, utils_ts_1.aInRange)("coordinate " + title, n, min, MASK);
5777
5980
  }
5778
- function assertPoint(other) {
5981
+ function aextpoint(other) {
5779
5982
  if (!(other instanceof Point))
5780
5983
  throw new Error("ExtendedPoint expected");
5781
5984
  }
5782
- const toAffineMemo = (0, utils_js_1.memoized)((p, iz) => {
5985
+ const toAffineMemo = (0, utils_ts_1.memoized)((p, iz) => {
5783
5986
  const { ex: x, ey: y, ez: z2 } = p;
5784
5987
  const is0 = p.is0();
5785
5988
  if (iz == null)
@@ -5793,7 +5996,7 @@ var require_edwards = __commonJS((exports) => {
5793
5996
  throw new Error("invZ was invalid");
5794
5997
  return { x: ax, y: ay };
5795
5998
  });
5796
- const assertValidMemo = (0, utils_js_1.memoized)((p) => {
5999
+ const assertValidMemo = (0, utils_ts_1.memoized)((p) => {
5797
6000
  const { a, d } = CURVE;
5798
6001
  if (p.is0())
5799
6002
  throw new Error("bad point: ZERO");
@@ -5816,14 +6019,14 @@ var require_edwards = __commonJS((exports) => {
5816
6019
 
5817
6020
  class Point {
5818
6021
  constructor(ex, ey, ez, et) {
6022
+ aCoordinate("x", ex);
6023
+ aCoordinate("y", ey);
6024
+ aCoordinate("z", ez, true);
6025
+ aCoordinate("t", et);
5819
6026
  this.ex = ex;
5820
6027
  this.ey = ey;
5821
6028
  this.ez = ez;
5822
6029
  this.et = et;
5823
- aCoordinate("x", ex);
5824
- aCoordinate("y", ey);
5825
- aCoordinate("z", ez);
5826
- aCoordinate("t", et);
5827
6030
  Object.freeze(this);
5828
6031
  }
5829
6032
  get x() {
@@ -5845,7 +6048,7 @@ var require_edwards = __commonJS((exports) => {
5845
6048
  return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);
5846
6049
  }
5847
6050
  static msm(points, scalars) {
5848
- return (0, curve_js_1.pippenger)(Point, Fn, points, scalars);
6051
+ return (0, curve_ts_1.pippenger)(Point, Fn, points, scalars);
5849
6052
  }
5850
6053
  _setWindowSize(windowSize) {
5851
6054
  wnaf.setWindowSize(this, windowSize);
@@ -5854,7 +6057,7 @@ var require_edwards = __commonJS((exports) => {
5854
6057
  assertValidMemo(this);
5855
6058
  }
5856
6059
  equals(other) {
5857
- assertPoint(other);
6060
+ aextpoint(other);
5858
6061
  const { ex: X1, ey: Y1, ez: Z1 } = this;
5859
6062
  const { ex: X2, ey: Y2, ez: Z2 } = other;
5860
6063
  const X1Z2 = modP(X1 * Z2);
@@ -5888,27 +6091,10 @@ var require_edwards = __commonJS((exports) => {
5888
6091
  return new Point(X3, Y3, Z3, T3);
5889
6092
  }
5890
6093
  add(other) {
5891
- assertPoint(other);
6094
+ aextpoint(other);
5892
6095
  const { a, d } = CURVE;
5893
6096
  const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;
5894
6097
  const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;
5895
- if (a === BigInt(-1)) {
5896
- const A2 = modP((Y1 - X1) * (Y2 + X2));
5897
- const B2 = modP((Y1 + X1) * (Y2 - X2));
5898
- const F2 = modP(B2 - A2);
5899
- if (F2 === _0n)
5900
- return this.double();
5901
- const C2 = modP(Z1 * _2n * T2);
5902
- const D2 = modP(T1 * _2n * Z2);
5903
- const E2 = D2 + C2;
5904
- const G3 = B2 + A2;
5905
- const H2 = D2 - C2;
5906
- const X32 = modP(E2 * F2);
5907
- const Y32 = modP(G3 * H2);
5908
- const T32 = modP(E2 * H2);
5909
- const Z32 = modP(F2 * G3);
5910
- return new Point(X32, Y32, Z32, T32);
5911
- }
5912
6098
  const A = modP(X1 * X2);
5913
6099
  const B = modP(Y1 * Y2);
5914
6100
  const C = modP(T1 * d * T2);
@@ -5931,13 +6117,13 @@ var require_edwards = __commonJS((exports) => {
5931
6117
  }
5932
6118
  multiply(scalar) {
5933
6119
  const n = scalar;
5934
- ut.aInRange("scalar", n, _1n, CURVE_ORDER);
6120
+ (0, utils_ts_1.aInRange)("scalar", n, _1n, CURVE_ORDER);
5935
6121
  const { p, f } = this.wNAF(n);
5936
6122
  return Point.normalizeZ([p, f])[0];
5937
6123
  }
5938
6124
  multiplyUnsafe(scalar, acc = Point.ZERO) {
5939
6125
  const n = scalar;
5940
- ut.aInRange("scalar", n, _0n, CURVE_ORDER);
6126
+ (0, utils_ts_1.aInRange)("scalar", n, _0n, CURVE_ORDER);
5941
6127
  if (n === _0n)
5942
6128
  return I;
5943
6129
  if (this.is0() || n === _1n)
@@ -5962,14 +6148,14 @@ var require_edwards = __commonJS((exports) => {
5962
6148
  static fromHex(hex, zip215 = false) {
5963
6149
  const { d, a } = CURVE;
5964
6150
  const len = Fp.BYTES;
5965
- hex = (0, utils_js_1.ensureBytes)("pointHex", hex, len);
5966
- (0, utils_js_1.abool)("zip215", zip215);
6151
+ hex = (0, utils_ts_1.ensureBytes)("pointHex", hex, len);
6152
+ (0, utils_ts_1.abool)("zip215", zip215);
5967
6153
  const normed = hex.slice();
5968
6154
  const lastByte = hex[len - 1];
5969
6155
  normed[len - 1] = lastByte & ~128;
5970
- const y = ut.bytesToNumberLE(normed);
6156
+ const y = (0, utils_ts_1.bytesToNumberLE)(normed);
5971
6157
  const max = zip215 ? MASK : Fp.ORDER;
5972
- ut.aInRange("pointHex.y", y, _0n, max);
6158
+ (0, utils_ts_1.aInRange)("pointHex.y", y, _0n, max);
5973
6159
  const y2 = modP(y * y);
5974
6160
  const u = modP(y2 - _1n);
5975
6161
  const v = modP(d * y2 - a);
@@ -5985,35 +6171,40 @@ var require_edwards = __commonJS((exports) => {
5985
6171
  return Point.fromAffine({ x, y });
5986
6172
  }
5987
6173
  static fromPrivateKey(privKey) {
5988
- return getExtendedPublicKey(privKey).point;
6174
+ const { scalar } = getPrivateScalar(privKey);
6175
+ return G.multiply(scalar);
5989
6176
  }
5990
6177
  toRawBytes() {
5991
6178
  const { x, y } = this.toAffine();
5992
- const bytes = ut.numberToBytesLE(y, Fp.BYTES);
6179
+ const bytes = (0, utils_ts_1.numberToBytesLE)(y, Fp.BYTES);
5993
6180
  bytes[bytes.length - 1] |= x & _1n ? 128 : 0;
5994
6181
  return bytes;
5995
6182
  }
5996
6183
  toHex() {
5997
- return ut.bytesToHex(this.toRawBytes());
6184
+ return (0, utils_ts_1.bytesToHex)(this.toRawBytes());
5998
6185
  }
5999
6186
  }
6000
6187
  Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy));
6001
6188
  Point.ZERO = new Point(_0n, _1n, _1n, _0n);
6002
6189
  const { BASE: G, ZERO: I } = Point;
6003
- const wnaf = (0, curve_js_1.wNAF)(Point, nByteLength * 8);
6190
+ const wnaf = (0, curve_ts_1.wNAF)(Point, nByteLength * 8);
6004
6191
  function modN(a) {
6005
- return (0, modular_js_1.mod)(a, CURVE_ORDER);
6192
+ return (0, modular_ts_1.mod)(a, CURVE_ORDER);
6006
6193
  }
6007
6194
  function modN_LE(hash) {
6008
- return modN(ut.bytesToNumberLE(hash));
6195
+ return modN((0, utils_ts_1.bytesToNumberLE)(hash));
6009
6196
  }
6010
- function getExtendedPublicKey(key) {
6197
+ function getPrivateScalar(key) {
6011
6198
  const len = Fp.BYTES;
6012
- key = (0, utils_js_1.ensureBytes)("private key", key, len);
6013
- const hashed = (0, utils_js_1.ensureBytes)("hashed private key", cHash(key), 2 * len);
6199
+ key = (0, utils_ts_1.ensureBytes)("private key", key, len);
6200
+ const hashed = (0, utils_ts_1.ensureBytes)("hashed private key", cHash(key), 2 * len);
6014
6201
  const head = adjustScalarBytes(hashed.slice(0, len));
6015
6202
  const prefix = hashed.slice(len, 2 * len);
6016
6203
  const scalar = modN_LE(head);
6204
+ return { head, prefix, scalar };
6205
+ }
6206
+ function getExtendedPublicKey(key) {
6207
+ const { head, prefix, scalar } = getPrivateScalar(key);
6017
6208
  const point = G.multiply(scalar);
6018
6209
  const pointBytes = point.toRawBytes();
6019
6210
  return { head, prefix, scalar, point, pointBytes };
@@ -6022,11 +6213,11 @@ var require_edwards = __commonJS((exports) => {
6022
6213
  return getExtendedPublicKey(privKey).pointBytes;
6023
6214
  }
6024
6215
  function hashDomainToScalar(context = new Uint8Array, ...msgs) {
6025
- const msg = ut.concatBytes(...msgs);
6026
- return modN_LE(cHash(domain(msg, (0, utils_js_1.ensureBytes)("context", context), !!prehash)));
6216
+ const msg = (0, utils_ts_1.concatBytes)(...msgs);
6217
+ return modN_LE(cHash(domain(msg, (0, utils_ts_1.ensureBytes)("context", context), !!prehash)));
6027
6218
  }
6028
6219
  function sign(msg, privKey, options = {}) {
6029
- msg = (0, utils_js_1.ensureBytes)("message", msg);
6220
+ msg = (0, utils_ts_1.ensureBytes)("message", msg);
6030
6221
  if (prehash)
6031
6222
  msg = prehash(msg);
6032
6223
  const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey);
@@ -6034,22 +6225,22 @@ var require_edwards = __commonJS((exports) => {
6034
6225
  const R = G.multiply(r).toRawBytes();
6035
6226
  const k = hashDomainToScalar(options.context, R, pointBytes, msg);
6036
6227
  const s = modN(r + k * scalar);
6037
- ut.aInRange("signature.s", s, _0n, CURVE_ORDER);
6038
- const res = ut.concatBytes(R, ut.numberToBytesLE(s, Fp.BYTES));
6039
- return (0, utils_js_1.ensureBytes)("result", res, Fp.BYTES * 2);
6228
+ (0, utils_ts_1.aInRange)("signature.s", s, _0n, CURVE_ORDER);
6229
+ const res = (0, utils_ts_1.concatBytes)(R, (0, utils_ts_1.numberToBytesLE)(s, Fp.BYTES));
6230
+ return (0, utils_ts_1.ensureBytes)("result", res, Fp.BYTES * 2);
6040
6231
  }
6041
6232
  const verifyOpts = VERIFY_DEFAULT;
6042
6233
  function verify(sig, msg, publicKey, options = verifyOpts) {
6043
6234
  const { context, zip215 } = options;
6044
6235
  const len = Fp.BYTES;
6045
- sig = (0, utils_js_1.ensureBytes)("signature", sig, 2 * len);
6046
- msg = (0, utils_js_1.ensureBytes)("message", msg);
6047
- publicKey = (0, utils_js_1.ensureBytes)("publicKey", publicKey, len);
6236
+ sig = (0, utils_ts_1.ensureBytes)("signature", sig, 2 * len);
6237
+ msg = (0, utils_ts_1.ensureBytes)("message", msg);
6238
+ publicKey = (0, utils_ts_1.ensureBytes)("publicKey", publicKey, len);
6048
6239
  if (zip215 !== undefined)
6049
- (0, utils_js_1.abool)("zip215", zip215);
6240
+ (0, utils_ts_1.abool)("zip215", zip215);
6050
6241
  if (prehash)
6051
6242
  msg = prehash(msg);
6052
- const s = ut.bytesToNumberLE(sig.slice(len, 2 * len));
6243
+ const s = (0, utils_ts_1.bytesToNumberLE)(sig.slice(len, 2 * len));
6053
6244
  let A, R, SB;
6054
6245
  try {
6055
6246
  A = Point.fromHex(publicKey, zip215);
@@ -6093,9 +6284,9 @@ var require_hash_to_curve = __commonJS((exports) => {
6093
6284
  exports.hash_to_field = hash_to_field;
6094
6285
  exports.isogenyMap = isogenyMap;
6095
6286
  exports.createHasher = createHasher;
6096
- var modular_js_1 = require_modular();
6097
- var utils_js_1 = require_utils5();
6098
- var os2ip = utils_js_1.bytesToNumberBE;
6287
+ var modular_ts_1 = require_modular();
6288
+ var utils_ts_1 = require_utils5();
6289
+ var os2ip = utils_ts_1.bytesToNumberBE;
6099
6290
  function i2osp(value, length) {
6100
6291
  anum(value);
6101
6292
  anum(length);
@@ -6120,42 +6311,42 @@ var require_hash_to_curve = __commonJS((exports) => {
6120
6311
  throw new Error("number expected");
6121
6312
  }
6122
6313
  function expand_message_xmd(msg, DST, lenInBytes, H) {
6123
- (0, utils_js_1.abytes)(msg);
6124
- (0, utils_js_1.abytes)(DST);
6314
+ (0, utils_ts_1.abytes)(msg);
6315
+ (0, utils_ts_1.abytes)(DST);
6125
6316
  anum(lenInBytes);
6126
6317
  if (DST.length > 255)
6127
- DST = H((0, utils_js_1.concatBytes)((0, utils_js_1.utf8ToBytes)("H2C-OVERSIZE-DST-"), DST));
6318
+ DST = H((0, utils_ts_1.concatBytes)((0, utils_ts_1.utf8ToBytes)("H2C-OVERSIZE-DST-"), DST));
6128
6319
  const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
6129
6320
  const ell = Math.ceil(lenInBytes / b_in_bytes);
6130
6321
  if (lenInBytes > 65535 || ell > 255)
6131
6322
  throw new Error("expand_message_xmd: invalid lenInBytes");
6132
- const DST_prime = (0, utils_js_1.concatBytes)(DST, i2osp(DST.length, 1));
6323
+ const DST_prime = (0, utils_ts_1.concatBytes)(DST, i2osp(DST.length, 1));
6133
6324
  const Z_pad = i2osp(0, r_in_bytes);
6134
6325
  const l_i_b_str = i2osp(lenInBytes, 2);
6135
6326
  const b = new Array(ell);
6136
- const b_0 = H((0, utils_js_1.concatBytes)(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
6137
- b[0] = H((0, utils_js_1.concatBytes)(b_0, i2osp(1, 1), DST_prime));
6327
+ const b_0 = H((0, utils_ts_1.concatBytes)(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
6328
+ b[0] = H((0, utils_ts_1.concatBytes)(b_0, i2osp(1, 1), DST_prime));
6138
6329
  for (let i = 1;i <= ell; i++) {
6139
6330
  const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];
6140
- b[i] = H((0, utils_js_1.concatBytes)(...args));
6331
+ b[i] = H((0, utils_ts_1.concatBytes)(...args));
6141
6332
  }
6142
- const pseudo_random_bytes = (0, utils_js_1.concatBytes)(...b);
6333
+ const pseudo_random_bytes = (0, utils_ts_1.concatBytes)(...b);
6143
6334
  return pseudo_random_bytes.slice(0, lenInBytes);
6144
6335
  }
6145
6336
  function expand_message_xof(msg, DST, lenInBytes, k, H) {
6146
- (0, utils_js_1.abytes)(msg);
6147
- (0, utils_js_1.abytes)(DST);
6337
+ (0, utils_ts_1.abytes)(msg);
6338
+ (0, utils_ts_1.abytes)(DST);
6148
6339
  anum(lenInBytes);
6149
6340
  if (DST.length > 255) {
6150
6341
  const dkLen = Math.ceil(2 * k / 8);
6151
- DST = H.create({ dkLen }).update((0, utils_js_1.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(DST).digest();
6342
+ DST = H.create({ dkLen }).update((0, utils_ts_1.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(DST).digest();
6152
6343
  }
6153
6344
  if (lenInBytes > 65535 || DST.length > 255)
6154
6345
  throw new Error("expand_message_xof: invalid lenInBytes");
6155
6346
  return H.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
6156
6347
  }
6157
6348
  function hash_to_field(msg, count, options) {
6158
- (0, utils_js_1.validateObject)(options, {
6349
+ (0, utils_ts_1.validateObject)(options, {
6159
6350
  DST: "stringOrUint8Array",
6160
6351
  p: "bigint",
6161
6352
  m: "isSafeInteger",
@@ -6163,9 +6354,9 @@ var require_hash_to_curve = __commonJS((exports) => {
6163
6354
  hash: "hash"
6164
6355
  });
6165
6356
  const { p, k, m, hash, expand, DST: _DST } = options;
6166
- (0, utils_js_1.abytes)(msg);
6357
+ (0, utils_ts_1.abytes)(msg);
6167
6358
  anum(count);
6168
- const DST = typeof _DST === "string" ? (0, utils_js_1.utf8ToBytes)(_DST) : _DST;
6359
+ const DST = typeof _DST === "string" ? (0, utils_ts_1.utf8ToBytes)(_DST) : _DST;
6169
6360
  const log2p = p.toString(2).length;
6170
6361
  const L = Math.ceil((log2p + k) / 8);
6171
6362
  const len_in_bytes = count * m * L;
@@ -6185,7 +6376,7 @@ var require_hash_to_curve = __commonJS((exports) => {
6185
6376
  for (let j = 0;j < m; j++) {
6186
6377
  const elm_offset = L * (j + i * m);
6187
6378
  const tv = prb.subarray(elm_offset, elm_offset + L);
6188
- e[j] = (0, modular_js_1.mod)(os2ip(tv), p);
6379
+ e[j] = (0, modular_ts_1.mod)(os2ip(tv), p);
6189
6380
  }
6190
6381
  u[i] = e;
6191
6382
  }
@@ -6195,6 +6386,8 @@ var require_hash_to_curve = __commonJS((exports) => {
6195
6386
  const COEFF = map.map((i) => Array.from(i).reverse());
6196
6387
  return (x, y) => {
6197
6388
  const [xNum, xDen, yNum, yDen] = COEFF.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i)));
6389
+ if (field.is0(xDen) || field.is0(yDen))
6390
+ throw new Error("bad point: ZERO");
6198
6391
  x = field.div(xNum, xDen);
6199
6392
  y = field.mul(y, field.div(yNum, yDen));
6200
6393
  return { x, y };
@@ -6237,12 +6430,12 @@ var require_montgomery = __commonJS((exports) => {
6237
6430
  Object.defineProperty(exports, "__esModule", { value: true });
6238
6431
  exports.montgomery = montgomery;
6239
6432
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6240
- var modular_js_1 = require_modular();
6241
- var utils_js_1 = require_utils5();
6433
+ var modular_ts_1 = require_modular();
6434
+ var utils_ts_1 = require_utils5();
6242
6435
  var _0n = BigInt(0);
6243
6436
  var _1n = BigInt(1);
6244
6437
  function validateOpts(curve) {
6245
- (0, utils_js_1.validateObject)(curve, {
6438
+ (0, utils_ts_1.validateObject)(curve, {
6246
6439
  a: "bigint"
6247
6440
  }, {
6248
6441
  montgomeryBits: "isSafeInteger",
@@ -6257,12 +6450,12 @@ var require_montgomery = __commonJS((exports) => {
6257
6450
  function montgomery(curveDef) {
6258
6451
  const CURVE = validateOpts(curveDef);
6259
6452
  const { P } = CURVE;
6260
- const modP = (n) => (0, modular_js_1.mod)(n, P);
6453
+ const modP = (n) => (0, modular_ts_1.mod)(n, P);
6261
6454
  const montgomeryBits = CURVE.montgomeryBits;
6262
6455
  const montgomeryBytes = Math.ceil(montgomeryBits / 8);
6263
6456
  const fieldLen = CURVE.nByteLength;
6264
6457
  const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes);
6265
- const powPminus2 = CURVE.powPminus2 || ((x) => (0, modular_js_1.pow)(x, P - BigInt(2), P));
6458
+ const powPminus2 = CURVE.powPminus2 || ((x) => (0, modular_ts_1.pow)(x, P - BigInt(2), P));
6266
6459
  function cswap(swap, x_2, x_3) {
6267
6460
  const dummy = modP(swap * (x_2 - x_3));
6268
6461
  x_2 = modP(x_2 - dummy);
@@ -6271,8 +6464,8 @@ var require_montgomery = __commonJS((exports) => {
6271
6464
  }
6272
6465
  const a24 = (CURVE.a - BigInt(2)) / BigInt(4);
6273
6466
  function montgomeryLadder(u, scalar) {
6274
- (0, utils_js_1.aInRange)("u", u, _0n, P);
6275
- (0, utils_js_1.aInRange)("scalar", scalar, _0n, P);
6467
+ (0, utils_ts_1.aInRange)("u", u, _0n, P);
6468
+ (0, utils_ts_1.aInRange)("scalar", scalar, _0n, P);
6276
6469
  const k = scalar;
6277
6470
  const x_1 = u;
6278
6471
  let x_2 = _1n;
@@ -6317,22 +6510,22 @@ var require_montgomery = __commonJS((exports) => {
6317
6510
  return modP(x_2 * z2);
6318
6511
  }
6319
6512
  function encodeUCoordinate(u) {
6320
- return (0, utils_js_1.numberToBytesLE)(modP(u), montgomeryBytes);
6513
+ return (0, utils_ts_1.numberToBytesLE)(modP(u), montgomeryBytes);
6321
6514
  }
6322
6515
  function decodeUCoordinate(uEnc) {
6323
- const u = (0, utils_js_1.ensureBytes)("u coordinate", uEnc, montgomeryBytes);
6516
+ const u = (0, utils_ts_1.ensureBytes)("u coordinate", uEnc, montgomeryBytes);
6324
6517
  if (fieldLen === 32)
6325
6518
  u[31] &= 127;
6326
- return (0, utils_js_1.bytesToNumberLE)(u);
6519
+ return (0, utils_ts_1.bytesToNumberLE)(u);
6327
6520
  }
6328
6521
  function decodeScalar(n) {
6329
- const bytes = (0, utils_js_1.ensureBytes)("scalar", n);
6522
+ const bytes = (0, utils_ts_1.ensureBytes)("scalar", n);
6330
6523
  const len = bytes.length;
6331
6524
  if (len !== montgomeryBytes && len !== fieldLen) {
6332
6525
  let valid = "" + montgomeryBytes + " or " + fieldLen;
6333
6526
  throw new Error("invalid scalar, expected " + valid + " bytes, got " + len);
6334
6527
  }
6335
- return (0, utils_js_1.bytesToNumberLE)(adjustScalarBytes(bytes));
6528
+ return (0, utils_ts_1.bytesToNumberLE)(adjustScalarBytes(bytes));
6336
6529
  }
6337
6530
  function scalarMult(scalar, u) {
6338
6531
  const pointU = decodeUCoordinate(u);
@@ -6364,14 +6557,14 @@ var require_ed25519 = __commonJS((exports) => {
6364
6557
  exports.edwardsToMontgomeryPub = edwardsToMontgomeryPub;
6365
6558
  exports.edwardsToMontgomeryPriv = edwardsToMontgomeryPriv;
6366
6559
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6367
- var sha512_1 = require_sha512();
6560
+ var sha2_1 = require_sha2();
6368
6561
  var utils_1 = require_utils4();
6369
- var curve_js_1 = require_curve();
6370
- var edwards_js_1 = require_edwards();
6371
- var hash_to_curve_js_1 = require_hash_to_curve();
6372
- var modular_js_1 = require_modular();
6373
- var montgomery_js_1 = require_montgomery();
6374
- var utils_js_1 = require_utils5();
6562
+ var curve_ts_1 = require_curve();
6563
+ var edwards_ts_1 = require_edwards();
6564
+ var hash_to_curve_ts_1 = require_hash_to_curve();
6565
+ var modular_ts_1 = require_modular();
6566
+ var montgomery_ts_1 = require_montgomery();
6567
+ var utils_ts_1 = require_utils5();
6375
6568
  var ED25519_P = BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");
6376
6569
  var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
6377
6570
  var _0n = BigInt(0);
@@ -6385,16 +6578,16 @@ var require_ed25519 = __commonJS((exports) => {
6385
6578
  const P = ED25519_P;
6386
6579
  const x2 = x * x % P;
6387
6580
  const b2 = x2 * x % P;
6388
- const b4 = (0, modular_js_1.pow2)(b2, _2n, P) * b2 % P;
6389
- const b5 = (0, modular_js_1.pow2)(b4, _1n, P) * x % P;
6390
- const b10 = (0, modular_js_1.pow2)(b5, _5n, P) * b5 % P;
6391
- const b20 = (0, modular_js_1.pow2)(b10, _10n, P) * b10 % P;
6392
- const b40 = (0, modular_js_1.pow2)(b20, _20n, P) * b20 % P;
6393
- const b80 = (0, modular_js_1.pow2)(b40, _40n, P) * b40 % P;
6394
- const b160 = (0, modular_js_1.pow2)(b80, _80n, P) * b80 % P;
6395
- const b240 = (0, modular_js_1.pow2)(b160, _80n, P) * b80 % P;
6396
- const b250 = (0, modular_js_1.pow2)(b240, _10n, P) * b10 % P;
6397
- const pow_p_5_8 = (0, modular_js_1.pow2)(b250, _2n, P) * x % P;
6581
+ const b4 = (0, modular_ts_1.pow2)(b2, _2n, P) * b2 % P;
6582
+ const b5 = (0, modular_ts_1.pow2)(b4, _1n, P) * x % P;
6583
+ const b10 = (0, modular_ts_1.pow2)(b5, _5n, P) * b5 % P;
6584
+ const b20 = (0, modular_ts_1.pow2)(b10, _10n, P) * b10 % P;
6585
+ const b40 = (0, modular_ts_1.pow2)(b20, _20n, P) * b20 % P;
6586
+ const b80 = (0, modular_ts_1.pow2)(b40, _40n, P) * b40 % P;
6587
+ const b160 = (0, modular_ts_1.pow2)(b80, _80n, P) * b80 % P;
6588
+ const b240 = (0, modular_ts_1.pow2)(b160, _80n, P) * b80 % P;
6589
+ const b250 = (0, modular_ts_1.pow2)(b240, _10n, P) * b10 % P;
6590
+ const pow_p_5_8 = (0, modular_ts_1.pow2)(b250, _2n, P) * x % P;
6398
6591
  return { pow_p_5_8, b2 };
6399
6592
  }
6400
6593
  function adjustScalarBytes(bytes) {
@@ -6405,22 +6598,22 @@ var require_ed25519 = __commonJS((exports) => {
6405
6598
  }
6406
6599
  function uvRatio(u, v) {
6407
6600
  const P = ED25519_P;
6408
- const v3 = (0, modular_js_1.mod)(v * v * v, P);
6409
- const v7 = (0, modular_js_1.mod)(v3 * v3 * v, P);
6601
+ const v3 = (0, modular_ts_1.mod)(v * v * v, P);
6602
+ const v7 = (0, modular_ts_1.mod)(v3 * v3 * v, P);
6410
6603
  const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8;
6411
- let x = (0, modular_js_1.mod)(u * v3 * pow, P);
6412
- const vx2 = (0, modular_js_1.mod)(v * x * x, P);
6604
+ let x = (0, modular_ts_1.mod)(u * v3 * pow, P);
6605
+ const vx2 = (0, modular_ts_1.mod)(v * x * x, P);
6413
6606
  const root1 = x;
6414
- const root2 = (0, modular_js_1.mod)(x * ED25519_SQRT_M1, P);
6607
+ const root2 = (0, modular_ts_1.mod)(x * ED25519_SQRT_M1, P);
6415
6608
  const useRoot1 = vx2 === u;
6416
- const useRoot2 = vx2 === (0, modular_js_1.mod)(-u, P);
6417
- const noRoot = vx2 === (0, modular_js_1.mod)(-u * ED25519_SQRT_M1, P);
6609
+ const useRoot2 = vx2 === (0, modular_ts_1.mod)(-u, P);
6610
+ const noRoot = vx2 === (0, modular_ts_1.mod)(-u * ED25519_SQRT_M1, P);
6418
6611
  if (useRoot1)
6419
6612
  x = root1;
6420
6613
  if (useRoot2 || noRoot)
6421
6614
  x = root2;
6422
- if ((0, modular_js_1.isNegativeLE)(x, P))
6423
- x = (0, modular_js_1.mod)(-x, P);
6615
+ if ((0, modular_ts_1.isNegativeLE)(x, P))
6616
+ x = (0, modular_ts_1.mod)(-x, P);
6424
6617
  return { isValid: useRoot1 || useRoot2, value: x };
6425
6618
  }
6426
6619
  exports.ED25519_TORSION_SUBGROUP = [
@@ -6433,35 +6626,35 @@ var require_ed25519 = __commonJS((exports) => {
6433
6626
  "0000000000000000000000000000000000000000000000000000000000000000",
6434
6627
  "c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"
6435
6628
  ];
6436
- var Fp = /* @__PURE__ */ (() => (0, modular_js_1.Field)(ED25519_P, undefined, true))();
6629
+ var Fp = /* @__PURE__ */ (() => (0, modular_ts_1.Field)(ED25519_P, undefined, true))();
6437
6630
  var ed25519Defaults = /* @__PURE__ */ (() => ({
6438
- a: BigInt(-1),
6631
+ a: Fp.create(BigInt(-1)),
6439
6632
  d: BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),
6440
6633
  Fp,
6441
6634
  n: BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),
6442
6635
  h: _8n,
6443
6636
  Gx: BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),
6444
6637
  Gy: BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),
6445
- hash: sha512_1.sha512,
6638
+ hash: sha2_1.sha512,
6446
6639
  randomBytes: utils_1.randomBytes,
6447
6640
  adjustScalarBytes,
6448
6641
  uvRatio
6449
6642
  }))();
6450
- exports.ed25519 = (() => (0, edwards_js_1.twistedEdwards)(ed25519Defaults))();
6643
+ exports.ed25519 = (() => (0, edwards_ts_1.twistedEdwards)(ed25519Defaults))();
6451
6644
  function ed25519_domain(data, ctx, phflag) {
6452
6645
  if (ctx.length > 255)
6453
6646
  throw new Error("Context is too big");
6454
6647
  return (0, utils_1.concatBytes)((0, utils_1.utf8ToBytes)("SigEd25519 no Ed25519 collisions"), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
6455
6648
  }
6456
- exports.ed25519ctx = (() => (0, edwards_js_1.twistedEdwards)({
6649
+ exports.ed25519ctx = (() => (0, edwards_ts_1.twistedEdwards)({
6457
6650
  ...ed25519Defaults,
6458
6651
  domain: ed25519_domain
6459
6652
  }))();
6460
- exports.ed25519ph = (() => (0, edwards_js_1.twistedEdwards)(Object.assign({}, ed25519Defaults, {
6653
+ exports.ed25519ph = (() => (0, edwards_ts_1.twistedEdwards)(Object.assign({}, ed25519Defaults, {
6461
6654
  domain: ed25519_domain,
6462
- prehash: sha512_1.sha512
6655
+ prehash: sha2_1.sha512
6463
6656
  })))();
6464
- exports.x25519 = (() => (0, montgomery_js_1.montgomery)({
6657
+ exports.x25519 = (() => (0, montgomery_ts_1.montgomery)({
6465
6658
  P: ED25519_P,
6466
6659
  a: BigInt(486662),
6467
6660
  montgomeryBits: 255,
@@ -6470,7 +6663,7 @@ var require_ed25519 = __commonJS((exports) => {
6470
6663
  powPminus2: (x) => {
6471
6664
  const P = ED25519_P;
6472
6665
  const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x);
6473
- return (0, modular_js_1.mod)((0, modular_js_1.pow2)(pow_p_5_8, _3n, P) * b2, P);
6666
+ return (0, modular_ts_1.mod)((0, modular_ts_1.pow2)(pow_p_5_8, _3n, P) * b2, P);
6474
6667
  },
6475
6668
  adjustScalarBytes,
6476
6669
  randomBytes: utils_1.randomBytes
@@ -6531,7 +6724,7 @@ var require_ed25519 = __commonJS((exports) => {
6531
6724
  y = Fp.cmov(y, Fp.neg(y), e3 !== e4);
6532
6725
  return { xMn: xn, xMd: xd, yMn: y, yMd: _1n };
6533
6726
  }
6534
- var ELL2_C1_EDWARDS = /* @__PURE__ */ (() => (0, modular_js_1.FpSqrtEven)(Fp, Fp.neg(BigInt(486664))))();
6727
+ var ELL2_C1_EDWARDS = /* @__PURE__ */ (() => (0, modular_ts_1.FpSqrtEven)(Fp, Fp.neg(BigInt(486664))))();
6535
6728
  function map_to_curve_elligator2_edwards25519(u) {
6536
6729
  const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u);
6537
6730
  let xn = Fp.mul(xMn, yMd);
@@ -6548,18 +6741,18 @@ var require_ed25519 = __commonJS((exports) => {
6548
6741
  const inv = Fp.invertBatch([xd, yd]);
6549
6742
  return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) };
6550
6743
  }
6551
- var htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.ed25519.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), {
6744
+ var htf = /* @__PURE__ */ (() => (0, hash_to_curve_ts_1.createHasher)(exports.ed25519.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), {
6552
6745
  DST: "edwards25519_XMD:SHA-512_ELL2_RO_",
6553
6746
  encodeDST: "edwards25519_XMD:SHA-512_ELL2_NU_",
6554
6747
  p: Fp.ORDER,
6555
6748
  m: 1,
6556
6749
  k: 128,
6557
6750
  expand: "xmd",
6558
- hash: sha512_1.sha512
6751
+ hash: sha2_1.sha512
6559
6752
  }))();
6560
6753
  exports.hashToCurve = (() => htf.hashToCurve)();
6561
6754
  exports.encodeToCurve = (() => htf.encodeToCurve)();
6562
- function assertRstPoint(other) {
6755
+ function aristp(other) {
6563
6756
  if (!(other instanceof RistPoint))
6564
6757
  throw new Error("RistrettoPoint expected");
6565
6758
  }
@@ -6570,7 +6763,7 @@ var require_ed25519 = __commonJS((exports) => {
6570
6763
  var D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");
6571
6764
  var invertSqrt = (number) => uvRatio(_1n, number);
6572
6765
  var MAX_255B = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
6573
- var bytes255ToNumberLE = (bytes) => exports.ed25519.CURVE.Fp.create((0, utils_js_1.bytesToNumberLE)(bytes) & MAX_255B);
6766
+ var bytes255ToNumberLE = (bytes) => exports.ed25519.CURVE.Fp.create((0, utils_ts_1.bytesToNumberLE)(bytes) & MAX_255B);
6574
6767
  function calcElligatorRistrettoMap(r0) {
6575
6768
  const { d } = exports.ed25519.CURVE;
6576
6769
  const P = exports.ed25519.CURVE.Fp.ORDER;
@@ -6581,7 +6774,7 @@ var require_ed25519 = __commonJS((exports) => {
6581
6774
  const D = mod((c - d * r) * mod(r + d));
6582
6775
  let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D);
6583
6776
  let s_ = mod(s * r0);
6584
- if (!(0, modular_js_1.isNegativeLE)(s_, P))
6777
+ if (!(0, modular_ts_1.isNegativeLE)(s_, P))
6585
6778
  s_ = mod(-s_);
6586
6779
  if (!Ns_D_is_sq)
6587
6780
  s = s_;
@@ -6604,7 +6797,7 @@ var require_ed25519 = __commonJS((exports) => {
6604
6797
  return new RistPoint(exports.ed25519.ExtendedPoint.fromAffine(ap));
6605
6798
  }
6606
6799
  static hashToCurve(hex) {
6607
- hex = (0, utils_js_1.ensureBytes)("ristrettoHash", hex, 64);
6800
+ hex = (0, utils_ts_1.ensureBytes)("ristrettoHash", hex, 64);
6608
6801
  const r1 = bytes255ToNumberLE(hex.slice(0, 32));
6609
6802
  const R1 = calcElligatorRistrettoMap(r1);
6610
6803
  const r2 = bytes255ToNumberLE(hex.slice(32, 64));
@@ -6612,13 +6805,13 @@ var require_ed25519 = __commonJS((exports) => {
6612
6805
  return new RistPoint(R1.add(R2));
6613
6806
  }
6614
6807
  static fromHex(hex) {
6615
- hex = (0, utils_js_1.ensureBytes)("ristrettoHex", hex, 32);
6808
+ hex = (0, utils_ts_1.ensureBytes)("ristrettoHex", hex, 32);
6616
6809
  const { a, d } = exports.ed25519.CURVE;
6617
6810
  const P = exports.ed25519.CURVE.Fp.ORDER;
6618
6811
  const mod = exports.ed25519.CURVE.Fp.create;
6619
6812
  const emsg = "RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint";
6620
6813
  const s = bytes255ToNumberLE(hex);
6621
- if (!(0, utils_js_1.equalBytes)((0, utils_js_1.numberToBytesLE)(s, 32), hex) || (0, modular_js_1.isNegativeLE)(s, P))
6814
+ if (!(0, utils_ts_1.equalBytes)((0, utils_ts_1.numberToBytesLE)(s, 32), hex) || (0, modular_ts_1.isNegativeLE)(s, P))
6622
6815
  throw new Error(emsg);
6623
6816
  const s2 = mod(s * s);
6624
6817
  const u1 = mod(_1n + a * s2);
@@ -6630,17 +6823,17 @@ var require_ed25519 = __commonJS((exports) => {
6630
6823
  const Dx = mod(I * u2);
6631
6824
  const Dy = mod(I * Dx * v);
6632
6825
  let x = mod((s + s) * Dx);
6633
- if ((0, modular_js_1.isNegativeLE)(x, P))
6826
+ if ((0, modular_ts_1.isNegativeLE)(x, P))
6634
6827
  x = mod(-x);
6635
6828
  const y = mod(u1 * Dy);
6636
6829
  const t = mod(x * y);
6637
- if (!isValid2 || (0, modular_js_1.isNegativeLE)(t, P) || y === _0n)
6830
+ if (!isValid2 || (0, modular_ts_1.isNegativeLE)(t, P) || y === _0n)
6638
6831
  throw new Error(emsg);
6639
6832
  return new RistPoint(new exports.ed25519.ExtendedPoint(x, y, _1n, t));
6640
6833
  }
6641
6834
  static msm(points, scalars) {
6642
- const Fn = (0, modular_js_1.Field)(exports.ed25519.CURVE.n, exports.ed25519.CURVE.nBitLength);
6643
- return (0, curve_js_1.pippenger)(RistPoint, Fn, points, scalars);
6835
+ const Fn = (0, modular_ts_1.Field)(exports.ed25519.CURVE.n, exports.ed25519.CURVE.nBitLength);
6836
+ return (0, curve_ts_1.pippenger)(RistPoint, Fn, points, scalars);
6644
6837
  }
6645
6838
  toRawBytes() {
6646
6839
  let { ex: x, ey: y, ez: z2, et: t } = this.ep;
@@ -6654,7 +6847,7 @@ var require_ed25519 = __commonJS((exports) => {
6654
6847
  const D2 = mod(invsqrt * u2);
6655
6848
  const zInv = mod(D1 * D2 * t);
6656
6849
  let D;
6657
- if ((0, modular_js_1.isNegativeLE)(t * zInv, P)) {
6850
+ if ((0, modular_ts_1.isNegativeLE)(t * zInv, P)) {
6658
6851
  let _x = mod(y * SQRT_M1);
6659
6852
  let _y = mod(x * SQRT_M1);
6660
6853
  x = _x;
@@ -6663,21 +6856,21 @@ var require_ed25519 = __commonJS((exports) => {
6663
6856
  } else {
6664
6857
  D = D2;
6665
6858
  }
6666
- if ((0, modular_js_1.isNegativeLE)(x * zInv, P))
6859
+ if ((0, modular_ts_1.isNegativeLE)(x * zInv, P))
6667
6860
  y = mod(-y);
6668
6861
  let s = mod((z2 - y) * D);
6669
- if ((0, modular_js_1.isNegativeLE)(s, P))
6862
+ if ((0, modular_ts_1.isNegativeLE)(s, P))
6670
6863
  s = mod(-s);
6671
- return (0, utils_js_1.numberToBytesLE)(s, 32);
6864
+ return (0, utils_ts_1.numberToBytesLE)(s, 32);
6672
6865
  }
6673
6866
  toHex() {
6674
- return (0, utils_js_1.bytesToHex)(this.toRawBytes());
6867
+ return (0, utils_ts_1.bytesToHex)(this.toRawBytes());
6675
6868
  }
6676
6869
  toString() {
6677
6870
  return this.toHex();
6678
6871
  }
6679
6872
  equals(other) {
6680
- assertRstPoint(other);
6873
+ aristp(other);
6681
6874
  const { ex: X1, ey: Y1 } = this.ep;
6682
6875
  const { ex: X2, ey: Y2 } = other.ep;
6683
6876
  const mod = exports.ed25519.CURVE.Fp.create;
@@ -6686,11 +6879,11 @@ var require_ed25519 = __commonJS((exports) => {
6686
6879
  return one || two;
6687
6880
  }
6688
6881
  add(other) {
6689
- assertRstPoint(other);
6882
+ aristp(other);
6690
6883
  return new RistPoint(this.ep.add(other.ep));
6691
6884
  }
6692
6885
  subtract(other) {
6693
- assertRstPoint(other);
6886
+ aristp(other);
6694
6887
  return new RistPoint(this.ep.subtract(other.ep));
6695
6888
  }
6696
6889
  multiply(scalar) {
@@ -6716,7 +6909,7 @@ var require_ed25519 = __commonJS((exports) => {
6716
6909
  var hashToRistretto255 = (msg, options) => {
6717
6910
  const d = options.DST;
6718
6911
  const DST = typeof d === "string" ? (0, utils_1.utf8ToBytes)(d) : d;
6719
- const uniform_bytes = (0, hash_to_curve_js_1.expand_message_xmd)(msg, DST, 64, sha512_1.sha512);
6912
+ const uniform_bytes = (0, hash_to_curve_ts_1.expand_message_xmd)(msg, DST, 64, sha2_1.sha512);
6720
6913
  const P = RistPoint.hashToCurve(uniform_bytes);
6721
6914
  return P;
6722
6915
  };
@@ -6724,193 +6917,20 @@ var require_ed25519 = __commonJS((exports) => {
6724
6917
  exports.hash_to_ristretto255 = exports.hashToRistretto255;
6725
6918
  });
6726
6919
 
6727
- // ../../node_modules/@noble/hashes/sha256.js
6728
- var require_sha256 = __commonJS((exports) => {
6729
- Object.defineProperty(exports, "__esModule", { value: true });
6730
- exports.sha224 = exports.sha256 = exports.SHA256 = undefined;
6731
- var _md_js_1 = require__md();
6732
- var utils_js_1 = require_utils4();
6733
- var SHA256_K = /* @__PURE__ */ new Uint32Array([
6734
- 1116352408,
6735
- 1899447441,
6736
- 3049323471,
6737
- 3921009573,
6738
- 961987163,
6739
- 1508970993,
6740
- 2453635748,
6741
- 2870763221,
6742
- 3624381080,
6743
- 310598401,
6744
- 607225278,
6745
- 1426881987,
6746
- 1925078388,
6747
- 2162078206,
6748
- 2614888103,
6749
- 3248222580,
6750
- 3835390401,
6751
- 4022224774,
6752
- 264347078,
6753
- 604807628,
6754
- 770255983,
6755
- 1249150122,
6756
- 1555081692,
6757
- 1996064986,
6758
- 2554220882,
6759
- 2821834349,
6760
- 2952996808,
6761
- 3210313671,
6762
- 3336571891,
6763
- 3584528711,
6764
- 113926993,
6765
- 338241895,
6766
- 666307205,
6767
- 773529912,
6768
- 1294757372,
6769
- 1396182291,
6770
- 1695183700,
6771
- 1986661051,
6772
- 2177026350,
6773
- 2456956037,
6774
- 2730485921,
6775
- 2820302411,
6776
- 3259730800,
6777
- 3345764771,
6778
- 3516065817,
6779
- 3600352804,
6780
- 4094571909,
6781
- 275423344,
6782
- 430227734,
6783
- 506948616,
6784
- 659060556,
6785
- 883997877,
6786
- 958139571,
6787
- 1322822218,
6788
- 1537002063,
6789
- 1747873779,
6790
- 1955562222,
6791
- 2024104815,
6792
- 2227730452,
6793
- 2361852424,
6794
- 2428436474,
6795
- 2756734187,
6796
- 3204031479,
6797
- 3329325298
6798
- ]);
6799
- var SHA256_IV = /* @__PURE__ */ new Uint32Array([
6800
- 1779033703,
6801
- 3144134277,
6802
- 1013904242,
6803
- 2773480762,
6804
- 1359893119,
6805
- 2600822924,
6806
- 528734635,
6807
- 1541459225
6808
- ]);
6809
- var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
6810
-
6811
- class SHA256 extends _md_js_1.HashMD {
6812
- constructor() {
6813
- super(64, 32, 8, false);
6814
- this.A = SHA256_IV[0] | 0;
6815
- this.B = SHA256_IV[1] | 0;
6816
- this.C = SHA256_IV[2] | 0;
6817
- this.D = SHA256_IV[3] | 0;
6818
- this.E = SHA256_IV[4] | 0;
6819
- this.F = SHA256_IV[5] | 0;
6820
- this.G = SHA256_IV[6] | 0;
6821
- this.H = SHA256_IV[7] | 0;
6822
- }
6823
- get() {
6824
- const { A, B, C, D, E, F, G, H } = this;
6825
- return [A, B, C, D, E, F, G, H];
6826
- }
6827
- set(A, B, C, D, E, F, G, H) {
6828
- this.A = A | 0;
6829
- this.B = B | 0;
6830
- this.C = C | 0;
6831
- this.D = D | 0;
6832
- this.E = E | 0;
6833
- this.F = F | 0;
6834
- this.G = G | 0;
6835
- this.H = H | 0;
6836
- }
6837
- process(view, offset) {
6838
- for (let i = 0;i < 16; i++, offset += 4)
6839
- SHA256_W[i] = view.getUint32(offset, false);
6840
- for (let i = 16;i < 64; i++) {
6841
- const W15 = SHA256_W[i - 15];
6842
- const W2 = SHA256_W[i - 2];
6843
- const s0 = (0, utils_js_1.rotr)(W15, 7) ^ (0, utils_js_1.rotr)(W15, 18) ^ W15 >>> 3;
6844
- const s1 = (0, utils_js_1.rotr)(W2, 17) ^ (0, utils_js_1.rotr)(W2, 19) ^ W2 >>> 10;
6845
- SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
6846
- }
6847
- let { A, B, C, D, E, F, G, H } = this;
6848
- for (let i = 0;i < 64; i++) {
6849
- const sigma1 = (0, utils_js_1.rotr)(E, 6) ^ (0, utils_js_1.rotr)(E, 11) ^ (0, utils_js_1.rotr)(E, 25);
6850
- const T1 = H + sigma1 + (0, _md_js_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
6851
- const sigma0 = (0, utils_js_1.rotr)(A, 2) ^ (0, utils_js_1.rotr)(A, 13) ^ (0, utils_js_1.rotr)(A, 22);
6852
- const T2 = sigma0 + (0, _md_js_1.Maj)(A, B, C) | 0;
6853
- H = G;
6854
- G = F;
6855
- F = E;
6856
- E = D + T1 | 0;
6857
- D = C;
6858
- C = B;
6859
- B = A;
6860
- A = T1 + T2 | 0;
6861
- }
6862
- A = A + this.A | 0;
6863
- B = B + this.B | 0;
6864
- C = C + this.C | 0;
6865
- D = D + this.D | 0;
6866
- E = E + this.E | 0;
6867
- F = F + this.F | 0;
6868
- G = G + this.G | 0;
6869
- H = H + this.H | 0;
6870
- this.set(A, B, C, D, E, F, G, H);
6871
- }
6872
- roundClean() {
6873
- SHA256_W.fill(0);
6874
- }
6875
- destroy() {
6876
- this.set(0, 0, 0, 0, 0, 0, 0, 0);
6877
- this.buffer.fill(0);
6878
- }
6879
- }
6880
- exports.SHA256 = SHA256;
6881
-
6882
- class SHA224 extends SHA256 {
6883
- constructor() {
6884
- super();
6885
- this.A = 3238371032 | 0;
6886
- this.B = 914150663 | 0;
6887
- this.C = 812702999 | 0;
6888
- this.D = 4144912697 | 0;
6889
- this.E = 4290775857 | 0;
6890
- this.F = 1750603025 | 0;
6891
- this.G = 1694076839 | 0;
6892
- this.H = 3204075428 | 0;
6893
- this.outputLen = 28;
6894
- }
6895
- }
6896
- exports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256);
6897
- exports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224);
6898
- });
6899
-
6900
6920
  // ../../node_modules/@noble/hashes/hmac.js
6901
6921
  var require_hmac = __commonJS((exports) => {
6902
6922
  Object.defineProperty(exports, "__esModule", { value: true });
6903
6923
  exports.hmac = exports.HMAC = undefined;
6904
- var _assert_js_1 = require__assert2();
6905
- var utils_js_1 = require_utils4();
6924
+ var _assert_ts_1 = require__assert2();
6925
+ var utils_ts_1 = require_utils4();
6906
6926
 
6907
- class HMAC extends utils_js_1.Hash {
6927
+ class HMAC extends utils_ts_1.Hash {
6908
6928
  constructor(hash, _key) {
6909
6929
  super();
6910
6930
  this.finished = false;
6911
6931
  this.destroyed = false;
6912
- (0, _assert_js_1.ahash)(hash);
6913
- const key = (0, utils_js_1.toBytes)(_key);
6932
+ (0, _assert_ts_1.ahash)(hash);
6933
+ const key = (0, utils_ts_1.toBytes)(_key);
6914
6934
  this.iHash = hash.create();
6915
6935
  if (typeof this.iHash.update !== "function")
6916
6936
  throw new Error("Expected instance of class which extends utils.Hash");
@@ -6929,13 +6949,13 @@ var require_hmac = __commonJS((exports) => {
6929
6949
  pad.fill(0);
6930
6950
  }
6931
6951
  update(buf) {
6932
- (0, _assert_js_1.aexists)(this);
6952
+ (0, _assert_ts_1.aexists)(this);
6933
6953
  this.iHash.update(buf);
6934
6954
  return this;
6935
6955
  }
6936
6956
  digestInto(out) {
6937
- (0, _assert_js_1.aexists)(this);
6938
- (0, _assert_js_1.abytes)(out, this.outputLen);
6957
+ (0, _assert_ts_1.aexists)(this);
6958
+ (0, _assert_ts_1.abytes)(out, this.outputLen);
6939
6959
  this.finished = true;
6940
6960
  this.iHash.digestInto(out);
6941
6961
  this.oHash.update(out);
@@ -6980,19 +7000,18 @@ var require_weierstrass = __commonJS((exports) => {
6980
7000
  exports.SWUFpSqrtRatio = SWUFpSqrtRatio;
6981
7001
  exports.mapToCurveSimpleSWU = mapToCurveSimpleSWU;
6982
7002
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
6983
- var curve_js_1 = require_curve();
6984
- var modular_js_1 = require_modular();
6985
- var ut = require_utils5();
6986
- var utils_js_1 = require_utils5();
7003
+ var curve_ts_1 = require_curve();
7004
+ var modular_ts_1 = require_modular();
7005
+ var utils_ts_1 = require_utils5();
6987
7006
  function validateSigVerOpts(opts) {
6988
7007
  if (opts.lowS !== undefined)
6989
- (0, utils_js_1.abool)("lowS", opts.lowS);
7008
+ (0, utils_ts_1.abool)("lowS", opts.lowS);
6990
7009
  if (opts.prehash !== undefined)
6991
- (0, utils_js_1.abool)("prehash", opts.prehash);
7010
+ (0, utils_ts_1.abool)("prehash", opts.prehash);
6992
7011
  }
6993
7012
  function validatePointOpts(curve) {
6994
- const opts = (0, curve_js_1.validateBasic)(curve);
6995
- ut.validateObject(opts, {
7013
+ const opts = (0, curve_ts_1.validateBasic)(curve);
7014
+ (0, utils_ts_1.validateObject)(opts, {
6996
7015
  a: "field",
6997
7016
  b: "field"
6998
7017
  }, {
@@ -7015,7 +7034,6 @@ var require_weierstrass = __commonJS((exports) => {
7015
7034
  }
7016
7035
  return Object.freeze({ ...opts });
7017
7036
  }
7018
- var { bytesToNumberBE: b2n, hexToBytes: h2b } = ut;
7019
7037
 
7020
7038
  class DERErr extends Error {
7021
7039
  constructor(m = "") {
@@ -7033,11 +7051,11 @@ var require_weierstrass = __commonJS((exports) => {
7033
7051
  if (data.length & 1)
7034
7052
  throw new E("tlv.encode: unpadded data");
7035
7053
  const dataLen = data.length / 2;
7036
- const len = ut.numberToHexUnpadded(dataLen);
7054
+ const len = (0, utils_ts_1.numberToHexUnpadded)(dataLen);
7037
7055
  if (len.length / 2 & 128)
7038
7056
  throw new E("tlv.encode: long form length too big");
7039
- const lenLen = dataLen > 127 ? ut.numberToHexUnpadded(len.length / 2 | 128) : "";
7040
- const t = ut.numberToHexUnpadded(tag);
7057
+ const lenLen = dataLen > 127 ? (0, utils_ts_1.numberToHexUnpadded)(len.length / 2 | 128) : "";
7058
+ const t = (0, utils_ts_1.numberToHexUnpadded)(tag);
7041
7059
  return t + lenLen + len + data;
7042
7060
  },
7043
7061
  decode(tag, data) {
@@ -7080,7 +7098,7 @@ var require_weierstrass = __commonJS((exports) => {
7080
7098
  const { Err: E } = exports.DER;
7081
7099
  if (num < _0n)
7082
7100
  throw new E("integer: negative integers are not allowed");
7083
- let hex = ut.numberToHexUnpadded(num);
7101
+ let hex = (0, utils_ts_1.numberToHexUnpadded)(num);
7084
7102
  if (Number.parseInt(hex[0], 16) & 8)
7085
7103
  hex = "00" + hex;
7086
7104
  if (hex.length & 1)
@@ -7093,13 +7111,12 @@ var require_weierstrass = __commonJS((exports) => {
7093
7111
  throw new E("invalid signature integer: negative");
7094
7112
  if (data[0] === 0 && !(data[1] & 128))
7095
7113
  throw new E("invalid signature integer: unnecessary leading zero");
7096
- return b2n(data);
7114
+ return (0, utils_ts_1.bytesToNumberBE)(data);
7097
7115
  }
7098
7116
  },
7099
7117
  toSig(hex) {
7100
7118
  const { Err: E, _int: int, _tlv: tlv } = exports.DER;
7101
- const data = typeof hex === "string" ? h2b(hex) : hex;
7102
- ut.abytes(data);
7119
+ const data = (0, utils_ts_1.ensureBytes)("signature", hex);
7103
7120
  const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
7104
7121
  if (seqLeftBytes.length)
7105
7122
  throw new E("invalid signature: left bytes after parsing");
@@ -7125,10 +7142,10 @@ var require_weierstrass = __commonJS((exports) => {
7125
7142
  function weierstrassPoints(opts) {
7126
7143
  const CURVE = validatePointOpts(opts);
7127
7144
  const { Fp } = CURVE;
7128
- const Fn = (0, modular_js_1.Field)(CURVE.n, CURVE.nBitLength);
7145
+ const Fn = (0, modular_ts_1.Field)(CURVE.n, CURVE.nBitLength);
7129
7146
  const toBytes = CURVE.toBytes || ((_c, point, _isCompressed) => {
7130
7147
  const a = point.toAffine();
7131
- return ut.concatBytes(Uint8Array.from([4]), Fp.toBytes(a.x), Fp.toBytes(a.y));
7148
+ return (0, utils_ts_1.concatBytes)(Uint8Array.from([4]), Fp.toBytes(a.x), Fp.toBytes(a.y));
7132
7149
  });
7133
7150
  const fromBytes = CURVE.fromBytes || ((bytes) => {
7134
7151
  const tail = bytes.subarray(1);
@@ -7145,33 +7162,33 @@ var require_weierstrass = __commonJS((exports) => {
7145
7162
  if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))
7146
7163
  throw new Error("bad generator point: equation left != right");
7147
7164
  function isWithinCurveOrder(num) {
7148
- return ut.inRange(num, _1n, CURVE.n);
7165
+ return (0, utils_ts_1.inRange)(num, _1n, CURVE.n);
7149
7166
  }
7150
7167
  function normPrivateKeyToScalar(key) {
7151
7168
  const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;
7152
7169
  if (lengths && typeof key !== "bigint") {
7153
- if (ut.isBytes(key))
7154
- key = ut.bytesToHex(key);
7170
+ if ((0, utils_ts_1.isBytes)(key))
7171
+ key = (0, utils_ts_1.bytesToHex)(key);
7155
7172
  if (typeof key !== "string" || !lengths.includes(key.length))
7156
7173
  throw new Error("invalid private key");
7157
7174
  key = key.padStart(nByteLength * 2, "0");
7158
7175
  }
7159
7176
  let num;
7160
7177
  try {
7161
- num = typeof key === "bigint" ? key : ut.bytesToNumberBE((0, utils_js_1.ensureBytes)("private key", key, nByteLength));
7178
+ num = typeof key === "bigint" ? key : (0, utils_ts_1.bytesToNumberBE)((0, utils_ts_1.ensureBytes)("private key", key, nByteLength));
7162
7179
  } catch (error) {
7163
7180
  throw new Error("invalid private key, expected hex or " + nByteLength + " bytes, got " + typeof key);
7164
7181
  }
7165
7182
  if (wrapPrivateKey)
7166
- num = (0, modular_js_1.mod)(num, N);
7167
- ut.aInRange("private key", num, _1n, N);
7183
+ num = (0, modular_ts_1.mod)(num, N);
7184
+ (0, utils_ts_1.aInRange)("private key", num, _1n, N);
7168
7185
  return num;
7169
7186
  }
7170
- function assertPrjPoint(other) {
7187
+ function aprjpoint(other) {
7171
7188
  if (!(other instanceof Point))
7172
7189
  throw new Error("ProjectivePoint expected");
7173
7190
  }
7174
- const toAffineMemo = (0, utils_js_1.memoized)((p, iz) => {
7191
+ const toAffineMemo = (0, utils_ts_1.memoized)((p, iz) => {
7175
7192
  const { px: x, py: y, pz: z2 } = p;
7176
7193
  if (Fp.eql(z2, Fp.ONE))
7177
7194
  return { x, y };
@@ -7187,7 +7204,7 @@ var require_weierstrass = __commonJS((exports) => {
7187
7204
  throw new Error("invZ was invalid");
7188
7205
  return { x: ax, y: ay };
7189
7206
  });
7190
- const assertValidMemo = (0, utils_js_1.memoized)((p) => {
7207
+ const assertValidMemo = (0, utils_ts_1.memoized)((p) => {
7191
7208
  if (p.is0()) {
7192
7209
  if (CURVE.allowInfinityPoint && !Fp.is0(p.py))
7193
7210
  return;
@@ -7207,15 +7224,15 @@ var require_weierstrass = __commonJS((exports) => {
7207
7224
 
7208
7225
  class Point {
7209
7226
  constructor(px, py, pz) {
7210
- this.px = px;
7211
- this.py = py;
7212
- this.pz = pz;
7213
7227
  if (px == null || !Fp.isValid(px))
7214
7228
  throw new Error("x required");
7215
7229
  if (py == null || !Fp.isValid(py))
7216
7230
  throw new Error("y required");
7217
7231
  if (pz == null || !Fp.isValid(pz))
7218
7232
  throw new Error("z required");
7233
+ this.px = px;
7234
+ this.py = py;
7235
+ this.pz = pz;
7219
7236
  Object.freeze(this);
7220
7237
  }
7221
7238
  static fromAffine(p) {
@@ -7240,7 +7257,7 @@ var require_weierstrass = __commonJS((exports) => {
7240
7257
  return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);
7241
7258
  }
7242
7259
  static fromHex(hex) {
7243
- const P = Point.fromAffine(fromBytes((0, utils_js_1.ensureBytes)("pointHex", hex)));
7260
+ const P = Point.fromAffine(fromBytes((0, utils_ts_1.ensureBytes)("pointHex", hex)));
7244
7261
  P.assertValidity();
7245
7262
  return P;
7246
7263
  }
@@ -7248,7 +7265,7 @@ var require_weierstrass = __commonJS((exports) => {
7248
7265
  return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));
7249
7266
  }
7250
7267
  static msm(points, scalars) {
7251
- return (0, curve_js_1.pippenger)(Point, Fn, points, scalars);
7268
+ return (0, curve_ts_1.pippenger)(Point, Fn, points, scalars);
7252
7269
  }
7253
7270
  _setWindowSize(windowSize) {
7254
7271
  wnaf.setWindowSize(this, windowSize);
@@ -7263,7 +7280,7 @@ var require_weierstrass = __commonJS((exports) => {
7263
7280
  throw new Error("Field doesn't support isOdd");
7264
7281
  }
7265
7282
  equals(other) {
7266
- assertPrjPoint(other);
7283
+ aprjpoint(other);
7267
7284
  const { px: X1, py: Y1, pz: Z1 } = this;
7268
7285
  const { px: X2, py: Y2, pz: Z2 } = other;
7269
7286
  const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));
@@ -7312,7 +7329,7 @@ var require_weierstrass = __commonJS((exports) => {
7312
7329
  return new Point(X3, Y3, Z3);
7313
7330
  }
7314
7331
  add(other) {
7315
- assertPrjPoint(other);
7332
+ aprjpoint(other);
7316
7333
  const { px: X1, py: Y1, pz: Z1 } = this;
7317
7334
  const { px: X2, py: Y2, pz: Z2 } = other;
7318
7335
  let { ZERO: X3, ZERO: Y3, ZERO: Z3 } = Fp;
@@ -7371,7 +7388,7 @@ var require_weierstrass = __commonJS((exports) => {
7371
7388
  }
7372
7389
  multiplyUnsafe(sc) {
7373
7390
  const { endo, n: N } = CURVE;
7374
- ut.aInRange("scalar", sc, _0n, N);
7391
+ (0, utils_ts_1.aInRange)("scalar", sc, _0n, N);
7375
7392
  const I = Point.ZERO;
7376
7393
  if (sc === _0n)
7377
7394
  return I;
@@ -7401,7 +7418,7 @@ var require_weierstrass = __commonJS((exports) => {
7401
7418
  }
7402
7419
  multiply(scalar) {
7403
7420
  const { endo, n: N } = CURVE;
7404
- ut.aInRange("scalar", scalar, _1n, N);
7421
+ (0, utils_ts_1.aInRange)("scalar", scalar, _1n, N);
7405
7422
  let point, fake;
7406
7423
  if (endo) {
7407
7424
  const { k1neg, k1, k2neg, k2 } = endo.splitScalar(scalar);
@@ -7445,19 +7462,19 @@ var require_weierstrass = __commonJS((exports) => {
7445
7462
  return this.multiplyUnsafe(CURVE.h);
7446
7463
  }
7447
7464
  toRawBytes(isCompressed = true) {
7448
- (0, utils_js_1.abool)("isCompressed", isCompressed);
7465
+ (0, utils_ts_1.abool)("isCompressed", isCompressed);
7449
7466
  this.assertValidity();
7450
7467
  return toBytes(Point, this, isCompressed);
7451
7468
  }
7452
7469
  toHex(isCompressed = true) {
7453
- (0, utils_js_1.abool)("isCompressed", isCompressed);
7454
- return ut.bytesToHex(this.toRawBytes(isCompressed));
7470
+ (0, utils_ts_1.abool)("isCompressed", isCompressed);
7471
+ return (0, utils_ts_1.bytesToHex)(this.toRawBytes(isCompressed));
7455
7472
  }
7456
7473
  }
7457
7474
  Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);
7458
7475
  Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);
7459
7476
  const _bits = CURVE.nBitLength;
7460
- const wnaf = (0, curve_js_1.wNAF)(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits);
7477
+ const wnaf = (0, curve_ts_1.wNAF)(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits);
7461
7478
  return {
7462
7479
  CURVE,
7463
7480
  ProjectivePoint: Point,
@@ -7467,8 +7484,8 @@ var require_weierstrass = __commonJS((exports) => {
7467
7484
  };
7468
7485
  }
7469
7486
  function validateOpts(curve) {
7470
- const opts = (0, curve_js_1.validateBasic)(curve);
7471
- ut.validateObject(opts, {
7487
+ const opts = (0, curve_ts_1.validateBasic)(curve);
7488
+ (0, utils_ts_1.validateObject)(opts, {
7472
7489
  hash: "hash",
7473
7490
  hmac: "function",
7474
7491
  randomBytes: "function"
@@ -7485,18 +7502,18 @@ var require_weierstrass = __commonJS((exports) => {
7485
7502
  const compressedLen = Fp.BYTES + 1;
7486
7503
  const uncompressedLen = 2 * Fp.BYTES + 1;
7487
7504
  function modN(a) {
7488
- return (0, modular_js_1.mod)(a, CURVE_ORDER);
7505
+ return (0, modular_ts_1.mod)(a, CURVE_ORDER);
7489
7506
  }
7490
7507
  function invN(a) {
7491
- return (0, modular_js_1.invert)(a, CURVE_ORDER);
7508
+ return (0, modular_ts_1.invert)(a, CURVE_ORDER);
7492
7509
  }
7493
7510
  const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
7494
7511
  ...CURVE,
7495
7512
  toBytes(_c, point, isCompressed) {
7496
7513
  const a = point.toAffine();
7497
7514
  const x = Fp.toBytes(a.x);
7498
- const cat = ut.concatBytes;
7499
- (0, utils_js_1.abool)("isCompressed", isCompressed);
7515
+ const cat = utils_ts_1.concatBytes;
7516
+ (0, utils_ts_1.abool)("isCompressed", isCompressed);
7500
7517
  if (isCompressed) {
7501
7518
  return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
7502
7519
  } else {
@@ -7508,8 +7525,8 @@ var require_weierstrass = __commonJS((exports) => {
7508
7525
  const head = bytes[0];
7509
7526
  const tail = bytes.subarray(1);
7510
7527
  if (len === compressedLen && (head === 2 || head === 3)) {
7511
- const x = ut.bytesToNumberBE(tail);
7512
- if (!ut.inRange(x, _1n, Fp.ORDER))
7528
+ const x = (0, utils_ts_1.bytesToNumberBE)(tail);
7529
+ if (!(0, utils_ts_1.inRange)(x, _1n, Fp.ORDER))
7513
7530
  throw new Error("Point is not on curve");
7514
7531
  const y2 = weierstrassEquation(x);
7515
7532
  let y;
@@ -7535,7 +7552,7 @@ var require_weierstrass = __commonJS((exports) => {
7535
7552
  }
7536
7553
  }
7537
7554
  });
7538
- const numToNByteStr = (num) => ut.bytesToHex(ut.numberToBytesBE(num, CURVE.nByteLength));
7555
+ const numToNByteHex = (num) => (0, utils_ts_1.bytesToHex)((0, utils_ts_1.numberToBytesBE)(num, CURVE.nByteLength));
7539
7556
  function isBiggerThanHalfOrder(number) {
7540
7557
  const HALF = CURVE_ORDER >> _1n;
7541
7558
  return number > HALF;
@@ -7543,41 +7560,41 @@ var require_weierstrass = __commonJS((exports) => {
7543
7560
  function normalizeS(s) {
7544
7561
  return isBiggerThanHalfOrder(s) ? modN(-s) : s;
7545
7562
  }
7546
- const slcNum = (b, from, to) => ut.bytesToNumberBE(b.slice(from, to));
7563
+ const slcNum = (b, from, to) => (0, utils_ts_1.bytesToNumberBE)(b.slice(from, to));
7547
7564
 
7548
7565
  class Signature {
7549
7566
  constructor(r, s, recovery) {
7567
+ (0, utils_ts_1.aInRange)("r", r, _1n, CURVE_ORDER);
7568
+ (0, utils_ts_1.aInRange)("s", s, _1n, CURVE_ORDER);
7550
7569
  this.r = r;
7551
7570
  this.s = s;
7552
- this.recovery = recovery;
7553
- this.assertValidity();
7571
+ if (recovery != null)
7572
+ this.recovery = recovery;
7573
+ Object.freeze(this);
7554
7574
  }
7555
7575
  static fromCompact(hex) {
7556
7576
  const l = CURVE.nByteLength;
7557
- hex = (0, utils_js_1.ensureBytes)("compactSignature", hex, l * 2);
7577
+ hex = (0, utils_ts_1.ensureBytes)("compactSignature", hex, l * 2);
7558
7578
  return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
7559
7579
  }
7560
7580
  static fromDER(hex) {
7561
- const { r, s } = exports.DER.toSig((0, utils_js_1.ensureBytes)("DER", hex));
7581
+ const { r, s } = exports.DER.toSig((0, utils_ts_1.ensureBytes)("DER", hex));
7562
7582
  return new Signature(r, s);
7563
7583
  }
7564
- assertValidity() {
7565
- ut.aInRange("r", this.r, _1n, CURVE_ORDER);
7566
- ut.aInRange("s", this.s, _1n, CURVE_ORDER);
7567
- }
7584
+ assertValidity() {}
7568
7585
  addRecoveryBit(recovery) {
7569
7586
  return new Signature(this.r, this.s, recovery);
7570
7587
  }
7571
7588
  recoverPublicKey(msgHash) {
7572
7589
  const { r, s, recovery: rec } = this;
7573
- const h = bits2int_modN((0, utils_js_1.ensureBytes)("msgHash", msgHash));
7590
+ const h = bits2int_modN((0, utils_ts_1.ensureBytes)("msgHash", msgHash));
7574
7591
  if (rec == null || ![0, 1, 2, 3].includes(rec))
7575
7592
  throw new Error("recovery id invalid");
7576
7593
  const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;
7577
7594
  if (radj >= Fp.ORDER)
7578
7595
  throw new Error("recovery id 2 or 3 invalid");
7579
7596
  const prefix = (rec & 1) === 0 ? "02" : "03";
7580
- const R = Point.fromHex(prefix + numToNByteStr(radj));
7597
+ const R = Point.fromHex(prefix + numToNByteHex(radj));
7581
7598
  const ir = invN(radj);
7582
7599
  const u1 = modN(-h * ir);
7583
7600
  const u2 = modN(s * ir);
@@ -7594,16 +7611,16 @@ var require_weierstrass = __commonJS((exports) => {
7594
7611
  return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;
7595
7612
  }
7596
7613
  toDERRawBytes() {
7597
- return ut.hexToBytes(this.toDERHex());
7614
+ return (0, utils_ts_1.hexToBytes)(this.toDERHex());
7598
7615
  }
7599
7616
  toDERHex() {
7600
7617
  return exports.DER.hexFromSig({ r: this.r, s: this.s });
7601
7618
  }
7602
7619
  toCompactRawBytes() {
7603
- return ut.hexToBytes(this.toCompactHex());
7620
+ return (0, utils_ts_1.hexToBytes)(this.toCompactHex());
7604
7621
  }
7605
7622
  toCompactHex() {
7606
- return numToNByteStr(this.r) + numToNByteStr(this.s);
7623
+ return numToNByteHex(this.r) + numToNByteHex(this.s);
7607
7624
  }
7608
7625
  }
7609
7626
  const utils = {
@@ -7617,8 +7634,8 @@ var require_weierstrass = __commonJS((exports) => {
7617
7634
  },
7618
7635
  normPrivateKeyToScalar,
7619
7636
  randomPrivateKey: () => {
7620
- const length = (0, modular_js_1.getMinHashLength)(CURVE.n);
7621
- return (0, modular_js_1.mapHashToField)(CURVE.randomBytes(length), CURVE.n);
7637
+ const length = (0, modular_ts_1.getMinHashLength)(CURVE.n);
7638
+ return (0, modular_ts_1.mapHashToField)(CURVE.randomBytes(length), CURVE.n);
7622
7639
  },
7623
7640
  precompute(windowSize = 8, point = Point.BASE) {
7624
7641
  point._setWindowSize(windowSize);
@@ -7630,7 +7647,7 @@ var require_weierstrass = __commonJS((exports) => {
7630
7647
  return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
7631
7648
  }
7632
7649
  function isProbPub(item) {
7633
- const arr = ut.isBytes(item);
7650
+ const arr = (0, utils_ts_1.isBytes)(item);
7634
7651
  const str = typeof item === "string";
7635
7652
  const len = (arr || str) && item.length;
7636
7653
  if (arr)
@@ -7652,17 +7669,17 @@ var require_weierstrass = __commonJS((exports) => {
7652
7669
  const bits2int = CURVE.bits2int || function(bytes) {
7653
7670
  if (bytes.length > 8192)
7654
7671
  throw new Error("input is too large");
7655
- const num = ut.bytesToNumberBE(bytes);
7672
+ const num = (0, utils_ts_1.bytesToNumberBE)(bytes);
7656
7673
  const delta = bytes.length * 8 - CURVE.nBitLength;
7657
7674
  return delta > 0 ? num >> BigInt(delta) : num;
7658
7675
  };
7659
7676
  const bits2int_modN = CURVE.bits2int_modN || function(bytes) {
7660
7677
  return modN(bits2int(bytes));
7661
7678
  };
7662
- const ORDER_MASK = ut.bitMask(CURVE.nBitLength);
7679
+ const ORDER_MASK = (0, utils_ts_1.bitMask)(CURVE.nBitLength);
7663
7680
  function int2octets(num) {
7664
- ut.aInRange("num < 2^" + CURVE.nBitLength, num, _0n, ORDER_MASK);
7665
- return ut.numberToBytesBE(num, CURVE.nByteLength);
7681
+ (0, utils_ts_1.aInRange)("num < 2^" + CURVE.nBitLength, num, _0n, ORDER_MASK);
7682
+ return (0, utils_ts_1.numberToBytesBE)(num, CURVE.nByteLength);
7666
7683
  }
7667
7684
  function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
7668
7685
  if (["recovered", "canonical"].some((k) => (k in opts)))
@@ -7671,18 +7688,18 @@ var require_weierstrass = __commonJS((exports) => {
7671
7688
  let { lowS, prehash, extraEntropy: ent } = opts;
7672
7689
  if (lowS == null)
7673
7690
  lowS = true;
7674
- msgHash = (0, utils_js_1.ensureBytes)("msgHash", msgHash);
7691
+ msgHash = (0, utils_ts_1.ensureBytes)("msgHash", msgHash);
7675
7692
  validateSigVerOpts(opts);
7676
7693
  if (prehash)
7677
- msgHash = (0, utils_js_1.ensureBytes)("prehashed msgHash", hash(msgHash));
7694
+ msgHash = (0, utils_ts_1.ensureBytes)("prehashed msgHash", hash(msgHash));
7678
7695
  const h1int = bits2int_modN(msgHash);
7679
7696
  const d = normPrivateKeyToScalar(privateKey);
7680
7697
  const seedArgs = [int2octets(d), int2octets(h1int)];
7681
7698
  if (ent != null && ent !== false) {
7682
7699
  const e = ent === true ? randomBytes(Fp.BYTES) : ent;
7683
- seedArgs.push((0, utils_js_1.ensureBytes)("extraEntropy", e));
7700
+ seedArgs.push((0, utils_ts_1.ensureBytes)("extraEntropy", e));
7684
7701
  }
7685
- const seed = ut.concatBytes(...seedArgs);
7702
+ const seed = (0, utils_ts_1.concatBytes)(...seedArgs);
7686
7703
  const m = h1int;
7687
7704
  function k2sig(kBytes) {
7688
7705
  const k = bits2int(kBytes);
@@ -7711,21 +7728,21 @@ var require_weierstrass = __commonJS((exports) => {
7711
7728
  function sign(msgHash, privKey, opts = defaultSigOpts) {
7712
7729
  const { seed, k2sig } = prepSig(msgHash, privKey, opts);
7713
7730
  const C = CURVE;
7714
- const drbg = ut.createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac);
7731
+ const drbg = (0, utils_ts_1.createHmacDrbg)(C.hash.outputLen, C.nByteLength, C.hmac);
7715
7732
  return drbg(seed, k2sig);
7716
7733
  }
7717
7734
  Point.BASE._setWindowSize(8);
7718
7735
  function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
7719
7736
  const sg = signature;
7720
- msgHash = (0, utils_js_1.ensureBytes)("msgHash", msgHash);
7721
- publicKey = (0, utils_js_1.ensureBytes)("publicKey", publicKey);
7737
+ msgHash = (0, utils_ts_1.ensureBytes)("msgHash", msgHash);
7738
+ publicKey = (0, utils_ts_1.ensureBytes)("publicKey", publicKey);
7722
7739
  const { lowS, prehash, format: format2 } = opts;
7723
7740
  validateSigVerOpts(opts);
7724
7741
  if ("strict" in opts)
7725
7742
  throw new Error("options.strict was renamed to lowS");
7726
7743
  if (format2 !== undefined && format2 !== "compact" && format2 !== "der")
7727
7744
  throw new Error("format must be compact or der");
7728
- const isHex = typeof sg === "string" || ut.isBytes(sg);
7745
+ const isHex = typeof sg === "string" || (0, utils_ts_1.isBytes)(sg);
7729
7746
  const isObj = !isHex && !format2 && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
7730
7747
  if (!isHex && !isObj)
7731
7748
  throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
@@ -7840,7 +7857,7 @@ var require_weierstrass = __commonJS((exports) => {
7840
7857
  return sqrtRatio;
7841
7858
  }
7842
7859
  function mapToCurveSimpleSWU(Fp, opts) {
7843
- (0, modular_js_1.validateField)(Fp);
7860
+ (0, modular_ts_1.validateField)(Fp);
7844
7861
  if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))
7845
7862
  throw new Error("mapToCurveSimpleSWU: invalid opts");
7846
7863
  const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);
@@ -7886,7 +7903,7 @@ var require__shortw_utils = __commonJS((exports) => {
7886
7903
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7887
7904
  var hmac_1 = require_hmac();
7888
7905
  var utils_1 = require_utils4();
7889
- var weierstrass_js_1 = require_weierstrass();
7906
+ var weierstrass_ts_1 = require_weierstrass();
7890
7907
  function getHash(hash) {
7891
7908
  return {
7892
7909
  hash,
@@ -7895,7 +7912,7 @@ var require__shortw_utils = __commonJS((exports) => {
7895
7912
  };
7896
7913
  }
7897
7914
  function createCurve(curveDef, defHash) {
7898
- const create = (hash) => (0, weierstrass_js_1.weierstrass)({ ...curveDef, ...getHash(hash) });
7915
+ const create = (hash) => (0, weierstrass_ts_1.weierstrass)({ ...curveDef, ...getHash(hash) });
7899
7916
  return { ...create(defHash), create };
7900
7917
  }
7901
7918
  });
@@ -7905,13 +7922,13 @@ var require_secp256k1 = __commonJS((exports) => {
7905
7922
  Object.defineProperty(exports, "__esModule", { value: true });
7906
7923
  exports.encodeToCurve = exports.hashToCurve = exports.schnorr = exports.secp256k1 = undefined;
7907
7924
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
7908
- var sha256_1 = require_sha256();
7925
+ var sha2_1 = require_sha2();
7909
7926
  var utils_1 = require_utils4();
7910
- var _shortw_utils_js_1 = require__shortw_utils();
7911
- var hash_to_curve_js_1 = require_hash_to_curve();
7912
- var modular_js_1 = require_modular();
7913
- var utils_js_1 = require_utils5();
7914
- var weierstrass_js_1 = require_weierstrass();
7927
+ var _shortw_utils_ts_1 = require__shortw_utils();
7928
+ var hash_to_curve_ts_1 = require_hash_to_curve();
7929
+ var modular_ts_1 = require_modular();
7930
+ var utils_ts_1 = require_utils5();
7931
+ var weierstrass_ts_1 = require_weierstrass();
7915
7932
  var secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
7916
7933
  var secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
7917
7934
  var _1n = BigInt(1);
@@ -7923,24 +7940,24 @@ var require_secp256k1 = __commonJS((exports) => {
7923
7940
  const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
7924
7941
  const b2 = y * y * y % P;
7925
7942
  const b3 = b2 * b2 * y % P;
7926
- const b6 = (0, modular_js_1.pow2)(b3, _3n, P) * b3 % P;
7927
- const b9 = (0, modular_js_1.pow2)(b6, _3n, P) * b3 % P;
7928
- const b11 = (0, modular_js_1.pow2)(b9, _2n, P) * b2 % P;
7929
- const b22 = (0, modular_js_1.pow2)(b11, _11n, P) * b11 % P;
7930
- const b44 = (0, modular_js_1.pow2)(b22, _22n, P) * b22 % P;
7931
- const b88 = (0, modular_js_1.pow2)(b44, _44n, P) * b44 % P;
7932
- const b176 = (0, modular_js_1.pow2)(b88, _88n, P) * b88 % P;
7933
- const b220 = (0, modular_js_1.pow2)(b176, _44n, P) * b44 % P;
7934
- const b223 = (0, modular_js_1.pow2)(b220, _3n, P) * b3 % P;
7935
- const t1 = (0, modular_js_1.pow2)(b223, _23n, P) * b22 % P;
7936
- const t2 = (0, modular_js_1.pow2)(t1, _6n, P) * b2 % P;
7937
- const root = (0, modular_js_1.pow2)(t2, _2n, P);
7943
+ const b6 = (0, modular_ts_1.pow2)(b3, _3n, P) * b3 % P;
7944
+ const b9 = (0, modular_ts_1.pow2)(b6, _3n, P) * b3 % P;
7945
+ const b11 = (0, modular_ts_1.pow2)(b9, _2n, P) * b2 % P;
7946
+ const b22 = (0, modular_ts_1.pow2)(b11, _11n, P) * b11 % P;
7947
+ const b44 = (0, modular_ts_1.pow2)(b22, _22n, P) * b22 % P;
7948
+ const b88 = (0, modular_ts_1.pow2)(b44, _44n, P) * b44 % P;
7949
+ const b176 = (0, modular_ts_1.pow2)(b88, _88n, P) * b88 % P;
7950
+ const b220 = (0, modular_ts_1.pow2)(b176, _44n, P) * b44 % P;
7951
+ const b223 = (0, modular_ts_1.pow2)(b220, _3n, P) * b3 % P;
7952
+ const t1 = (0, modular_ts_1.pow2)(b223, _23n, P) * b22 % P;
7953
+ const t2 = (0, modular_ts_1.pow2)(t1, _6n, P) * b2 % P;
7954
+ const root = (0, modular_ts_1.pow2)(t2, _2n, P);
7938
7955
  if (!Fpk1.eql(Fpk1.sqr(root), y))
7939
7956
  throw new Error("Cannot find square root");
7940
7957
  return root;
7941
7958
  }
7942
- var Fpk1 = (0, modular_js_1.Field)(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
7943
- exports.secp256k1 = (0, _shortw_utils_js_1.createCurve)({
7959
+ var Fpk1 = (0, modular_ts_1.Field)(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
7960
+ exports.secp256k1 = (0, _shortw_utils_ts_1.createCurve)({
7944
7961
  a: BigInt(0),
7945
7962
  b: BigInt(7),
7946
7963
  Fp: Fpk1,
@@ -7960,8 +7977,8 @@ var require_secp256k1 = __commonJS((exports) => {
7960
7977
  const POW_2_128 = BigInt("0x100000000000000000000000000000000");
7961
7978
  const c1 = divNearest(b2 * k, n);
7962
7979
  const c2 = divNearest(-b1 * k, n);
7963
- let k1 = (0, modular_js_1.mod)(k - c1 * a1 - c2 * a2, n);
7964
- let k2 = (0, modular_js_1.mod)(-c1 * b1 - c2 * b2, n);
7980
+ let k1 = (0, modular_ts_1.mod)(k - c1 * a1 - c2 * a2, n);
7981
+ let k2 = (0, modular_ts_1.mod)(-c1 * b1 - c2 * b2, n);
7965
7982
  const k1neg = k1 > POW_2_128;
7966
7983
  const k2neg = k2 > POW_2_128;
7967
7984
  if (k1neg)
@@ -7974,22 +7991,22 @@ var require_secp256k1 = __commonJS((exports) => {
7974
7991
  return { k1neg, k1, k2neg, k2 };
7975
7992
  }
7976
7993
  }
7977
- }, sha256_1.sha256);
7994
+ }, sha2_1.sha256);
7978
7995
  var _0n = BigInt(0);
7979
7996
  var TAGGED_HASH_PREFIXES = {};
7980
7997
  function taggedHash(tag, ...messages) {
7981
7998
  let tagP = TAGGED_HASH_PREFIXES[tag];
7982
7999
  if (tagP === undefined) {
7983
- const tagH = (0, sha256_1.sha256)(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
7984
- tagP = (0, utils_js_1.concatBytes)(tagH, tagH);
8000
+ const tagH = (0, sha2_1.sha256)(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
8001
+ tagP = (0, utils_ts_1.concatBytes)(tagH, tagH);
7985
8002
  TAGGED_HASH_PREFIXES[tag] = tagP;
7986
8003
  }
7987
- return (0, sha256_1.sha256)((0, utils_js_1.concatBytes)(tagP, ...messages));
8004
+ return (0, sha2_1.sha256)((0, utils_ts_1.concatBytes)(tagP, ...messages));
7988
8005
  }
7989
8006
  var pointToBytes = (point) => point.toRawBytes(true).slice(1);
7990
- var numTo32b = (n) => (0, utils_js_1.numberToBytesBE)(n, 32);
7991
- var modP = (x) => (0, modular_js_1.mod)(x, secp256k1P);
7992
- var modN = (x) => (0, modular_js_1.mod)(x, secp256k1N);
8007
+ var numTo32b = (n) => (0, utils_ts_1.numberToBytesBE)(n, 32);
8008
+ var modP = (x) => (0, modular_ts_1.mod)(x, secp256k1P);
8009
+ var modN = (x) => (0, modular_ts_1.mod)(x, secp256k1N);
7993
8010
  var Point = exports.secp256k1.ProjectivePoint;
7994
8011
  var GmulAdd = (Q, a, b) => Point.BASE.multiplyAndAddUnsafe(Q, a, b);
7995
8012
  function schnorrGetExtPubKey(priv) {
@@ -7999,7 +8016,7 @@ var require_secp256k1 = __commonJS((exports) => {
7999
8016
  return { scalar, bytes: pointToBytes(p) };
8000
8017
  }
8001
8018
  function lift_x(x) {
8002
- (0, utils_js_1.aInRange)("x", x, _1n, secp256k1P);
8019
+ (0, utils_ts_1.aInRange)("x", x, _1n, secp256k1P);
8003
8020
  const xx = modP(x * x);
8004
8021
  const c = modP(xx * x + BigInt(7));
8005
8022
  let y = sqrtMod(c);
@@ -8009,7 +8026,7 @@ var require_secp256k1 = __commonJS((exports) => {
8009
8026
  p.assertValidity();
8010
8027
  return p;
8011
8028
  }
8012
- var num = utils_js_1.bytesToNumberBE;
8029
+ var num = utils_ts_1.bytesToNumberBE;
8013
8030
  function challenge(...args) {
8014
8031
  return modN(num(taggedHash("BIP0340/challenge", ...args)));
8015
8032
  }
@@ -8017,9 +8034,9 @@ var require_secp256k1 = __commonJS((exports) => {
8017
8034
  return schnorrGetExtPubKey(privateKey).bytes;
8018
8035
  }
8019
8036
  function schnorrSign(message, privateKey, auxRand = (0, utils_1.randomBytes)(32)) {
8020
- const m = (0, utils_js_1.ensureBytes)("message", message);
8037
+ const m = (0, utils_ts_1.ensureBytes)("message", message);
8021
8038
  const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey);
8022
- const a = (0, utils_js_1.ensureBytes)("auxRand", auxRand, 32);
8039
+ const a = (0, utils_ts_1.ensureBytes)("auxRand", auxRand, 32);
8023
8040
  const t = numTo32b(d ^ num(taggedHash("BIP0340/aux", a)));
8024
8041
  const rand = taggedHash("BIP0340/nonce", t, px, m);
8025
8042
  const k_ = modN(num(rand));
@@ -8035,16 +8052,16 @@ var require_secp256k1 = __commonJS((exports) => {
8035
8052
  return sig;
8036
8053
  }
8037
8054
  function schnorrVerify(signature, message, publicKey) {
8038
- const sig = (0, utils_js_1.ensureBytes)("signature", signature, 64);
8039
- const m = (0, utils_js_1.ensureBytes)("message", message);
8040
- const pub = (0, utils_js_1.ensureBytes)("publicKey", publicKey, 32);
8055
+ const sig = (0, utils_ts_1.ensureBytes)("signature", signature, 64);
8056
+ const m = (0, utils_ts_1.ensureBytes)("message", message);
8057
+ const pub = (0, utils_ts_1.ensureBytes)("publicKey", publicKey, 32);
8041
8058
  try {
8042
8059
  const P = lift_x(num(pub));
8043
8060
  const r = num(sig.subarray(0, 32));
8044
- if (!(0, utils_js_1.inRange)(r, _1n, secp256k1P))
8061
+ if (!(0, utils_ts_1.inRange)(r, _1n, secp256k1P))
8045
8062
  return false;
8046
8063
  const s = num(sig.subarray(32, 64));
8047
- if (!(0, utils_js_1.inRange)(s, _1n, secp256k1N))
8064
+ if (!(0, utils_ts_1.inRange)(s, _1n, secp256k1N))
8048
8065
  return false;
8049
8066
  const e = challenge(numTo32b(r), pointToBytes(P), m);
8050
8067
  const R = GmulAdd(P, s, modN(-e));
@@ -8063,13 +8080,13 @@ var require_secp256k1 = __commonJS((exports) => {
8063
8080
  randomPrivateKey: exports.secp256k1.utils.randomPrivateKey,
8064
8081
  lift_x,
8065
8082
  pointToBytes,
8066
- numberToBytesBE: utils_js_1.numberToBytesBE,
8067
- bytesToNumberBE: utils_js_1.bytesToNumberBE,
8083
+ numberToBytesBE: utils_ts_1.numberToBytesBE,
8084
+ bytesToNumberBE: utils_ts_1.bytesToNumberBE,
8068
8085
  taggedHash,
8069
- mod: modular_js_1.mod
8086
+ mod: modular_ts_1.mod
8070
8087
  }
8071
8088
  }))();
8072
- var isoMap = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.isogenyMap)(Fpk1, [
8089
+ var isoMap = /* @__PURE__ */ (() => (0, hash_to_curve_ts_1.isogenyMap)(Fpk1, [
8073
8090
  [
8074
8091
  "0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7",
8075
8092
  "0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581",
@@ -8094,12 +8111,12 @@ var require_secp256k1 = __commonJS((exports) => {
8094
8111
  "0x0000000000000000000000000000000000000000000000000000000000000001"
8095
8112
  ]
8096
8113
  ].map((i) => i.map((j) => BigInt(j)))))();
8097
- var mapSWU = /* @__PURE__ */ (() => (0, weierstrass_js_1.mapToCurveSimpleSWU)(Fpk1, {
8114
+ var mapSWU = /* @__PURE__ */ (() => (0, weierstrass_ts_1.mapToCurveSimpleSWU)(Fpk1, {
8098
8115
  A: BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),
8099
8116
  B: BigInt("1771"),
8100
8117
  Z: Fpk1.create(BigInt("-11"))
8101
8118
  }))();
8102
- var htf = /* @__PURE__ */ (() => (0, hash_to_curve_js_1.createHasher)(exports.secp256k1.ProjectivePoint, (scalars) => {
8119
+ var htf = /* @__PURE__ */ (() => (0, hash_to_curve_ts_1.createHasher)(exports.secp256k1.ProjectivePoint, (scalars) => {
8103
8120
  const { x, y } = mapSWU(Fpk1.create(scalars[0]));
8104
8121
  return isoMap(x, y);
8105
8122
  }, {
@@ -8109,7 +8126,7 @@ var require_secp256k1 = __commonJS((exports) => {
8109
8126
  m: 1,
8110
8127
  k: 128,
8111
8128
  expand: "xmd",
8112
- hash: sha256_1.sha256
8129
+ hash: sha2_1.sha256
8113
8130
  }))();
8114
8131
  exports.hashToCurve = (() => htf.hashToCurve)();
8115
8132
  exports.encodeToCurve = (() => htf.encodeToCurve)();
@@ -8232,27 +8249,27 @@ var require_hkdf = __commonJS((exports) => {
8232
8249
  exports.hkdf = undefined;
8233
8250
  exports.extract = extract;
8234
8251
  exports.expand = expand;
8235
- var _assert_js_1 = require__assert2();
8236
- var hmac_js_1 = require_hmac();
8237
- var utils_js_1 = require_utils4();
8252
+ var _assert_ts_1 = require__assert2();
8253
+ var hmac_ts_1 = require_hmac();
8254
+ var utils_ts_1 = require_utils4();
8238
8255
  function extract(hash, ikm, salt) {
8239
- (0, _assert_js_1.ahash)(hash);
8256
+ (0, _assert_ts_1.ahash)(hash);
8240
8257
  if (salt === undefined)
8241
8258
  salt = new Uint8Array(hash.outputLen);
8242
- return (0, hmac_js_1.hmac)(hash, (0, utils_js_1.toBytes)(salt), (0, utils_js_1.toBytes)(ikm));
8259
+ return (0, hmac_ts_1.hmac)(hash, (0, utils_ts_1.toBytes)(salt), (0, utils_ts_1.toBytes)(ikm));
8243
8260
  }
8244
8261
  var HKDF_COUNTER = /* @__PURE__ */ new Uint8Array([0]);
8245
8262
  var EMPTY_BUFFER = /* @__PURE__ */ new Uint8Array;
8246
8263
  function expand(hash, prk, info, length = 32) {
8247
- (0, _assert_js_1.ahash)(hash);
8248
- (0, _assert_js_1.anumber)(length);
8264
+ (0, _assert_ts_1.ahash)(hash);
8265
+ (0, _assert_ts_1.anumber)(length);
8249
8266
  if (length > 255 * hash.outputLen)
8250
8267
  throw new Error("Length should be <= 255*HashLen");
8251
8268
  const blocks = Math.ceil(length / hash.outputLen);
8252
8269
  if (info === undefined)
8253
8270
  info = EMPTY_BUFFER;
8254
8271
  const okm = new Uint8Array(blocks * hash.outputLen);
8255
- const HMAC = hmac_js_1.hmac.create(hash, prk);
8272
+ const HMAC = hmac_ts_1.hmac.create(hash, prk);
8256
8273
  const HMACTmp = HMAC._cloneInto();
8257
8274
  const T = new Uint8Array(HMAC.outputLen);
8258
8275
  for (let counter = 0;counter < blocks; counter++) {
@@ -9088,7 +9105,7 @@ var require_parse2 = __commonJS((exports, module) => {
9088
9105
  // ../../node_modules/@dotenvx/dotenvx/src/lib/helpers/dotenvParse.js
9089
9106
  var require_dotenvParse = __commonJS((exports, module) => {
9090
9107
  var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
9091
- function dotenvParse(src, skipExpandForDoubleQuotes = false, skipConvertingWindowsNewlines = false) {
9108
+ function dotenvParse(src, skipExpandForDoubleQuotes = false, skipConvertingWindowsNewlines = false, collectAllValues = false) {
9092
9109
  const obj = {};
9093
9110
  let lines = src.toString();
9094
9111
  if (!skipConvertingWindowsNewlines) {
@@ -9108,7 +9125,12 @@ var require_dotenvParse = __commonJS((exports, module) => {
9108
9125
  value = value.replace(/\\r/g, "\r");
9109
9126
  value = value.replace(/\\t/g, "\t");
9110
9127
  }
9111
- obj[key] = value;
9128
+ if (collectAllValues) {
9129
+ obj[key] = obj[key] || [];
9130
+ obj[key].push(value);
9131
+ } else {
9132
+ obj[key] = value;
9133
+ }
9112
9134
  }
9113
9135
  return obj;
9114
9136
  }
@@ -31162,6 +31184,23 @@ var require_lib4 = __commonJS((exports, module) => {
31162
31184
  var fromUrl = require_from_url();
31163
31185
  var parseUrl = require_parse_url();
31164
31186
  var cache = new LRUCache2({ max: 1000 });
31187
+ function unknownHostedUrl(url) {
31188
+ try {
31189
+ const {
31190
+ protocol,
31191
+ hostname,
31192
+ pathname
31193
+ } = new URL(url);
31194
+ if (!hostname) {
31195
+ return null;
31196
+ }
31197
+ const proto = /(?:git\+)http:$/.test(protocol) ? "http:" : "https:";
31198
+ const path6 = pathname.replace(/\.git$/, "");
31199
+ return `${proto}//${hostname}${path6}`;
31200
+ } catch {
31201
+ return null;
31202
+ }
31203
+ }
31165
31204
 
31166
31205
  class GitHost {
31167
31206
  constructor(type2, user, auth, project, committish, defaultRepresentation, opts = {}) {
@@ -31205,6 +31244,22 @@ var require_lib4 = __commonJS((exports, module) => {
31205
31244
  }
31206
31245
  return cache.get(key2);
31207
31246
  }
31247
+ static fromManifest(manifest, opts = {}) {
31248
+ if (!manifest || typeof manifest !== "object") {
31249
+ return;
31250
+ }
31251
+ const r2 = manifest.repository;
31252
+ const rurl = r2 && (typeof r2 === "string" ? r2 : typeof r2 === "object" && typeof r2.url === "string" ? r2.url : null);
31253
+ if (!rurl) {
31254
+ throw new Error("no repository");
31255
+ }
31256
+ const info = rurl && GitHost.fromUrl(rurl.replace(/^git\+/, ""), opts) || null;
31257
+ if (info) {
31258
+ return info;
31259
+ }
31260
+ const unk = unknownHostedUrl(rurl);
31261
+ return GitHost.fromUrl(unk, opts) || unk;
31262
+ }
31208
31263
  static parseUrl(url) {
31209
31264
  return parseUrl(url);
31210
31265
  }
@@ -245278,7 +245333,7 @@ function pruneCurrentEnv(currentEnv, env2) {
245278
245333
  var package_default = {
245279
245334
  name: "@settlemint/sdk-cli",
245280
245335
  description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
245281
- version: "2.1.1-prc71cad32",
245336
+ version: "2.1.1-prcb1d9c8d",
245282
245337
  type: "module",
245283
245338
  private: false,
245284
245339
  license: "FSL-1.1-MIT",
@@ -245327,8 +245382,8 @@ var package_default = {
245327
245382
  "@inquirer/input": "4.1.9",
245328
245383
  "@inquirer/password": "4.0.12",
245329
245384
  "@inquirer/select": "4.1.1",
245330
- "@settlemint/sdk-js": "2.1.1-prc71cad32",
245331
- "@settlemint/sdk-utils": "2.1.1-prc71cad32",
245385
+ "@settlemint/sdk-js": "2.1.1-prcb1d9c8d",
245386
+ "@settlemint/sdk-utils": "2.1.1-prcb1d9c8d",
245332
245387
  "@types/node": "22.14.1",
245333
245388
  "@types/semver": "7.7.0",
245334
245389
  "@types/which": "3.0.4",
@@ -248684,24 +248739,18 @@ function generateResponse(pincode, salt, challenge) {
248684
248739
  const hashedPincode = hashPincode(pincode, salt);
248685
248740
  return createHash("sha256").update(`${hashedPincode}_${challenge}`).digest("hex");
248686
248741
  }
248687
- async function getPincodeVerificationResponse({
248742
+ async function getPincodeVerificationChallenges({
248688
248743
  userWalletAddress,
248689
- pincode,
248690
248744
  accessToken,
248691
248745
  instance,
248692
248746
  nodeId
248693
248747
  }) {
248694
- const response = await fetch(`${instance}/cm/nodes/${encodeURIComponent(nodeId)}/user-wallets/${encodeURIComponent(userWalletAddress)}/verifications/challenges`, {
248748
+ const response = await fetch(`${instance}/cm/nodes/${encodeURIComponent(nodeId)}/user-wallets/${encodeURIComponent(userWalletAddress)}/verifications/challenges?type=PINCODE`, {
248695
248749
  method: "POST",
248696
248750
  headers: {
248697
248751
  "Content-Type": "application/json",
248698
248752
  "x-auth-token": accessToken
248699
- },
248700
- body: JSON.stringify({
248701
- pincode,
248702
- verificationType: "PINCODE",
248703
- name: "pincode"
248704
- })
248753
+ }
248705
248754
  });
248706
248755
  if (!response.ok) {
248707
248756
  if (response.status === 404) {
@@ -248710,15 +248759,16 @@ async function getPincodeVerificationResponse({
248710
248759
  throw new Error("Failed to get verification challenge");
248711
248760
  }
248712
248761
  const verificationChallenges = await response.json();
248713
- if (!verificationChallenges.length) {
248714
- throw new Error("No verification challenges received");
248715
- }
248716
- const firstChallenge = verificationChallenges[0];
248717
- const challenge = firstChallenge?.challenge;
248718
- if (!challenge?.secret || !challenge?.salt) {
248762
+ return verificationChallenges;
248763
+ }
248764
+ function getPincodeVerificationChallengeResponse({
248765
+ verificationChallenge,
248766
+ pincode
248767
+ }) {
248768
+ if (!verificationChallenge?.challenge?.secret || !verificationChallenge?.challenge?.salt) {
248719
248769
  throw new Error("Could not authenticate pin code, invalid challenge format");
248720
248770
  }
248721
- const { secret, salt } = challenge;
248771
+ const { secret, salt } = verificationChallenge.challenge;
248722
248772
  return generateResponse(pincode, salt, secret);
248723
248773
  }
248724
248774
  function createSettleMintClient(options) {
@@ -248820,7 +248870,8 @@ function createSettleMintClient(options) {
248820
248870
  config: getPlatformConfig(gqlClient)
248821
248871
  },
248822
248872
  wallet: {
248823
- pincodeVerificationResponse: (args) => getPincodeVerificationResponse({
248873
+ pincodeVerificationChallengeResponse: getPincodeVerificationChallengeResponse,
248874
+ pincodeVerificationChallenges: (args) => getPincodeVerificationChallenges({
248824
248875
  ...args,
248825
248876
  instance: validatedOptions.instance,
248826
248877
  accessToken: validatedOptions.accessToken
@@ -248855,6 +248906,7 @@ var LOCKS = {
248855
248906
  "bun.lockb": "bun",
248856
248907
  "deno.lock": "deno",
248857
248908
  "pnpm-lock.yaml": "pnpm",
248909
+ "pnpm-workspace.yaml": "pnpm",
248858
248910
  "yarn.lock": "yarn",
248859
248911
  "package-lock.json": "npm",
248860
248912
  "npm-shrinkwrap.json": "npm"
@@ -251894,7 +251946,6 @@ async function codegenMinio(env2) {
251894
251946
 
251895
251947
  export const { client } = createServerMinioClient({
251896
251948
  instance: process.env.SETTLEMINT_MINIO_ENDPOINT!,
251897
- accessToken: process.env.SETTLEMINT_ACCESS_TOKEN!,
251898
251949
  accessKey: process.env.SETTLEMINT_MINIO_ACCESS_KEY!,
251899
251950
  secretKey: process.env.SETTLEMINT_MINIO_SECRET_KEY!
251900
251951
  });`;
@@ -256500,6 +256551,27 @@ function logoutCommand() {
256500
256551
  });
256501
256552
  }
256502
256553
 
256554
+ // src/prompts/pincode-verification.prompt.ts
256555
+ async function pincodeVerificationPrompt(verificationChallenges) {
256556
+ if (verificationChallenges.length === 0) {
256557
+ cancel2("No pincode is configured");
256558
+ }
256559
+ if (verificationChallenges.length === 1) {
256560
+ return verificationChallenges[0];
256561
+ }
256562
+ const verificationChallenge = await esm_default3({
256563
+ message: "Which pincode verification do you want to use?",
256564
+ choices: verificationChallenges.map((verificationChallenge2) => ({
256565
+ name: verificationChallenge2.name,
256566
+ value: verificationChallenge2
256567
+ }))
256568
+ });
256569
+ if (!verificationChallenge) {
256570
+ cancel2("No pincode verification challenge selected");
256571
+ }
256572
+ return verificationChallenge;
256573
+ }
256574
+
256503
256575
  // src/commands/pincode-verification-response.ts
256504
256576
  function pincodeVerificationResponseCommand() {
256505
256577
  return new Command("pincode-verification-response").alias("pvr").description("Get pincode verification response for a blockchain node").requiredOption("--wallet-address <walletAddress>", "The wallet address to get pincode verification response for").option("-i, --instance <instance>", "The instance to connect to (defaults to the instance in the .env file)").option("--blockchain-node <blockchainNode>", "Blockchain Node unique name to get pincode verification response for").action(async ({ instance, blockchainNode, walletAddress }) => {
@@ -256531,6 +256603,11 @@ function pincodeVerificationResponseCommand() {
256531
256603
  return nothingSelectedError("blockchain node");
256532
256604
  }
256533
256605
  }
256606
+ const pincodeVerificationChallenges = await settlemint.wallet.pincodeVerificationChallenges({
256607
+ userWalletAddress: walletAddress,
256608
+ nodeId: selectedBlockchainNode.id
256609
+ });
256610
+ const verificationChallenge = await pincodeVerificationPrompt(pincodeVerificationChallenges);
256534
256611
  const pincode = await esm_default5({
256535
256612
  message: "Enter your pincode",
256536
256613
  validate(value4) {
@@ -256540,10 +256617,9 @@ function pincodeVerificationResponseCommand() {
256540
256617
  return true;
256541
256618
  }
256542
256619
  });
256543
- const pincodeVerificationResponse = await settlemint.wallet.pincodeVerificationResponse({
256544
- userWalletAddress: walletAddress,
256545
- pincode,
256546
- nodeId: selectedBlockchainNode.id
256620
+ const pincodeVerificationResponse = settlemint.wallet.pincodeVerificationChallengeResponse({
256621
+ verificationChallenge,
256622
+ pincode
256547
256623
  });
256548
256624
  note(`Pincode verification response: ${pincodeVerificationResponse}`);
256549
256625
  outro("Pincode verification response generated");
@@ -256597,7 +256673,7 @@ async function waitForCompletion({
256597
256673
  } else {
256598
256674
  note(`${capitalizeFirstLetter2(type4)} failed to ${getActionLabel(action)}`);
256599
256675
  }
256600
- return true;
256676
+ return false;
256601
256677
  }
256602
256678
  if (spinner2) {
256603
256679
  spinner2.text = `${capitalizeFirstLetter2(type4)} is not ready yet (status: ${resource.status})`;
@@ -259873,4 +259949,4 @@ async function sdkCliCommand(argv = process.argv) {
259873
259949
  // src/cli.ts
259874
259950
  sdkCliCommand();
259875
259951
 
259876
- //# debugId=74B3AFA75E7CA76164756E2164756E21
259952
+ //# debugId=557B9B3595B2199D64756E2164756E21