@toon-protocol/townhouse 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,6 +25,7 @@ import {
25
25
  u32
26
26
  } from "./chunk-5O4SBV5O.js";
27
27
  import {
28
+ ACCOUNT_INDEX_APEX,
28
29
  ACCOUNT_INDEX_DVM,
29
30
  ACCOUNT_INDEX_MILL,
30
31
  ACCOUNT_INDEX_TOWN,
@@ -34,7 +35,7 @@ import {
34
35
  MILL_HEALTH_PORT,
35
36
  NODE_BTP_PORT,
36
37
  TOWN_HEALTH_PORT
37
- } from "./chunk-NZR5C3KD.js";
38
+ } from "./chunk-RCHQDZBZ.js";
38
39
  import {
39
40
  __commonJS,
40
41
  __require,
@@ -6489,11 +6490,13 @@ function validateConfig(raw) {
6489
6490
  `${path}.tokenAddress must match /^0x[a-fA-F0-9]+$/`
6490
6491
  );
6491
6492
  }
6492
- assertString(entry["keyId"], `${path}.keyId`);
6493
- if (!HEX_ADDRESS.test(entry["keyId"])) {
6494
- throw new ConfigValidationError(
6495
- `${path}.keyId must match /^0x[a-fA-F0-9]+$/`
6496
- );
6493
+ if (entry["keyId"] !== void 0) {
6494
+ assertString(entry["keyId"], `${path}.keyId`);
6495
+ if (!HEX_ADDRESS.test(entry["keyId"])) {
6496
+ throw new ConfigValidationError(
6497
+ `${path}.keyId must match /^0x[a-fA-F0-9]+$/`
6498
+ );
6499
+ }
6497
6500
  }
6498
6501
  return {
6499
6502
  chainType: "evm",
@@ -6501,13 +6504,15 @@ function validateConfig(raw) {
6501
6504
  rpcUrl: entry["rpcUrl"],
6502
6505
  registryAddress: entry["registryAddress"],
6503
6506
  tokenAddress: entry["tokenAddress"],
6504
- keyId: entry["keyId"]
6507
+ ...entry["keyId"] !== void 0 ? { keyId: entry["keyId"] } : {}
6505
6508
  };
6506
6509
  }
6507
6510
  if (chainType === "solana") {
6508
6511
  assertString(entry["rpcUrl"], `${path}.rpcUrl`);
6509
6512
  assertString(entry["programId"], `${path}.programId`);
6510
- assertString(entry["keyId"], `${path}.keyId`);
6513
+ if (entry["keyId"] !== void 0) {
6514
+ assertString(entry["keyId"], `${path}.keyId`);
6515
+ }
6511
6516
  if (entry["wsUrl"] !== void 0) {
6512
6517
  assertString(entry["wsUrl"], `${path}.wsUrl`);
6513
6518
  }
@@ -6521,7 +6526,7 @@ function validateConfig(raw) {
6521
6526
  ...entry["wsUrl"] !== void 0 ? { wsUrl: entry["wsUrl"] } : {},
6522
6527
  programId: entry["programId"],
6523
6528
  ...entry["tokenMint"] !== void 0 ? { tokenMint: entry["tokenMint"] } : {},
6524
- keyId: entry["keyId"]
6529
+ ...entry["keyId"] !== void 0 ? { keyId: entry["keyId"] } : {}
6525
6530
  };
6526
6531
  }
6527
6532
  assertString(entry["graphqlUrl"], `${path}.graphqlUrl`);
@@ -6809,7 +6814,7 @@ var ConnectorConfigGenerator = class {
6809
6814
  rpcUrl: p.rpcUrl,
6810
6815
  registryAddress: p.registryAddress,
6811
6816
  tokenAddress: p.tokenAddress,
6812
- keyId: p.keyId
6817
+ ...p.keyId !== void 0 ? { keyId: p.keyId } : {}
6813
6818
  };
6814
6819
  }
6815
6820
  if (p.chainType === "solana") {
@@ -6820,7 +6825,7 @@ var ConnectorConfigGenerator = class {
6820
6825
  ...p.wsUrl !== void 0 ? { wsUrl: p.wsUrl } : {},
6821
6826
  programId: p.programId,
6822
6827
  ...p.tokenMint !== void 0 ? { tokenMint: p.tokenMint } : {},
6823
- keyId: p.keyId
6828
+ ...p.keyId !== void 0 ? { keyId: p.keyId } : {}
6824
6829
  };
6825
6830
  }
6826
6831
  return {
@@ -8754,9 +8759,45 @@ var import_websocket_server = __toESM(require_websocket_server(), 1);
8754
8759
 
8755
8760
  // ../core/dist/index.js
8756
8761
  import { getPublicKey as getPublicKey2, verifyEvent } from "nostr-tools/pure";
8757
- import { SimplePool as SimplePool3 } from "nostr-tools/pool";
8758
- import { getPublicKey as getPublicKey3 } from "nostr-tools/pure";
8759
- import { getPublicKey as getPublicKey4 } from "nostr-tools/pure";
8762
+
8763
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js
8764
+ var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
8765
+ var _32n = /* @__PURE__ */ BigInt(32);
8766
+ function fromBig(n, le = false) {
8767
+ if (le)
8768
+ return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
8769
+ return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
8770
+ }
8771
+ function split2(lst, le = false) {
8772
+ const len = lst.length;
8773
+ let Ah = new Uint32Array(len);
8774
+ let Al = new Uint32Array(len);
8775
+ for (let i = 0; i < len; i++) {
8776
+ const { h, l } = fromBig(lst[i], le);
8777
+ [Ah[i], Al[i]] = [h, l];
8778
+ }
8779
+ return [Ah, Al];
8780
+ }
8781
+ var shrSH = (h, _l, s) => h >>> s;
8782
+ var shrSL = (h, l, s) => h << 32 - s | l >>> s;
8783
+ var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
8784
+ var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
8785
+ var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
8786
+ var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
8787
+ var rotlSH2 = (h, l, s) => h << s | l >>> 32 - s;
8788
+ var rotlSL2 = (h, l, s) => l << s | h >>> 32 - s;
8789
+ var rotlBH2 = (h, l, s) => l << s - 32 | h >>> 64 - s;
8790
+ var rotlBL2 = (h, l, s) => h << s - 32 | l >>> 64 - s;
8791
+ function add(Ah, Al, Bh, Bl) {
8792
+ const l = (Al >>> 0) + (Bl >>> 0);
8793
+ return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
8794
+ }
8795
+ var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
8796
+ var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
8797
+ var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
8798
+ var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
8799
+ var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
8800
+ var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
8760
8801
 
8761
8802
  // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/utils.js
8762
8803
  function isBytes2(a) {
@@ -8923,121 +8964,190 @@ var oidNist = (suffix) => ({
8923
8964
  oid: Uint8Array.from([6, 9, 96, 134, 72, 1, 101, 3, 4, 2, suffix])
8924
8965
  });
8925
8966
 
8926
- // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/hmac.js
8927
- var _HMAC = class {
8928
- oHash;
8929
- iHash;
8930
- blockLen;
8931
- outputLen;
8967
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/sha3.js
8968
+ var _0n = BigInt(0);
8969
+ var _1n = BigInt(1);
8970
+ var _2n = BigInt(2);
8971
+ var _7n = BigInt(7);
8972
+ var _256n = BigInt(256);
8973
+ var _0x71n = BigInt(113);
8974
+ var SHA3_PI = [];
8975
+ var SHA3_ROTL = [];
8976
+ var _SHA3_IOTA = [];
8977
+ for (let round = 0, R = _1n, x = 1, y = 0; round < 24; round++) {
8978
+ [x, y] = [y, (2 * x + 3 * y) % 5];
8979
+ SHA3_PI.push(2 * (5 * y + x));
8980
+ SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
8981
+ let t = _0n;
8982
+ for (let j = 0; j < 7; j++) {
8983
+ R = (R << _1n ^ (R >> _7n) * _0x71n) % _256n;
8984
+ if (R & _2n)
8985
+ t ^= _1n << (_1n << BigInt(j)) - _1n;
8986
+ }
8987
+ _SHA3_IOTA.push(t);
8988
+ }
8989
+ var IOTAS = split2(_SHA3_IOTA, true);
8990
+ var SHA3_IOTA_H = IOTAS[0];
8991
+ var SHA3_IOTA_L = IOTAS[1];
8992
+ var rotlH = (h, l, s) => s > 32 ? rotlBH2(h, l, s) : rotlSH2(h, l, s);
8993
+ var rotlL = (h, l, s) => s > 32 ? rotlBL2(h, l, s) : rotlSL2(h, l, s);
8994
+ function keccakP(s, rounds = 24) {
8995
+ const B = new Uint32Array(5 * 2);
8996
+ for (let round = 24 - rounds; round < 24; round++) {
8997
+ for (let x = 0; x < 10; x++)
8998
+ B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
8999
+ for (let x = 0; x < 10; x += 2) {
9000
+ const idx1 = (x + 8) % 10;
9001
+ const idx0 = (x + 2) % 10;
9002
+ const B0 = B[idx0];
9003
+ const B1 = B[idx0 + 1];
9004
+ const Th = rotlH(B0, B1, 1) ^ B[idx1];
9005
+ const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
9006
+ for (let y = 0; y < 50; y += 10) {
9007
+ s[x + y] ^= Th;
9008
+ s[x + y + 1] ^= Tl;
9009
+ }
9010
+ }
9011
+ let curH = s[2];
9012
+ let curL = s[3];
9013
+ for (let t = 0; t < 24; t++) {
9014
+ const shift = SHA3_ROTL[t];
9015
+ const Th = rotlH(curH, curL, shift);
9016
+ const Tl = rotlL(curH, curL, shift);
9017
+ const PI = SHA3_PI[t];
9018
+ curH = s[PI];
9019
+ curL = s[PI + 1];
9020
+ s[PI] = Th;
9021
+ s[PI + 1] = Tl;
9022
+ }
9023
+ for (let y = 0; y < 50; y += 10) {
9024
+ for (let x = 0; x < 10; x++)
9025
+ B[x] = s[y + x];
9026
+ for (let x = 0; x < 10; x++)
9027
+ s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
9028
+ }
9029
+ s[0] ^= SHA3_IOTA_H[round];
9030
+ s[1] ^= SHA3_IOTA_L[round];
9031
+ }
9032
+ clean2(B);
9033
+ }
9034
+ var Keccak = class _Keccak {
9035
+ state;
9036
+ pos = 0;
9037
+ posOut = 0;
8932
9038
  finished = false;
9039
+ state32;
8933
9040
  destroyed = false;
8934
- constructor(hash, key) {
8935
- ahash2(hash);
8936
- abytes2(key, void 0, "key");
8937
- this.iHash = hash.create();
8938
- if (typeof this.iHash.update !== "function")
8939
- throw new Error("Expected instance of class which extends utils.Hash");
8940
- this.blockLen = this.iHash.blockLen;
8941
- this.outputLen = this.iHash.outputLen;
8942
- const blockLen = this.blockLen;
8943
- const pad = new Uint8Array(blockLen);
8944
- pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
8945
- for (let i = 0; i < pad.length; i++)
8946
- pad[i] ^= 54;
8947
- this.iHash.update(pad);
8948
- this.oHash = hash.create();
8949
- for (let i = 0; i < pad.length; i++)
8950
- pad[i] ^= 54 ^ 92;
8951
- this.oHash.update(pad);
8952
- clean2(pad);
9041
+ blockLen;
9042
+ suffix;
9043
+ outputLen;
9044
+ enableXOF = false;
9045
+ rounds;
9046
+ // NOTE: we accept arguments in bytes instead of bits here.
9047
+ constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
9048
+ this.blockLen = blockLen;
9049
+ this.suffix = suffix;
9050
+ this.outputLen = outputLen;
9051
+ this.enableXOF = enableXOF;
9052
+ this.rounds = rounds;
9053
+ anumber2(outputLen, "outputLen");
9054
+ if (!(0 < blockLen && blockLen < 200))
9055
+ throw new Error("only keccak-f1600 function is supported");
9056
+ this.state = new Uint8Array(200);
9057
+ this.state32 = u322(this.state);
8953
9058
  }
8954
- update(buf) {
9059
+ clone() {
9060
+ return this._cloneInto();
9061
+ }
9062
+ keccak() {
9063
+ swap32IfBE2(this.state32);
9064
+ keccakP(this.state32, this.rounds);
9065
+ swap32IfBE2(this.state32);
9066
+ this.posOut = 0;
9067
+ this.pos = 0;
9068
+ }
9069
+ update(data) {
8955
9070
  aexists2(this);
8956
- this.iHash.update(buf);
9071
+ abytes2(data);
9072
+ const { blockLen, state } = this;
9073
+ const len = data.length;
9074
+ for (let pos = 0; pos < len; ) {
9075
+ const take = Math.min(blockLen - this.pos, len - pos);
9076
+ for (let i = 0; i < take; i++)
9077
+ state[this.pos++] ^= data[pos++];
9078
+ if (this.pos === blockLen)
9079
+ this.keccak();
9080
+ }
8957
9081
  return this;
8958
9082
  }
8959
- digestInto(out) {
8960
- aexists2(this);
8961
- abytes2(out, this.outputLen, "output");
9083
+ finish() {
9084
+ if (this.finished)
9085
+ return;
8962
9086
  this.finished = true;
8963
- this.iHash.digestInto(out);
8964
- this.oHash.update(out);
8965
- this.oHash.digestInto(out);
8966
- this.destroy();
9087
+ const { state, suffix, pos, blockLen } = this;
9088
+ state[pos] ^= suffix;
9089
+ if ((suffix & 128) !== 0 && pos === blockLen - 1)
9090
+ this.keccak();
9091
+ state[blockLen - 1] ^= 128;
9092
+ this.keccak();
8967
9093
  }
8968
- digest() {
8969
- const out = new Uint8Array(this.oHash.outputLen);
8970
- this.digestInto(out);
9094
+ writeInto(out) {
9095
+ aexists2(this, false);
9096
+ abytes2(out);
9097
+ this.finish();
9098
+ const bufferOut = this.state;
9099
+ const { blockLen } = this;
9100
+ for (let pos = 0, len = out.length; pos < len; ) {
9101
+ if (this.posOut >= blockLen)
9102
+ this.keccak();
9103
+ const take = Math.min(blockLen - this.posOut, len - pos);
9104
+ out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
9105
+ this.posOut += take;
9106
+ pos += take;
9107
+ }
8971
9108
  return out;
8972
9109
  }
8973
- _cloneInto(to) {
8974
- to ||= Object.create(Object.getPrototypeOf(this), {});
8975
- const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
8976
- to = to;
8977
- to.finished = finished;
8978
- to.destroyed = destroyed;
8979
- to.blockLen = blockLen;
8980
- to.outputLen = outputLen;
8981
- to.oHash = oHash._cloneInto(to.oHash);
8982
- to.iHash = iHash._cloneInto(to.iHash);
8983
- return to;
9110
+ xofInto(out) {
9111
+ if (!this.enableXOF)
9112
+ throw new Error("XOF is not possible for this instance");
9113
+ return this.writeInto(out);
8984
9114
  }
8985
- clone() {
8986
- return this._cloneInto();
9115
+ xof(bytes) {
9116
+ anumber2(bytes);
9117
+ return this.xofInto(new Uint8Array(bytes));
9118
+ }
9119
+ digestInto(out) {
9120
+ aoutput2(out, this);
9121
+ if (this.finished)
9122
+ throw new Error("digest() was already called");
9123
+ this.writeInto(out);
9124
+ this.destroy();
9125
+ return out;
9126
+ }
9127
+ digest() {
9128
+ return this.digestInto(new Uint8Array(this.outputLen));
8987
9129
  }
8988
9130
  destroy() {
8989
9131
  this.destroyed = true;
8990
- this.oHash.destroy();
8991
- this.iHash.destroy();
9132
+ clean2(this.state);
8992
9133
  }
8993
- };
8994
- var hmac2 = (hash, key, message) => new _HMAC(hash, key).update(message).digest();
8995
- hmac2.create = (hash, key) => new _HMAC(hash, key);
8996
-
8997
- // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/pbkdf2.js
8998
- function pbkdf2Init(hash, _password, _salt, _opts) {
8999
- ahash2(hash);
9000
- const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts);
9001
- const { c, dkLen, asyncTick } = opts;
9002
- anumber2(c, "c");
9003
- anumber2(dkLen, "dkLen");
9004
- anumber2(asyncTick, "asyncTick");
9005
- if (c < 1)
9006
- throw new Error("iterations (c) must be >= 1");
9007
- const password = kdfInputToBytes(_password, "password");
9008
- const salt = kdfInputToBytes(_salt, "salt");
9009
- const DK = new Uint8Array(dkLen);
9010
- const PRF = hmac2.create(hash, password);
9011
- const PRFSalt = PRF._cloneInto().update(salt);
9012
- return { c, dkLen, asyncTick, DK, PRF, PRFSalt };
9013
- }
9014
- function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
9015
- PRF.destroy();
9016
- PRFSalt.destroy();
9017
- if (prfW)
9018
- prfW.destroy();
9019
- clean2(u);
9020
- return DK;
9021
- }
9022
- function pbkdf2(hash, password, salt, opts) {
9023
- const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
9024
- let prfW;
9025
- const arr = new Uint8Array(4);
9026
- const view = createView(arr);
9027
- const u = new Uint8Array(PRF.outputLen);
9028
- for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
9029
- const Ti = DK.subarray(pos, pos + PRF.outputLen);
9030
- view.setInt32(0, ti, false);
9031
- (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
9032
- Ti.set(u.subarray(0, Ti.length));
9033
- for (let ui = 1; ui < c; ui++) {
9034
- PRF._cloneInto(prfW).update(u).digestInto(u);
9035
- for (let i = 0; i < Ti.length; i++)
9036
- Ti[i] ^= u[i];
9037
- }
9134
+ _cloneInto(to) {
9135
+ const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
9136
+ to ||= new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
9137
+ to.state32.set(this.state32);
9138
+ to.pos = this.pos;
9139
+ to.posOut = this.posOut;
9140
+ to.finished = this.finished;
9141
+ to.rounds = rounds;
9142
+ to.suffix = suffix;
9143
+ to.outputLen = outputLen;
9144
+ to.enableXOF = enableXOF;
9145
+ to.destroyed = this.destroyed;
9146
+ return to;
9038
9147
  }
9039
- return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
9040
- }
9148
+ };
9149
+ var genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher2(() => new Keccak(blockLen, suffix, outputLen), info);
9150
+ var keccak_256 = /* @__PURE__ */ genKeccak(1, 136, 32);
9041
9151
 
9042
9152
  // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_md.js
9043
9153
  function Chi(a, b, c) {
@@ -9170,45 +9280,6 @@ var SHA512_IV = /* @__PURE__ */ Uint32Array.from([
9170
9280
  327033209
9171
9281
  ]);
9172
9282
 
9173
- // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/_u64.js
9174
- var U32_MASK64 = /* @__PURE__ */ BigInt(2 ** 32 - 1);
9175
- var _32n = /* @__PURE__ */ BigInt(32);
9176
- function fromBig(n, le = false) {
9177
- if (le)
9178
- return { h: Number(n & U32_MASK64), l: Number(n >> _32n & U32_MASK64) };
9179
- return { h: Number(n >> _32n & U32_MASK64) | 0, l: Number(n & U32_MASK64) | 0 };
9180
- }
9181
- function split2(lst, le = false) {
9182
- const len = lst.length;
9183
- let Ah = new Uint32Array(len);
9184
- let Al = new Uint32Array(len);
9185
- for (let i = 0; i < len; i++) {
9186
- const { h, l } = fromBig(lst[i], le);
9187
- [Ah[i], Al[i]] = [h, l];
9188
- }
9189
- return [Ah, Al];
9190
- }
9191
- var shrSH = (h, _l, s) => h >>> s;
9192
- var shrSL = (h, l, s) => h << 32 - s | l >>> s;
9193
- var rotrSH = (h, l, s) => h >>> s | l << 32 - s;
9194
- var rotrSL = (h, l, s) => h << 32 - s | l >>> s;
9195
- var rotrBH = (h, l, s) => h << 64 - s | l >>> s - 32;
9196
- var rotrBL = (h, l, s) => h >>> s - 32 | l << 64 - s;
9197
- var rotlSH2 = (h, l, s) => h << s | l >>> 32 - s;
9198
- var rotlSL2 = (h, l, s) => l << s | h >>> 32 - s;
9199
- var rotlBH2 = (h, l, s) => l << s - 32 | h >>> 64 - s;
9200
- var rotlBL2 = (h, l, s) => h << s - 32 | l >>> 64 - s;
9201
- function add(Ah, Al, Bh, Bl) {
9202
- const l = (Al >>> 0) + (Bl >>> 0);
9203
- return { h: Ah + Bh + (l / 2 ** 32 | 0) | 0, l: l | 0 };
9204
- }
9205
- var add3L = (Al, Bl, Cl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0);
9206
- var add3H = (low, Ah, Bh, Ch) => Ah + Bh + Ch + (low / 2 ** 32 | 0) | 0;
9207
- var add4L = (Al, Bl, Cl, Dl) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0);
9208
- var add4H = (low, Ah, Bh, Ch, Dh) => Ah + Bh + Ch + Dh + (low / 2 ** 32 | 0) | 0;
9209
- var add5L = (Al, Bl, Cl, Dl, El) => (Al >>> 0) + (Bl >>> 0) + (Cl >>> 0) + (Dl >>> 0) + (El >>> 0);
9210
- var add5H = (low, Ah, Bh, Ch, Dh, Eh) => Ah + Bh + Ch + Dh + Eh + (low / 2 ** 32 | 0) | 0;
9211
-
9212
9283
  // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/sha2.js
9213
9284
  var SHA256_K = /* @__PURE__ */ Uint32Array.from([
9214
9285
  1116352408,
@@ -9565,6 +9636,127 @@ var sha512 = /* @__PURE__ */ createHasher2(
9565
9636
  /* @__PURE__ */ oidNist(3)
9566
9637
  );
9567
9638
 
9639
+ // ../core/dist/index.js
9640
+ import { SimplePool as SimplePool3 } from "nostr-tools/pool";
9641
+ import { getPublicKey as getPublicKey3 } from "nostr-tools/pure";
9642
+ import { getPublicKey as getPublicKey4 } from "nostr-tools/pure";
9643
+
9644
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/hmac.js
9645
+ var _HMAC = class {
9646
+ oHash;
9647
+ iHash;
9648
+ blockLen;
9649
+ outputLen;
9650
+ finished = false;
9651
+ destroyed = false;
9652
+ constructor(hash, key) {
9653
+ ahash2(hash);
9654
+ abytes2(key, void 0, "key");
9655
+ this.iHash = hash.create();
9656
+ if (typeof this.iHash.update !== "function")
9657
+ throw new Error("Expected instance of class which extends utils.Hash");
9658
+ this.blockLen = this.iHash.blockLen;
9659
+ this.outputLen = this.iHash.outputLen;
9660
+ const blockLen = this.blockLen;
9661
+ const pad = new Uint8Array(blockLen);
9662
+ pad.set(key.length > blockLen ? hash.create().update(key).digest() : key);
9663
+ for (let i = 0; i < pad.length; i++)
9664
+ pad[i] ^= 54;
9665
+ this.iHash.update(pad);
9666
+ this.oHash = hash.create();
9667
+ for (let i = 0; i < pad.length; i++)
9668
+ pad[i] ^= 54 ^ 92;
9669
+ this.oHash.update(pad);
9670
+ clean2(pad);
9671
+ }
9672
+ update(buf) {
9673
+ aexists2(this);
9674
+ this.iHash.update(buf);
9675
+ return this;
9676
+ }
9677
+ digestInto(out) {
9678
+ aexists2(this);
9679
+ abytes2(out, this.outputLen, "output");
9680
+ this.finished = true;
9681
+ this.iHash.digestInto(out);
9682
+ this.oHash.update(out);
9683
+ this.oHash.digestInto(out);
9684
+ this.destroy();
9685
+ }
9686
+ digest() {
9687
+ const out = new Uint8Array(this.oHash.outputLen);
9688
+ this.digestInto(out);
9689
+ return out;
9690
+ }
9691
+ _cloneInto(to) {
9692
+ to ||= Object.create(Object.getPrototypeOf(this), {});
9693
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
9694
+ to = to;
9695
+ to.finished = finished;
9696
+ to.destroyed = destroyed;
9697
+ to.blockLen = blockLen;
9698
+ to.outputLen = outputLen;
9699
+ to.oHash = oHash._cloneInto(to.oHash);
9700
+ to.iHash = iHash._cloneInto(to.iHash);
9701
+ return to;
9702
+ }
9703
+ clone() {
9704
+ return this._cloneInto();
9705
+ }
9706
+ destroy() {
9707
+ this.destroyed = true;
9708
+ this.oHash.destroy();
9709
+ this.iHash.destroy();
9710
+ }
9711
+ };
9712
+ var hmac2 = (hash, key, message) => new _HMAC(hash, key).update(message).digest();
9713
+ hmac2.create = (hash, key) => new _HMAC(hash, key);
9714
+
9715
+ // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/pbkdf2.js
9716
+ function pbkdf2Init(hash, _password, _salt, _opts) {
9717
+ ahash2(hash);
9718
+ const opts = checkOpts({ dkLen: 32, asyncTick: 10 }, _opts);
9719
+ const { c, dkLen, asyncTick } = opts;
9720
+ anumber2(c, "c");
9721
+ anumber2(dkLen, "dkLen");
9722
+ anumber2(asyncTick, "asyncTick");
9723
+ if (c < 1)
9724
+ throw new Error("iterations (c) must be >= 1");
9725
+ const password = kdfInputToBytes(_password, "password");
9726
+ const salt = kdfInputToBytes(_salt, "salt");
9727
+ const DK = new Uint8Array(dkLen);
9728
+ const PRF = hmac2.create(hash, password);
9729
+ const PRFSalt = PRF._cloneInto().update(salt);
9730
+ return { c, dkLen, asyncTick, DK, PRF, PRFSalt };
9731
+ }
9732
+ function pbkdf2Output(PRF, PRFSalt, DK, prfW, u) {
9733
+ PRF.destroy();
9734
+ PRFSalt.destroy();
9735
+ if (prfW)
9736
+ prfW.destroy();
9737
+ clean2(u);
9738
+ return DK;
9739
+ }
9740
+ function pbkdf2(hash, password, salt, opts) {
9741
+ const { c, dkLen, DK, PRF, PRFSalt } = pbkdf2Init(hash, password, salt, opts);
9742
+ let prfW;
9743
+ const arr = new Uint8Array(4);
9744
+ const view = createView(arr);
9745
+ const u = new Uint8Array(PRF.outputLen);
9746
+ for (let ti = 1, pos = 0; pos < dkLen; ti++, pos += PRF.outputLen) {
9747
+ const Ti = DK.subarray(pos, pos + PRF.outputLen);
9748
+ view.setInt32(0, ti, false);
9749
+ (prfW = PRFSalt._cloneInto(prfW)).update(arr).digestInto(u);
9750
+ Ti.set(u.subarray(0, Ti.length));
9751
+ for (let ui = 1; ui < c; ui++) {
9752
+ PRF._cloneInto(prfW).update(u).digestInto(u);
9753
+ for (let i = 0; i < Ti.length; i++)
9754
+ Ti[i] ^= u[i];
9755
+ }
9756
+ }
9757
+ return pbkdf2Output(PRF, PRFSalt, DK, prfW, u);
9758
+ }
9759
+
9568
9760
  // ../../node_modules/.pnpm/@scure+base@2.0.0/node_modules/@scure/base/index.js
9569
9761
  function isBytes3(a) {
9570
9762
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
@@ -11964,8 +12156,8 @@ zone
11964
12156
  zoo`.split("\n");
11965
12157
 
11966
12158
  // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/utils.js
11967
- var _0n = /* @__PURE__ */ BigInt(0);
11968
- var _1n = /* @__PURE__ */ BigInt(1);
12159
+ var _0n2 = /* @__PURE__ */ BigInt(0);
12160
+ var _1n2 = /* @__PURE__ */ BigInt(1);
11969
12161
  function abool(value, title = "") {
11970
12162
  if (typeof value !== "boolean") {
11971
12163
  const prefix = title && `"${title}" `;
@@ -11988,7 +12180,7 @@ function numberToHexUnpadded(num) {
11988
12180
  function hexToNumber(hex) {
11989
12181
  if (typeof hex !== "string")
11990
12182
  throw new Error("hex string expected, got " + typeof hex);
11991
- return hex === "" ? _0n : BigInt("0x" + hex);
12183
+ return hex === "" ? _0n2 : BigInt("0x" + hex);
11992
12184
  }
11993
12185
  function bytesToNumberBE(bytes) {
11994
12186
  return hexToNumber(bytesToHex2(bytes));
@@ -12010,7 +12202,7 @@ function numberToBytesLE(n, len) {
12010
12202
  function copyBytes(bytes) {
12011
12203
  return Uint8Array.from(bytes);
12012
12204
  }
12013
- var isPosBig = (n) => typeof n === "bigint" && _0n <= n;
12205
+ var isPosBig = (n) => typeof n === "bigint" && _0n2 <= n;
12014
12206
  function inRange(n, min, max) {
12015
12207
  return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;
12016
12208
  }
@@ -12020,11 +12212,11 @@ function aInRange(title, n, min, max) {
12020
12212
  }
12021
12213
  function bitLen(n) {
12022
12214
  let len;
12023
- for (len = 0; n > _0n; n >>= _1n, len += 1)
12215
+ for (len = 0; n > _0n2; n >>= _1n2, len += 1)
12024
12216
  ;
12025
12217
  return len;
12026
12218
  }
12027
- var bitMask = (n) => (_1n << BigInt(n)) - _1n;
12219
+ var bitMask = (n) => (_1n2 << BigInt(n)) - _1n2;
12028
12220
  function createHmacDrbg(hashLen, qByteLen, hmacFn) {
12029
12221
  anumber2(hashLen, "hashLen");
12030
12222
  anumber2(qByteLen, "qByteLen");
@@ -12104,37 +12296,37 @@ function memoized(fn) {
12104
12296
  }
12105
12297
 
12106
12298
  // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/abstract/modular.js
12107
- var _0n2 = /* @__PURE__ */ BigInt(0);
12108
- var _1n2 = /* @__PURE__ */ BigInt(1);
12109
- var _2n = /* @__PURE__ */ BigInt(2);
12299
+ var _0n3 = /* @__PURE__ */ BigInt(0);
12300
+ var _1n3 = /* @__PURE__ */ BigInt(1);
12301
+ var _2n2 = /* @__PURE__ */ BigInt(2);
12110
12302
  var _3n = /* @__PURE__ */ BigInt(3);
12111
12303
  var _4n = /* @__PURE__ */ BigInt(4);
12112
12304
  var _5n = /* @__PURE__ */ BigInt(5);
12113
- var _7n = /* @__PURE__ */ BigInt(7);
12305
+ var _7n2 = /* @__PURE__ */ BigInt(7);
12114
12306
  var _8n = /* @__PURE__ */ BigInt(8);
12115
12307
  var _9n = /* @__PURE__ */ BigInt(9);
12116
12308
  var _16n = /* @__PURE__ */ BigInt(16);
12117
12309
  function mod(a, b) {
12118
12310
  const result = a % b;
12119
- return result >= _0n2 ? result : b + result;
12311
+ return result >= _0n3 ? result : b + result;
12120
12312
  }
12121
12313
  function pow2(x, power, modulo) {
12122
12314
  let res = x;
12123
- while (power-- > _0n2) {
12315
+ while (power-- > _0n3) {
12124
12316
  res *= res;
12125
12317
  res %= modulo;
12126
12318
  }
12127
12319
  return res;
12128
12320
  }
12129
12321
  function invert(number, modulo) {
12130
- if (number === _0n2)
12322
+ if (number === _0n3)
12131
12323
  throw new Error("invert: expected non-zero number");
12132
- if (modulo <= _0n2)
12324
+ if (modulo <= _0n3)
12133
12325
  throw new Error("invert: expected positive modulus, got " + modulo);
12134
12326
  let a = mod(number, modulo);
12135
12327
  let b = modulo;
12136
- let x = _0n2, y = _1n2, u = _1n2, v = _0n2;
12137
- while (a !== _0n2) {
12328
+ let x = _0n3, y = _1n3, u = _1n3, v = _0n3;
12329
+ while (a !== _0n3) {
12138
12330
  const q = b / a;
12139
12331
  const r = b % a;
12140
12332
  const m = x - u * q;
@@ -12142,7 +12334,7 @@ function invert(number, modulo) {
12142
12334
  b = a, a = r, x = u, y = v, u = m, v = n;
12143
12335
  }
12144
12336
  const gcd2 = b;
12145
- if (gcd2 !== _1n2)
12337
+ if (gcd2 !== _1n3)
12146
12338
  throw new Error("invert: does not exist");
12147
12339
  return mod(x, modulo);
12148
12340
  }
@@ -12151,17 +12343,17 @@ function assertIsSquare(Fp, root, n) {
12151
12343
  throw new Error("Cannot find square root");
12152
12344
  }
12153
12345
  function sqrt3mod4(Fp, n) {
12154
- const p1div4 = (Fp.ORDER + _1n2) / _4n;
12346
+ const p1div4 = (Fp.ORDER + _1n3) / _4n;
12155
12347
  const root = Fp.pow(n, p1div4);
12156
12348
  assertIsSquare(Fp, root, n);
12157
12349
  return root;
12158
12350
  }
12159
12351
  function sqrt5mod8(Fp, n) {
12160
12352
  const p5div8 = (Fp.ORDER - _5n) / _8n;
12161
- const n2 = Fp.mul(n, _2n);
12353
+ const n2 = Fp.mul(n, _2n2);
12162
12354
  const v = Fp.pow(n2, p5div8);
12163
12355
  const nv = Fp.mul(n, v);
12164
- const i = Fp.mul(Fp.mul(nv, _2n), v);
12356
+ const i = Fp.mul(Fp.mul(nv, _2n2), v);
12165
12357
  const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
12166
12358
  assertIsSquare(Fp, root, n);
12167
12359
  return root;
@@ -12172,7 +12364,7 @@ function sqrt9mod16(P) {
12172
12364
  const c1 = tn(Fp_, Fp_.neg(Fp_.ONE));
12173
12365
  const c2 = tn(Fp_, c1);
12174
12366
  const c3 = tn(Fp_, Fp_.neg(c1));
12175
- const c4 = (P + _7n) / _16n;
12367
+ const c4 = (P + _7n2) / _16n;
12176
12368
  return (Fp, n) => {
12177
12369
  let tv1 = Fp.pow(n, c4);
12178
12370
  let tv2 = Fp.mul(tv1, c1);
@@ -12191,13 +12383,13 @@ function sqrt9mod16(P) {
12191
12383
  function tonelliShanks(P) {
12192
12384
  if (P < _3n)
12193
12385
  throw new Error("sqrt is not defined for small field");
12194
- let Q = P - _1n2;
12386
+ let Q = P - _1n3;
12195
12387
  let S = 0;
12196
- while (Q % _2n === _0n2) {
12197
- Q /= _2n;
12388
+ while (Q % _2n2 === _0n3) {
12389
+ Q /= _2n2;
12198
12390
  S++;
12199
12391
  }
12200
- let Z = _2n;
12392
+ let Z = _2n2;
12201
12393
  const _Fp = Field(P);
12202
12394
  while (FpLegendre(_Fp, Z) === 1) {
12203
12395
  if (Z++ > 1e3)
@@ -12206,7 +12398,7 @@ function tonelliShanks(P) {
12206
12398
  if (S === 1)
12207
12399
  return sqrt3mod4;
12208
12400
  let cc = _Fp.pow(Z, Q);
12209
- const Q1div2 = (Q + _1n2) / _2n;
12401
+ const Q1div2 = (Q + _1n3) / _2n2;
12210
12402
  return function tonelliSlow(Fp, n) {
12211
12403
  if (Fp.is0(n))
12212
12404
  return n;
@@ -12227,7 +12419,7 @@ function tonelliShanks(P) {
12227
12419
  if (i === M)
12228
12420
  throw new Error("Cannot find square root");
12229
12421
  }
12230
- const exponent = _1n2 << BigInt(M - i - 1);
12422
+ const exponent = _1n3 << BigInt(M - i - 1);
12231
12423
  const b = Fp.pow(c, exponent);
12232
12424
  M = i;
12233
12425
  c = Fp.sqr(b);
@@ -12246,7 +12438,7 @@ function FpSqrt(P) {
12246
12438
  return sqrt9mod16(P);
12247
12439
  return tonelliShanks(P);
12248
12440
  }
12249
- var isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n2) === _1n2;
12441
+ var isNegativeLE = (num, modulo) => (mod(num, modulo) & _1n3) === _1n3;
12250
12442
  var FIELD_FIELDS = [
12251
12443
  "create",
12252
12444
  "isValid",
@@ -12280,19 +12472,19 @@ function validateField(field) {
12280
12472
  return field;
12281
12473
  }
12282
12474
  function FpPow(Fp, num, power) {
12283
- if (power < _0n2)
12475
+ if (power < _0n3)
12284
12476
  throw new Error("invalid exponent, negatives unsupported");
12285
- if (power === _0n2)
12477
+ if (power === _0n3)
12286
12478
  return Fp.ONE;
12287
- if (power === _1n2)
12479
+ if (power === _1n3)
12288
12480
  return num;
12289
12481
  let p = Fp.ONE;
12290
12482
  let d = num;
12291
- while (power > _0n2) {
12292
- if (power & _1n2)
12483
+ while (power > _0n3) {
12484
+ if (power & _1n3)
12293
12485
  p = Fp.mul(p, d);
12294
12486
  d = Fp.sqr(d);
12295
- power >>= _1n2;
12487
+ power >>= _1n3;
12296
12488
  }
12297
12489
  return p;
12298
12490
  }
@@ -12314,7 +12506,7 @@ function FpInvertBatch(Fp, nums, passZero = false) {
12314
12506
  return inverted;
12315
12507
  }
12316
12508
  function FpLegendre(Fp, n) {
12317
- const p1mod2 = (Fp.ORDER - _1n2) / _2n;
12509
+ const p1mod2 = (Fp.ORDER - _1n3) / _2n2;
12318
12510
  const powered = Fp.pow(n, p1mod2);
12319
12511
  const yes = Fp.eql(powered, Fp.ONE);
12320
12512
  const zero = Fp.eql(powered, Fp.ZERO);
@@ -12335,14 +12527,14 @@ var _Field = class {
12335
12527
  BITS;
12336
12528
  BYTES;
12337
12529
  isLE;
12338
- ZERO = _0n2;
12339
- ONE = _1n2;
12530
+ ZERO = _0n3;
12531
+ ONE = _1n3;
12340
12532
  _lengths;
12341
12533
  _sqrt;
12342
12534
  // cached sqrt
12343
12535
  _mod;
12344
12536
  constructor(ORDER, opts = {}) {
12345
- if (ORDER <= _0n2)
12537
+ if (ORDER <= _0n3)
12346
12538
  throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
12347
12539
  let _nbitLength = void 0;
12348
12540
  this.isLE = false;
@@ -12373,17 +12565,17 @@ var _Field = class {
12373
12565
  isValid(num) {
12374
12566
  if (typeof num !== "bigint")
12375
12567
  throw new Error("invalid field element: expected bigint, got " + typeof num);
12376
- return _0n2 <= num && num < this.ORDER;
12568
+ return _0n3 <= num && num < this.ORDER;
12377
12569
  }
12378
12570
  is0(num) {
12379
- return num === _0n2;
12571
+ return num === _0n3;
12380
12572
  }
12381
12573
  // is valid and invertible
12382
12574
  isValidNot0(num) {
12383
12575
  return !this.is0(num) && this.isValid(num);
12384
12576
  }
12385
12577
  isOdd(num) {
12386
- return (num & _1n2) === _1n2;
12578
+ return (num & _1n3) === _1n3;
12387
12579
  }
12388
12580
  neg(num) {
12389
12581
  return mod(-num, this.ORDER);
@@ -12486,13 +12678,13 @@ function mapHashToField(key, fieldOrder, isLE2 = false) {
12486
12678
  if (len < 16 || len < minLen || len > 1024)
12487
12679
  throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
12488
12680
  const num = isLE2 ? bytesToNumberLE(key) : bytesToNumberBE(key);
12489
- const reduced = mod(num, fieldOrder - _1n2) + _1n2;
12681
+ const reduced = mod(num, fieldOrder - _1n3) + _1n3;
12490
12682
  return isLE2 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
12491
12683
  }
12492
12684
 
12493
12685
  // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/abstract/curve.js
12494
- var _0n3 = /* @__PURE__ */ BigInt(0);
12495
- var _1n3 = /* @__PURE__ */ BigInt(1);
12686
+ var _0n4 = /* @__PURE__ */ BigInt(0);
12687
+ var _1n4 = /* @__PURE__ */ BigInt(1);
12496
12688
  function negateCt(condition, item) {
12497
12689
  const neg = item.negate();
12498
12690
  return condition ? neg : item;
@@ -12520,7 +12712,7 @@ function calcOffsets(n, window2, wOpts) {
12520
12712
  let nextN = n >> shiftBy;
12521
12713
  if (wbits > windowSize) {
12522
12714
  wbits -= maxNumber;
12523
- nextN += _1n3;
12715
+ nextN += _1n4;
12524
12716
  }
12525
12717
  const offsetStart = window2 * windowSize;
12526
12718
  const offset = offsetStart + Math.abs(wbits) - 1;
@@ -12536,7 +12728,7 @@ function getW(P) {
12536
12728
  return pointWindowSizes.get(P) || 1;
12537
12729
  }
12538
12730
  function assert0(n) {
12539
- if (n !== _0n3)
12731
+ if (n !== _0n4)
12540
12732
  throw new Error("invalid wNAF");
12541
12733
  }
12542
12734
  var wNAF = class {
@@ -12554,11 +12746,11 @@ var wNAF = class {
12554
12746
  // non-const time multiplication ladder
12555
12747
  _unsafeLadder(elm, n, p = this.ZERO) {
12556
12748
  let d = elm;
12557
- while (n > _0n3) {
12558
- if (n & _1n3)
12749
+ while (n > _0n4) {
12750
+ if (n & _1n4)
12559
12751
  p = p.add(d);
12560
12752
  d = d.double();
12561
- n >>= _1n3;
12753
+ n >>= _1n4;
12562
12754
  }
12563
12755
  return p;
12564
12756
  }
@@ -12622,7 +12814,7 @@ var wNAF = class {
12622
12814
  wNAFUnsafe(W, precomputes, n, acc = this.ZERO) {
12623
12815
  const wo = calcWOpts(W, this.bits);
12624
12816
  for (let window2 = 0; window2 < wo.windows; window2++) {
12625
- if (n === _0n3)
12817
+ if (n === _0n4)
12626
12818
  break;
12627
12819
  const { nextN, offset, isZero, isNeg } = calcOffsets(n, window2, wo);
12628
12820
  n = nextN;
@@ -12674,14 +12866,14 @@ function mulEndoUnsafe(Point2, point, k1, k2) {
12674
12866
  let acc = point;
12675
12867
  let p1 = Point2.ZERO;
12676
12868
  let p2 = Point2.ZERO;
12677
- while (k1 > _0n3 || k2 > _0n3) {
12678
- if (k1 & _1n3)
12869
+ while (k1 > _0n4 || k2 > _0n4) {
12870
+ if (k1 & _1n4)
12679
12871
  p1 = p1.add(acc);
12680
- if (k2 & _1n3)
12872
+ if (k2 & _1n4)
12681
12873
  p2 = p2.add(acc);
12682
12874
  acc = acc.double();
12683
- k1 >>= _1n3;
12684
- k2 >>= _1n3;
12875
+ k1 >>= _1n4;
12876
+ k2 >>= _1n4;
12685
12877
  }
12686
12878
  return { p1, p2 };
12687
12879
  }
@@ -12702,7 +12894,7 @@ function createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
12702
12894
  throw new Error(`expected valid ${type} CURVE object`);
12703
12895
  for (const p of ["p", "n", "h"]) {
12704
12896
  const val = CURVE[p];
12705
- if (!(typeof val === "bigint" && val > _0n3))
12897
+ if (!(typeof val === "bigint" && val > _0n4))
12706
12898
  throw new Error(`CURVE.${p} must be positive bigint`);
12707
12899
  }
12708
12900
  const Fp = createField(CURVE.p, curveOpts.Fp, FpFnLE);
@@ -12724,21 +12916,21 @@ function createKeygen(randomSecretKey, getPublicKey7) {
12724
12916
  }
12725
12917
 
12726
12918
  // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/abstract/weierstrass.js
12727
- var divNearest = (num, den) => (num + (num >= 0 ? den : -den) / _2n2) / den;
12919
+ var divNearest = (num, den) => (num + (num >= 0 ? den : -den) / _2n3) / den;
12728
12920
  function _splitEndoScalar(k, basis, n) {
12729
12921
  const [[a1, b1], [a2, b2]] = basis;
12730
12922
  const c1 = divNearest(b2 * k, n);
12731
12923
  const c2 = divNearest(-b1 * k, n);
12732
12924
  let k1 = k - c1 * a1 - c2 * a2;
12733
12925
  let k2 = -c1 * b1 - c2 * b2;
12734
- const k1neg = k1 < _0n4;
12735
- const k2neg = k2 < _0n4;
12926
+ const k1neg = k1 < _0n5;
12927
+ const k2neg = k2 < _0n5;
12736
12928
  if (k1neg)
12737
12929
  k1 = -k1;
12738
12930
  if (k2neg)
12739
12931
  k2 = -k2;
12740
- const MAX_NUM = bitMask(Math.ceil(bitLen(n) / 2)) + _1n4;
12741
- if (k1 < _0n4 || k1 >= MAX_NUM || k2 < _0n4 || k2 >= MAX_NUM) {
12932
+ const MAX_NUM = bitMask(Math.ceil(bitLen(n) / 2)) + _1n5;
12933
+ if (k1 < _0n5 || k1 >= MAX_NUM || k2 < _0n5 || k2 >= MAX_NUM) {
12742
12934
  throw new Error("splitScalar (endomorphism): failed, k=" + k);
12743
12935
  }
12744
12936
  return { k1neg, k1, k2neg, k2 };
@@ -12826,7 +13018,7 @@ var DER = {
12826
13018
  _int: {
12827
13019
  encode(num) {
12828
13020
  const { Err: E } = DER;
12829
- if (num < _0n4)
13021
+ if (num < _0n5)
12830
13022
  throw new E("integer: negative integers are not allowed");
12831
13023
  let hex = numberToHexUnpadded(num);
12832
13024
  if (Number.parseInt(hex[0], 16) & 8)
@@ -12864,9 +13056,9 @@ var DER = {
12864
13056
  return tlv.encode(48, seq);
12865
13057
  }
12866
13058
  };
12867
- var _0n4 = BigInt(0);
12868
- var _1n4 = BigInt(1);
12869
- var _2n2 = BigInt(2);
13059
+ var _0n5 = BigInt(0);
13060
+ var _1n5 = BigInt(1);
13061
+ var _2n3 = BigInt(2);
12870
13062
  var _3n2 = BigInt(3);
12871
13063
  var _4n2 = BigInt(4);
12872
13064
  function weierstrass(params, extraOpts = {}) {
@@ -13232,9 +13424,9 @@ function weierstrass(params, extraOpts = {}) {
13232
13424
  const p = this;
13233
13425
  if (!Fn2.isValid(sc))
13234
13426
  throw new Error("invalid scalar: out of range");
13235
- if (sc === _0n4 || p.is0())
13427
+ if (sc === _0n5 || p.is0())
13236
13428
  return Point2.ZERO;
13237
- if (sc === _1n4)
13429
+ if (sc === _1n5)
13238
13430
  return p;
13239
13431
  if (wnaf.hasCache(this))
13240
13432
  return this.multiply(sc);
@@ -13259,7 +13451,7 @@ function weierstrass(params, extraOpts = {}) {
13259
13451
  */
13260
13452
  isTorsionFree() {
13261
13453
  const { isTorsionFree } = extraOpts;
13262
- if (cofactor === _1n4)
13454
+ if (cofactor === _1n5)
13263
13455
  return true;
13264
13456
  if (isTorsionFree)
13265
13457
  return isTorsionFree(Point2, this);
@@ -13267,7 +13459,7 @@ function weierstrass(params, extraOpts = {}) {
13267
13459
  }
13268
13460
  clearCofactor() {
13269
13461
  const { clearCofactor } = extraOpts;
13270
- if (cofactor === _1n4)
13462
+ if (cofactor === _1n5)
13271
13463
  return this;
13272
13464
  if (clearCofactor)
13273
13465
  return clearCofactor(Point2, this);
@@ -13383,9 +13575,9 @@ function ecdsa(Point2, hash, ecdsaOpts = {}) {
13383
13575
  format: "compact",
13384
13576
  extraEntropy: false
13385
13577
  };
13386
- const hasLargeCofactor = CURVE_ORDER * _2n2 < Fp.ORDER;
13578
+ const hasLargeCofactor = CURVE_ORDER * _2n3 < Fp.ORDER;
13387
13579
  function isBiggerThanHalfOrder(number) {
13388
- const HALF = CURVE_ORDER >> _1n4;
13580
+ const HALF = CURVE_ORDER >> _1n5;
13389
13581
  return number > HALF;
13390
13582
  }
13391
13583
  function validateRS(title, num) {
@@ -13498,7 +13690,7 @@ function ecdsa(Point2, hash, ecdsaOpts = {}) {
13498
13690
  };
13499
13691
  const ORDER_MASK = bitMask(fnBits);
13500
13692
  function int2octets(num) {
13501
- aInRange("num < 2^" + fnBits, num, _0n4, ORDER_MASK);
13693
+ aInRange("num < 2^" + fnBits, num, _0n5, ORDER_MASK);
13502
13694
  return Fn2.toBytes(num);
13503
13695
  }
13504
13696
  function validateMsgAndHash(message, prehash) {
@@ -13526,12 +13718,12 @@ function ecdsa(Point2, hash, ecdsaOpts = {}) {
13526
13718
  const ik = Fn2.inv(k);
13527
13719
  const q = Point2.BASE.multiply(k).toAffine();
13528
13720
  const r = Fn2.create(q.x);
13529
- if (r === _0n4)
13721
+ if (r === _0n5)
13530
13722
  return;
13531
13723
  const s = Fn2.create(ik * Fn2.create(m + r * d));
13532
- if (s === _0n4)
13724
+ if (s === _0n5)
13533
13725
  return;
13534
- let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n4);
13726
+ let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n5);
13535
13727
  let normS = s;
13536
13728
  if (lowS && isBiggerThanHalfOrder(s)) {
13537
13729
  normS = Fn2.neg(s);
@@ -13612,7 +13804,7 @@ var secp256k1_ENDO = {
13612
13804
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
13613
13805
  ]
13614
13806
  };
13615
- var _2n3 = /* @__PURE__ */ BigInt(2);
13807
+ var _2n4 = /* @__PURE__ */ BigInt(2);
13616
13808
  function sqrtMod(y) {
13617
13809
  const P = secp256k1_CURVE.p;
13618
13810
  const _3n5 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
@@ -13621,7 +13813,7 @@ function sqrtMod(y) {
13621
13813
  const b3 = b2 * b2 * y % P;
13622
13814
  const b6 = pow2(b3, _3n5, P) * b3 % P;
13623
13815
  const b9 = pow2(b6, _3n5, P) * b3 % P;
13624
- const b11 = pow2(b9, _2n3, P) * b2 % P;
13816
+ const b11 = pow2(b9, _2n4, P) * b2 % P;
13625
13817
  const b22 = pow2(b11, _11n, P) * b11 % P;
13626
13818
  const b44 = pow2(b22, _22n, P) * b22 % P;
13627
13819
  const b88 = pow2(b44, _44n, P) * b44 % P;
@@ -13630,7 +13822,7 @@ function sqrtMod(y) {
13630
13822
  const b223 = pow2(b220, _3n5, P) * b3 % P;
13631
13823
  const t1 = pow2(b223, _23n, P) * b22 % P;
13632
13824
  const t2 = pow2(t1, _6n, P) * b2 % P;
13633
- const root = pow2(t2, _2n3, P);
13825
+ const root = pow2(t2, _2n4, P);
13634
13826
  if (!Fpk1.eql(Fpk1.sqr(root), y))
13635
13827
  throw new Error("Cannot find square root");
13636
13828
  return root;
@@ -14312,11 +14504,15 @@ function writeHsConnectorConfig(configDir, config, options = {}) {
14312
14504
  } catch {
14313
14505
  }
14314
14506
  }
14507
+ const apexEvmKey = options.apexSettlementKeys?.evmPrivateKeyHex;
14315
14508
  const derived = resolveConfigNetworkProfile(
14316
14509
  config,
14317
- DEFAULT_HS_CHAIN_PROVIDERS[0]?.keyId
14510
+ apexEvmKey ?? DEFAULT_HS_CHAIN_PROVIDERS[0]?.keyId
14318
14511
  ).chainProviders;
14319
- const hsConfig = derived.length > 0 ? { ...config, chainProviders: derived } : { ...config, chainProviders: [...DEFAULT_HS_CHAIN_PROVIDERS] };
14512
+ const fillApexKey = (providers) => providers.map(
14513
+ (p) => !p.keyId && p.chainType === "evm" && apexEvmKey ? { ...p, keyId: apexEvmKey } : p
14514
+ );
14515
+ const hsConfig = derived.length > 0 ? { ...config, chainProviders: fillApexKey(derived) } : { ...config, chainProviders: [...DEFAULT_HS_CHAIN_PROVIDERS] };
14320
14516
  const generator = new ConnectorConfigGenerator(hsConfig);
14321
14517
  const baseConfig = generator.generate([]);
14322
14518
  const HS_LOCAL_SOCKS_PROXY = "socks5h://127.0.0.1:9050";
@@ -15144,37 +15340,37 @@ async function readImageManifest(path) {
15144
15340
  return ImageManifestSchema.parse(parsed);
15145
15341
  }
15146
15342
 
15147
- // src/wallet/manager.ts
15148
- import { getPublicKey as getPublicKey6 } from "nostr-tools/pure";
15149
-
15150
- // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha3.js
15151
- var _0n5 = BigInt(0);
15152
- var _1n5 = BigInt(1);
15153
- var _2n4 = BigInt(2);
15154
- var _7n2 = BigInt(7);
15155
- var _256n = BigInt(256);
15156
- var _0x71n = BigInt(113);
15157
- var SHA3_PI = [];
15158
- var SHA3_ROTL = [];
15159
- var _SHA3_IOTA = [];
15160
- for (let round = 0, R = _1n5, x = 1, y = 0; round < 24; round++) {
15343
+ // src/wallet/manager.ts
15344
+ import { getPublicKey as getPublicKey6 } from "nostr-tools/pure";
15345
+
15346
+ // ../../node_modules/.pnpm/@noble+hashes@1.8.0/node_modules/@noble/hashes/esm/sha3.js
15347
+ var _0n6 = BigInt(0);
15348
+ var _1n6 = BigInt(1);
15349
+ var _2n5 = BigInt(2);
15350
+ var _7n3 = BigInt(7);
15351
+ var _256n2 = BigInt(256);
15352
+ var _0x71n2 = BigInt(113);
15353
+ var SHA3_PI2 = [];
15354
+ var SHA3_ROTL2 = [];
15355
+ var _SHA3_IOTA2 = [];
15356
+ for (let round = 0, R = _1n6, x = 1, y = 0; round < 24; round++) {
15161
15357
  [x, y] = [y, (2 * x + 3 * y) % 5];
15162
- SHA3_PI.push(2 * (5 * y + x));
15163
- SHA3_ROTL.push((round + 1) * (round + 2) / 2 % 64);
15164
- let t = _0n5;
15358
+ SHA3_PI2.push(2 * (5 * y + x));
15359
+ SHA3_ROTL2.push((round + 1) * (round + 2) / 2 % 64);
15360
+ let t = _0n6;
15165
15361
  for (let j = 0; j < 7; j++) {
15166
- R = (R << _1n5 ^ (R >> _7n2) * _0x71n) % _256n;
15167
- if (R & _2n4)
15168
- t ^= _1n5 << (_1n5 << /* @__PURE__ */ BigInt(j)) - _1n5;
15362
+ R = (R << _1n6 ^ (R >> _7n3) * _0x71n2) % _256n2;
15363
+ if (R & _2n5)
15364
+ t ^= _1n6 << (_1n6 << /* @__PURE__ */ BigInt(j)) - _1n6;
15169
15365
  }
15170
- _SHA3_IOTA.push(t);
15366
+ _SHA3_IOTA2.push(t);
15171
15367
  }
15172
- var IOTAS = split(_SHA3_IOTA, true);
15173
- var SHA3_IOTA_H = IOTAS[0];
15174
- var SHA3_IOTA_L = IOTAS[1];
15175
- var rotlH = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
15176
- var rotlL = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
15177
- function keccakP(s, rounds = 24) {
15368
+ var IOTAS2 = split(_SHA3_IOTA2, true);
15369
+ var SHA3_IOTA_H2 = IOTAS2[0];
15370
+ var SHA3_IOTA_L2 = IOTAS2[1];
15371
+ var rotlH2 = (h, l, s) => s > 32 ? rotlBH(h, l, s) : rotlSH(h, l, s);
15372
+ var rotlL2 = (h, l, s) => s > 32 ? rotlBL(h, l, s) : rotlSL(h, l, s);
15373
+ function keccakP2(s, rounds = 24) {
15178
15374
  const B = new Uint32Array(5 * 2);
15179
15375
  for (let round = 24 - rounds; round < 24; round++) {
15180
15376
  for (let x = 0; x < 10; x++)
@@ -15184,8 +15380,8 @@ function keccakP(s, rounds = 24) {
15184
15380
  const idx0 = (x + 2) % 10;
15185
15381
  const B0 = B[idx0];
15186
15382
  const B1 = B[idx0 + 1];
15187
- const Th = rotlH(B0, B1, 1) ^ B[idx1];
15188
- const Tl = rotlL(B0, B1, 1) ^ B[idx1 + 1];
15383
+ const Th = rotlH2(B0, B1, 1) ^ B[idx1];
15384
+ const Tl = rotlL2(B0, B1, 1) ^ B[idx1 + 1];
15189
15385
  for (let y = 0; y < 50; y += 10) {
15190
15386
  s[x + y] ^= Th;
15191
15387
  s[x + y + 1] ^= Tl;
@@ -15194,10 +15390,10 @@ function keccakP(s, rounds = 24) {
15194
15390
  let curH = s[2];
15195
15391
  let curL = s[3];
15196
15392
  for (let t = 0; t < 24; t++) {
15197
- const shift = SHA3_ROTL[t];
15198
- const Th = rotlH(curH, curL, shift);
15199
- const Tl = rotlL(curH, curL, shift);
15200
- const PI = SHA3_PI[t];
15393
+ const shift = SHA3_ROTL2[t];
15394
+ const Th = rotlH2(curH, curL, shift);
15395
+ const Tl = rotlL2(curH, curL, shift);
15396
+ const PI = SHA3_PI2[t];
15201
15397
  curH = s[PI];
15202
15398
  curL = s[PI + 1];
15203
15399
  s[PI] = Th;
@@ -15209,12 +15405,12 @@ function keccakP(s, rounds = 24) {
15209
15405
  for (let x = 0; x < 10; x++)
15210
15406
  s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
15211
15407
  }
15212
- s[0] ^= SHA3_IOTA_H[round];
15213
- s[1] ^= SHA3_IOTA_L[round];
15408
+ s[0] ^= SHA3_IOTA_H2[round];
15409
+ s[1] ^= SHA3_IOTA_L2[round];
15214
15410
  }
15215
15411
  clean(B);
15216
15412
  }
15217
- var Keccak = class _Keccak extends Hash {
15413
+ var Keccak2 = class _Keccak extends Hash {
15218
15414
  // NOTE: we accept arguments in bytes instead of bits here.
15219
15415
  constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
15220
15416
  super();
@@ -15239,7 +15435,7 @@ var Keccak = class _Keccak extends Hash {
15239
15435
  }
15240
15436
  keccak() {
15241
15437
  swap32IfBE(this.state32);
15242
- keccakP(this.state32, this.rounds);
15438
+ keccakP2(this.state32, this.rounds);
15243
15439
  swap32IfBE(this.state32);
15244
15440
  this.posOut = 0;
15245
15441
  this.pos = 0;
@@ -15325,12 +15521,12 @@ var Keccak = class _Keccak extends Hash {
15325
15521
  return to;
15326
15522
  }
15327
15523
  };
15328
- var gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak(blockLen, suffix, outputLen));
15329
- var keccak_256 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
15524
+ var gen = (suffix, blockLen, outputLen) => createHasher(() => new Keccak2(blockLen, suffix, outputLen));
15525
+ var keccak_2562 = /* @__PURE__ */ (() => gen(1, 136, 256 / 8))();
15330
15526
 
15331
15527
  // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/utils.js
15332
- var _0n6 = /* @__PURE__ */ BigInt(0);
15333
- var _1n6 = /* @__PURE__ */ BigInt(1);
15528
+ var _0n7 = /* @__PURE__ */ BigInt(0);
15529
+ var _1n7 = /* @__PURE__ */ BigInt(1);
15334
15530
  function _abool2(value, title = "") {
15335
15531
  if (typeof value !== "boolean") {
15336
15532
  const prefix = title && `"${title}"`;
@@ -15357,7 +15553,7 @@ function numberToHexUnpadded2(num) {
15357
15553
  function hexToNumber2(hex) {
15358
15554
  if (typeof hex !== "string")
15359
15555
  throw new Error("hex string expected, got " + typeof hex);
15360
- return hex === "" ? _0n6 : BigInt("0x" + hex);
15556
+ return hex === "" ? _0n7 : BigInt("0x" + hex);
15361
15557
  }
15362
15558
  function bytesToNumberBE2(bytes) {
15363
15559
  return hexToNumber2(bytesToHex(bytes));
@@ -15390,7 +15586,7 @@ function ensureBytes(title, hex, expectedLength) {
15390
15586
  throw new Error(title + " of length " + expectedLength + " expected, got " + len);
15391
15587
  return res;
15392
15588
  }
15393
- var isPosBig2 = (n) => typeof n === "bigint" && _0n6 <= n;
15589
+ var isPosBig2 = (n) => typeof n === "bigint" && _0n7 <= n;
15394
15590
  function inRange2(n, min, max) {
15395
15591
  return isPosBig2(n) && isPosBig2(min) && isPosBig2(max) && min <= n && n < max;
15396
15592
  }
@@ -15400,11 +15596,11 @@ function aInRange2(title, n, min, max) {
15400
15596
  }
15401
15597
  function bitLen2(n) {
15402
15598
  let len;
15403
- for (len = 0; n > _0n6; n >>= _1n6, len += 1)
15599
+ for (len = 0; n > _0n7; n >>= _1n7, len += 1)
15404
15600
  ;
15405
15601
  return len;
15406
15602
  }
15407
- var bitMask2 = (n) => (_1n6 << BigInt(n)) - _1n6;
15603
+ var bitMask2 = (n) => (_1n7 << BigInt(n)) - _1n7;
15408
15604
  function createHmacDrbg2(hashLen, qByteLen, hmacFn) {
15409
15605
  if (typeof hashLen !== "number" || hashLen < 2)
15410
15606
  throw new Error("hashLen must be a number");
@@ -15482,37 +15678,37 @@ function memoized2(fn) {
15482
15678
  }
15483
15679
 
15484
15680
  // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/modular.js
15485
- var _0n7 = BigInt(0);
15486
- var _1n7 = BigInt(1);
15487
- var _2n5 = /* @__PURE__ */ BigInt(2);
15681
+ var _0n8 = BigInt(0);
15682
+ var _1n8 = BigInt(1);
15683
+ var _2n6 = /* @__PURE__ */ BigInt(2);
15488
15684
  var _3n3 = /* @__PURE__ */ BigInt(3);
15489
15685
  var _4n3 = /* @__PURE__ */ BigInt(4);
15490
15686
  var _5n2 = /* @__PURE__ */ BigInt(5);
15491
- var _7n3 = /* @__PURE__ */ BigInt(7);
15687
+ var _7n4 = /* @__PURE__ */ BigInt(7);
15492
15688
  var _8n2 = /* @__PURE__ */ BigInt(8);
15493
15689
  var _9n2 = /* @__PURE__ */ BigInt(9);
15494
15690
  var _16n2 = /* @__PURE__ */ BigInt(16);
15495
15691
  function mod2(a, b) {
15496
15692
  const result = a % b;
15497
- return result >= _0n7 ? result : b + result;
15693
+ return result >= _0n8 ? result : b + result;
15498
15694
  }
15499
15695
  function pow22(x, power, modulo) {
15500
15696
  let res = x;
15501
- while (power-- > _0n7) {
15697
+ while (power-- > _0n8) {
15502
15698
  res *= res;
15503
15699
  res %= modulo;
15504
15700
  }
15505
15701
  return res;
15506
15702
  }
15507
15703
  function invert2(number, modulo) {
15508
- if (number === _0n7)
15704
+ if (number === _0n8)
15509
15705
  throw new Error("invert: expected non-zero number");
15510
- if (modulo <= _0n7)
15706
+ if (modulo <= _0n8)
15511
15707
  throw new Error("invert: expected positive modulus, got " + modulo);
15512
15708
  let a = mod2(number, modulo);
15513
15709
  let b = modulo;
15514
- let x = _0n7, y = _1n7, u = _1n7, v = _0n7;
15515
- while (a !== _0n7) {
15710
+ let x = _0n8, y = _1n8, u = _1n8, v = _0n8;
15711
+ while (a !== _0n8) {
15516
15712
  const q = b / a;
15517
15713
  const r = b % a;
15518
15714
  const m = x - u * q;
@@ -15520,7 +15716,7 @@ function invert2(number, modulo) {
15520
15716
  b = a, a = r, x = u, y = v, u = m, v = n;
15521
15717
  }
15522
15718
  const gcd2 = b;
15523
- if (gcd2 !== _1n7)
15719
+ if (gcd2 !== _1n8)
15524
15720
  throw new Error("invert: does not exist");
15525
15721
  return mod2(x, modulo);
15526
15722
  }
@@ -15529,17 +15725,17 @@ function assertIsSquare2(Fp, root, n) {
15529
15725
  throw new Error("Cannot find square root");
15530
15726
  }
15531
15727
  function sqrt3mod42(Fp, n) {
15532
- const p1div4 = (Fp.ORDER + _1n7) / _4n3;
15728
+ const p1div4 = (Fp.ORDER + _1n8) / _4n3;
15533
15729
  const root = Fp.pow(n, p1div4);
15534
15730
  assertIsSquare2(Fp, root, n);
15535
15731
  return root;
15536
15732
  }
15537
15733
  function sqrt5mod82(Fp, n) {
15538
15734
  const p5div8 = (Fp.ORDER - _5n2) / _8n2;
15539
- const n2 = Fp.mul(n, _2n5);
15735
+ const n2 = Fp.mul(n, _2n6);
15540
15736
  const v = Fp.pow(n2, p5div8);
15541
15737
  const nv = Fp.mul(n, v);
15542
- const i = Fp.mul(Fp.mul(nv, _2n5), v);
15738
+ const i = Fp.mul(Fp.mul(nv, _2n6), v);
15543
15739
  const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
15544
15740
  assertIsSquare2(Fp, root, n);
15545
15741
  return root;
@@ -15550,7 +15746,7 @@ function sqrt9mod162(P) {
15550
15746
  const c1 = tn(Fp_, Fp_.neg(Fp_.ONE));
15551
15747
  const c2 = tn(Fp_, c1);
15552
15748
  const c3 = tn(Fp_, Fp_.neg(c1));
15553
- const c4 = (P + _7n3) / _16n2;
15749
+ const c4 = (P + _7n4) / _16n2;
15554
15750
  return (Fp, n) => {
15555
15751
  let tv1 = Fp.pow(n, c4);
15556
15752
  let tv2 = Fp.mul(tv1, c1);
@@ -15569,13 +15765,13 @@ function sqrt9mod162(P) {
15569
15765
  function tonelliShanks2(P) {
15570
15766
  if (P < _3n3)
15571
15767
  throw new Error("sqrt is not defined for small field");
15572
- let Q = P - _1n7;
15768
+ let Q = P - _1n8;
15573
15769
  let S = 0;
15574
- while (Q % _2n5 === _0n7) {
15575
- Q /= _2n5;
15770
+ while (Q % _2n6 === _0n8) {
15771
+ Q /= _2n6;
15576
15772
  S++;
15577
15773
  }
15578
- let Z = _2n5;
15774
+ let Z = _2n6;
15579
15775
  const _Fp = Field2(P);
15580
15776
  while (FpLegendre2(_Fp, Z) === 1) {
15581
15777
  if (Z++ > 1e3)
@@ -15584,7 +15780,7 @@ function tonelliShanks2(P) {
15584
15780
  if (S === 1)
15585
15781
  return sqrt3mod42;
15586
15782
  let cc = _Fp.pow(Z, Q);
15587
- const Q1div2 = (Q + _1n7) / _2n5;
15783
+ const Q1div2 = (Q + _1n8) / _2n6;
15588
15784
  return function tonelliSlow(Fp, n) {
15589
15785
  if (Fp.is0(n))
15590
15786
  return n;
@@ -15605,7 +15801,7 @@ function tonelliShanks2(P) {
15605
15801
  if (i === M)
15606
15802
  throw new Error("Cannot find square root");
15607
15803
  }
15608
- const exponent = _1n7 << BigInt(M - i - 1);
15804
+ const exponent = _1n8 << BigInt(M - i - 1);
15609
15805
  const b = Fp.pow(c, exponent);
15610
15806
  M = i;
15611
15807
  c = Fp.sqr(b);
@@ -15658,19 +15854,19 @@ function validateField2(field) {
15658
15854
  return field;
15659
15855
  }
15660
15856
  function FpPow2(Fp, num, power) {
15661
- if (power < _0n7)
15857
+ if (power < _0n8)
15662
15858
  throw new Error("invalid exponent, negatives unsupported");
15663
- if (power === _0n7)
15859
+ if (power === _0n8)
15664
15860
  return Fp.ONE;
15665
- if (power === _1n7)
15861
+ if (power === _1n8)
15666
15862
  return num;
15667
15863
  let p = Fp.ONE;
15668
15864
  let d = num;
15669
- while (power > _0n7) {
15670
- if (power & _1n7)
15865
+ while (power > _0n8) {
15866
+ if (power & _1n8)
15671
15867
  p = Fp.mul(p, d);
15672
15868
  d = Fp.sqr(d);
15673
- power >>= _1n7;
15869
+ power >>= _1n8;
15674
15870
  }
15675
15871
  return p;
15676
15872
  }
@@ -15692,7 +15888,7 @@ function FpInvertBatch2(Fp, nums, passZero = false) {
15692
15888
  return inverted;
15693
15889
  }
15694
15890
  function FpLegendre2(Fp, n) {
15695
- const p1mod2 = (Fp.ORDER - _1n7) / _2n5;
15891
+ const p1mod2 = (Fp.ORDER - _1n8) / _2n6;
15696
15892
  const powered = Fp.pow(n, p1mod2);
15697
15893
  const yes = Fp.eql(powered, Fp.ONE);
15698
15894
  const zero = Fp.eql(powered, Fp.ZERO);
@@ -15709,7 +15905,7 @@ function nLength2(n, nBitLength) {
15709
15905
  return { nBitLength: _nBitLength, nByteLength };
15710
15906
  }
15711
15907
  function Field2(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
15712
- if (ORDER <= _0n7)
15908
+ if (ORDER <= _0n8)
15713
15909
  throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
15714
15910
  let _nbitLength = void 0;
15715
15911
  let _sqrt = void 0;
@@ -15744,19 +15940,19 @@ function Field2(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
15744
15940
  BITS,
15745
15941
  BYTES,
15746
15942
  MASK: bitMask2(BITS),
15747
- ZERO: _0n7,
15748
- ONE: _1n7,
15943
+ ZERO: _0n8,
15944
+ ONE: _1n8,
15749
15945
  allowedLengths,
15750
15946
  create: (num) => mod2(num, ORDER),
15751
15947
  isValid: (num) => {
15752
15948
  if (typeof num !== "bigint")
15753
15949
  throw new Error("invalid field element: expected bigint, got " + typeof num);
15754
- return _0n7 <= num && num < ORDER;
15950
+ return _0n8 <= num && num < ORDER;
15755
15951
  },
15756
- is0: (num) => num === _0n7,
15952
+ is0: (num) => num === _0n8,
15757
15953
  // is valid and invertible
15758
15954
  isValidNot0: (num) => !f.is0(num) && f.isValid(num),
15759
- isOdd: (num) => (num & _1n7) === _1n7,
15955
+ isOdd: (num) => (num & _1n8) === _1n8,
15760
15956
  neg: (num) => mod2(-num, ORDER),
15761
15957
  eql: (lhs, rhs) => lhs === rhs,
15762
15958
  sqr: (num) => mod2(num * num, ORDER),
@@ -15822,13 +16018,13 @@ function mapHashToField2(key, fieldOrder, isLE2 = false) {
15822
16018
  if (len < 16 || len < minLen || len > 1024)
15823
16019
  throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
15824
16020
  const num = isLE2 ? bytesToNumberLE2(key) : bytesToNumberBE2(key);
15825
- const reduced = mod2(num, fieldOrder - _1n7) + _1n7;
16021
+ const reduced = mod2(num, fieldOrder - _1n8) + _1n8;
15826
16022
  return isLE2 ? numberToBytesLE2(reduced, fieldLen) : numberToBytesBE2(reduced, fieldLen);
15827
16023
  }
15828
16024
 
15829
16025
  // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/curve.js
15830
- var _0n8 = BigInt(0);
15831
- var _1n8 = BigInt(1);
16026
+ var _0n9 = BigInt(0);
16027
+ var _1n9 = BigInt(1);
15832
16028
  function negateCt2(condition, item) {
15833
16029
  const neg = item.negate();
15834
16030
  return condition ? neg : item;
@@ -15856,7 +16052,7 @@ function calcOffsets2(n, window2, wOpts) {
15856
16052
  let nextN = n >> shiftBy;
15857
16053
  if (wbits > windowSize) {
15858
16054
  wbits -= maxNumber;
15859
- nextN += _1n8;
16055
+ nextN += _1n9;
15860
16056
  }
15861
16057
  const offsetStart = window2 * windowSize;
15862
16058
  const offset = offsetStart + Math.abs(wbits) - 1;
@@ -15888,7 +16084,7 @@ function getW2(P) {
15888
16084
  return pointWindowSizes2.get(P) || 1;
15889
16085
  }
15890
16086
  function assert02(n) {
15891
- if (n !== _0n8)
16087
+ if (n !== _0n9)
15892
16088
  throw new Error("invalid wNAF");
15893
16089
  }
15894
16090
  var wNAF2 = class {
@@ -15902,11 +16098,11 @@ var wNAF2 = class {
15902
16098
  // non-const time multiplication ladder
15903
16099
  _unsafeLadder(elm, n, p = this.ZERO) {
15904
16100
  let d = elm;
15905
- while (n > _0n8) {
15906
- if (n & _1n8)
16101
+ while (n > _0n9) {
16102
+ if (n & _1n9)
15907
16103
  p = p.add(d);
15908
16104
  d = d.double();
15909
- n >>= _1n8;
16105
+ n >>= _1n9;
15910
16106
  }
15911
16107
  return p;
15912
16108
  }
@@ -15970,7 +16166,7 @@ var wNAF2 = class {
15970
16166
  wNAFUnsafe(W, precomputes, n, acc = this.ZERO) {
15971
16167
  const wo = calcWOpts2(W, this.bits);
15972
16168
  for (let window2 = 0; window2 < wo.windows; window2++) {
15973
- if (n === _0n8)
16169
+ if (n === _0n9)
15974
16170
  break;
15975
16171
  const { nextN, offset, isZero, isNeg } = calcOffsets2(n, window2, wo);
15976
16172
  n = nextN;
@@ -16022,14 +16218,14 @@ function mulEndoUnsafe2(Point2, point, k1, k2) {
16022
16218
  let acc = point;
16023
16219
  let p1 = Point2.ZERO;
16024
16220
  let p2 = Point2.ZERO;
16025
- while (k1 > _0n8 || k2 > _0n8) {
16026
- if (k1 & _1n8)
16221
+ while (k1 > _0n9 || k2 > _0n9) {
16222
+ if (k1 & _1n9)
16027
16223
  p1 = p1.add(acc);
16028
- if (k2 & _1n8)
16224
+ if (k2 & _1n9)
16029
16225
  p2 = p2.add(acc);
16030
16226
  acc = acc.double();
16031
- k1 >>= _1n8;
16032
- k2 >>= _1n8;
16227
+ k1 >>= _1n9;
16228
+ k2 >>= _1n9;
16033
16229
  }
16034
16230
  return { p1, p2 };
16035
16231
  }
@@ -16089,7 +16285,7 @@ function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
16089
16285
  throw new Error(`expected valid ${type} CURVE object`);
16090
16286
  for (const p of ["p", "n", "h"]) {
16091
16287
  const val = CURVE[p];
16092
- if (!(typeof val === "bigint" && val > _0n8))
16288
+ if (!(typeof val === "bigint" && val > _0n9))
16093
16289
  throw new Error(`CURVE.${p} must be positive bigint`);
16094
16290
  }
16095
16291
  const Fp = createField2(CURVE.p, curveOpts.Fp, FpFnLE);
@@ -16105,21 +16301,21 @@ function _createCurveFields(type, CURVE, curveOpts = {}, FpFnLE) {
16105
16301
  }
16106
16302
 
16107
16303
  // ../../node_modules/.pnpm/@noble+curves@1.9.7/node_modules/@noble/curves/esm/abstract/weierstrass.js
16108
- var divNearest2 = (num, den) => (num + (num >= 0 ? den : -den) / _2n6) / den;
16304
+ var divNearest2 = (num, den) => (num + (num >= 0 ? den : -den) / _2n7) / den;
16109
16305
  function _splitEndoScalar2(k, basis, n) {
16110
16306
  const [[a1, b1], [a2, b2]] = basis;
16111
16307
  const c1 = divNearest2(b2 * k, n);
16112
16308
  const c2 = divNearest2(-b1 * k, n);
16113
16309
  let k1 = k - c1 * a1 - c2 * a2;
16114
16310
  let k2 = -c1 * b1 - c2 * b2;
16115
- const k1neg = k1 < _0n9;
16116
- const k2neg = k2 < _0n9;
16311
+ const k1neg = k1 < _0n10;
16312
+ const k2neg = k2 < _0n10;
16117
16313
  if (k1neg)
16118
16314
  k1 = -k1;
16119
16315
  if (k2neg)
16120
16316
  k2 = -k2;
16121
- const MAX_NUM = bitMask2(Math.ceil(bitLen2(n) / 2)) + _1n9;
16122
- if (k1 < _0n9 || k1 >= MAX_NUM || k2 < _0n9 || k2 >= MAX_NUM) {
16317
+ const MAX_NUM = bitMask2(Math.ceil(bitLen2(n) / 2)) + _1n10;
16318
+ if (k1 < _0n10 || k1 >= MAX_NUM || k2 < _0n10 || k2 >= MAX_NUM) {
16123
16319
  throw new Error("splitScalar (endomorphism): failed, k=" + k);
16124
16320
  }
16125
16321
  return { k1neg, k1, k2neg, k2 };
@@ -16207,7 +16403,7 @@ var DER2 = {
16207
16403
  _int: {
16208
16404
  encode(num) {
16209
16405
  const { Err: E } = DER2;
16210
- if (num < _0n9)
16406
+ if (num < _0n10)
16211
16407
  throw new E("integer: negative integers are not allowed");
16212
16408
  let hex = numberToHexUnpadded2(num);
16213
16409
  if (Number.parseInt(hex[0], 16) & 8)
@@ -16245,9 +16441,9 @@ var DER2 = {
16245
16441
  return tlv.encode(48, seq);
16246
16442
  }
16247
16443
  };
16248
- var _0n9 = BigInt(0);
16249
- var _1n9 = BigInt(1);
16250
- var _2n6 = BigInt(2);
16444
+ var _0n10 = BigInt(0);
16445
+ var _1n10 = BigInt(1);
16446
+ var _2n7 = BigInt(2);
16251
16447
  var _3n4 = BigInt(3);
16252
16448
  var _4n4 = BigInt(4);
16253
16449
  function _normFnElement(Fn2, key) {
@@ -16619,9 +16815,9 @@ function weierstrassN(params, extraOpts = {}) {
16619
16815
  const p = this;
16620
16816
  if (!Fn2.isValid(sc))
16621
16817
  throw new Error("invalid scalar: out of range");
16622
- if (sc === _0n9 || p.is0())
16818
+ if (sc === _0n10 || p.is0())
16623
16819
  return Point2.ZERO;
16624
- if (sc === _1n9)
16820
+ if (sc === _1n10)
16625
16821
  return p;
16626
16822
  if (wnaf.hasCache(this))
16627
16823
  return this.multiply(sc);
@@ -16650,7 +16846,7 @@ function weierstrassN(params, extraOpts = {}) {
16650
16846
  */
16651
16847
  isTorsionFree() {
16652
16848
  const { isTorsionFree } = extraOpts;
16653
- if (cofactor === _1n9)
16849
+ if (cofactor === _1n10)
16654
16850
  return true;
16655
16851
  if (isTorsionFree)
16656
16852
  return isTorsionFree(Point2, this);
@@ -16658,7 +16854,7 @@ function weierstrassN(params, extraOpts = {}) {
16658
16854
  }
16659
16855
  clearCofactor() {
16660
16856
  const { clearCofactor } = extraOpts;
16661
- if (cofactor === _1n9)
16857
+ if (cofactor === _1n10)
16662
16858
  return this;
16663
16859
  if (clearCofactor)
16664
16860
  return clearCofactor(Point2, this);
@@ -16816,7 +17012,7 @@ function ecdsa2(Point2, hash, ecdsaOpts = {}) {
16816
17012
  };
16817
17013
  const defaultSigOpts_format = "compact";
16818
17014
  function isBiggerThanHalfOrder(number) {
16819
- const HALF = CURVE_ORDER >> _1n9;
17015
+ const HALF = CURVE_ORDER >> _1n10;
16820
17016
  return number > HALF;
16821
17017
  }
16822
17018
  function validateRS(title, num) {
@@ -16866,7 +17062,7 @@ function ecdsa2(Point2, hash, ecdsaOpts = {}) {
16866
17062
  const { r, s, recovery: rec } = this;
16867
17063
  if (rec == null || ![0, 1, 2, 3].includes(rec))
16868
17064
  throw new Error("recovery id invalid");
16869
- const hasCofactor = CURVE_ORDER * _2n6 < FIELD_ORDER;
17065
+ const hasCofactor = CURVE_ORDER * _2n7 < FIELD_ORDER;
16870
17066
  if (hasCofactor && rec > 1)
16871
17067
  throw new Error("recovery id is ambiguous for h>1 curve");
16872
17068
  const radj = rec === 2 || rec === 3 ? r + CURVE_ORDER : r;
@@ -16941,7 +17137,7 @@ function ecdsa2(Point2, hash, ecdsaOpts = {}) {
16941
17137
  };
16942
17138
  const ORDER_MASK = bitMask2(fnBits);
16943
17139
  function int2octets(num) {
16944
- aInRange2("num < 2^" + fnBits, num, _0n9, ORDER_MASK);
17140
+ aInRange2("num < 2^" + fnBits, num, _0n10, ORDER_MASK);
16945
17141
  return Fn2.toBytes(num);
16946
17142
  }
16947
17143
  function validateMsgAndHash(message, prehash) {
@@ -16969,12 +17165,12 @@ function ecdsa2(Point2, hash, ecdsaOpts = {}) {
16969
17165
  const ik = Fn2.inv(k);
16970
17166
  const q = Point2.BASE.multiply(k).toAffine();
16971
17167
  const r = Fn2.create(q.x);
16972
- if (r === _0n9)
17168
+ if (r === _0n10)
16973
17169
  return;
16974
17170
  const s = Fn2.create(ik * Fn2.create(m + r * d));
16975
- if (s === _0n9)
17171
+ if (s === _0n10)
16976
17172
  return;
16977
- let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n9);
17173
+ let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n10);
16978
17174
  let normS = s;
16979
17175
  if (lowS && isBiggerThanHalfOrder(s)) {
16980
17176
  normS = Fn2.neg(s);
@@ -17141,7 +17337,7 @@ var secp256k1_ENDO2 = {
17141
17337
  [BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), BigInt("0x3086d221a7d46bcde86c90e49284eb15")]
17142
17338
  ]
17143
17339
  };
17144
- var _2n7 = /* @__PURE__ */ BigInt(2);
17340
+ var _2n8 = /* @__PURE__ */ BigInt(2);
17145
17341
  function sqrtMod2(y) {
17146
17342
  const P = secp256k1_CURVE2.p;
17147
17343
  const _3n5 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
@@ -17150,7 +17346,7 @@ function sqrtMod2(y) {
17150
17346
  const b3 = b2 * b2 * y % P;
17151
17347
  const b6 = pow22(b3, _3n5, P) * b3 % P;
17152
17348
  const b9 = pow22(b6, _3n5, P) * b3 % P;
17153
- const b11 = pow22(b9, _2n7, P) * b2 % P;
17349
+ const b11 = pow22(b9, _2n8, P) * b2 % P;
17154
17350
  const b22 = pow22(b11, _11n, P) * b11 % P;
17155
17351
  const b44 = pow22(b22, _22n, P) * b22 % P;
17156
17352
  const b88 = pow22(b44, _44n, P) * b44 % P;
@@ -17159,7 +17355,7 @@ function sqrtMod2(y) {
17159
17355
  const b223 = pow22(b220, _3n5, P) * b3 % P;
17160
17356
  const t1 = pow22(b223, _23n, P) * b22 % P;
17161
17357
  const t2 = pow22(t1, _6n, P) * b2 % P;
17162
- const root = pow22(t2, _2n7, P);
17358
+ const root = pow22(t2, _2n8, P);
17163
17359
  if (!Fpk12.eql(Fpk12.sqr(root), y))
17164
17360
  throw new Error("Cannot find square root");
17165
17361
  return root;
@@ -17274,9 +17470,9 @@ async function deleteArweaveJwkFromCache(path, nodeType) {
17274
17470
  }
17275
17471
 
17276
17472
  // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/abstract/edwards.js
17277
- var _0n10 = BigInt(0);
17278
- var _1n10 = BigInt(1);
17279
- var _2n8 = BigInt(2);
17473
+ var _0n11 = BigInt(0);
17474
+ var _1n11 = BigInt(1);
17475
+ var _2n9 = BigInt(2);
17280
17476
  var _8n3 = BigInt(8);
17281
17477
  function isEdValidXY(Fp, CURVE, x, y) {
17282
17478
  const x2 = Fp.sqr(x);
@@ -17291,19 +17487,19 @@ function edwards(params, extraOpts = {}) {
17291
17487
  let CURVE = validated.CURVE;
17292
17488
  const { h: cofactor } = CURVE;
17293
17489
  validateObject(extraOpts, {}, { uvRatio: "function" });
17294
- const MASK = _2n8 << BigInt(Fn2.BYTES * 8) - _1n10;
17490
+ const MASK = _2n9 << BigInt(Fn2.BYTES * 8) - _1n11;
17295
17491
  const modP = (n) => Fp.create(n);
17296
17492
  const uvRatio2 = extraOpts.uvRatio || ((u, v) => {
17297
17493
  try {
17298
17494
  return { isValid: true, value: Fp.sqrt(Fp.div(u, v)) };
17299
17495
  } catch (e) {
17300
- return { isValid: false, value: _0n10 };
17496
+ return { isValid: false, value: _0n11 };
17301
17497
  }
17302
17498
  });
17303
17499
  if (!isEdValidXY(Fp, CURVE, CURVE.Gx, CURVE.Gy))
17304
17500
  throw new Error("bad curve params: generator point");
17305
17501
  function acoord(title, n, banZero = false) {
17306
- const min = banZero ? _1n10 : _0n10;
17502
+ const min = banZero ? _1n11 : _0n11;
17307
17503
  aInRange("coordinate " + title, n, min, MASK);
17308
17504
  return n;
17309
17505
  }
@@ -17320,8 +17516,8 @@ function edwards(params, extraOpts = {}) {
17320
17516
  const y = modP(Y * iz);
17321
17517
  const zz = Fp.mul(Z, iz);
17322
17518
  if (is0)
17323
- return { x: _0n10, y: _1n10 };
17324
- if (zz !== _1n10)
17519
+ return { x: _0n11, y: _1n11 };
17520
+ if (zz !== _1n11)
17325
17521
  throw new Error("invZ was invalid");
17326
17522
  return { x, y };
17327
17523
  });
@@ -17347,9 +17543,9 @@ function edwards(params, extraOpts = {}) {
17347
17543
  });
17348
17544
  class Point2 {
17349
17545
  // base / generator point
17350
- static BASE = new Point2(CURVE.Gx, CURVE.Gy, _1n10, modP(CURVE.Gx * CURVE.Gy));
17546
+ static BASE = new Point2(CURVE.Gx, CURVE.Gy, _1n11, modP(CURVE.Gx * CURVE.Gy));
17351
17547
  // zero / infinity / identity point
17352
- static ZERO = new Point2(_0n10, _1n10, _1n10, _0n10);
17548
+ static ZERO = new Point2(_0n11, _1n11, _1n11, _0n11);
17353
17549
  // 0, 1, 1, 0
17354
17550
  // math field
17355
17551
  static Fp = Fp;
@@ -17375,7 +17571,7 @@ function edwards(params, extraOpts = {}) {
17375
17571
  const { x, y } = p || {};
17376
17572
  acoord("x", x);
17377
17573
  acoord("y", y);
17378
- return new Point2(x, y, _1n10, modP(x * y));
17574
+ return new Point2(x, y, _1n11, modP(x * y));
17379
17575
  }
17380
17576
  // Uses algo from RFC8032 5.1.3.
17381
17577
  static fromBytes(bytes, zip215 = false) {
@@ -17388,16 +17584,16 @@ function edwards(params, extraOpts = {}) {
17388
17584
  normed[len - 1] = lastByte & ~128;
17389
17585
  const y = bytesToNumberLE(normed);
17390
17586
  const max = zip215 ? MASK : Fp.ORDER;
17391
- aInRange("point.y", y, _0n10, max);
17587
+ aInRange("point.y", y, _0n11, max);
17392
17588
  const y2 = modP(y * y);
17393
- const u = modP(y2 - _1n10);
17589
+ const u = modP(y2 - _1n11);
17394
17590
  const v = modP(d * y2 - a);
17395
17591
  let { isValid, value: x } = uvRatio2(u, v);
17396
17592
  if (!isValid)
17397
17593
  throw new Error("bad point: invalid y coordinate");
17398
- const isXOdd = (x & _1n10) === _1n10;
17594
+ const isXOdd = (x & _1n11) === _1n11;
17399
17595
  const isLastByteOdd = (lastByte & 128) !== 0;
17400
- if (!zip215 && x === _0n10 && isLastByteOdd)
17596
+ if (!zip215 && x === _0n11 && isLastByteOdd)
17401
17597
  throw new Error("bad point: x=0 and x_0=1");
17402
17598
  if (isLastByteOdd !== isXOdd)
17403
17599
  x = modP(-x);
@@ -17415,7 +17611,7 @@ function edwards(params, extraOpts = {}) {
17415
17611
  precompute(windowSize = 8, isLazy = true) {
17416
17612
  wnaf.createCache(this, windowSize);
17417
17613
  if (!isLazy)
17418
- this.multiply(_2n8);
17614
+ this.multiply(_2n9);
17419
17615
  return this;
17420
17616
  }
17421
17617
  // Useful in fromAffine() - not for fromBytes(), which always created valid points.
@@ -17447,7 +17643,7 @@ function edwards(params, extraOpts = {}) {
17447
17643
  const { X: X1, Y: Y1, Z: Z1 } = this;
17448
17644
  const A = modP(X1 * X1);
17449
17645
  const B = modP(Y1 * Y1);
17450
- const C = modP(_2n8 * modP(Z1 * Z1));
17646
+ const C = modP(_2n9 * modP(Z1 * Z1));
17451
17647
  const D = modP(a * A);
17452
17648
  const x1y1 = X1 + Y1;
17453
17649
  const E = modP(modP(x1y1 * x1y1) - A - B);
@@ -17500,9 +17696,9 @@ function edwards(params, extraOpts = {}) {
17500
17696
  multiplyUnsafe(scalar, acc = Point2.ZERO) {
17501
17697
  if (!Fn2.isValid(scalar))
17502
17698
  throw new Error("invalid scalar: expected 0 <= sc < curve.n");
17503
- if (scalar === _0n10)
17699
+ if (scalar === _0n11)
17504
17700
  return Point2.ZERO;
17505
- if (this.is0() || scalar === _1n10)
17701
+ if (this.is0() || scalar === _1n11)
17506
17702
  return this;
17507
17703
  return wnaf.unsafe(this, scalar, (p) => normalizeZ(Point2, p), acc);
17508
17704
  }
@@ -17524,14 +17720,14 @@ function edwards(params, extraOpts = {}) {
17524
17720
  return toAffineMemo(this, invertedZ);
17525
17721
  }
17526
17722
  clearCofactor() {
17527
- if (cofactor === _1n10)
17723
+ if (cofactor === _1n11)
17528
17724
  return this;
17529
17725
  return this.multiplyUnsafe(cofactor);
17530
17726
  }
17531
17727
  toBytes() {
17532
17728
  const { x, y } = this.toAffine();
17533
17729
  const bytes = Fp.toBytes(y);
17534
- bytes[bytes.length - 1] |= x & _1n10 ? 128 : 0;
17730
+ bytes[bytes.length - 1] |= x & _1n11 ? 128 : 0;
17535
17731
  return bytes;
17536
17732
  }
17537
17733
  toHex() {
@@ -17672,7 +17868,7 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
17672
17868
  const is25519 = size === 32;
17673
17869
  if (!is25519 && size !== 57)
17674
17870
  throw new Error("only defined for 25519 and 448");
17675
- const u = is25519 ? Fp.div(_1n10 + y, _1n10 - y) : Fp.div(y - _1n10, y + _1n10);
17871
+ const u = is25519 ? Fp.div(_1n11 + y, _1n11 - y) : Fp.div(y - _1n11, y + _1n11);
17676
17872
  return Fp.toBytes(u);
17677
17873
  },
17678
17874
  toMontgomerySecret(secretKey) {
@@ -17694,8 +17890,8 @@ function eddsa(Point2, cHash, eddsaOpts = {}) {
17694
17890
  }
17695
17891
 
17696
17892
  // ../../node_modules/.pnpm/@noble+curves@2.0.1/node_modules/@noble/curves/ed25519.js
17697
- var _1n11 = BigInt(1);
17698
- var _2n9 = BigInt(2);
17893
+ var _1n12 = BigInt(1);
17894
+ var _2n10 = BigInt(2);
17699
17895
  var _5n3 = BigInt(5);
17700
17896
  var _8n4 = BigInt(8);
17701
17897
  var ed25519_CURVE_p = BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed");
@@ -17713,8 +17909,8 @@ function ed25519_pow_2_252_3(x) {
17713
17909
  const P = ed25519_CURVE_p;
17714
17910
  const x2 = x * x % P;
17715
17911
  const b2 = x2 * x % P;
17716
- const b4 = pow2(b2, _2n9, P) * b2 % P;
17717
- const b5 = pow2(b4, _1n11, P) * x % P;
17912
+ const b4 = pow2(b2, _2n10, P) * b2 % P;
17913
+ const b5 = pow2(b4, _1n12, P) * x % P;
17718
17914
  const b10 = pow2(b5, _5n3, P) * b5 % P;
17719
17915
  const b20 = pow2(b10, _10n, P) * b10 % P;
17720
17916
  const b40 = pow2(b20, _20n, P) * b20 % P;
@@ -17722,7 +17918,7 @@ function ed25519_pow_2_252_3(x) {
17722
17918
  const b160 = pow2(b80, _80n, P) * b80 % P;
17723
17919
  const b240 = pow2(b160, _80n, P) * b80 % P;
17724
17920
  const b250 = pow2(b240, _10n, P) * b10 % P;
17725
- const pow_p_5_8 = pow2(b250, _2n9, P) * x % P;
17921
+ const pow_p_5_8 = pow2(b250, _2n10, P) * x % P;
17726
17922
  return { pow_p_5_8, b2 };
17727
17923
  }
17728
17924
  function adjustScalarBytes(bytes) {
@@ -17758,191 +17954,6 @@ function ed(opts) {
17758
17954
  }
17759
17955
  var ed25519 = /* @__PURE__ */ ed({});
17760
17956
 
17761
- // ../../node_modules/.pnpm/@noble+hashes@2.0.1/node_modules/@noble/hashes/sha3.js
17762
- var _0n11 = BigInt(0);
17763
- var _1n12 = BigInt(1);
17764
- var _2n10 = BigInt(2);
17765
- var _7n4 = BigInt(7);
17766
- var _256n2 = BigInt(256);
17767
- var _0x71n2 = BigInt(113);
17768
- var SHA3_PI2 = [];
17769
- var SHA3_ROTL2 = [];
17770
- var _SHA3_IOTA2 = [];
17771
- for (let round = 0, R = _1n12, x = 1, y = 0; round < 24; round++) {
17772
- [x, y] = [y, (2 * x + 3 * y) % 5];
17773
- SHA3_PI2.push(2 * (5 * y + x));
17774
- SHA3_ROTL2.push((round + 1) * (round + 2) / 2 % 64);
17775
- let t = _0n11;
17776
- for (let j = 0; j < 7; j++) {
17777
- R = (R << _1n12 ^ (R >> _7n4) * _0x71n2) % _256n2;
17778
- if (R & _2n10)
17779
- t ^= _1n12 << (_1n12 << BigInt(j)) - _1n12;
17780
- }
17781
- _SHA3_IOTA2.push(t);
17782
- }
17783
- var IOTAS2 = split2(_SHA3_IOTA2, true);
17784
- var SHA3_IOTA_H2 = IOTAS2[0];
17785
- var SHA3_IOTA_L2 = IOTAS2[1];
17786
- var rotlH2 = (h, l, s) => s > 32 ? rotlBH2(h, l, s) : rotlSH2(h, l, s);
17787
- var rotlL2 = (h, l, s) => s > 32 ? rotlBL2(h, l, s) : rotlSL2(h, l, s);
17788
- function keccakP2(s, rounds = 24) {
17789
- const B = new Uint32Array(5 * 2);
17790
- for (let round = 24 - rounds; round < 24; round++) {
17791
- for (let x = 0; x < 10; x++)
17792
- B[x] = s[x] ^ s[x + 10] ^ s[x + 20] ^ s[x + 30] ^ s[x + 40];
17793
- for (let x = 0; x < 10; x += 2) {
17794
- const idx1 = (x + 8) % 10;
17795
- const idx0 = (x + 2) % 10;
17796
- const B0 = B[idx0];
17797
- const B1 = B[idx0 + 1];
17798
- const Th = rotlH2(B0, B1, 1) ^ B[idx1];
17799
- const Tl = rotlL2(B0, B1, 1) ^ B[idx1 + 1];
17800
- for (let y = 0; y < 50; y += 10) {
17801
- s[x + y] ^= Th;
17802
- s[x + y + 1] ^= Tl;
17803
- }
17804
- }
17805
- let curH = s[2];
17806
- let curL = s[3];
17807
- for (let t = 0; t < 24; t++) {
17808
- const shift = SHA3_ROTL2[t];
17809
- const Th = rotlH2(curH, curL, shift);
17810
- const Tl = rotlL2(curH, curL, shift);
17811
- const PI = SHA3_PI2[t];
17812
- curH = s[PI];
17813
- curL = s[PI + 1];
17814
- s[PI] = Th;
17815
- s[PI + 1] = Tl;
17816
- }
17817
- for (let y = 0; y < 50; y += 10) {
17818
- for (let x = 0; x < 10; x++)
17819
- B[x] = s[y + x];
17820
- for (let x = 0; x < 10; x++)
17821
- s[y + x] ^= ~B[(x + 2) % 10] & B[(x + 4) % 10];
17822
- }
17823
- s[0] ^= SHA3_IOTA_H2[round];
17824
- s[1] ^= SHA3_IOTA_L2[round];
17825
- }
17826
- clean2(B);
17827
- }
17828
- var Keccak2 = class _Keccak {
17829
- state;
17830
- pos = 0;
17831
- posOut = 0;
17832
- finished = false;
17833
- state32;
17834
- destroyed = false;
17835
- blockLen;
17836
- suffix;
17837
- outputLen;
17838
- enableXOF = false;
17839
- rounds;
17840
- // NOTE: we accept arguments in bytes instead of bits here.
17841
- constructor(blockLen, suffix, outputLen, enableXOF = false, rounds = 24) {
17842
- this.blockLen = blockLen;
17843
- this.suffix = suffix;
17844
- this.outputLen = outputLen;
17845
- this.enableXOF = enableXOF;
17846
- this.rounds = rounds;
17847
- anumber2(outputLen, "outputLen");
17848
- if (!(0 < blockLen && blockLen < 200))
17849
- throw new Error("only keccak-f1600 function is supported");
17850
- this.state = new Uint8Array(200);
17851
- this.state32 = u322(this.state);
17852
- }
17853
- clone() {
17854
- return this._cloneInto();
17855
- }
17856
- keccak() {
17857
- swap32IfBE2(this.state32);
17858
- keccakP2(this.state32, this.rounds);
17859
- swap32IfBE2(this.state32);
17860
- this.posOut = 0;
17861
- this.pos = 0;
17862
- }
17863
- update(data) {
17864
- aexists2(this);
17865
- abytes2(data);
17866
- const { blockLen, state } = this;
17867
- const len = data.length;
17868
- for (let pos = 0; pos < len; ) {
17869
- const take = Math.min(blockLen - this.pos, len - pos);
17870
- for (let i = 0; i < take; i++)
17871
- state[this.pos++] ^= data[pos++];
17872
- if (this.pos === blockLen)
17873
- this.keccak();
17874
- }
17875
- return this;
17876
- }
17877
- finish() {
17878
- if (this.finished)
17879
- return;
17880
- this.finished = true;
17881
- const { state, suffix, pos, blockLen } = this;
17882
- state[pos] ^= suffix;
17883
- if ((suffix & 128) !== 0 && pos === blockLen - 1)
17884
- this.keccak();
17885
- state[blockLen - 1] ^= 128;
17886
- this.keccak();
17887
- }
17888
- writeInto(out) {
17889
- aexists2(this, false);
17890
- abytes2(out);
17891
- this.finish();
17892
- const bufferOut = this.state;
17893
- const { blockLen } = this;
17894
- for (let pos = 0, len = out.length; pos < len; ) {
17895
- if (this.posOut >= blockLen)
17896
- this.keccak();
17897
- const take = Math.min(blockLen - this.posOut, len - pos);
17898
- out.set(bufferOut.subarray(this.posOut, this.posOut + take), pos);
17899
- this.posOut += take;
17900
- pos += take;
17901
- }
17902
- return out;
17903
- }
17904
- xofInto(out) {
17905
- if (!this.enableXOF)
17906
- throw new Error("XOF is not possible for this instance");
17907
- return this.writeInto(out);
17908
- }
17909
- xof(bytes) {
17910
- anumber2(bytes);
17911
- return this.xofInto(new Uint8Array(bytes));
17912
- }
17913
- digestInto(out) {
17914
- aoutput2(out, this);
17915
- if (this.finished)
17916
- throw new Error("digest() was already called");
17917
- this.writeInto(out);
17918
- this.destroy();
17919
- return out;
17920
- }
17921
- digest() {
17922
- return this.digestInto(new Uint8Array(this.outputLen));
17923
- }
17924
- destroy() {
17925
- this.destroyed = true;
17926
- clean2(this.state);
17927
- }
17928
- _cloneInto(to) {
17929
- const { blockLen, suffix, outputLen, rounds, enableXOF } = this;
17930
- to ||= new _Keccak(blockLen, suffix, outputLen, enableXOF, rounds);
17931
- to.state32.set(this.state32);
17932
- to.pos = this.pos;
17933
- to.posOut = this.posOut;
17934
- to.finished = this.finished;
17935
- to.rounds = rounds;
17936
- to.suffix = suffix;
17937
- to.outputLen = outputLen;
17938
- to.enableXOF = enableXOF;
17939
- to.destroyed = this.destroyed;
17940
- return to;
17941
- }
17942
- };
17943
- var genKeccak = (suffix, blockLen, outputLen, info = {}) => createHasher2(() => new Keccak2(blockLen, suffix, outputLen), info);
17944
- var keccak_2562 = /* @__PURE__ */ genKeccak(1, 136, 32);
17945
-
17946
17957
  // ../mill/dist/chunk-44VWYELC.js
17947
17958
  var import_ed25519_hd_key = __toESM(require_dist(), 1);
17948
17959
  var MillWalletError = class extends Error {
@@ -18014,13 +18025,13 @@ function deriveEvm(seed, accountIndex, addressIndex) {
18014
18025
  }
18015
18026
  function computeEvmAddress(privateKey) {
18016
18027
  const uncompressed = secp256k1.getPublicKey(privateKey, false);
18017
- const hash = keccak_2562(uncompressed.slice(1));
18028
+ const hash = keccak_256(uncompressed.slice(1));
18018
18029
  const addressHex = bytesToHex2(hash.slice(-20));
18019
18030
  return toChecksumAddress(addressHex);
18020
18031
  }
18021
18032
  function toChecksumAddress(addressHex) {
18022
18033
  const lower = addressHex.toLowerCase();
18023
- const hashHex = bytesToHex2(keccak_2562(new TextEncoder().encode(lower)));
18034
+ const hashHex = bytesToHex2(keccak_256(new TextEncoder().encode(lower)));
18024
18035
  let out = "0x";
18025
18036
  for (let i = 0; i < 40; i++) {
18026
18037
  const ch = lower.charAt(i);
@@ -18048,7 +18059,7 @@ function deriveMina(seed, accountIndex, addressIndex) {
18048
18059
  const firstByte = scalar[0];
18049
18060
  scalar[0] = firstByte & 63;
18050
18061
  const privateKeyHex = bytesToHex2(scalar);
18051
- const publicKeyHex = bytesToHex2(keccak_2562(scalar));
18062
+ const publicKeyHex = bytesToHex2(keccak_256(scalar));
18052
18063
  return {
18053
18064
  privateKey: privateKeyHex,
18054
18065
  publicKey: publicKeyHex,
@@ -18261,6 +18272,37 @@ var WalletManager = class {
18261
18272
  const keys = this.getNodeKeys(nodeType);
18262
18273
  return bytesToHex(keys.evmPrivateKey);
18263
18274
  }
18275
+ /**
18276
+ * Derive the APEX (connector) settlement key from the operator mnemonic at
18277
+ * ACCOUNT_INDEX_APEX. The apex signs settlement claims with this key, so the
18278
+ * operator never has to supply a raw `keyId` to `townhouse chains add`.
18279
+ *
18280
+ * Returns the EVM private key as a `0x`-prefixed 64-char hex string — the
18281
+ * form the connector config's `keyId` expects (matches the dev placeholder
18282
+ * `0x7c85…`). Throws when the wallet is locked. Structured as an object so
18283
+ * Solana/Mina apex keys can be added in a later phase.
18284
+ */
18285
+ getApexSettlementKeys() {
18286
+ if (!this.state) {
18287
+ throw new Error(
18288
+ "Wallet not initialized. Call generate() or fromMnemonic() first."
18289
+ );
18290
+ }
18291
+ let seed;
18292
+ try {
18293
+ seed = mnemonicToSeedSync(this.state.mnemonic);
18294
+ const path = `m/44'/60'/${ACCOUNT_INDEX_APEX}'/0/0`;
18295
+ const hd = HDKey.fromMasterSeed(seed).derive(path);
18296
+ if (!hd.privateKey) {
18297
+ throw new Error(`Apex EVM private key missing at ${path}`);
18298
+ }
18299
+ return {
18300
+ evmPrivateKeyHex: `0x${bytesToHex(new Uint8Array(hd.privateKey))}`
18301
+ };
18302
+ } finally {
18303
+ if (seed) seed.fill(0);
18304
+ }
18305
+ }
18264
18306
  /**
18265
18307
  * Returns the Solana Ed25519 private key seed for a node as a 64-char
18266
18308
  * lowercase hex string (32 raw seed bytes). Throws when the wallet is
@@ -18512,13 +18554,13 @@ function zeroArweaveJwk(jwk) {
18512
18554
  }
18513
18555
  function computeEvmAddress2(privateKey) {
18514
18556
  const uncompressed = secp256k12.getPublicKey(privateKey, false);
18515
- const hash = keccak_256(uncompressed.slice(1));
18557
+ const hash = keccak_2562(uncompressed.slice(1));
18516
18558
  const addressHex = bytesToHex(hash.slice(-20));
18517
18559
  return toChecksumAddress2(addressHex);
18518
18560
  }
18519
18561
  function toChecksumAddress2(addressHex) {
18520
18562
  const lower = addressHex.toLowerCase();
18521
- const hashHex = bytesToHex(keccak_256(new TextEncoder().encode(lower)));
18563
+ const hashHex = bytesToHex(keccak_2562(new TextEncoder().encode(lower)));
18522
18564
  let out = "0x";
18523
18565
  for (let i = 0; i < 40; i++) {
18524
18566
  const ch = lower.charAt(i);
@@ -22862,4 +22904,4 @@ export {
22862
22904
  @scure/bip32/index.js:
22863
22905
  (*! scure-bip32 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) *)
22864
22906
  */
22865
- //# sourceMappingURL=chunk-ZUMMJFGH.js.map
22907
+ //# sourceMappingURL=chunk-BDT2FIQL.js.map