nostr-double-ratchet 0.0.6 → 0.0.7

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.
@@ -5,7 +5,7 @@ function En(e) {
5
5
  if (!Number.isSafeInteger(e) || e < 0)
6
6
  throw new Error(`Wrong positive integer: ${e}`);
7
7
  }
8
- function Pn(e, ...t) {
8
+ function On(e, ...t) {
9
9
  if (!(e instanceof Uint8Array))
10
10
  throw new Error("Expected Uint8Array");
11
11
  if (t.length > 0 && !t.includes(e.length))
@@ -23,14 +23,14 @@ function rt(e, t = !0) {
23
23
  throw new Error("Hash#digest() has already been called");
24
24
  }
25
25
  function ci(e, t) {
26
- Pn(e);
26
+ On(e);
27
27
  const n = t.outputLen;
28
28
  if (e.length < n)
29
29
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
30
30
  }
31
31
  const St = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
32
32
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
33
- const On = (e) => e instanceof Uint8Array, At = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ne = (e, t) => e << 32 - t | e >>> t, li = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
33
+ const Pn = (e) => e instanceof Uint8Array, At = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ne = (e, t) => e << 32 - t | e >>> t, li = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
34
34
  if (!li)
35
35
  throw new Error("Non little-endian hardware is not supported");
36
36
  function ui(e) {
@@ -38,8 +38,8 @@ function ui(e) {
38
38
  throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
39
39
  return new Uint8Array(new TextEncoder().encode(e));
40
40
  }
41
- function Vt(e) {
42
- if (typeof e == "string" && (e = ui(e)), !On(e))
41
+ function Zt(e) {
42
+ if (typeof e == "string" && (e = ui(e)), !Pn(e))
43
43
  throw new Error(`expected Uint8Array, got ${typeof e}`);
44
44
  return e;
45
45
  }
@@ -47,7 +47,7 @@ function fi(...e) {
47
47
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
48
48
  let n = 0;
49
49
  return e.forEach((r) => {
50
- if (!On(r))
50
+ if (!Pn(r))
51
51
  throw new Error("Uint8Array expected");
52
52
  t.set(r, n), n += r.length;
53
53
  }), t;
@@ -59,7 +59,7 @@ let Mn = class {
59
59
  }
60
60
  };
61
61
  function hi(e) {
62
- const t = (r) => e().update(Vt(r)).digest(), n = e();
62
+ const t = (r) => e().update(Zt(r)).digest(), n = e();
63
63
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
64
64
  }
65
65
  function Hn(e = 32) {
@@ -70,8 +70,8 @@ function Hn(e = 32) {
70
70
  function di(e, t, n, r) {
71
71
  if (typeof e.setBigUint64 == "function")
72
72
  return e.setBigUint64(t, n, r);
73
- const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), c = Number(n & o), a = r ? 4 : 0, l = r ? 0 : 4;
74
- e.setUint32(t + a, s, r), e.setUint32(t + l, c, r);
73
+ const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), a = Number(n & o), c = r ? 4 : 0, l = r ? 0 : 4;
74
+ e.setUint32(t + c, s, r), e.setUint32(t + l, a, r);
75
75
  }
76
76
  let yi = class extends Mn {
77
77
  constructor(t, n, r, i) {
@@ -80,17 +80,17 @@ let yi = class extends Mn {
80
80
  update(t) {
81
81
  rt(this);
82
82
  const { view: n, buffer: r, blockLen: i } = this;
83
- t = Vt(t);
83
+ t = Zt(t);
84
84
  const o = t.length;
85
85
  for (let s = 0; s < o; ) {
86
- const c = Math.min(i - this.pos, o - s);
87
- if (c === i) {
88
- const a = At(t);
86
+ const a = Math.min(i - this.pos, o - s);
87
+ if (a === i) {
88
+ const c = At(t);
89
89
  for (; i <= o - s; s += i)
90
- this.process(a, s);
90
+ this.process(c, s);
91
91
  continue;
92
92
  }
93
- r.set(t.subarray(s, s + c), this.pos), this.pos += c, s += c, this.pos === i && (this.process(n, 0), this.pos = 0);
93
+ r.set(t.subarray(s, s + a), this.pos), this.pos += a, s += a, this.pos === i && (this.process(n, 0), this.pos = 0);
94
94
  }
95
95
  return this.length += t.length, this.roundClean(), this;
96
96
  }
@@ -102,14 +102,14 @@ let yi = class extends Mn {
102
102
  for (let u = s; u < i; u++)
103
103
  n[u] = 0;
104
104
  di(r, i - 8, BigInt(this.length * 8), o), this.process(r, 0);
105
- const c = At(t), a = this.outputLen;
106
- if (a % 4)
105
+ const a = At(t), c = this.outputLen;
106
+ if (c % 4)
107
107
  throw new Error("_sha2: outputLen should be aligned to 32bit");
108
- const l = a / 4, f = this.get();
108
+ const l = c / 4, f = this.get();
109
109
  if (l > f.length)
110
110
  throw new Error("_sha2: outputLen bigger than state");
111
111
  for (let u = 0; u < l; u++)
112
- c.setUint32(4 * u, f[u], o);
112
+ a.setUint32(4 * u, f[u], o);
113
113
  }
114
114
  digest() {
115
115
  const { buffer: t, outputLen: n } = this;
@@ -119,8 +119,8 @@ let yi = class extends Mn {
119
119
  }
120
120
  _cloneInto(t) {
121
121
  t || (t = new this.constructor()), t.set(...this.get());
122
- const { blockLen: n, buffer: r, length: i, finished: o, destroyed: s, pos: c } = this;
123
- return t.length = i, t.pos = c, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
122
+ const { blockLen: n, buffer: r, length: i, finished: o, destroyed: s, pos: a } = this;
123
+ return t.length = i, t.pos = a, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
124
124
  }
125
125
  };
126
126
  const pi = (e, t, n) => e & t ^ ~e & n, gi = (e, t, n) => e & t ^ e & n ^ t & n, wi = /* @__PURE__ */ new Uint32Array([
@@ -203,12 +203,12 @@ let bi = class extends yi {
203
203
  super(64, 32, 8, !1), this.A = ge[0] | 0, this.B = ge[1] | 0, this.C = ge[2] | 0, this.D = ge[3] | 0, this.E = ge[4] | 0, this.F = ge[5] | 0, this.G = ge[6] | 0, this.H = ge[7] | 0;
204
204
  }
205
205
  get() {
206
- const { A: t, B: n, C: r, D: i, E: o, F: s, G: c, H: a } = this;
207
- return [t, n, r, i, o, s, c, a];
206
+ const { A: t, B: n, C: r, D: i, E: o, F: s, G: a, H: c } = this;
207
+ return [t, n, r, i, o, s, a, c];
208
208
  }
209
209
  // prettier-ignore
210
- set(t, n, r, i, o, s, c, a) {
211
- this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = c | 0, this.H = a | 0;
210
+ set(t, n, r, i, o, s, a, c) {
211
+ this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = a | 0, this.H = c | 0;
212
212
  }
213
213
  process(t, n) {
214
214
  for (let u = 0; u < 16; u++, n += 4)
@@ -217,12 +217,12 @@ let bi = class extends yi {
217
217
  const d = we[u - 15], p = we[u - 2], g = ne(d, 7) ^ ne(d, 18) ^ d >>> 3, h = ne(p, 17) ^ ne(p, 19) ^ p >>> 10;
218
218
  we[u] = h + we[u - 7] + g + we[u - 16] | 0;
219
219
  }
220
- let { A: r, B: i, C: o, D: s, E: c, F: a, G: l, H: f } = this;
220
+ let { A: r, B: i, C: o, D: s, E: a, F: c, G: l, H: f } = this;
221
221
  for (let u = 0; u < 64; u++) {
222
- const d = ne(c, 6) ^ ne(c, 11) ^ ne(c, 25), p = f + d + pi(c, a, l) + wi[u] + we[u] | 0, h = (ne(r, 2) ^ ne(r, 13) ^ ne(r, 22)) + gi(r, i, o) | 0;
223
- f = l, l = a, a = c, c = s + p | 0, s = o, o = i, i = r, r = p + h | 0;
222
+ const d = ne(a, 6) ^ ne(a, 11) ^ ne(a, 25), p = f + d + pi(a, c, l) + wi[u] + we[u] | 0, h = (ne(r, 2) ^ ne(r, 13) ^ ne(r, 22)) + gi(r, i, o) | 0;
223
+ f = l, l = c, c = a, a = s + p | 0, s = o, o = i, i = r, r = p + h | 0;
224
224
  }
225
- r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, c, a, l, f);
225
+ r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, a, c, l, f);
226
226
  }
227
227
  roundClean() {
228
228
  we.fill(0);
@@ -231,22 +231,22 @@ let bi = class extends yi {
231
231
  this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
232
232
  }
233
233
  };
234
- const Lt = /* @__PURE__ */ hi(() => new bi());
234
+ const $t = /* @__PURE__ */ hi(() => new bi());
235
235
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
236
- const qn = BigInt(0), lt = BigInt(1), vi = BigInt(2), ut = (e) => e instanceof Uint8Array, Ei = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
236
+ const qn = BigInt(0), lt = BigInt(1), vi = BigInt(2), ut = (e) => e instanceof Uint8Array, mi = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
237
237
  function He(e) {
238
238
  if (!ut(e))
239
239
  throw new Error("Uint8Array expected");
240
240
  let t = "";
241
241
  for (let n = 0; n < e.length; n++)
242
- t += Ei[e[n]];
242
+ t += mi[e[n]];
243
243
  return t;
244
244
  }
245
245
  function Dn(e) {
246
246
  const t = e.toString(16);
247
247
  return t.length & 1 ? `0${t}` : t;
248
248
  }
249
- function Zt(e) {
249
+ function Ft(e) {
250
250
  if (typeof e != "string")
251
251
  throw new Error("hex string expected, got " + typeof e);
252
252
  return BigInt(e === "" ? "0" : `0x${e}`);
@@ -267,20 +267,20 @@ function qe(e) {
267
267
  return n;
268
268
  }
269
269
  function G(e) {
270
- return Zt(He(e));
270
+ return Ft(He(e));
271
271
  }
272
- function Ft(e) {
272
+ function Wt(e) {
273
273
  if (!ut(e))
274
274
  throw new Error("Uint8Array expected");
275
- return Zt(He(Uint8Array.from(e).reverse()));
275
+ return Ft(He(Uint8Array.from(e).reverse()));
276
276
  }
277
277
  function xe(e, t) {
278
278
  return qe(e.toString(16).padStart(t * 2, "0"));
279
279
  }
280
- function Wt(e, t) {
280
+ function Gt(e, t) {
281
281
  return xe(e, t).reverse();
282
282
  }
283
- function mi(e) {
283
+ function Ei(e) {
284
284
  return qe(Dn(e));
285
285
  }
286
286
  function Z(e, t, n) {
@@ -300,7 +300,7 @@ function Z(e, t, n) {
300
300
  throw new Error(`${e} expected ${n} bytes, got ${i}`);
301
301
  return r;
302
302
  }
303
- function Ie(...e) {
303
+ function ke(...e) {
304
304
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
305
305
  let n = 0;
306
306
  return e.forEach((r) => {
@@ -331,7 +331,7 @@ function Ai(e) {
331
331
  function Ki(e, t) {
332
332
  return e >> BigInt(t) & lt;
333
333
  }
334
- const Ni = (e, t, n) => e | (n ? lt : qn) << BigInt(t), Gt = (e) => (vi << BigInt(e - 1)) - lt, Kt = (e) => new Uint8Array(e), mn = (e) => Uint8Array.from(e);
334
+ const Ni = (e, t, n) => e | (n ? lt : qn) << BigInt(t), Jt = (e) => (vi << BigInt(e - 1)) - lt, Kt = (e) => new Uint8Array(e), xn = (e) => Uint8Array.from(e);
335
335
  function jn(e, t, n) {
336
336
  if (typeof e != "number" || e < 2)
337
337
  throw new Error("hashLen must be a number");
@@ -342,29 +342,29 @@ function jn(e, t, n) {
342
342
  let r = Kt(e), i = Kt(e), o = 0;
343
343
  const s = () => {
344
344
  r.fill(1), i.fill(0), o = 0;
345
- }, c = (...u) => n(i, r, ...u), a = (u = Kt()) => {
346
- i = c(mn([0]), u), r = c(), u.length !== 0 && (i = c(mn([1]), u), r = c());
345
+ }, a = (...u) => n(i, r, ...u), c = (u = Kt()) => {
346
+ i = a(xn([0]), u), r = a(), u.length !== 0 && (i = a(xn([1]), u), r = a());
347
347
  }, l = () => {
348
348
  if (o++ >= 1e3)
349
349
  throw new Error("drbg: tried 1000 values");
350
350
  let u = 0;
351
351
  const d = [];
352
352
  for (; u < t; ) {
353
- r = c();
353
+ r = a();
354
354
  const p = r.slice();
355
355
  d.push(p), u += r.length;
356
356
  }
357
- return Ie(...d);
357
+ return ke(...d);
358
358
  };
359
359
  return (u, d) => {
360
- s(), a(u);
360
+ s(), c(u);
361
361
  let p;
362
362
  for (; !(p = d(l())); )
363
- a();
363
+ c();
364
364
  return s(), p;
365
365
  };
366
366
  }
367
- const Bi = {
367
+ const Ci = {
368
368
  bigint: (e) => typeof e == "bigint",
369
369
  function: (e) => typeof e == "function",
370
370
  boolean: (e) => typeof e == "boolean",
@@ -377,12 +377,12 @@ const Bi = {
377
377
  };
378
378
  function Je(e, t, n = {}) {
379
379
  const r = (i, o, s) => {
380
- const c = Bi[o];
381
- if (typeof c != "function")
380
+ const a = Ci[o];
381
+ if (typeof a != "function")
382
382
  throw new Error(`Invalid validator "${o}", expected function`);
383
- const a = e[i];
384
- if (!(s && a === void 0) && !c(a, e))
385
- throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${o}`);
383
+ const c = e[i];
384
+ if (!(s && c === void 0) && !a(c, e))
385
+ throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`);
386
386
  };
387
387
  for (const [i, o] of Object.entries(t))
388
388
  r(i, o, !1);
@@ -390,100 +390,100 @@ function Je(e, t, n = {}) {
390
390
  r(i, o, !0);
391
391
  return e;
392
392
  }
393
- const Ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
393
+ const Bi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
394
394
  __proto__: null,
395
395
  bitGet: Ki,
396
396
  bitLen: Ai,
397
- bitMask: Gt,
397
+ bitMask: Jt,
398
398
  bitSet: Ni,
399
399
  bytesToHex: He,
400
400
  bytesToNumberBE: G,
401
- bytesToNumberLE: Ft,
402
- concatBytes: Ie,
401
+ bytesToNumberLE: Wt,
402
+ concatBytes: ke,
403
403
  createHmacDrbg: jn,
404
404
  ensureBytes: Z,
405
405
  equalBytes: xi,
406
406
  hexToBytes: qe,
407
- hexToNumber: Zt,
407
+ hexToNumber: Ft,
408
408
  numberToBytesBE: xe,
409
- numberToBytesLE: Wt,
409
+ numberToBytesLE: Gt,
410
410
  numberToHexUnpadded: Dn,
411
- numberToVarBytesBE: mi,
411
+ numberToVarBytesBE: Ei,
412
412
  utf8ToBytes: Si,
413
413
  validateObject: Je
414
414
  }, Symbol.toStringTag, { value: "Module" }));
415
415
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
416
- const j = BigInt(0), q = BigInt(1), Ne = BigInt(2), Ii = BigInt(3), $t = BigInt(4), xn = BigInt(5), Sn = BigInt(8);
416
+ const z = BigInt(0), q = BigInt(1), Ne = BigInt(2), ki = BigInt(3), Tt = BigInt(4), Sn = BigInt(5), An = BigInt(8);
417
417
  BigInt(9);
418
418
  BigInt(16);
419
419
  function V(e, t) {
420
420
  const n = e % t;
421
- return n >= j ? n : t + n;
421
+ return n >= z ? n : t + n;
422
422
  }
423
423
  function Ui(e, t, n) {
424
- if (n <= j || t < j)
424
+ if (n <= z || t < z)
425
425
  throw new Error("Expected power/modulo > 0");
426
426
  if (n === q)
427
- return j;
427
+ return z;
428
428
  let r = q;
429
- for (; t > j; )
429
+ for (; t > z; )
430
430
  t & q && (r = r * e % n), e = e * e % n, t >>= q;
431
431
  return r;
432
432
  }
433
433
  function J(e, t, n) {
434
434
  let r = e;
435
- for (; t-- > j; )
435
+ for (; t-- > z; )
436
436
  r *= r, r %= n;
437
437
  return r;
438
438
  }
439
- function Tt(e, t) {
440
- if (e === j || t <= j)
439
+ function Rt(e, t) {
440
+ if (e === z || t <= z)
441
441
  throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);
442
- let n = V(e, t), r = t, i = j, o = q;
443
- for (; n !== j; ) {
444
- const c = r / n, a = r % n, l = i - o * c;
445
- r = n, n = a, i = o, o = l;
442
+ let n = V(e, t), r = t, i = z, o = q;
443
+ for (; n !== z; ) {
444
+ const a = r / n, c = r % n, l = i - o * a;
445
+ r = n, n = c, i = o, o = l;
446
446
  }
447
447
  if (r !== q)
448
448
  throw new Error("invert: does not exist");
449
449
  return V(i, t);
450
450
  }
451
- function ki(e) {
451
+ function Ii(e) {
452
452
  const t = (e - q) / Ne;
453
453
  let n, r, i;
454
- for (n = e - q, r = 0; n % Ne === j; n /= Ne, r++)
454
+ for (n = e - q, r = 0; n % Ne === z; n /= Ne, r++)
455
455
  ;
456
456
  for (i = Ne; i < e && Ui(i, t, e) !== e - q; i++)
457
457
  ;
458
458
  if (r === 1) {
459
- const s = (e + q) / $t;
460
- return function(a, l) {
461
- const f = a.pow(l, s);
462
- if (!a.eql(a.sqr(f), l))
459
+ const s = (e + q) / Tt;
460
+ return function(c, l) {
461
+ const f = c.pow(l, s);
462
+ if (!c.eql(c.sqr(f), l))
463
463
  throw new Error("Cannot find square root");
464
464
  return f;
465
465
  };
466
466
  }
467
467
  const o = (n + q) / Ne;
468
- return function(c, a) {
469
- if (c.pow(a, t) === c.neg(c.ONE))
468
+ return function(a, c) {
469
+ if (a.pow(c, t) === a.neg(a.ONE))
470
470
  throw new Error("Cannot find square root");
471
- let l = r, f = c.pow(c.mul(c.ONE, i), n), u = c.pow(a, o), d = c.pow(a, n);
472
- for (; !c.eql(d, c.ONE); ) {
473
- if (c.eql(d, c.ZERO))
474
- return c.ZERO;
471
+ let l = r, f = a.pow(a.mul(a.ONE, i), n), u = a.pow(c, o), d = a.pow(c, n);
472
+ for (; !a.eql(d, a.ONE); ) {
473
+ if (a.eql(d, a.ZERO))
474
+ return a.ZERO;
475
475
  let p = 1;
476
- for (let h = c.sqr(d); p < l && !c.eql(h, c.ONE); p++)
477
- h = c.sqr(h);
478
- const g = c.pow(f, q << BigInt(l - p - 1));
479
- f = c.sqr(g), u = c.mul(u, g), d = c.mul(d, f), l = p;
476
+ for (let h = a.sqr(d); p < l && !a.eql(h, a.ONE); p++)
477
+ h = a.sqr(h);
478
+ const g = a.pow(f, q << BigInt(l - p - 1));
479
+ f = a.sqr(g), u = a.mul(u, g), d = a.mul(d, f), l = p;
480
480
  }
481
481
  return u;
482
482
  };
483
483
  }
484
484
  function _i(e) {
485
- if (e % $t === Ii) {
486
- const t = (e + q) / $t;
485
+ if (e % Tt === ki) {
486
+ const t = (e + q) / Tt;
487
487
  return function(r, i) {
488
488
  const o = r.pow(i, t);
489
489
  if (!r.eql(r.sqr(o), i))
@@ -491,16 +491,16 @@ function _i(e) {
491
491
  return o;
492
492
  };
493
493
  }
494
- if (e % Sn === xn) {
495
- const t = (e - xn) / Sn;
494
+ if (e % An === Sn) {
495
+ const t = (e - Sn) / An;
496
496
  return function(r, i) {
497
- const o = r.mul(i, Ne), s = r.pow(o, t), c = r.mul(i, s), a = r.mul(r.mul(c, Ne), s), l = r.mul(c, r.sub(a, r.ONE));
497
+ const o = r.mul(i, Ne), s = r.pow(o, t), a = r.mul(i, s), c = r.mul(r.mul(a, Ne), s), l = r.mul(a, r.sub(c, r.ONE));
498
498
  if (!r.eql(r.sqr(l), i))
499
499
  throw new Error("Cannot find square root");
500
500
  return l;
501
501
  };
502
502
  }
503
- return ki(e);
503
+ return Ii(e);
504
504
  }
505
505
  const Li = [
506
506
  "create",
@@ -531,73 +531,73 @@ function $i(e) {
531
531
  return Je(e, n);
532
532
  }
533
533
  function Ti(e, t, n) {
534
- if (n < j)
534
+ if (n < z)
535
535
  throw new Error("Expected power > 0");
536
- if (n === j)
536
+ if (n === z)
537
537
  return e.ONE;
538
538
  if (n === q)
539
539
  return t;
540
540
  let r = e.ONE, i = t;
541
- for (; n > j; )
541
+ for (; n > z; )
542
542
  n & q && (r = e.mul(r, i)), i = e.sqr(i), n >>= q;
543
543
  return r;
544
544
  }
545
545
  function Ri(e, t) {
546
- const n = new Array(t.length), r = t.reduce((o, s, c) => e.is0(s) ? o : (n[c] = o, e.mul(o, s)), e.ONE), i = e.inv(r);
547
- return t.reduceRight((o, s, c) => e.is0(s) ? o : (n[c] = e.mul(o, n[c]), e.mul(o, s)), i), n;
546
+ const n = new Array(t.length), r = t.reduce((o, s, a) => e.is0(s) ? o : (n[a] = o, e.mul(o, s)), e.ONE), i = e.inv(r);
547
+ return t.reduceRight((o, s, a) => e.is0(s) ? o : (n[a] = e.mul(o, n[a]), e.mul(o, s)), i), n;
548
548
  }
549
549
  function zn(e, t) {
550
550
  const n = t !== void 0 ? t : e.toString(2).length, r = Math.ceil(n / 8);
551
551
  return { nBitLength: n, nByteLength: r };
552
552
  }
553
- function Pi(e, t, n = !1, r = {}) {
554
- if (e <= j)
553
+ function Oi(e, t, n = !1, r = {}) {
554
+ if (e <= z)
555
555
  throw new Error(`Expected Field ORDER > 0, got ${e}`);
556
556
  const { nBitLength: i, nByteLength: o } = zn(e, t);
557
557
  if (o > 2048)
558
558
  throw new Error("Field lengths over 2048 bytes are not supported");
559
- const s = _i(e), c = Object.freeze({
559
+ const s = _i(e), a = Object.freeze({
560
560
  ORDER: e,
561
561
  BITS: i,
562
562
  BYTES: o,
563
- MASK: Gt(i),
564
- ZERO: j,
563
+ MASK: Jt(i),
564
+ ZERO: z,
565
565
  ONE: q,
566
- create: (a) => V(a, e),
567
- isValid: (a) => {
568
- if (typeof a != "bigint")
569
- throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);
570
- return j <= a && a < e;
566
+ create: (c) => V(c, e),
567
+ isValid: (c) => {
568
+ if (typeof c != "bigint")
569
+ throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);
570
+ return z <= c && c < e;
571
571
  },
572
- is0: (a) => a === j,
573
- isOdd: (a) => (a & q) === q,
574
- neg: (a) => V(-a, e),
575
- eql: (a, l) => a === l,
576
- sqr: (a) => V(a * a, e),
577
- add: (a, l) => V(a + l, e),
578
- sub: (a, l) => V(a - l, e),
579
- mul: (a, l) => V(a * l, e),
580
- pow: (a, l) => Ti(c, a, l),
581
- div: (a, l) => V(a * Tt(l, e), e),
572
+ is0: (c) => c === z,
573
+ isOdd: (c) => (c & q) === q,
574
+ neg: (c) => V(-c, e),
575
+ eql: (c, l) => c === l,
576
+ sqr: (c) => V(c * c, e),
577
+ add: (c, l) => V(c + l, e),
578
+ sub: (c, l) => V(c - l, e),
579
+ mul: (c, l) => V(c * l, e),
580
+ pow: (c, l) => Ti(a, c, l),
581
+ div: (c, l) => V(c * Rt(l, e), e),
582
582
  // Same as above, but doesn't normalize
583
- sqrN: (a) => a * a,
584
- addN: (a, l) => a + l,
585
- subN: (a, l) => a - l,
586
- mulN: (a, l) => a * l,
587
- inv: (a) => Tt(a, e),
588
- sqrt: r.sqrt || ((a) => s(c, a)),
589
- invertBatch: (a) => Ri(c, a),
583
+ sqrN: (c) => c * c,
584
+ addN: (c, l) => c + l,
585
+ subN: (c, l) => c - l,
586
+ mulN: (c, l) => c * l,
587
+ inv: (c) => Rt(c, e),
588
+ sqrt: r.sqrt || ((c) => s(a, c)),
589
+ invertBatch: (c) => Ri(a, c),
590
590
  // TODO: do we really need constant cmov?
591
591
  // We don't have const-time bigints anyway, so probably will be not very useful
592
- cmov: (a, l, f) => f ? l : a,
593
- toBytes: (a) => n ? Wt(a, o) : xe(a, o),
594
- fromBytes: (a) => {
595
- if (a.length !== o)
596
- throw new Error(`Fp.fromBytes: expected ${o}, got ${a.length}`);
597
- return n ? Ft(a) : G(a);
592
+ cmov: (c, l, f) => f ? l : c,
593
+ toBytes: (c) => n ? Gt(c, o) : xe(c, o),
594
+ fromBytes: (c) => {
595
+ if (c.length !== o)
596
+ throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);
597
+ return n ? Wt(c) : G(c);
598
598
  }
599
599
  });
600
- return Object.freeze(c);
600
+ return Object.freeze(a);
601
601
  }
602
602
  function Vn(e) {
603
603
  if (typeof e != "bigint")
@@ -609,12 +609,12 @@ function Zn(e) {
609
609
  const t = Vn(e);
610
610
  return t + Math.ceil(t / 2);
611
611
  }
612
- function Oi(e, t, n = !1) {
612
+ function Pi(e, t, n = !1) {
613
613
  const r = e.length, i = Vn(t), o = Zn(t);
614
614
  if (r < 16 || r < o || r > 1024)
615
615
  throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);
616
- const s = n ? G(e) : Ft(e), c = V(s, t - q) + q;
617
- return n ? Wt(c, i) : xe(c, i);
616
+ const s = n ? G(e) : Wt(e), a = V(s, t - q) + q;
617
+ return n ? Gt(a, i) : xe(a, i);
618
618
  }
619
619
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
620
620
  const Mi = BigInt(0), Nt = BigInt(1);
@@ -630,9 +630,9 @@ function Hi(e, t) {
630
630
  constTimeNegate: n,
631
631
  // non-const time multiplication ladder
632
632
  unsafeLadder(i, o) {
633
- let s = e.ZERO, c = i;
633
+ let s = e.ZERO, a = i;
634
634
  for (; o > Mi; )
635
- o & Nt && (s = s.add(c)), c = c.double(), o >>= Nt;
635
+ o & Nt && (s = s.add(a)), a = a.double(), o >>= Nt;
636
636
  return s;
637
637
  },
638
638
  /**
@@ -646,15 +646,15 @@ function Hi(e, t) {
646
646
  * @returns precomputed point tables flattened to a single array
647
647
  */
648
648
  precomputeWindow(i, o) {
649
- const { windows: s, windowSize: c } = r(o), a = [];
649
+ const { windows: s, windowSize: a } = r(o), c = [];
650
650
  let l = i, f = l;
651
651
  for (let u = 0; u < s; u++) {
652
- f = l, a.push(f);
653
- for (let d = 1; d < c; d++)
654
- f = f.add(l), a.push(f);
652
+ f = l, c.push(f);
653
+ for (let d = 1; d < a; d++)
654
+ f = f.add(l), c.push(f);
655
655
  l = f.double();
656
656
  }
657
- return a;
657
+ return c;
658
658
  },
659
659
  /**
660
660
  * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
@@ -664,22 +664,22 @@ function Hi(e, t) {
664
664
  * @returns real and fake (for const-time) points
665
665
  */
666
666
  wNAF(i, o, s) {
667
- const { windows: c, windowSize: a } = r(i);
667
+ const { windows: a, windowSize: c } = r(i);
668
668
  let l = e.ZERO, f = e.BASE;
669
669
  const u = BigInt(2 ** i - 1), d = 2 ** i, p = BigInt(i);
670
- for (let g = 0; g < c; g++) {
671
- const h = g * a;
670
+ for (let g = 0; g < a; g++) {
671
+ const h = g * c;
672
672
  let y = Number(s & u);
673
- s >>= p, y > a && (y -= d, s += Nt);
674
- const w = h, m = h + Math.abs(y) - 1, K = g % 2 !== 0, k = y < 0;
675
- y === 0 ? f = f.add(n(K, o[w])) : l = l.add(n(k, o[m]));
673
+ s >>= p, y > c && (y -= d, s += Nt);
674
+ const w = h, E = h + Math.abs(y) - 1, K = g % 2 !== 0, I = y < 0;
675
+ y === 0 ? f = f.add(n(K, o[w])) : l = l.add(n(I, o[E]));
676
676
  }
677
677
  return { p: l, f };
678
678
  },
679
- wNAFCached(i, o, s, c) {
680
- const a = i._WINDOW_SIZE || 1;
679
+ wNAFCached(i, o, s, a) {
680
+ const c = i._WINDOW_SIZE || 1;
681
681
  let l = o.get(i);
682
- return l || (l = this.precomputeWindow(i, a), a !== 1 && o.set(i, c(l))), this.wNAF(a, l, s);
682
+ return l || (l = this.precomputeWindow(i, c), c !== 1 && o.set(i, a(l))), this.wNAF(c, l, s);
683
683
  }
684
684
  };
685
685
  }
@@ -722,7 +722,7 @@ function qi(e) {
722
722
  }
723
723
  return Object.freeze({ ...t });
724
724
  }
725
- const { bytesToNumberBE: Di, hexToBytes: ji } = Ci, Be = {
725
+ const { bytesToNumberBE: Di, hexToBytes: ji } = Bi, Ce = {
726
726
  // asn.1 DER encoding utils
727
727
  Err: class extends Error {
728
728
  constructor(t = "") {
@@ -730,7 +730,7 @@ const { bytesToNumberBE: Di, hexToBytes: ji } = Ci, Be = {
730
730
  }
731
731
  },
732
732
  _parseInt(e) {
733
- const { Err: t } = Be;
733
+ const { Err: t } = Ce;
734
734
  if (e.length < 2 || e[0] !== 2)
735
735
  throw new t("Invalid signature integer tag");
736
736
  const n = e[1], r = e.subarray(2, n + 2);
@@ -743,7 +743,7 @@ const { bytesToNumberBE: Di, hexToBytes: ji } = Ci, Be = {
743
743
  return { d: Di(r), l: e.subarray(n + 2) };
744
744
  },
745
745
  toSig(e) {
746
- const { Err: t } = Be, n = typeof e == "string" ? ji(e) : e;
746
+ const { Err: t } = Ce, n = typeof e == "string" ? ji(e) : e;
747
747
  if (!(n instanceof Uint8Array))
748
748
  throw new Error("ui8a expected");
749
749
  let r = n.length;
@@ -751,8 +751,8 @@ const { bytesToNumberBE: Di, hexToBytes: ji } = Ci, Be = {
751
751
  throw new t("Invalid signature tag");
752
752
  if (n[1] !== r - 2)
753
753
  throw new t("Invalid signature: incorrect length");
754
- const { d: i, l: o } = Be._parseInt(n.subarray(2)), { d: s, l: c } = Be._parseInt(o);
755
- if (c.length)
754
+ const { d: i, l: o } = Ce._parseInt(n.subarray(2)), { d: s, l: a } = Ce._parseInt(o);
755
+ if (a.length)
756
756
  throw new t("Invalid signature: left bytes after parsing");
757
757
  return { r: i, s };
758
758
  },
@@ -760,36 +760,36 @@ const { bytesToNumberBE: Di, hexToBytes: ji } = Ci, Be = {
760
760
  const t = (l) => Number.parseInt(l[0], 16) & 8 ? "00" + l : l, n = (l) => {
761
761
  const f = l.toString(16);
762
762
  return f.length & 1 ? `0${f}` : f;
763
- }, r = t(n(e.s)), i = t(n(e.r)), o = r.length / 2, s = i.length / 2, c = n(o), a = n(s);
764
- return `30${n(s + o + 4)}02${a}${i}02${c}${r}`;
763
+ }, r = t(n(e.s)), i = t(n(e.r)), o = r.length / 2, s = i.length / 2, a = n(o), c = n(s);
764
+ return `30${n(s + o + 4)}02${c}${i}02${a}${r}`;
765
765
  }
766
766
  }, ce = BigInt(0), Y = BigInt(1);
767
767
  BigInt(2);
768
- const An = BigInt(3);
768
+ const Kn = BigInt(3);
769
769
  BigInt(4);
770
770
  function zi(e) {
771
771
  const t = qi(e), { Fp: n } = t, r = t.toBytes || ((g, h, y) => {
772
772
  const w = h.toAffine();
773
- return Ie(Uint8Array.from([4]), n.toBytes(w.x), n.toBytes(w.y));
773
+ return ke(Uint8Array.from([4]), n.toBytes(w.x), n.toBytes(w.y));
774
774
  }), i = t.fromBytes || ((g) => {
775
775
  const h = g.subarray(1), y = n.fromBytes(h.subarray(0, n.BYTES)), w = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
776
776
  return { x: y, y: w };
777
777
  });
778
778
  function o(g) {
779
- const { a: h, b: y } = t, w = n.sqr(g), m = n.mul(w, g);
780
- return n.add(n.add(m, n.mul(g, h)), y);
779
+ const { a: h, b: y } = t, w = n.sqr(g), E = n.mul(w, g);
780
+ return n.add(n.add(E, n.mul(g, h)), y);
781
781
  }
782
782
  if (!n.eql(n.sqr(t.Gy), o(t.Gx)))
783
783
  throw new Error("bad generator point: equation left != right");
784
784
  function s(g) {
785
785
  return typeof g == "bigint" && ce < g && g < t.n;
786
786
  }
787
- function c(g) {
787
+ function a(g) {
788
788
  if (!s(g))
789
789
  throw new Error("Expected valid bigint: 0 < bigint < curve.n");
790
790
  }
791
- function a(g) {
792
- const { allowedPrivateKeyLengths: h, nByteLength: y, wrapPrivateKey: w, n: m } = t;
791
+ function c(g) {
792
+ const { allowedPrivateKeyLengths: h, nByteLength: y, wrapPrivateKey: w, n: E } = t;
793
793
  if (h && typeof g != "bigint") {
794
794
  if (g instanceof Uint8Array && (g = He(g)), typeof g != "string" || !h.includes(g.length))
795
795
  throw new Error("Invalid key");
@@ -801,7 +801,7 @@ function zi(e) {
801
801
  } catch {
802
802
  throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof g}`);
803
803
  }
804
- return w && (K = V(K, m)), c(K), K;
804
+ return w && (K = V(K, E)), a(K), K;
805
805
  }
806
806
  const l = /* @__PURE__ */ new Map();
807
807
  function f(g) {
@@ -825,8 +825,8 @@ function zi(e) {
825
825
  throw new Error("invalid affine point");
826
826
  if (h instanceof u)
827
827
  throw new Error("projective point not allowed");
828
- const m = (K) => n.eql(K, n.ZERO);
829
- return m(y) && m(w) ? u.ZERO : new u(y, w, n.ONE);
828
+ const E = (K) => n.eql(K, n.ZERO);
829
+ return E(y) && E(w) ? u.ZERO : new u(y, w, n.ONE);
830
830
  }
831
831
  get x() {
832
832
  return this.toAffine().x;
@@ -842,7 +842,7 @@ function zi(e) {
842
842
  */
843
843
  static normalizeZ(h) {
844
844
  const y = n.invertBatch(h.map((w) => w.pz));
845
- return h.map((w, m) => w.toAffine(y[m])).map(u.fromAffine);
845
+ return h.map((w, E) => w.toAffine(y[E])).map(u.fromAffine);
846
846
  }
847
847
  /**
848
848
  * Converts hash string or Uint8Array to Point.
@@ -854,7 +854,7 @@ function zi(e) {
854
854
  }
855
855
  // Multiplies generator point by privateKey.
856
856
  static fromPrivateKey(h) {
857
- return u.BASE.multiply(a(h));
857
+ return u.BASE.multiply(c(h));
858
858
  }
859
859
  // "Private method", don't use it directly
860
860
  _setWindowSize(h) {
@@ -870,8 +870,8 @@ function zi(e) {
870
870
  const { x: h, y } = this.toAffine();
871
871
  if (!n.isValid(h) || !n.isValid(y))
872
872
  throw new Error("bad point: x or y not FE");
873
- const w = n.sqr(y), m = o(h);
874
- if (!n.eql(w, m))
873
+ const w = n.sqr(y), E = o(h);
874
+ if (!n.eql(w, E))
875
875
  throw new Error("bad point: equation left != right");
876
876
  if (!this.isTorsionFree())
877
877
  throw new Error("bad point: not in prime-order subgroup");
@@ -887,8 +887,8 @@ function zi(e) {
887
887
  */
888
888
  equals(h) {
889
889
  f(h);
890
- const { px: y, py: w, pz: m } = this, { px: K, py: k, pz: C } = h, E = n.eql(n.mul(y, C), n.mul(K, m)), x = n.eql(n.mul(w, C), n.mul(k, m));
891
- return E && x;
890
+ const { px: y, py: w, pz: E } = this, { px: K, py: I, pz: B } = h, m = n.eql(n.mul(y, B), n.mul(K, E)), x = n.eql(n.mul(w, B), n.mul(I, E));
891
+ return m && x;
892
892
  }
893
893
  /**
894
894
  * Flips point to one corresponding to (x, -y) in Affine coordinates.
@@ -901,9 +901,9 @@ function zi(e) {
901
901
  // https://eprint.iacr.org/2015/1060, algorithm 3
902
902
  // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
903
903
  double() {
904
- const { a: h, b: y } = t, w = n.mul(y, An), { px: m, py: K, pz: k } = this;
905
- let C = n.ZERO, E = n.ZERO, x = n.ZERO, S = n.mul(m, m), O = n.mul(K, K), U = n.mul(k, k), N = n.mul(m, K);
906
- return N = n.add(N, N), x = n.mul(m, k), x = n.add(x, x), C = n.mul(h, x), E = n.mul(w, U), E = n.add(C, E), C = n.sub(O, E), E = n.add(O, E), E = n.mul(C, E), C = n.mul(N, C), x = n.mul(w, x), U = n.mul(h, U), N = n.sub(S, U), N = n.mul(h, N), N = n.add(N, x), x = n.add(S, S), S = n.add(x, S), S = n.add(S, U), S = n.mul(S, N), E = n.add(E, S), U = n.mul(K, k), U = n.add(U, U), S = n.mul(U, N), C = n.sub(C, S), x = n.mul(U, O), x = n.add(x, x), x = n.add(x, x), new u(C, E, x);
904
+ const { a: h, b: y } = t, w = n.mul(y, Kn), { px: E, py: K, pz: I } = this;
905
+ let B = n.ZERO, m = n.ZERO, x = n.ZERO, S = n.mul(E, E), P = n.mul(K, K), U = n.mul(I, I), N = n.mul(E, K);
906
+ return N = n.add(N, N), x = n.mul(E, I), x = n.add(x, x), B = n.mul(h, x), m = n.mul(w, U), m = n.add(B, m), B = n.sub(P, m), m = n.add(P, m), m = n.mul(B, m), B = n.mul(N, B), x = n.mul(w, x), U = n.mul(h, U), N = n.sub(S, U), N = n.mul(h, N), N = n.add(N, x), x = n.add(S, S), S = n.add(x, S), S = n.add(S, U), S = n.mul(S, N), m = n.add(m, S), U = n.mul(K, I), U = n.add(U, U), S = n.mul(U, N), B = n.sub(B, S), x = n.mul(U, P), x = n.add(x, x), x = n.add(x, x), new u(B, m, x);
907
907
  }
908
908
  // Renes-Costello-Batina exception-free addition formula.
909
909
  // There is 30% faster Jacobian formula, but it is not complete.
@@ -911,13 +911,13 @@ function zi(e) {
911
911
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
912
912
  add(h) {
913
913
  f(h);
914
- const { px: y, py: w, pz: m } = this, { px: K, py: k, pz: C } = h;
915
- let E = n.ZERO, x = n.ZERO, S = n.ZERO;
916
- const O = t.a, U = n.mul(t.b, An);
917
- let N = n.mul(y, K), T = n.mul(w, k), R = n.mul(m, C), H = n.add(y, w), b = n.add(K, k);
918
- H = n.mul(H, b), b = n.add(N, T), H = n.sub(H, b), b = n.add(y, m);
919
- let v = n.add(K, C);
920
- return b = n.mul(b, v), v = n.add(N, R), b = n.sub(b, v), v = n.add(w, m), E = n.add(k, C), v = n.mul(v, E), E = n.add(T, R), v = n.sub(v, E), S = n.mul(O, b), E = n.mul(U, R), S = n.add(E, S), E = n.sub(T, S), S = n.add(T, S), x = n.mul(E, S), T = n.add(N, N), T = n.add(T, N), R = n.mul(O, R), b = n.mul(U, b), T = n.add(T, R), R = n.sub(N, R), R = n.mul(O, R), b = n.add(b, R), N = n.mul(T, b), x = n.add(x, N), N = n.mul(v, b), E = n.mul(H, E), E = n.sub(E, N), N = n.mul(H, T), S = n.mul(v, S), S = n.add(S, N), new u(E, x, S);
914
+ const { px: y, py: w, pz: E } = this, { px: K, py: I, pz: B } = h;
915
+ let m = n.ZERO, x = n.ZERO, S = n.ZERO;
916
+ const P = t.a, U = n.mul(t.b, Kn);
917
+ let N = n.mul(y, K), T = n.mul(w, I), R = n.mul(E, B), H = n.add(y, w), b = n.add(K, I);
918
+ H = n.mul(H, b), b = n.add(N, T), H = n.sub(H, b), b = n.add(y, E);
919
+ let v = n.add(K, B);
920
+ return b = n.mul(b, v), v = n.add(N, R), b = n.sub(b, v), v = n.add(w, E), m = n.add(I, B), v = n.mul(v, m), m = n.add(T, R), v = n.sub(v, m), S = n.mul(P, b), m = n.mul(U, R), S = n.add(m, S), m = n.sub(T, S), S = n.add(T, S), x = n.mul(m, S), T = n.add(N, N), T = n.add(T, N), R = n.mul(P, R), b = n.mul(U, b), T = n.add(T, R), R = n.sub(N, R), R = n.mul(P, R), b = n.add(b, R), N = n.mul(T, b), x = n.add(x, N), N = n.mul(v, b), m = n.mul(H, m), m = n.sub(m, N), N = n.mul(H, T), S = n.mul(v, S), S = n.add(S, N), new u(m, x, S);
921
921
  }
922
922
  subtract(h) {
923
923
  return this.add(h.negate());
@@ -927,8 +927,8 @@ function zi(e) {
927
927
  }
928
928
  wNAF(h) {
929
929
  return p.wNAFCached(this, l, h, (y) => {
930
- const w = n.invertBatch(y.map((m) => m.pz));
931
- return y.map((m, K) => m.toAffine(w[K])).map(u.fromAffine);
930
+ const w = n.invertBatch(y.map((E) => E.pz));
931
+ return y.map((E, K) => E.toAffine(w[K])).map(u.fromAffine);
932
932
  });
933
933
  }
934
934
  /**
@@ -940,15 +940,15 @@ function zi(e) {
940
940
  const y = u.ZERO;
941
941
  if (h === ce)
942
942
  return y;
943
- if (c(h), h === Y)
943
+ if (a(h), h === Y)
944
944
  return this;
945
945
  const { endo: w } = t;
946
946
  if (!w)
947
947
  return p.unsafeLadder(this, h);
948
- let { k1neg: m, k1: K, k2neg: k, k2: C } = w.splitScalar(h), E = y, x = y, S = this;
949
- for (; K > ce || C > ce; )
950
- K & Y && (E = E.add(S)), C & Y && (x = x.add(S)), S = S.double(), K >>= Y, C >>= Y;
951
- return m && (E = E.negate()), k && (x = x.negate()), x = new u(n.mul(x.px, w.beta), x.py, x.pz), E.add(x);
948
+ let { k1neg: E, k1: K, k2neg: I, k2: B } = w.splitScalar(h), m = y, x = y, S = this;
949
+ for (; K > ce || B > ce; )
950
+ K & Y && (m = m.add(S)), B & Y && (x = x.add(S)), S = S.double(), K >>= Y, B >>= Y;
951
+ return E && (m = m.negate()), I && (x = x.negate()), x = new u(n.mul(x.px, w.beta), x.py, x.pz), m.add(x);
952
952
  }
953
953
  /**
954
954
  * Constant time multiplication.
@@ -960,18 +960,18 @@ function zi(e) {
960
960
  * @returns New point
961
961
  */
962
962
  multiply(h) {
963
- c(h);
964
- let y = h, w, m;
963
+ a(h);
964
+ let y = h, w, E;
965
965
  const { endo: K } = t;
966
966
  if (K) {
967
- const { k1neg: k, k1: C, k2neg: E, k2: x } = K.splitScalar(y);
968
- let { p: S, f: O } = this.wNAF(C), { p: U, f: N } = this.wNAF(x);
969
- S = p.constTimeNegate(k, S), U = p.constTimeNegate(E, U), U = new u(n.mul(U.px, K.beta), U.py, U.pz), w = S.add(U), m = O.add(N);
967
+ const { k1neg: I, k1: B, k2neg: m, k2: x } = K.splitScalar(y);
968
+ let { p: S, f: P } = this.wNAF(B), { p: U, f: N } = this.wNAF(x);
969
+ S = p.constTimeNegate(I, S), U = p.constTimeNegate(m, U), U = new u(n.mul(U.px, K.beta), U.py, U.pz), w = S.add(U), E = P.add(N);
970
970
  } else {
971
- const { p: k, f: C } = this.wNAF(y);
972
- w = k, m = C;
971
+ const { p: I, f: B } = this.wNAF(y);
972
+ w = I, E = B;
973
973
  }
974
- return u.normalizeZ([w, m])[0];
974
+ return u.normalizeZ([w, E])[0];
975
975
  }
976
976
  /**
977
977
  * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
@@ -980,21 +980,21 @@ function zi(e) {
980
980
  * @returns non-zero affine point
981
981
  */
982
982
  multiplyAndAddUnsafe(h, y, w) {
983
- const m = u.BASE, K = (C, E) => E === ce || E === Y || !C.equals(m) ? C.multiplyUnsafe(E) : C.multiply(E), k = K(this, y).add(K(h, w));
984
- return k.is0() ? void 0 : k;
983
+ const E = u.BASE, K = (B, m) => m === ce || m === Y || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), I = K(this, y).add(K(h, w));
984
+ return I.is0() ? void 0 : I;
985
985
  }
986
986
  // Converts Projective point to affine (x, y) coordinates.
987
987
  // Can accept precomputed Z^-1 - for example, from invertBatch.
988
988
  // (x, y, z) ∋ (x=x/z, y=y/z)
989
989
  toAffine(h) {
990
- const { px: y, py: w, pz: m } = this, K = this.is0();
991
- h == null && (h = K ? n.ONE : n.inv(m));
992
- const k = n.mul(y, h), C = n.mul(w, h), E = n.mul(m, h);
990
+ const { px: y, py: w, pz: E } = this, K = this.is0();
991
+ h == null && (h = K ? n.ONE : n.inv(E));
992
+ const I = n.mul(y, h), B = n.mul(w, h), m = n.mul(E, h);
993
993
  if (K)
994
994
  return { x: n.ZERO, y: n.ZERO };
995
- if (!n.eql(E, n.ONE))
995
+ if (!n.eql(m, n.ONE))
996
996
  throw new Error("invZ was invalid");
997
- return { x: k, y: C };
997
+ return { x: I, y: B };
998
998
  }
999
999
  isTorsionFree() {
1000
1000
  const { h, isTorsionFree: y } = t;
@@ -1020,7 +1020,7 @@ function zi(e) {
1020
1020
  return {
1021
1021
  CURVE: t,
1022
1022
  ProjectivePoint: u,
1023
- normPrivateKeyToScalar: a,
1023
+ normPrivateKeyToScalar: c,
1024
1024
  weierstrassEquation: o,
1025
1025
  isWithinCurveOrder: s
1026
1026
  };
@@ -1042,31 +1042,31 @@ function Zi(e) {
1042
1042
  function s(b) {
1043
1043
  return ce < b && b < n.ORDER;
1044
1044
  }
1045
- function c(b) {
1045
+ function a(b) {
1046
1046
  return V(b, r);
1047
1047
  }
1048
- function a(b) {
1049
- return Tt(b, r);
1048
+ function c(b) {
1049
+ return Rt(b, r);
1050
1050
  }
1051
1051
  const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: d } = zi({
1052
1052
  ...t,
1053
1053
  toBytes(b, v, A) {
1054
- const I = v.toAffine(), B = n.toBytes(I.x), _ = Ie;
1055
- return A ? _(Uint8Array.from([v.hasEvenY() ? 2 : 3]), B) : _(Uint8Array.from([4]), B, n.toBytes(I.y));
1054
+ const k = v.toAffine(), C = n.toBytes(k.x), _ = ke;
1055
+ return A ? _(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : _(Uint8Array.from([4]), C, n.toBytes(k.y));
1056
1056
  },
1057
1057
  fromBytes(b) {
1058
- const v = b.length, A = b[0], I = b.subarray(1);
1058
+ const v = b.length, A = b[0], k = b.subarray(1);
1059
1059
  if (v === i && (A === 2 || A === 3)) {
1060
- const B = G(I);
1061
- if (!s(B))
1060
+ const C = G(k);
1061
+ if (!s(C))
1062
1062
  throw new Error("Point is not on curve");
1063
- const _ = u(B);
1064
- let P = n.sqrt(_);
1065
- const $ = (P & Y) === Y;
1066
- return (A & 1) === 1 !== $ && (P = n.neg(P)), { x: B, y: P };
1063
+ const _ = u(C);
1064
+ let O = n.sqrt(_);
1065
+ const $ = (O & Y) === Y;
1066
+ return (A & 1) === 1 !== $ && (O = n.neg(O)), { x: C, y: O };
1067
1067
  } else if (v === o && A === 4) {
1068
- const B = n.fromBytes(I.subarray(0, n.BYTES)), _ = n.fromBytes(I.subarray(n.BYTES, 2 * n.BYTES));
1069
- return { x: B, y: _ };
1068
+ const C = n.fromBytes(k.subarray(0, n.BYTES)), _ = n.fromBytes(k.subarray(n.BYTES, 2 * n.BYTES));
1069
+ return { x: C, y: _ };
1070
1070
  } else
1071
1071
  throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`);
1072
1072
  }
@@ -1076,12 +1076,12 @@ function Zi(e) {
1076
1076
  return b > v;
1077
1077
  }
1078
1078
  function h(b) {
1079
- return g(b) ? c(-b) : b;
1079
+ return g(b) ? a(-b) : b;
1080
1080
  }
1081
1081
  const y = (b, v, A) => G(b.slice(v, A));
1082
1082
  class w {
1083
- constructor(v, A, I) {
1084
- this.r = v, this.s = A, this.recovery = I, this.assertValidity();
1083
+ constructor(v, A, k) {
1084
+ this.r = v, this.s = A, this.recovery = k, this.assertValidity();
1085
1085
  }
1086
1086
  // pair (bytes of r, bytes of s)
1087
1087
  static fromCompact(v) {
@@ -1091,8 +1091,8 @@ function Zi(e) {
1091
1091
  // DER encoded ECDSA signature
1092
1092
  // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
1093
1093
  static fromDER(v) {
1094
- const { r: A, s: I } = Be.toSig(Z("DER", v));
1095
- return new w(A, I);
1094
+ const { r: A, s: k } = Ce.toSig(Z("DER", v));
1095
+ return new w(A, k);
1096
1096
  }
1097
1097
  assertValidity() {
1098
1098
  if (!d(this.r))
@@ -1104,13 +1104,13 @@ function Zi(e) {
1104
1104
  return new w(this.r, this.s, v);
1105
1105
  }
1106
1106
  recoverPublicKey(v) {
1107
- const { r: A, s: I, recovery: B } = this, _ = x(Z("msgHash", v));
1108
- if (B == null || ![0, 1, 2, 3].includes(B))
1107
+ const { r: A, s: k, recovery: C } = this, _ = x(Z("msgHash", v));
1108
+ if (C == null || ![0, 1, 2, 3].includes(C))
1109
1109
  throw new Error("recovery id invalid");
1110
- const P = B === 2 || B === 3 ? A + t.n : A;
1111
- if (P >= n.ORDER)
1110
+ const O = C === 2 || C === 3 ? A + t.n : A;
1111
+ if (O >= n.ORDER)
1112
1112
  throw new Error("recovery id 2 or 3 invalid");
1113
- const $ = B & 1 ? "03" : "02", X = l.fromHex($ + p(P)), ye = a(P), ke = c(-_ * ye), ze = c(I * ye), pe = l.BASE.multiplyAndAddUnsafe(X, ke, ze);
1113
+ const $ = C & 1 ? "03" : "02", X = l.fromHex($ + p(O)), ye = c(O), Ie = a(-_ * ye), ze = a(k * ye), pe = l.BASE.multiplyAndAddUnsafe(X, Ie, ze);
1114
1114
  if (!pe)
1115
1115
  throw new Error("point at infinify");
1116
1116
  return pe.assertValidity(), pe;
@@ -1120,14 +1120,14 @@ function Zi(e) {
1120
1120
  return g(this.s);
1121
1121
  }
1122
1122
  normalizeS() {
1123
- return this.hasHighS() ? new w(this.r, c(-this.s), this.recovery) : this;
1123
+ return this.hasHighS() ? new w(this.r, a(-this.s), this.recovery) : this;
1124
1124
  }
1125
1125
  // DER-encoded
1126
1126
  toDERRawBytes() {
1127
1127
  return qe(this.toDERHex());
1128
1128
  }
1129
1129
  toDERHex() {
1130
- return Be.hexFromSig({ r: this.r, s: this.s });
1130
+ return Ce.hexFromSig({ r: this.r, s: this.s });
1131
1131
  }
1132
1132
  // padded bytes of r, then padded bytes of s
1133
1133
  toCompactRawBytes() {
@@ -1137,7 +1137,7 @@ function Zi(e) {
1137
1137
  return p(this.r) + p(this.s);
1138
1138
  }
1139
1139
  }
1140
- const m = {
1140
+ const E = {
1141
1141
  isValidPrivateKey(b) {
1142
1142
  try {
1143
1143
  return f(b), !0;
@@ -1152,7 +1152,7 @@ function Zi(e) {
1152
1152
  */
1153
1153
  randomPrivateKey: () => {
1154
1154
  const b = Zn(t.n);
1155
- return Oi(t.randomBytes(b), t.n);
1155
+ return Pi(t.randomBytes(b), t.n);
1156
1156
  },
1157
1157
  /**
1158
1158
  * Creates precompute table for an arbitrary EC point. Makes point "cached".
@@ -1169,24 +1169,24 @@ function Zi(e) {
1169
1169
  function K(b, v = !0) {
1170
1170
  return l.fromPrivateKey(b).toRawBytes(v);
1171
1171
  }
1172
- function k(b) {
1173
- const v = b instanceof Uint8Array, A = typeof b == "string", I = (v || A) && b.length;
1174
- return v ? I === i || I === o : A ? I === 2 * i || I === 2 * o : b instanceof l;
1172
+ function I(b) {
1173
+ const v = b instanceof Uint8Array, A = typeof b == "string", k = (v || A) && b.length;
1174
+ return v ? k === i || k === o : A ? k === 2 * i || k === 2 * o : b instanceof l;
1175
1175
  }
1176
- function C(b, v, A = !0) {
1177
- if (k(b))
1176
+ function B(b, v, A = !0) {
1177
+ if (I(b))
1178
1178
  throw new Error("first arg must be private key");
1179
- if (!k(v))
1179
+ if (!I(v))
1180
1180
  throw new Error("second arg must be public key");
1181
1181
  return l.fromHex(v).multiply(f(b)).toRawBytes(A);
1182
1182
  }
1183
- const E = t.bits2int || function(b) {
1183
+ const m = t.bits2int || function(b) {
1184
1184
  const v = G(b), A = b.length * 8 - t.nBitLength;
1185
1185
  return A > 0 ? v >> BigInt(A) : v;
1186
1186
  }, x = t.bits2int_modN || function(b) {
1187
- return c(E(b));
1188
- }, S = Gt(t.nBitLength);
1189
- function O(b) {
1187
+ return a(m(b));
1188
+ }, S = Jt(t.nBitLength);
1189
+ function P(b) {
1190
1190
  if (typeof b != "bigint")
1191
1191
  throw new Error("bigint expected");
1192
1192
  if (!(ce <= b && b < S))
@@ -1196,54 +1196,54 @@ function Zi(e) {
1196
1196
  function U(b, v, A = N) {
1197
1197
  if (["recovered", "canonical"].some((Ke) => Ke in A))
1198
1198
  throw new Error("sign() legacy options not supported");
1199
- const { hash: I, randomBytes: B } = t;
1200
- let { lowS: _, prehash: P, extraEntropy: $ } = A;
1201
- _ == null && (_ = !0), b = Z("msgHash", b), P && (b = Z("prehashed msgHash", I(b)));
1202
- const X = x(b), ye = f(v), ke = [O(ye), O(X)];
1199
+ const { hash: k, randomBytes: C } = t;
1200
+ let { lowS: _, prehash: O, extraEntropy: $ } = A;
1201
+ _ == null && (_ = !0), b = Z("msgHash", b), O && (b = Z("prehashed msgHash", k(b)));
1202
+ const X = x(b), ye = f(v), Ie = [P(ye), P(X)];
1203
1203
  if ($ != null) {
1204
- const Ke = $ === !0 ? B(n.BYTES) : $;
1205
- ke.push(Z("extraEntropy", Ke));
1204
+ const Ke = $ === !0 ? C(n.BYTES) : $;
1205
+ Ie.push(Z("extraEntropy", Ke));
1206
1206
  }
1207
- const ze = Ie(...ke), pe = X;
1207
+ const ze = ke(...Ie), pe = X;
1208
1208
  function xt(Ke) {
1209
- const _e = E(Ke);
1209
+ const _e = m(Ke);
1210
1210
  if (!d(_e))
1211
1211
  return;
1212
- const wn = a(_e), Le = l.BASE.multiply(_e).toAffine(), Q = c(Le.x);
1212
+ const bn = c(_e), Le = l.BASE.multiply(_e).toAffine(), Q = a(Le.x);
1213
1213
  if (Q === ce)
1214
1214
  return;
1215
- const $e = c(wn * c(pe + Q * ye));
1215
+ const $e = a(bn * a(pe + Q * ye));
1216
1216
  if ($e === ce)
1217
1217
  return;
1218
- let bn = (Le.x === Q ? 0 : 2) | Number(Le.y & Y), vn = $e;
1219
- return _ && g($e) && (vn = h($e), bn ^= 1), new w(Q, vn, bn);
1218
+ let vn = (Le.x === Q ? 0 : 2) | Number(Le.y & Y), mn = $e;
1219
+ return _ && g($e) && (mn = h($e), vn ^= 1), new w(Q, mn, vn);
1220
1220
  }
1221
1221
  return { seed: ze, k2sig: xt };
1222
1222
  }
1223
1223
  const N = { lowS: t.lowS, prehash: !1 }, T = { lowS: t.lowS, prehash: !1 };
1224
1224
  function R(b, v, A = N) {
1225
- const { seed: I, k2sig: B } = U(b, v, A), _ = t;
1226
- return jn(_.hash.outputLen, _.nByteLength, _.hmac)(I, B);
1225
+ const { seed: k, k2sig: C } = U(b, v, A), _ = t;
1226
+ return jn(_.hash.outputLen, _.nByteLength, _.hmac)(k, C);
1227
1227
  }
1228
1228
  l.BASE._setWindowSize(8);
1229
- function H(b, v, A, I = T) {
1229
+ function H(b, v, A, k = T) {
1230
1230
  var Le;
1231
- const B = b;
1232
- if (v = Z("msgHash", v), A = Z("publicKey", A), "strict" in I)
1231
+ const C = b;
1232
+ if (v = Z("msgHash", v), A = Z("publicKey", A), "strict" in k)
1233
1233
  throw new Error("options.strict was renamed to lowS");
1234
- const { lowS: _, prehash: P } = I;
1234
+ const { lowS: _, prehash: O } = k;
1235
1235
  let $, X;
1236
1236
  try {
1237
- if (typeof B == "string" || B instanceof Uint8Array)
1237
+ if (typeof C == "string" || C instanceof Uint8Array)
1238
1238
  try {
1239
- $ = w.fromDER(B);
1239
+ $ = w.fromDER(C);
1240
1240
  } catch (Q) {
1241
- if (!(Q instanceof Be.Err))
1241
+ if (!(Q instanceof Ce.Err))
1242
1242
  throw Q;
1243
- $ = w.fromCompact(B);
1243
+ $ = w.fromCompact(C);
1244
1244
  }
1245
- else if (typeof B == "object" && typeof B.r == "bigint" && typeof B.s == "bigint") {
1246
- const { r: Q, s: $e } = B;
1245
+ else if (typeof C == "object" && typeof C.r == "bigint" && typeof C.s == "bigint") {
1246
+ const { r: Q, s: $e } = C;
1247
1247
  $ = new w(Q, $e);
1248
1248
  } else
1249
1249
  throw new Error("PARSE");
@@ -1255,25 +1255,25 @@ function Zi(e) {
1255
1255
  }
1256
1256
  if (_ && $.hasHighS())
1257
1257
  return !1;
1258
- P && (v = t.hash(v));
1259
- const { r: ye, s: ke } = $, ze = x(v), pe = a(ke), xt = c(ze * pe), Ke = c(ye * pe), _e = (Le = l.BASE.multiplyAndAddUnsafe(X, xt, Ke)) == null ? void 0 : Le.toAffine();
1260
- return _e ? c(_e.x) === ye : !1;
1258
+ O && (v = t.hash(v));
1259
+ const { r: ye, s: Ie } = $, ze = x(v), pe = c(Ie), xt = a(ze * pe), Ke = a(ye * pe), _e = (Le = l.BASE.multiplyAndAddUnsafe(X, xt, Ke)) == null ? void 0 : Le.toAffine();
1260
+ return _e ? a(_e.x) === ye : !1;
1261
1261
  }
1262
1262
  return {
1263
1263
  CURVE: t,
1264
1264
  getPublicKey: K,
1265
- getSharedSecret: C,
1265
+ getSharedSecret: B,
1266
1266
  sign: R,
1267
1267
  verify: H,
1268
1268
  ProjectivePoint: l,
1269
1269
  Signature: w,
1270
- utils: m
1270
+ utils: E
1271
1271
  };
1272
1272
  }
1273
1273
  let Wn = class extends Mn {
1274
1274
  constructor(t, n) {
1275
1275
  super(), this.finished = !1, this.destroyed = !1, ai(t);
1276
- const r = Vt(n);
1276
+ const r = Zt(n);
1277
1277
  if (this.iHash = t.create(), typeof this.iHash.update != "function")
1278
1278
  throw new Error("Expected instance of class which extends utils.Hash");
1279
1279
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
@@ -1290,7 +1290,7 @@ let Wn = class extends Mn {
1290
1290
  return rt(this), this.iHash.update(t), this;
1291
1291
  }
1292
1292
  digestInto(t) {
1293
- rt(this), Pn(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1293
+ rt(this), On(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1294
1294
  }
1295
1295
  digest() {
1296
1296
  const t = new Uint8Array(this.oHash.outputLen);
@@ -1298,8 +1298,8 @@ let Wn = class extends Mn {
1298
1298
  }
1299
1299
  _cloneInto(t) {
1300
1300
  t || (t = Object.create(Object.getPrototypeOf(this), {}));
1301
- const { oHash: n, iHash: r, finished: i, destroyed: o, blockLen: s, outputLen: c } = this;
1302
- return t = t, t.finished = i, t.destroyed = o, t.blockLen = s, t.outputLen = c, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
1301
+ const { oHash: n, iHash: r, finished: i, destroyed: o, blockLen: s, outputLen: a } = this;
1302
+ return t = t, t.finished = i, t.destroyed = o, t.blockLen = s, t.outputLen = a, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
1303
1303
  }
1304
1304
  destroy() {
1305
1305
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
@@ -1320,17 +1320,17 @@ function Wi(e, t) {
1320
1320
  return Object.freeze({ ...n(t), create: n });
1321
1321
  }
1322
1322
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1323
- const ft = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), it = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Jn = BigInt(1), ot = BigInt(2), Kn = (e, t) => (e + t / ot) / t;
1323
+ const ft = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), it = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Jn = BigInt(1), ot = BigInt(2), Nn = (e, t) => (e + t / ot) / t;
1324
1324
  function Yn(e) {
1325
- const t = ft, n = BigInt(3), r = BigInt(6), i = BigInt(11), o = BigInt(22), s = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = J(f, n, t) * f % t, d = J(u, n, t) * f % t, p = J(d, ot, t) * l % t, g = J(p, i, t) * p % t, h = J(g, o, t) * g % t, y = J(h, c, t) * h % t, w = J(y, a, t) * y % t, m = J(w, c, t) * h % t, K = J(m, n, t) * f % t, k = J(K, s, t) * g % t, C = J(k, r, t) * l % t, E = J(C, ot, t);
1326
- if (!Rt.eql(Rt.sqr(E), e))
1325
+ const t = ft, n = BigInt(3), r = BigInt(6), i = BigInt(11), o = BigInt(22), s = BigInt(23), a = BigInt(44), c = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = J(f, n, t) * f % t, d = J(u, n, t) * f % t, p = J(d, ot, t) * l % t, g = J(p, i, t) * p % t, h = J(g, o, t) * g % t, y = J(h, a, t) * h % t, w = J(y, c, t) * y % t, E = J(w, a, t) * h % t, K = J(E, n, t) * f % t, I = J(K, s, t) * g % t, B = J(I, r, t) * l % t, m = J(B, ot, t);
1326
+ if (!Ot.eql(Ot.sqr(m), e))
1327
1327
  throw new Error("Cannot find square root");
1328
- return E;
1328
+ return m;
1329
1329
  }
1330
- const Rt = Pi(ft, void 0, void 0, { sqrt: Yn }), Ue = Wi({
1330
+ const Ot = Oi(ft, void 0, void 0, { sqrt: Yn }), Ue = Wi({
1331
1331
  a: BigInt(0),
1332
1332
  b: BigInt(7),
1333
- Fp: Rt,
1333
+ Fp: Ot,
1334
1334
  n: it,
1335
1335
  // Base point (x, y) aka generator point
1336
1336
  Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
@@ -1346,48 +1346,48 @@ const Rt = Pi(ft, void 0, void 0, { sqrt: Yn }), Ue = Wi({
1346
1346
  endo: {
1347
1347
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
1348
1348
  splitScalar: (e) => {
1349
- const t = it, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -Jn * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), o = n, s = BigInt("0x100000000000000000000000000000000"), c = Kn(o * e, t), a = Kn(-r * e, t);
1350
- let l = V(e - c * n - a * i, t), f = V(-c * r - a * o, t);
1349
+ const t = it, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -Jn * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), o = n, s = BigInt("0x100000000000000000000000000000000"), a = Nn(o * e, t), c = Nn(-r * e, t);
1350
+ let l = V(e - a * n - c * i, t), f = V(-a * r - c * o, t);
1351
1351
  const u = l > s, d = f > s;
1352
1352
  if (u && (l = t - l), d && (f = t - f), l > s || f > s)
1353
1353
  throw new Error("splitScalar: Endomorphism failed, k=" + e);
1354
1354
  return { k1neg: u, k1: l, k2neg: d, k2: f };
1355
1355
  }
1356
1356
  }
1357
- }, Lt), ht = BigInt(0), Xn = (e) => typeof e == "bigint" && ht < e && e < ft, Gi = (e) => typeof e == "bigint" && ht < e && e < it, Nn = {};
1357
+ }, $t), ht = BigInt(0), Xn = (e) => typeof e == "bigint" && ht < e && e < ft, Gi = (e) => typeof e == "bigint" && ht < e && e < it, Cn = {};
1358
1358
  function st(e, ...t) {
1359
- let n = Nn[e];
1359
+ let n = Cn[e];
1360
1360
  if (n === void 0) {
1361
- const r = Lt(Uint8Array.from(e, (i) => i.charCodeAt(0)));
1362
- n = Ie(r, r), Nn[e] = n;
1361
+ const r = $t(Uint8Array.from(e, (i) => i.charCodeAt(0)));
1362
+ n = ke(r, r), Cn[e] = n;
1363
1363
  }
1364
- return Lt(Ie(n, ...t));
1364
+ return $t(ke(n, ...t));
1365
1365
  }
1366
- const Jt = (e) => e.toRawBytes(!0).slice(1), Pt = (e) => xe(e, 32), Bt = (e) => V(e, ft), We = (e) => V(e, it), Yt = Ue.ProjectivePoint, Ji = (e, t, n) => Yt.BASE.multiplyAndAddUnsafe(e, t, n);
1367
- function Ot(e) {
1368
- let t = Ue.utils.normPrivateKeyToScalar(e), n = Yt.fromPrivateKey(t);
1369
- return { scalar: n.hasEvenY() ? t : We(-t), bytes: Jt(n) };
1366
+ const Yt = (e) => e.toRawBytes(!0).slice(1), Pt = (e) => xe(e, 32), Ct = (e) => V(e, ft), We = (e) => V(e, it), Xt = Ue.ProjectivePoint, Ji = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
1367
+ function Mt(e) {
1368
+ let t = Ue.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
1369
+ return { scalar: n.hasEvenY() ? t : We(-t), bytes: Yt(n) };
1370
1370
  }
1371
1371
  function Qn(e) {
1372
1372
  if (!Xn(e))
1373
1373
  throw new Error("bad x: need 0 < x < p");
1374
- const t = Bt(e * e), n = Bt(t * e + BigInt(7));
1374
+ const t = Ct(e * e), n = Ct(t * e + BigInt(7));
1375
1375
  let r = Yn(n);
1376
- r % ot !== ht && (r = Bt(-r));
1377
- const i = new Yt(e, r, Jn);
1376
+ r % ot !== ht && (r = Ct(-r));
1377
+ const i = new Xt(e, r, Jn);
1378
1378
  return i.assertValidity(), i;
1379
1379
  }
1380
1380
  function er(...e) {
1381
1381
  return We(G(st("BIP0340/challenge", ...e)));
1382
1382
  }
1383
1383
  function Yi(e) {
1384
- return Ot(e).bytes;
1384
+ return Mt(e).bytes;
1385
1385
  }
1386
1386
  function Xi(e, t, n = Hn(32)) {
1387
- const r = Z("message", e), { bytes: i, scalar: o } = Ot(t), s = Z("auxRand", n, 32), c = Pt(o ^ G(st("BIP0340/aux", s))), a = st("BIP0340/nonce", c, i, r), l = We(G(a));
1387
+ const r = Z("message", e), { bytes: i, scalar: o } = Mt(t), s = Z("auxRand", n, 32), a = Pt(o ^ G(st("BIP0340/aux", s))), c = st("BIP0340/nonce", a, i, r), l = We(G(c));
1388
1388
  if (l === ht)
1389
1389
  throw new Error("sign failed: k is zero");
1390
- const { bytes: f, scalar: u } = Ot(l), d = er(f, i, r), p = new Uint8Array(64);
1390
+ const { bytes: f, scalar: u } = Mt(l), d = er(f, i, r), p = new Uint8Array(64);
1391
1391
  if (p.set(f, 0), p.set(Pt(We(u + d * o)), 32), !tr(p, r, i))
1392
1392
  throw new Error("sign: Invalid signature produced");
1393
1393
  return p;
@@ -1395,14 +1395,14 @@ function Xi(e, t, n = Hn(32)) {
1395
1395
  function tr(e, t, n) {
1396
1396
  const r = Z("signature", e, 64), i = Z("message", t), o = Z("publicKey", n, 32);
1397
1397
  try {
1398
- const s = Qn(G(o)), c = G(r.subarray(0, 32));
1399
- if (!Xn(c))
1398
+ const s = Qn(G(o)), a = G(r.subarray(0, 32));
1399
+ if (!Xn(a))
1400
1400
  return !1;
1401
- const a = G(r.subarray(32, 64));
1402
- if (!Gi(a))
1401
+ const c = G(r.subarray(32, 64));
1402
+ if (!Gi(c))
1403
1403
  return !1;
1404
- const l = er(Pt(c), Jt(s), i), f = Ji(s, a, We(-l));
1405
- return !(!f || !f.hasEvenY() || f.toAffine().x !== c);
1404
+ const l = er(Pt(a), Yt(s), i), f = Ji(s, c, We(-l));
1405
+ return !(!f || !f.hasEvenY() || f.toAffine().x !== a);
1406
1406
  } catch {
1407
1407
  return !1;
1408
1408
  }
@@ -1414,20 +1414,20 @@ const Ve = {
1414
1414
  utils: {
1415
1415
  randomPrivateKey: Ue.utils.randomPrivateKey,
1416
1416
  lift_x: Qn,
1417
- pointToBytes: Jt,
1417
+ pointToBytes: Yt,
1418
1418
  numberToBytesBE: xe,
1419
1419
  bytesToNumberBE: G,
1420
1420
  taggedHash: st,
1421
1421
  mod: V
1422
1422
  }
1423
- }, Ct = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1423
+ }, Bt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1424
1424
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1425
- const Xt = (e) => e instanceof Uint8Array, It = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, Qi = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1425
+ const Qt = (e) => e instanceof Uint8Array, kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, Qi = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1426
1426
  if (!Qi)
1427
1427
  throw new Error("Non little-endian hardware is not supported");
1428
1428
  const eo = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1429
1429
  function M(e) {
1430
- if (!Xt(e))
1430
+ if (!Qt(e))
1431
1431
  throw new Error("Uint8Array expected");
1432
1432
  let t = "";
1433
1433
  for (let n = 0; n < e.length; n++)
@@ -1455,7 +1455,7 @@ function to(e) {
1455
1455
  return new Uint8Array(new TextEncoder().encode(e));
1456
1456
  }
1457
1457
  function Ge(e) {
1458
- if (typeof e == "string" && (e = to(e)), !Xt(e))
1458
+ if (typeof e == "string" && (e = to(e)), !Qt(e))
1459
1459
  throw new Error(`expected Uint8Array, got ${typeof e}`);
1460
1460
  return e;
1461
1461
  }
@@ -1463,7 +1463,7 @@ function dt(...e) {
1463
1463
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
1464
1464
  let n = 0;
1465
1465
  return e.forEach((r) => {
1466
- if (!Xt(r))
1466
+ if (!Qt(r))
1467
1467
  throw new Error("Uint8Array expected");
1468
1468
  t.set(r, n), n += r.length;
1469
1469
  }), t;
@@ -1479,11 +1479,11 @@ function rr(e) {
1479
1479
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
1480
1480
  }
1481
1481
  function ir(e = 32) {
1482
- if (Ct && typeof Ct.getRandomValues == "function")
1483
- return Ct.getRandomValues(new Uint8Array(e));
1482
+ if (Bt && typeof Bt.getRandomValues == "function")
1483
+ return Bt.getRandomValues(new Uint8Array(e));
1484
1484
  throw new Error("crypto.getRandomValues must be defined");
1485
1485
  }
1486
- function Mt(e) {
1486
+ function Ht(e) {
1487
1487
  if (!Number.isSafeInteger(e) || e < 0)
1488
1488
  throw new Error(`Wrong positive integer: ${e}`);
1489
1489
  }
@@ -1500,7 +1500,7 @@ function or(e, ...t) {
1500
1500
  function ro(e) {
1501
1501
  if (typeof e != "function" || typeof e.create != "function")
1502
1502
  throw new Error("Hash should be wrapped by utils.wrapConstructor");
1503
- Mt(e.outputLen), Mt(e.blockLen);
1503
+ Ht(e.outputLen), Ht(e.blockLen);
1504
1504
  }
1505
1505
  function io(e, t = !0) {
1506
1506
  if (e.destroyed)
@@ -1515,7 +1515,7 @@ function oo(e, t) {
1515
1515
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
1516
1516
  }
1517
1517
  const oe = {
1518
- number: Mt,
1518
+ number: Ht,
1519
1519
  bool: no,
1520
1520
  bytes: or,
1521
1521
  hash: ro,
@@ -1525,12 +1525,12 @@ const oe = {
1525
1525
  function so(e, t, n, r) {
1526
1526
  if (typeof e.setBigUint64 == "function")
1527
1527
  return e.setBigUint64(t, n, r);
1528
- const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), c = Number(n & o), a = r ? 4 : 0, l = r ? 0 : 4;
1529
- e.setUint32(t + a, s, r), e.setUint32(t + l, c, r);
1528
+ const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), a = Number(n & o), c = r ? 4 : 0, l = r ? 0 : 4;
1529
+ e.setUint32(t + c, s, r), e.setUint32(t + l, a, r);
1530
1530
  }
1531
1531
  class ao extends nr {
1532
1532
  constructor(t, n, r, i) {
1533
- super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = It(this.buffer);
1533
+ super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = kt(this.buffer);
1534
1534
  }
1535
1535
  update(t) {
1536
1536
  oe.exists(this);
@@ -1538,14 +1538,14 @@ class ao extends nr {
1538
1538
  t = Ge(t);
1539
1539
  const o = t.length;
1540
1540
  for (let s = 0; s < o; ) {
1541
- const c = Math.min(i - this.pos, o - s);
1542
- if (c === i) {
1543
- const a = It(t);
1541
+ const a = Math.min(i - this.pos, o - s);
1542
+ if (a === i) {
1543
+ const c = kt(t);
1544
1544
  for (; i <= o - s; s += i)
1545
- this.process(a, s);
1545
+ this.process(c, s);
1546
1546
  continue;
1547
1547
  }
1548
- r.set(t.subarray(s, s + c), this.pos), this.pos += c, s += c, this.pos === i && (this.process(n, 0), this.pos = 0);
1548
+ r.set(t.subarray(s, s + a), this.pos), this.pos += a, s += a, this.pos === i && (this.process(n, 0), this.pos = 0);
1549
1549
  }
1550
1550
  return this.length += t.length, this.roundClean(), this;
1551
1551
  }
@@ -1557,14 +1557,14 @@ class ao extends nr {
1557
1557
  for (let u = s; u < i; u++)
1558
1558
  n[u] = 0;
1559
1559
  so(r, i - 8, BigInt(this.length * 8), o), this.process(r, 0);
1560
- const c = It(t), a = this.outputLen;
1561
- if (a % 4)
1560
+ const a = kt(t), c = this.outputLen;
1561
+ if (c % 4)
1562
1562
  throw new Error("_sha2: outputLen should be aligned to 32bit");
1563
- const l = a / 4, f = this.get();
1563
+ const l = c / 4, f = this.get();
1564
1564
  if (l > f.length)
1565
1565
  throw new Error("_sha2: outputLen bigger than state");
1566
1566
  for (let u = 0; u < l; u++)
1567
- c.setUint32(4 * u, f[u], o);
1567
+ a.setUint32(4 * u, f[u], o);
1568
1568
  }
1569
1569
  digest() {
1570
1570
  const { buffer: t, outputLen: n } = this;
@@ -1574,8 +1574,8 @@ class ao extends nr {
1574
1574
  }
1575
1575
  _cloneInto(t) {
1576
1576
  t || (t = new this.constructor()), t.set(...this.get());
1577
- const { blockLen: n, buffer: r, length: i, finished: o, destroyed: s, pos: c } = this;
1578
- return t.length = i, t.pos = c, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
1577
+ const { blockLen: n, buffer: r, length: i, finished: o, destroyed: s, pos: a } = this;
1578
+ return t.length = i, t.pos = a, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
1579
1579
  }
1580
1580
  }
1581
1581
  const co = (e, t, n) => e & t ^ ~e & n, lo = (e, t, n) => e & t ^ e & n ^ t & n, uo = new Uint32Array([
@@ -1658,12 +1658,12 @@ class sr extends ao {
1658
1658
  super(64, 32, 8, !1), this.A = be[0] | 0, this.B = be[1] | 0, this.C = be[2] | 0, this.D = be[3] | 0, this.E = be[4] | 0, this.F = be[5] | 0, this.G = be[6] | 0, this.H = be[7] | 0;
1659
1659
  }
1660
1660
  get() {
1661
- const { A: t, B: n, C: r, D: i, E: o, F: s, G: c, H: a } = this;
1662
- return [t, n, r, i, o, s, c, a];
1661
+ const { A: t, B: n, C: r, D: i, E: o, F: s, G: a, H: c } = this;
1662
+ return [t, n, r, i, o, s, a, c];
1663
1663
  }
1664
1664
  // prettier-ignore
1665
- set(t, n, r, i, o, s, c, a) {
1666
- this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = c | 0, this.H = a | 0;
1665
+ set(t, n, r, i, o, s, a, c) {
1666
+ this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = a | 0, this.H = c | 0;
1667
1667
  }
1668
1668
  process(t, n) {
1669
1669
  for (let u = 0; u < 16; u++, n += 4)
@@ -1672,12 +1672,12 @@ class sr extends ao {
1672
1672
  const d = ve[u - 15], p = ve[u - 2], g = re(d, 7) ^ re(d, 18) ^ d >>> 3, h = re(p, 17) ^ re(p, 19) ^ p >>> 10;
1673
1673
  ve[u] = h + ve[u - 7] + g + ve[u - 16] | 0;
1674
1674
  }
1675
- let { A: r, B: i, C: o, D: s, E: c, F: a, G: l, H: f } = this;
1675
+ let { A: r, B: i, C: o, D: s, E: a, F: c, G: l, H: f } = this;
1676
1676
  for (let u = 0; u < 64; u++) {
1677
- const d = re(c, 6) ^ re(c, 11) ^ re(c, 25), p = f + d + co(c, a, l) + uo[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + lo(r, i, o) | 0;
1678
- f = l, l = a, a = c, c = s + p | 0, s = o, o = i, i = r, r = p + h | 0;
1677
+ const d = re(a, 6) ^ re(a, 11) ^ re(a, 25), p = f + d + co(a, c, l) + uo[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + lo(r, i, o) | 0;
1678
+ f = l, l = c, c = a, a = s + p | 0, s = o, o = i, i = r, r = p + h | 0;
1679
1679
  }
1680
- r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, c, a, l, f);
1680
+ r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, a, c, l, f);
1681
1681
  }
1682
1682
  roundClean() {
1683
1683
  ve.fill(0);
@@ -1796,18 +1796,18 @@ function Bn(e, t, n) {
1796
1796
  if (je(s), s < 0 || s >= t)
1797
1797
  throw new Error(`Wrong integer: ${s}`);
1798
1798
  }); ; ) {
1799
- let s = 0, c = !0;
1800
- for (let a = r; a < o.length; a++) {
1801
- const l = o[a], f = t * s + l;
1799
+ let s = 0, a = !0;
1800
+ for (let c = r; c < o.length; c++) {
1801
+ const l = o[c], f = t * s + l;
1802
1802
  if (!Number.isSafeInteger(f) || t * s / t !== s || f - l !== t * s)
1803
1803
  throw new Error("convertRadix: carry overflow");
1804
- if (s = f % n, o[a] = Math.floor(f / n), !Number.isSafeInteger(o[a]) || o[a] * n + s !== f)
1804
+ if (s = f % n, o[c] = Math.floor(f / n), !Number.isSafeInteger(o[c]) || o[c] * n + s !== f)
1805
1805
  throw new Error("convertRadix: carry overflow");
1806
- if (c)
1807
- o[a] ? c = !1 : r = a;
1806
+ if (a)
1807
+ o[c] ? a = !1 : r = c;
1808
1808
  else continue;
1809
1809
  }
1810
- if (i.push(s), c)
1810
+ if (i.push(s), a)
1811
1811
  break;
1812
1812
  }
1813
1813
  for (let s = 0; s < e.length - 1 && e[s] === 0; s++)
@@ -1815,7 +1815,7 @@ function Bn(e, t, n) {
1815
1815
  return i.reverse();
1816
1816
  }
1817
1817
  const cr = (e, t) => t ? cr(t, e % t) : e, at = (e, t) => e + (t - cr(e, t));
1818
- function Ht(e, t, n, r) {
1818
+ function qt(e, t, n, r) {
1819
1819
  if (!Array.isArray(e))
1820
1820
  throw new Error("convertRadix2: data should be array");
1821
1821
  if (t <= 0 || t > 32)
@@ -1825,21 +1825,21 @@ function Ht(e, t, n, r) {
1825
1825
  if (at(t, n) > 32)
1826
1826
  throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${at(t, n)}`);
1827
1827
  let i = 0, o = 0;
1828
- const s = 2 ** n - 1, c = [];
1829
- for (const a of e) {
1830
- if (je(a), a >= 2 ** t)
1831
- throw new Error(`convertRadix2: invalid data word=${a} from=${t}`);
1832
- if (i = i << t | a, o + t > 32)
1828
+ const s = 2 ** n - 1, a = [];
1829
+ for (const c of e) {
1830
+ if (je(c), c >= 2 ** t)
1831
+ throw new Error(`convertRadix2: invalid data word=${c} from=${t}`);
1832
+ if (i = i << t | c, o + t > 32)
1833
1833
  throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);
1834
1834
  for (o += t; o >= n; o -= n)
1835
- c.push((i >> o - n & s) >>> 0);
1835
+ a.push((i >> o - n & s) >>> 0);
1836
1836
  i &= 2 ** o - 1;
1837
1837
  }
1838
1838
  if (i = i << n - o & s, !r && o >= t)
1839
1839
  throw new Error("Excess padding");
1840
1840
  if (!r && i)
1841
1841
  throw new Error(`Non-zero padding: ${i}`);
1842
- return r && o > 0 && c.push(i >>> 0), c;
1842
+ return r && o > 0 && a.push(i >>> 0), a;
1843
1843
  }
1844
1844
  function ho(e) {
1845
1845
  return je(e), {
@@ -1864,16 +1864,16 @@ function Ae(e, t = !1) {
1864
1864
  encode: (n) => {
1865
1865
  if (!(n instanceof Uint8Array))
1866
1866
  throw new Error("radix2.encode input should be Uint8Array");
1867
- return Ht(Array.from(n), 8, e, !t);
1867
+ return qt(Array.from(n), 8, e, !t);
1868
1868
  },
1869
1869
  decode: (n) => {
1870
1870
  if (!Array.isArray(n) || n.length && typeof n[0] != "number")
1871
1871
  throw new Error("radix2.decode input should be array of strings");
1872
- return Uint8Array.from(Ht(n, e, 8, t));
1872
+ return Uint8Array.from(qt(n, e, 8, t));
1873
1873
  }
1874
1874
  };
1875
1875
  }
1876
- function Cn(e) {
1876
+ function kn(e) {
1877
1877
  if (typeof e != "function")
1878
1878
  throw new Error("unsafeWrapper fn should be function");
1879
1879
  return function(...t) {
@@ -1886,22 +1886,22 @@ function Cn(e) {
1886
1886
  const yo = fe(Ae(4), he("0123456789ABCDEF"), de("")), po = fe(Ae(5), he("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), yt(5), de(""));
1887
1887
  fe(Ae(5), he("0123456789ABCDEFGHIJKLMNOPQRSTUV"), yt(5), de(""));
1888
1888
  fe(Ae(5), he("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), de(""), ar((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
- const ue = fe(Ae(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), yt(6), de("")), go = fe(Ae(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), yt(6), de("")), Qt = (e) => fe(ho(58), he(e), de("")), qt = Qt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
- Qt("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
- Qt("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1892
- const In = [0, 2, 3, 5, 6, 7, 9, 10, 11], wo = {
1889
+ const ue = fe(Ae(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), yt(6), de("")), go = fe(Ae(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), yt(6), de("")), en = (e) => fe(ho(58), he(e), de("")), Dt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
+ en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
+ en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1892
+ const Un = [0, 2, 3, 5, 6, 7, 9, 10, 11], wo = {
1893
1893
  encode(e) {
1894
1894
  let t = "";
1895
1895
  for (let n = 0; n < e.length; n += 8) {
1896
1896
  const r = e.subarray(n, n + 8);
1897
- t += qt.encode(r).padStart(In[r.length], "1");
1897
+ t += Dt.encode(r).padStart(Un[r.length], "1");
1898
1898
  }
1899
1899
  return t;
1900
1900
  },
1901
1901
  decode(e) {
1902
1902
  let t = [];
1903
1903
  for (let n = 0; n < e.length; n += 11) {
1904
- const r = e.slice(n, n + 11), i = In.indexOf(r.length), o = qt.decode(r);
1904
+ const r = e.slice(n, n + 11), i = Un.indexOf(r.length), o = Dt.decode(r);
1905
1905
  for (let s = 0; s < o.length - i; s++)
1906
1906
  if (o[s] !== 0)
1907
1907
  throw new Error("base58xmr: wrong padding");
@@ -1909,15 +1909,15 @@ const In = [0, 2, 3, 5, 6, 7, 9, 10, 11], wo = {
1909
1909
  }
1910
1910
  return Uint8Array.from(t);
1911
1911
  }
1912
- }, Dt = fe(he("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), de("")), Un = [996825010, 642813549, 513874426, 1027748829, 705979059];
1912
+ }, jt = fe(he("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), de("")), In = [996825010, 642813549, 513874426, 1027748829, 705979059];
1913
1913
  function Ze(e) {
1914
1914
  const t = e >> 25;
1915
1915
  let n = (e & 33554431) << 5;
1916
- for (let r = 0; r < Un.length; r++)
1917
- (t >> r & 1) === 1 && (n ^= Un[r]);
1916
+ for (let r = 0; r < In.length; r++)
1917
+ (t >> r & 1) === 1 && (n ^= In[r]);
1918
1918
  return n;
1919
1919
  }
1920
- function kn(e, t, n = 1) {
1920
+ function _n(e, t, n = 1) {
1921
1921
  const r = e.length;
1922
1922
  let i = 1;
1923
1923
  for (let o = 0; o < r; o++) {
@@ -1933,10 +1933,10 @@ function kn(e, t, n = 1) {
1933
1933
  i = Ze(i) ^ o;
1934
1934
  for (let o = 0; o < 6; o++)
1935
1935
  i = Ze(i);
1936
- return i ^= n, Dt.encode(Ht([i % 2 ** 30], 30, 5, !1));
1936
+ return i ^= n, jt.encode(qt([i % 2 ** 30], 30, 5, !1));
1937
1937
  }
1938
1938
  function lr(e) {
1939
- const t = e === "bech32" ? 1 : 734539939, n = Ae(5), r = n.decode, i = n.encode, o = Cn(r);
1939
+ const t = e === "bech32" ? 1 : 734539939, n = Ae(5), r = n.decode, i = n.encode, o = kn(r);
1940
1940
  function s(f, u, d = 90) {
1941
1941
  if (typeof f != "string")
1942
1942
  throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);
@@ -1945,9 +1945,9 @@ function lr(e) {
1945
1945
  const p = f.length + 7 + u.length;
1946
1946
  if (d !== !1 && p > d)
1947
1947
  throw new TypeError(`Length ${p} exceeds limit ${d}`);
1948
- return f = f.toLowerCase(), `${f}1${Dt.encode(u)}${kn(f, u, t)}`;
1948
+ return f = f.toLowerCase(), `${f}1${jt.encode(u)}${_n(f, u, t)}`;
1949
1949
  }
1950
- function c(f, u = 90) {
1950
+ function a(f, u = 90) {
1951
1951
  if (typeof f != "string")
1952
1952
  throw new Error(`bech32.decode input should be string, not ${typeof f}`);
1953
1953
  if (f.length < 8 || u !== !1 && f.length > u)
@@ -1962,17 +1962,17 @@ function lr(e) {
1962
1962
  const g = f.slice(0, p), h = f.slice(p + 1);
1963
1963
  if (h.length < 6)
1964
1964
  throw new Error("Data must be at least 6 characters long");
1965
- const y = Dt.decode(h).slice(0, -6), w = kn(g, y, t);
1965
+ const y = jt.decode(h).slice(0, -6), w = _n(g, y, t);
1966
1966
  if (!h.endsWith(w))
1967
1967
  throw new Error(`Invalid checksum in ${f}: expected "${w}"`);
1968
1968
  return { prefix: g, words: y };
1969
1969
  }
1970
- const a = Cn(c);
1970
+ const c = kn(a);
1971
1971
  function l(f) {
1972
- const { prefix: u, words: d } = c(f, !1);
1972
+ const { prefix: u, words: d } = a(f, !1);
1973
1973
  return { prefix: u, words: d, bytes: r(d) };
1974
1974
  }
1975
- return { encode: s, decode: c, decodeToBytes: l, decodeUnsafe: a, fromWords: r, fromWordsUnsafe: o, toWords: i };
1975
+ return { encode: s, decode: a, decodeToBytes: l, decodeUnsafe: c, fromWords: r, fromWordsUnsafe: o, toWords: i };
1976
1976
  }
1977
1977
  const De = lr("bech32");
1978
1978
  lr("bech32m");
@@ -1983,30 +1983,30 @@ const bo = {
1983
1983
  if (typeof e != "string" || e.length % 2)
1984
1984
  throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);
1985
1985
  return e.toLowerCase();
1986
- })), Eo = {
1986
+ })), mo = {
1987
1987
  utf8: bo,
1988
1988
  hex: vo,
1989
1989
  base16: yo,
1990
1990
  base32: po,
1991
1991
  base64: ue,
1992
1992
  base64url: go,
1993
- base58: qt,
1993
+ base58: Dt,
1994
1994
  base58xmr: wo
1995
1995
  };
1996
- `${Object.keys(Eo).join(", ")}`;
1996
+ `${Object.keys(mo).join(", ")}`;
1997
1997
  function Ut(e) {
1998
1998
  if (!Number.isSafeInteger(e) || e < 0)
1999
1999
  throw new Error(`positive integer expected, not ${e}`);
2000
2000
  }
2001
- function _n(e) {
2001
+ function Ln(e) {
2002
2002
  if (typeof e != "boolean")
2003
2003
  throw new Error(`boolean expected, not ${e}`);
2004
2004
  }
2005
- function mo(e) {
2005
+ function Eo(e) {
2006
2006
  return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array";
2007
2007
  }
2008
2008
  function le(e, ...t) {
2009
- if (!mo(e))
2009
+ if (!Eo(e))
2010
2010
  throw new Error("Uint8Array expected");
2011
2011
  if (t.length > 0 && !t.includes(e.length))
2012
2012
  throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`);
@@ -2028,19 +2028,19 @@ function Ao(e, t) {
2028
2028
  n |= e[r] ^ t[r];
2029
2029
  return n === 0;
2030
2030
  }
2031
- const Ko = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), me = 16, No = 283;
2032
- function en(e) {
2031
+ const Ko = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ee = 16, No = 283;
2032
+ function tn(e) {
2033
2033
  return e << 1 ^ No & -(e >> 7);
2034
2034
  }
2035
- function Pe(e, t) {
2035
+ function Oe(e, t) {
2036
2036
  let n = 0;
2037
2037
  for (; t > 0; t >>= 1)
2038
- n ^= e & -(t & 1), e = en(e);
2038
+ n ^= e & -(t & 1), e = tn(e);
2039
2039
  return n;
2040
2040
  }
2041
- const jt = /* @__PURE__ */ (() => {
2041
+ const zt = /* @__PURE__ */ (() => {
2042
2042
  let e = new Uint8Array(256);
2043
- for (let n = 0, r = 1; n < 256; n++, r ^= en(r))
2043
+ for (let n = 0, r = 1; n < 256; n++, r ^= tn(r))
2044
2044
  e[n] = r;
2045
2045
  const t = new Uint8Array(256);
2046
2046
  t[0] = 99;
@@ -2049,21 +2049,21 @@ const jt = /* @__PURE__ */ (() => {
2049
2049
  r |= r << 8, t[e[n]] = (r ^ r >> 4 ^ r >> 5 ^ r >> 6 ^ r >> 7 ^ 99) & 255;
2050
2050
  }
2051
2051
  return t;
2052
- })(), Bo = /* @__PURE__ */ jt.map((e, t) => jt.indexOf(t)), Co = (e) => e << 24 | e >>> 8, kt = (e) => e << 8 | e >>> 24;
2052
+ })(), Co = /* @__PURE__ */ zt.map((e, t) => zt.indexOf(t)), Bo = (e) => e << 24 | e >>> 8, It = (e) => e << 8 | e >>> 24;
2053
2053
  function ur(e, t) {
2054
2054
  if (e.length !== 256)
2055
2055
  throw new Error("Wrong sbox length");
2056
- const n = new Uint32Array(256).map((l, f) => t(e[f])), r = n.map(kt), i = r.map(kt), o = i.map(kt), s = new Uint32Array(256 * 256), c = new Uint32Array(256 * 256), a = new Uint16Array(256 * 256);
2056
+ const n = new Uint32Array(256).map((l, f) => t(e[f])), r = n.map(It), i = r.map(It), o = i.map(It), s = new Uint32Array(256 * 256), a = new Uint32Array(256 * 256), c = new Uint16Array(256 * 256);
2057
2057
  for (let l = 0; l < 256; l++)
2058
2058
  for (let f = 0; f < 256; f++) {
2059
2059
  const u = l * 256 + f;
2060
- s[u] = n[l] ^ r[f], c[u] = i[l] ^ o[f], a[u] = e[l] << 8 | e[f];
2060
+ s[u] = n[l] ^ r[f], a[u] = i[l] ^ o[f], c[u] = e[l] << 8 | e[f];
2061
2061
  }
2062
- return { sbox: e, sbox2: a, T0: n, T1: r, T2: i, T3: o, T01: s, T23: c };
2062
+ return { sbox: e, sbox2: c, T0: n, T1: r, T2: i, T3: o, T01: s, T23: a };
2063
2063
  }
2064
- const tn = /* @__PURE__ */ ur(jt, (e) => Pe(e, 3) << 24 | e << 16 | e << 8 | Pe(e, 2)), fr = /* @__PURE__ */ ur(Bo, (e) => Pe(e, 11) << 24 | Pe(e, 13) << 16 | Pe(e, 9) << 8 | Pe(e, 14)), Io = /* @__PURE__ */ (() => {
2064
+ const nn = /* @__PURE__ */ ur(zt, (e) => Oe(e, 3) << 24 | e << 16 | e << 8 | Oe(e, 2)), fr = /* @__PURE__ */ ur(Co, (e) => Oe(e, 11) << 24 | Oe(e, 13) << 16 | Oe(e, 9) << 8 | Oe(e, 14)), ko = /* @__PURE__ */ (() => {
2065
2065
  const e = new Uint8Array(16);
2066
- for (let t = 0, n = 1; t < 16; t++, n = en(n))
2066
+ for (let t = 0, n = 1; t < 16; t++, n = tn(n))
2067
2067
  e[t] = n;
2068
2068
  return e;
2069
2069
  })();
@@ -2072,54 +2072,54 @@ function hr(e) {
2072
2072
  const t = e.length;
2073
2073
  if (![16, 24, 32].includes(t))
2074
2074
  throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);
2075
- const { sbox2: n } = tn, r = F(e), i = r.length, o = (c) => se(n, c, c, c, c), s = new Uint32Array(t + 28);
2075
+ const { sbox2: n } = nn, r = F(e), i = r.length, o = (a) => se(n, a, a, a, a), s = new Uint32Array(t + 28);
2076
2076
  s.set(r);
2077
- for (let c = i; c < s.length; c++) {
2078
- let a = s[c - 1];
2079
- c % i === 0 ? a = o(Co(a)) ^ Io[c / i - 1] : i > 6 && c % i === 4 && (a = o(a)), s[c] = s[c - i] ^ a;
2077
+ for (let a = i; a < s.length; a++) {
2078
+ let c = s[a - 1];
2079
+ a % i === 0 ? c = o(Bo(c)) ^ ko[a / i - 1] : i > 6 && a % i === 4 && (c = o(c)), s[a] = s[a - i] ^ c;
2080
2080
  }
2081
2081
  return s;
2082
2082
  }
2083
2083
  function Uo(e) {
2084
- const t = hr(e), n = t.slice(), r = t.length, { sbox2: i } = tn, { T0: o, T1: s, T2: c, T3: a } = fr;
2084
+ const t = hr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: o, T1: s, T2: a, T3: c } = fr;
2085
2085
  for (let l = 0; l < r; l += 4)
2086
2086
  for (let f = 0; f < 4; f++)
2087
2087
  n[l + f] = t[r - l - 4 + f];
2088
2088
  t.fill(0);
2089
2089
  for (let l = 4; l < r - 4; l++) {
2090
2090
  const f = n[l], u = se(i, f, f, f, f);
2091
- n[l] = o[u & 255] ^ s[u >>> 8 & 255] ^ c[u >>> 16 & 255] ^ a[u >>> 24];
2091
+ n[l] = o[u & 255] ^ s[u >>> 8 & 255] ^ a[u >>> 16 & 255] ^ c[u >>> 24];
2092
2092
  }
2093
2093
  return n;
2094
2094
  }
2095
- function Ee(e, t, n, r, i, o) {
2095
+ function me(e, t, n, r, i, o) {
2096
2096
  return e[n << 8 & 65280 | r >>> 8 & 255] ^ t[i >>> 8 & 65280 | o >>> 24 & 255];
2097
2097
  }
2098
2098
  function se(e, t, n, r, i) {
2099
2099
  return e[t & 255 | n & 65280] | e[r >>> 16 & 255 | i >>> 16 & 65280] << 16;
2100
2100
  }
2101
- function Ln(e, t, n, r, i) {
2102
- const { sbox2: o, T01: s, T23: c } = tn;
2103
- let a = 0;
2104
- t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2101
+ function $n(e, t, n, r, i) {
2102
+ const { sbox2: o, T01: s, T23: a } = nn;
2103
+ let c = 0;
2104
+ t ^= e[c++], n ^= e[c++], r ^= e[c++], i ^= e[c++];
2105
2105
  const l = e.length / 4 - 2;
2106
2106
  for (let g = 0; g < l; g++) {
2107
- const h = e[a++] ^ Ee(s, c, t, n, r, i), y = e[a++] ^ Ee(s, c, n, r, i, t), w = e[a++] ^ Ee(s, c, r, i, t, n), m = e[a++] ^ Ee(s, c, i, t, n, r);
2108
- t = h, n = y, r = w, i = m;
2107
+ const h = e[c++] ^ me(s, a, t, n, r, i), y = e[c++] ^ me(s, a, n, r, i, t), w = e[c++] ^ me(s, a, r, i, t, n), E = e[c++] ^ me(s, a, i, t, n, r);
2108
+ t = h, n = y, r = w, i = E;
2109
2109
  }
2110
- const f = e[a++] ^ se(o, t, n, r, i), u = e[a++] ^ se(o, n, r, i, t), d = e[a++] ^ se(o, r, i, t, n), p = e[a++] ^ se(o, i, t, n, r);
2110
+ const f = e[c++] ^ se(o, t, n, r, i), u = e[c++] ^ se(o, n, r, i, t), d = e[c++] ^ se(o, r, i, t, n), p = e[c++] ^ se(o, i, t, n, r);
2111
2111
  return { s0: f, s1: u, s2: d, s3: p };
2112
2112
  }
2113
- function ko(e, t, n, r, i) {
2114
- const { sbox2: o, T01: s, T23: c } = fr;
2115
- let a = 0;
2116
- t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2113
+ function Io(e, t, n, r, i) {
2114
+ const { sbox2: o, T01: s, T23: a } = fr;
2115
+ let c = 0;
2116
+ t ^= e[c++], n ^= e[c++], r ^= e[c++], i ^= e[c++];
2117
2117
  const l = e.length / 4 - 2;
2118
2118
  for (let g = 0; g < l; g++) {
2119
- const h = e[a++] ^ Ee(s, c, t, i, r, n), y = e[a++] ^ Ee(s, c, n, t, i, r), w = e[a++] ^ Ee(s, c, r, n, t, i), m = e[a++] ^ Ee(s, c, i, r, n, t);
2120
- t = h, n = y, r = w, i = m;
2119
+ const h = e[c++] ^ me(s, a, t, i, r, n), y = e[c++] ^ me(s, a, n, t, i, r), w = e[c++] ^ me(s, a, r, n, t, i), E = e[c++] ^ me(s, a, i, r, n, t);
2120
+ t = h, n = y, r = w, i = E;
2121
2121
  }
2122
- const f = e[a++] ^ se(o, t, i, r, n), u = e[a++] ^ se(o, n, t, i, r), d = e[a++] ^ se(o, r, n, t, i), p = e[a++] ^ se(o, i, r, n, t);
2122
+ const f = e[c++] ^ se(o, t, i, r, n), u = e[c++] ^ se(o, n, t, i, r), d = e[c++] ^ se(o, r, n, t, i), p = e[c++] ^ se(o, i, r, n, t);
2123
2123
  return { s0: f, s1: u, s2: d, s3: p };
2124
2124
  }
2125
2125
  function dr(e, t) {
@@ -2130,21 +2130,21 @@ function dr(e, t) {
2130
2130
  return t;
2131
2131
  }
2132
2132
  function _o(e) {
2133
- if (le(e), e.length % me !== 0)
2134
- throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${me}`);
2133
+ if (le(e), e.length % Ee !== 0)
2134
+ throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ee}`);
2135
2135
  }
2136
2136
  function Lo(e, t, n) {
2137
2137
  let r = e.length;
2138
- const i = r % me;
2138
+ const i = r % Ee;
2139
2139
  if (!t && i !== 0)
2140
2140
  throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");
2141
2141
  const o = F(e);
2142
2142
  if (t) {
2143
- let a = me - i;
2144
- a || (a = me), r = r + a;
2143
+ let c = Ee - i;
2144
+ c || (c = Ee), r = r + c;
2145
2145
  }
2146
- const s = dr(r, n), c = F(s);
2147
- return { b: o, o: c, out: s };
2146
+ const s = dr(r, n), a = F(s);
2147
+ return { b: o, o: a, out: s };
2148
2148
  }
2149
2149
  function $o(e, t) {
2150
2150
  if (!t)
@@ -2164,8 +2164,8 @@ function $o(e, t) {
2164
2164
  function To(e) {
2165
2165
  const t = new Uint8Array(16), n = F(t);
2166
2166
  t.set(e);
2167
- const r = me - e.length;
2168
- for (let i = me - r; i < me; i++)
2167
+ const r = Ee - e.length;
2168
+ for (let i = Ee - r; i < Ee; i++)
2169
2169
  t[i] = r;
2170
2170
  return n;
2171
2171
  }
@@ -2174,50 +2174,50 @@ const yr = /* @__PURE__ */ Ko({ blockSize: 16, nonceLength: 16 }, function(t, n,
2174
2174
  const i = !r.disablePadding;
2175
2175
  return {
2176
2176
  encrypt: (o, s) => {
2177
- const c = hr(t), { b: a, o: l, out: f } = Lo(o, i, s), u = F(n);
2177
+ const a = hr(t), { b: c, o: l, out: f } = Lo(o, i, s), u = F(n);
2178
2178
  let d = u[0], p = u[1], g = u[2], h = u[3], y = 0;
2179
- for (; y + 4 <= a.length; )
2180
- d ^= a[y + 0], p ^= a[y + 1], g ^= a[y + 2], h ^= a[y + 3], { s0: d, s1: p, s2: g, s3: h } = Ln(c, d, p, g, h), l[y++] = d, l[y++] = p, l[y++] = g, l[y++] = h;
2179
+ for (; y + 4 <= c.length; )
2180
+ d ^= c[y + 0], p ^= c[y + 1], g ^= c[y + 2], h ^= c[y + 3], { s0: d, s1: p, s2: g, s3: h } = $n(a, d, p, g, h), l[y++] = d, l[y++] = p, l[y++] = g, l[y++] = h;
2181
2181
  if (i) {
2182
2182
  const w = To(o.subarray(y * 4));
2183
- d ^= w[0], p ^= w[1], g ^= w[2], h ^= w[3], { s0: d, s1: p, s2: g, s3: h } = Ln(c, d, p, g, h), l[y++] = d, l[y++] = p, l[y++] = g, l[y++] = h;
2183
+ d ^= w[0], p ^= w[1], g ^= w[2], h ^= w[3], { s0: d, s1: p, s2: g, s3: h } = $n(a, d, p, g, h), l[y++] = d, l[y++] = p, l[y++] = g, l[y++] = h;
2184
2184
  }
2185
- return c.fill(0), f;
2185
+ return a.fill(0), f;
2186
2186
  },
2187
2187
  decrypt: (o, s) => {
2188
2188
  _o(o);
2189
- const c = Uo(t), a = F(n), l = dr(o.length, s), f = F(o), u = F(l);
2190
- let d = a[0], p = a[1], g = a[2], h = a[3];
2189
+ const a = Uo(t), c = F(n), l = dr(o.length, s), f = F(o), u = F(l);
2190
+ let d = c[0], p = c[1], g = c[2], h = c[3];
2191
2191
  for (let y = 0; y + 4 <= f.length; ) {
2192
- const w = d, m = p, K = g, k = h;
2192
+ const w = d, E = p, K = g, I = h;
2193
2193
  d = f[y + 0], p = f[y + 1], g = f[y + 2], h = f[y + 3];
2194
- const { s0: C, s1: E, s2: x, s3: S } = ko(c, d, p, g, h);
2195
- u[y++] = C ^ w, u[y++] = E ^ m, u[y++] = x ^ K, u[y++] = S ^ k;
2194
+ const { s0: B, s1: m, s2: x, s3: S } = Io(a, d, p, g, h);
2195
+ u[y++] = B ^ w, u[y++] = m ^ E, u[y++] = x ^ K, u[y++] = S ^ I;
2196
2196
  }
2197
- return c.fill(0), $o(l, i);
2197
+ return a.fill(0), $o(l, i);
2198
2198
  }
2199
2199
  };
2200
- }), pr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Ro = pr("expand 16-byte k"), Po = pr("expand 32-byte k"), Oo = F(Ro), gr = F(Po);
2200
+ }), pr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Ro = pr("expand 16-byte k"), Oo = pr("expand 32-byte k"), Po = F(Ro), gr = F(Oo);
2201
2201
  gr.slice();
2202
2202
  function L(e, t) {
2203
2203
  return e << t | e >>> 32 - t;
2204
2204
  }
2205
- function zt(e) {
2205
+ function Vt(e) {
2206
2206
  return e.byteOffset % 4 === 0;
2207
2207
  }
2208
- const Xe = 64, Mo = 16, wr = 2 ** 32 - 1, $n = new Uint32Array();
2209
- function Ho(e, t, n, r, i, o, s, c) {
2210
- const a = i.length, l = new Uint8Array(Xe), f = F(l), u = zt(i) && zt(o), d = u ? F(i) : $n, p = u ? F(o) : $n;
2211
- for (let g = 0; g < a; s++) {
2212
- if (e(t, n, r, f, s, c), s >= wr)
2208
+ const Xe = 64, Mo = 16, wr = 2 ** 32 - 1, Tn = new Uint32Array();
2209
+ function Ho(e, t, n, r, i, o, s, a) {
2210
+ const c = i.length, l = new Uint8Array(Xe), f = F(l), u = Vt(i) && Vt(o), d = u ? F(i) : Tn, p = u ? F(o) : Tn;
2211
+ for (let g = 0; g < c; s++) {
2212
+ if (e(t, n, r, f, s, a), s >= wr)
2213
2213
  throw new Error("arx: counter overflow");
2214
- const h = Math.min(Xe, a - g);
2214
+ const h = Math.min(Xe, c - g);
2215
2215
  if (u && h === Xe) {
2216
2216
  const y = g / 4;
2217
2217
  if (g % 4 !== 0)
2218
2218
  throw new Error("arx: invalid block position");
2219
- for (let w = 0, m; w < Mo; w++)
2220
- m = y + w, p[m] = d[m] ^ f[w];
2219
+ for (let w = 0, E; w < Mo; w++)
2220
+ E = y + w, p[E] = d[E] ^ f[w];
2221
2221
  g += Xe;
2222
2222
  continue;
2223
2223
  }
@@ -2230,47 +2230,47 @@ function qo(e, t) {
2230
2230
  const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: o, rounds: s } = So({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t);
2231
2231
  if (typeof e != "function")
2232
2232
  throw new Error("core must be a function");
2233
- return Ut(i), Ut(s), _n(o), _n(n), (c, a, l, f, u = 0) => {
2234
- le(c), le(a), le(l);
2233
+ return Ut(i), Ut(s), Ln(o), Ln(n), (a, c, l, f, u = 0) => {
2234
+ le(a), le(c), le(l);
2235
2235
  const d = l.length;
2236
2236
  if (f || (f = new Uint8Array(d)), le(f), Ut(u), u < 0 || u >= wr)
2237
2237
  throw new Error("arx: counter overflow");
2238
2238
  if (f.length < d)
2239
2239
  throw new Error(`arx: output (${f.length}) is shorter than data (${d})`);
2240
2240
  const p = [];
2241
- let g = c.length, h, y;
2241
+ let g = a.length, h, y;
2242
2242
  if (g === 32)
2243
- h = c.slice(), p.push(h), y = gr;
2243
+ h = a.slice(), p.push(h), y = gr;
2244
2244
  else if (g === 16 && n)
2245
- h = new Uint8Array(32), h.set(c), h.set(c, 16), y = Oo, p.push(h);
2245
+ h = new Uint8Array(32), h.set(a), h.set(a, 16), y = Po, p.push(h);
2246
2246
  else
2247
2247
  throw new Error(`arx: invalid 32-byte key, got length=${g}`);
2248
- zt(a) || (a = a.slice(), p.push(a));
2248
+ Vt(c) || (c = c.slice(), p.push(c));
2249
2249
  const w = F(h);
2250
2250
  if (r) {
2251
- if (a.length !== 24)
2251
+ if (c.length !== 24)
2252
2252
  throw new Error("arx: extended nonce must be 24 bytes");
2253
- r(y, w, F(a.subarray(0, 16)), w), a = a.subarray(16);
2253
+ r(y, w, F(c.subarray(0, 16)), w), c = c.subarray(16);
2254
2254
  }
2255
- const m = 16 - i;
2256
- if (m !== a.length)
2257
- throw new Error(`arx: nonce must be ${m} or 16 bytes`);
2258
- if (m !== 12) {
2259
- const k = new Uint8Array(12);
2260
- k.set(a, o ? 0 : 12 - a.length), a = k, p.push(a);
2255
+ const E = 16 - i;
2256
+ if (E !== c.length)
2257
+ throw new Error(`arx: nonce must be ${E} or 16 bytes`);
2258
+ if (E !== 12) {
2259
+ const I = new Uint8Array(12);
2260
+ I.set(c, o ? 0 : 12 - c.length), c = I, p.push(c);
2261
2261
  }
2262
- const K = F(a);
2262
+ const K = F(c);
2263
2263
  for (Ho(e, y, w, K, l, f, u, s); p.length > 0; )
2264
2264
  p.pop().fill(0);
2265
2265
  return f;
2266
2266
  };
2267
2267
  }
2268
2268
  function Do(e, t, n, r, i, o = 20) {
2269
- let s = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], d = t[2], p = t[3], g = t[4], h = t[5], y = t[6], w = t[7], m = i, K = n[0], k = n[1], C = n[2], E = s, x = c, S = a, O = l, U = f, N = u, T = d, R = p, H = g, b = h, v = y, A = w, I = m, B = K, _ = k, P = C;
2269
+ let s = e[0], a = e[1], c = e[2], l = e[3], f = t[0], u = t[1], d = t[2], p = t[3], g = t[4], h = t[5], y = t[6], w = t[7], E = i, K = n[0], I = n[1], B = n[2], m = s, x = a, S = c, P = l, U = f, N = u, T = d, R = p, H = g, b = h, v = y, A = w, k = E, C = K, _ = I, O = B;
2270
2270
  for (let X = 0; X < o; X += 2)
2271
- E = E + U | 0, I = L(I ^ E, 16), H = H + I | 0, U = L(U ^ H, 12), E = E + U | 0, I = L(I ^ E, 8), H = H + I | 0, U = L(U ^ H, 7), x = x + N | 0, B = L(B ^ x, 16), b = b + B | 0, N = L(N ^ b, 12), x = x + N | 0, B = L(B ^ x, 8), b = b + B | 0, N = L(N ^ b, 7), S = S + T | 0, _ = L(_ ^ S, 16), v = v + _ | 0, T = L(T ^ v, 12), S = S + T | 0, _ = L(_ ^ S, 8), v = v + _ | 0, T = L(T ^ v, 7), O = O + R | 0, P = L(P ^ O, 16), A = A + P | 0, R = L(R ^ A, 12), O = O + R | 0, P = L(P ^ O, 8), A = A + P | 0, R = L(R ^ A, 7), E = E + N | 0, P = L(P ^ E, 16), v = v + P | 0, N = L(N ^ v, 12), E = E + N | 0, P = L(P ^ E, 8), v = v + P | 0, N = L(N ^ v, 7), x = x + T | 0, I = L(I ^ x, 16), A = A + I | 0, T = L(T ^ A, 12), x = x + T | 0, I = L(I ^ x, 8), A = A + I | 0, T = L(T ^ A, 7), S = S + R | 0, B = L(B ^ S, 16), H = H + B | 0, R = L(R ^ H, 12), S = S + R | 0, B = L(B ^ S, 8), H = H + B | 0, R = L(R ^ H, 7), O = O + U | 0, _ = L(_ ^ O, 16), b = b + _ | 0, U = L(U ^ b, 12), O = O + U | 0, _ = L(_ ^ O, 8), b = b + _ | 0, U = L(U ^ b, 7);
2271
+ m = m + U | 0, k = L(k ^ m, 16), H = H + k | 0, U = L(U ^ H, 12), m = m + U | 0, k = L(k ^ m, 8), H = H + k | 0, U = L(U ^ H, 7), x = x + N | 0, C = L(C ^ x, 16), b = b + C | 0, N = L(N ^ b, 12), x = x + N | 0, C = L(C ^ x, 8), b = b + C | 0, N = L(N ^ b, 7), S = S + T | 0, _ = L(_ ^ S, 16), v = v + _ | 0, T = L(T ^ v, 12), S = S + T | 0, _ = L(_ ^ S, 8), v = v + _ | 0, T = L(T ^ v, 7), P = P + R | 0, O = L(O ^ P, 16), A = A + O | 0, R = L(R ^ A, 12), P = P + R | 0, O = L(O ^ P, 8), A = A + O | 0, R = L(R ^ A, 7), m = m + N | 0, O = L(O ^ m, 16), v = v + O | 0, N = L(N ^ v, 12), m = m + N | 0, O = L(O ^ m, 8), v = v + O | 0, N = L(N ^ v, 7), x = x + T | 0, k = L(k ^ x, 16), A = A + k | 0, T = L(T ^ A, 12), x = x + T | 0, k = L(k ^ x, 8), A = A + k | 0, T = L(T ^ A, 7), S = S + R | 0, C = L(C ^ S, 16), H = H + C | 0, R = L(R ^ H, 12), S = S + R | 0, C = L(C ^ S, 8), H = H + C | 0, R = L(R ^ H, 7), P = P + U | 0, _ = L(_ ^ P, 16), b = b + _ | 0, U = L(U ^ b, 12), P = P + U | 0, _ = L(_ ^ P, 8), b = b + _ | 0, U = L(U ^ b, 7);
2272
2272
  let $ = 0;
2273
- r[$++] = s + E | 0, r[$++] = c + x | 0, r[$++] = a + S | 0, r[$++] = l + O | 0, r[$++] = f + U | 0, r[$++] = u + N | 0, r[$++] = d + T | 0, r[$++] = p + R | 0, r[$++] = g + H | 0, r[$++] = h + b | 0, r[$++] = y + v | 0, r[$++] = w + A | 0, r[$++] = m + I | 0, r[$++] = K + B | 0, r[$++] = k + _ | 0, r[$++] = C + P | 0;
2273
+ r[$++] = s + m | 0, r[$++] = a + x | 0, r[$++] = c + S | 0, r[$++] = l + P | 0, r[$++] = f + U | 0, r[$++] = u + N | 0, r[$++] = d + T | 0, r[$++] = p + R | 0, r[$++] = g + H | 0, r[$++] = h + b | 0, r[$++] = y + v | 0, r[$++] = w + A | 0, r[$++] = E + k | 0, r[$++] = K + C | 0, r[$++] = I + _ | 0, r[$++] = B + O | 0;
2274
2274
  }
2275
2275
  const br = /* @__PURE__ */ qo(Do, {
2276
2276
  counterRight: !1,
@@ -2305,8 +2305,8 @@ class vr extends nr {
2305
2305
  }
2306
2306
  _cloneInto(t) {
2307
2307
  t || (t = Object.create(Object.getPrototypeOf(this), {}));
2308
- const { oHash: n, iHash: r, finished: i, destroyed: o, blockLen: s, outputLen: c } = this;
2309
- return t = t, t.finished = i, t.destroyed = o, t.blockLen = s, t.outputLen = c, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
2308
+ const { oHash: n, iHash: r, finished: i, destroyed: o, blockLen: s, outputLen: a } = this;
2309
+ return t = t, t.finished = i, t.destroyed = o, t.blockLen = s, t.outputLen = a, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
2310
2310
  }
2311
2311
  destroy() {
2312
2312
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
@@ -2314,25 +2314,25 @@ class vr extends nr {
2314
2314
  }
2315
2315
  const pt = (e, t, n) => new vr(e, t).update(n).digest();
2316
2316
  pt.create = (e, t) => new vr(e, t);
2317
- function nn(e, t, n) {
2317
+ function rn(e, t, n) {
2318
2318
  return oe.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), pt(e, Ge(n), Ge(t));
2319
2319
  }
2320
- const _t = new Uint8Array([0]), Tn = new Uint8Array();
2321
- function Er(e, t, n, r = 32) {
2320
+ const _t = new Uint8Array([0]), Rn = new Uint8Array();
2321
+ function mr(e, t, n, r = 32) {
2322
2322
  if (oe.hash(e), oe.number(r), r > 255 * e.outputLen)
2323
2323
  throw new Error("Length should be <= 255*HashLen");
2324
2324
  const i = Math.ceil(r / e.outputLen);
2325
- n === void 0 && (n = Tn);
2326
- const o = new Uint8Array(i * e.outputLen), s = pt.create(e, t), c = s._cloneInto(), a = new Uint8Array(s.outputLen);
2325
+ n === void 0 && (n = Rn);
2326
+ const o = new Uint8Array(i * e.outputLen), s = pt.create(e, t), a = s._cloneInto(), c = new Uint8Array(s.outputLen);
2327
2327
  for (let l = 0; l < i; l++)
2328
- _t[0] = l + 1, c.update(l === 0 ? Tn : a).update(n).update(_t).digestInto(a), o.set(a, e.outputLen * l), s._cloneInto(c);
2329
- return s.destroy(), c.destroy(), a.fill(0), _t.fill(0), o.slice(0, r);
2328
+ _t[0] = l + 1, a.update(l === 0 ? Rn : c).update(n).update(_t).digestInto(c), o.set(c, e.outputLen * l), s._cloneInto(a);
2329
+ return s.destroy(), a.destroy(), c.fill(0), _t.fill(0), o.slice(0, r);
2330
2330
  }
2331
2331
  var jo = Object.defineProperty, D = (e, t) => {
2332
2332
  for (var n in t)
2333
2333
  jo(e, n, { get: t[n], enumerable: !0 });
2334
2334
  }, Te = Symbol("verified"), zo = (e) => e instanceof Object;
2335
- function mr(e) {
2335
+ function Er(e) {
2336
2336
  if (!zo(e) || typeof e.kind != "number" || typeof e.content != "string" || typeof e.created_at != "number" || typeof e.pubkey != "string" || !e.pubkey.match(/^[a-f0-9]{64}$/) || !Array.isArray(e.tags))
2337
2337
  return !1;
2338
2338
  for (let t = 0; t < e.tags.length; t++) {
@@ -2349,7 +2349,7 @@ var Vo = {};
2349
2349
  D(Vo, {
2350
2350
  Queue: () => Go,
2351
2351
  QueueNode: () => xr,
2352
- binarySearch: () => rn,
2352
+ binarySearch: () => on,
2353
2353
  insertEventIntoAscendingList: () => Wo,
2354
2354
  insertEventIntoDescendingList: () => Fo,
2355
2355
  normalizeURL: () => Zo,
@@ -2363,14 +2363,14 @@ function Zo(e) {
2363
2363
  return t.pathname = t.pathname.replace(/\/+/g, "/"), t.pathname.endsWith("/") && (t.pathname = t.pathname.slice(0, -1)), (t.port === "80" && t.protocol === "ws:" || t.port === "443" && t.protocol === "wss:") && (t.port = ""), t.searchParams.sort(), t.hash = "", t.toString();
2364
2364
  }
2365
2365
  function Fo(e, t) {
2366
- const [n, r] = rn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
2366
+ const [n, r] = on(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
2367
2367
  return r || e.splice(n, 0, t), e;
2368
2368
  }
2369
2369
  function Wo(e, t) {
2370
- const [n, r] = rn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
2370
+ const [n, r] = on(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
2371
2371
  return r || e.splice(n, 0, t), e;
2372
2372
  }
2373
- function rn(e, t) {
2373
+ function on(e, t) {
2374
2374
  let n = 0, r = e.length - 1;
2375
2375
  for (; n <= r; ) {
2376
2376
  const i = Math.floor((n + r) / 2), o = t(e[i]);
@@ -2433,7 +2433,7 @@ var xr = class {
2433
2433
  }
2434
2434
  };
2435
2435
  function Yo(e) {
2436
- if (!mr(e))
2436
+ if (!Er(e))
2437
2437
  throw new Error("can't serialize event with wrong or missing properties");
2438
2438
  return JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content]);
2439
2439
  }
@@ -2441,24 +2441,24 @@ function tt(e) {
2441
2441
  let t = Se(te.encode(Yo(e)));
2442
2442
  return M(t);
2443
2443
  }
2444
- var gt = new Jo(), Oe = gt.generateSecretKey, Ce = gt.getPublicKey, ae = gt.finalizeEvent, on = gt.verifyEvent, Xo = {};
2444
+ var gt = new Jo(), Pe = gt.generateSecretKey, Be = gt.getPublicKey, ae = gt.finalizeEvent, sn = gt.verifyEvent, Xo = {};
2445
2445
  D(Xo, {
2446
2446
  Application: () => Xs,
2447
2447
  BadgeAward: () => as,
2448
2448
  BadgeDefinition: () => Vs,
2449
2449
  BlockedRelaysList: () => Us,
2450
- BookmarkList: () => Bs,
2450
+ BookmarkList: () => Cs,
2451
2451
  Bookmarksets: () => Ds,
2452
2452
  Calendar: () => oa,
2453
2453
  CalendarEventRSVP: () => sa,
2454
- ChannelCreation: () => Br,
2454
+ ChannelCreation: () => Cr,
2455
2455
  ChannelHideMessage: () => Ur,
2456
- ChannelMessage: () => Ir,
2457
- ChannelMetadata: () => Cr,
2458
- ChannelMuteUser: () => kr,
2456
+ ChannelMessage: () => kr,
2457
+ ChannelMetadata: () => Br,
2458
+ ChannelMuteUser: () => Ir,
2459
2459
  ClassifiedListing: () => ta,
2460
2460
  ClientAuth: () => _r,
2461
- CommunitiesList: () => Cs,
2461
+ CommunitiesList: () => Bs,
2462
2462
  CommunityDefinition: () => la,
2463
2463
  CommunityPostApproval: () => gs,
2464
2464
  Contacts: () => rs,
@@ -2477,7 +2477,7 @@ D(Xo, {
2477
2477
  Followsets: () => Ms,
2478
2478
  GenericRepost: () => cs,
2479
2479
  Genericlists: () => Hs,
2480
- HTTPAuth: () => cn,
2480
+ HTTPAuth: () => ln,
2481
2481
  Handlerinformation: () => ca,
2482
2482
  Handlerrecommendation: () => aa,
2483
2483
  Highlights: () => Ss,
@@ -2495,28 +2495,28 @@ D(Xo, {
2495
2495
  Mutelist: () => As,
2496
2496
  NWCWalletInfo: () => Ts,
2497
2497
  NWCWalletRequest: () => Lr,
2498
- NWCWalletResponse: () => Ps,
2499
- NostrConnect: () => Os,
2498
+ NWCWalletResponse: () => Os,
2499
+ NostrConnect: () => Ps,
2500
2500
  OpenTimestamps: () => ls,
2501
2501
  Pinlist: () => Ks,
2502
2502
  ProblemTracker: () => hs,
2503
2503
  ProfileBadges: () => zs,
2504
- PublicChatsList: () => Is,
2505
- Reaction: () => an,
2504
+ PublicChatsList: () => ks,
2505
+ Reaction: () => cn,
2506
2506
  RecommendRelay: () => ns,
2507
2507
  RelayList: () => Ns,
2508
2508
  Relaysets: () => qs,
2509
2509
  Report: () => ds,
2510
2510
  Reporting: () => ys,
2511
- Repost: () => sn,
2512
- SearchRelaysList: () => ks,
2511
+ Repost: () => an,
2512
+ SearchRelaysList: () => Is,
2513
2513
  ShortTextNote: () => ts,
2514
2514
  Time: () => ia,
2515
2515
  UserEmojiList: () => Ls,
2516
2516
  UserStatuses: () => ea,
2517
2517
  Zap: () => xs,
2518
- ZapGoal: () => Es,
2519
- ZapRequest: () => ms,
2518
+ ZapGoal: () => ms,
2519
+ ZapRequest: () => Es,
2520
2520
  classifyKind: () => Qo,
2521
2521
  isEphemeralKind: () => Kr,
2522
2522
  isParameterizedReplaceableKind: () => Nr,
@@ -2538,16 +2538,16 @@ function Nr(e) {
2538
2538
  function Qo(e) {
2539
2539
  return Sr(e) ? "regular" : Ar(e) ? "replaceable" : Kr(e) ? "ephemeral" : Nr(e) ? "parameterized" : "unknown";
2540
2540
  }
2541
- var es = 0, ts = 1, ns = 2, rs = 3, is = 4, os = 4, ss = 5, sn = 6, an = 7, as = 8, cs = 16, Br = 40, Cr = 41, Ir = 42, Ur = 43, kr = 44, ls = 1040, us = 1063, fs = 1311, hs = 1971, ds = 1984, ys = 1984, ps = 1985, gs = 4550, ws = 5999, bs = 6999, vs = 7e3, Es = 9041, ms = 9734, xs = 9735, Ss = 9802, As = 1e4, Ks = 10001, Ns = 10002, Bs = 10003, Cs = 10004, Is = 10005, Us = 10006, ks = 10007, _s = 10015, Ls = 10030, $s = 10096, Ts = 13194, Rs = 21e3, _r = 22242, Lr = 23194, Ps = 23195, Os = 24133, cn = 27235, Ms = 3e4, Hs = 30001, qs = 30002, Ds = 30003, js = 30004, zs = 30008, Vs = 30009, Zs = 30015, Fs = 30017, Ws = 30018, Gs = 30023, Js = 30024, Ys = 30030, Xs = 30078, Qs = 30311, ea = 30315, ta = 30402, na = 30403, ra = 31922, ia = 31923, oa = 31924, sa = 31925, aa = 31989, ca = 31990, la = 34550, ua = {};
2541
+ var es = 0, ts = 1, ns = 2, rs = 3, is = 4, os = 4, ss = 5, an = 6, cn = 7, as = 8, cs = 16, Cr = 40, Br = 41, kr = 42, Ur = 43, Ir = 44, ls = 1040, us = 1063, fs = 1311, hs = 1971, ds = 1984, ys = 1984, ps = 1985, gs = 4550, ws = 5999, bs = 6999, vs = 7e3, ms = 9041, Es = 9734, xs = 9735, Ss = 9802, As = 1e4, Ks = 10001, Ns = 10002, Cs = 10003, Bs = 10004, ks = 10005, Us = 10006, Is = 10007, _s = 10015, Ls = 10030, $s = 10096, Ts = 13194, Rs = 21e3, _r = 22242, Lr = 23194, Os = 23195, Ps = 24133, ln = 27235, Ms = 3e4, Hs = 30001, qs = 30002, Ds = 30003, js = 30004, zs = 30008, Vs = 30009, Zs = 30015, Fs = 30017, Ws = 30018, Gs = 30023, Js = 30024, Ys = 30030, Xs = 30078, Qs = 30311, ea = 30315, ta = 30402, na = 30403, ra = 31922, ia = 31923, oa = 31924, sa = 31925, aa = 31989, ca = 31990, la = 34550, ua = {};
2542
2542
  D(ua, {
2543
- getHex64: () => ln,
2543
+ getHex64: () => un,
2544
2544
  getInt: () => $r,
2545
2545
  getSubscriptionId: () => fa,
2546
2546
  matchEventId: () => ha,
2547
2547
  matchEventKind: () => ya,
2548
2548
  matchEventPubkey: () => da
2549
2549
  });
2550
- function ln(e, t) {
2550
+ function un(e, t) {
2551
2551
  let n = t.length + 3, r = e.indexOf(`"${t}":`) + n, i = e.slice(r).indexOf('"') + r + 1;
2552
2552
  return e.slice(i, i + 64);
2553
2553
  }
@@ -2569,10 +2569,10 @@ function fa(e) {
2569
2569
  return e.slice(r + 1, o);
2570
2570
  }
2571
2571
  function ha(e, t) {
2572
- return t === ln(e, "id");
2572
+ return t === un(e, "id");
2573
2573
  }
2574
2574
  function da(e, t) {
2575
- return t === ln(e, "pubkey");
2575
+ return t === un(e, "pubkey");
2576
2576
  }
2577
2577
  function ya(e, t) {
2578
2578
  return t === $r(e, "kind");
@@ -2605,25 +2605,25 @@ try {
2605
2605
  var Fe = {};
2606
2606
  D(Fe, {
2607
2607
  BECH32_REGEX: () => Tr,
2608
- Bech32MaxSize: () => un,
2608
+ Bech32MaxSize: () => fn,
2609
2609
  decode: () => wt,
2610
2610
  encodeBytes: () => bt,
2611
2611
  naddrEncode: () => Ka,
2612
2612
  neventEncode: () => Aa,
2613
2613
  noteEncode: () => xa,
2614
2614
  nprofileEncode: () => Sa,
2615
- npubEncode: () => ma,
2615
+ npubEncode: () => Ea,
2616
2616
  nrelayEncode: () => Na,
2617
- nsecEncode: () => Ea
2617
+ nsecEncode: () => ma
2618
2618
  });
2619
- var un = 5e3, Tr = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
2619
+ var fn = 5e3, Tr = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
2620
2620
  function va(e) {
2621
2621
  const t = new Uint8Array(4);
2622
2622
  return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t;
2623
2623
  }
2624
2624
  function wt(e) {
2625
- var i, o, s, c, a, l, f, u;
2626
- let { prefix: t, words: n } = De.decode(e, un), r = new Uint8Array(De.fromWords(n));
2625
+ var i, o, s, a, c, l, f, u;
2626
+ let { prefix: t, words: n } = De.decode(e, fn), r = new Uint8Array(De.fromWords(n));
2627
2627
  switch (t) {
2628
2628
  case "nprofile": {
2629
2629
  let d = Qe(r);
@@ -2655,13 +2655,13 @@ function wt(e) {
2655
2655
  id: M(d[0][0]),
2656
2656
  relays: d[1] ? d[1].map((p) => ie.decode(p)) : [],
2657
2657
  author: (s = d[2]) != null && s[0] ? M(d[2][0]) : void 0,
2658
- kind: (c = d[3]) != null && c[0] ? parseInt(M(d[3][0]), 16) : void 0
2658
+ kind: (a = d[3]) != null && a[0] ? parseInt(M(d[3][0]), 16) : void 0
2659
2659
  }
2660
2660
  };
2661
2661
  }
2662
2662
  case "naddr": {
2663
2663
  let d = Qe(r);
2664
- if (!((a = d[0]) != null && a[0]))
2664
+ if (!((c = d[0]) != null && c[0]))
2665
2665
  throw new Error("missing TLV 0 for naddr");
2666
2666
  if (!((l = d[2]) != null && l[0]))
2667
2667
  throw new Error("missing TLV 2 for naddr");
@@ -2709,10 +2709,10 @@ function Qe(e) {
2709
2709
  }
2710
2710
  return t;
2711
2711
  }
2712
- function Ea(e) {
2712
+ function ma(e) {
2713
2713
  return bt("nsec", e);
2714
2714
  }
2715
- function ma(e) {
2715
+ function Ea(e) {
2716
2716
  return bt("npub", W(e));
2717
2717
  }
2718
2718
  function xa(e) {
@@ -2720,7 +2720,7 @@ function xa(e) {
2720
2720
  }
2721
2721
  function Ye(e, t) {
2722
2722
  let n = De.toWords(t);
2723
- return De.encode(e, n, un);
2723
+ return De.encode(e, n, fn);
2724
2724
  }
2725
2725
  function bt(e, t) {
2726
2726
  return Ye(e, t);
@@ -2769,58 +2769,58 @@ function vt(e) {
2769
2769
  });
2770
2770
  }), dt(...t);
2771
2771
  }
2772
- var Ba = {};
2773
- D(Ba, {
2774
- decrypt: () => Ca,
2772
+ var Ca = {};
2773
+ D(Ca, {
2774
+ decrypt: () => Ba,
2775
2775
  encrypt: () => Rr
2776
2776
  });
2777
2777
  async function Rr(e, t, n) {
2778
- const r = e instanceof Uint8Array ? M(e) : e, i = Ue.getSharedSecret(r, "02" + t), o = Pr(i);
2779
- let s = Uint8Array.from(ir(16)), c = te.encode(n), a = yr(o, s).encrypt(c), l = ue.encode(new Uint8Array(a)), f = ue.encode(new Uint8Array(s.buffer));
2778
+ const r = e instanceof Uint8Array ? M(e) : e, i = Ue.getSharedSecret(r, "02" + t), o = Or(i);
2779
+ let s = Uint8Array.from(ir(16)), a = te.encode(n), c = yr(o, s).encrypt(a), l = ue.encode(new Uint8Array(c)), f = ue.encode(new Uint8Array(s.buffer));
2780
2780
  return `${l}?iv=${f}`;
2781
2781
  }
2782
- async function Ca(e, t, n) {
2782
+ async function Ba(e, t, n) {
2783
2783
  const r = e instanceof Uint8Array ? M(e) : e;
2784
- let [i, o] = n.split("?iv="), s = Ue.getSharedSecret(r, "02" + t), c = Pr(s), a = ue.decode(o), l = ue.decode(i), f = yr(c, a).decrypt(l);
2784
+ let [i, o] = n.split("?iv="), s = Ue.getSharedSecret(r, "02" + t), a = Or(s), c = ue.decode(o), l = ue.decode(i), f = yr(a, c).decrypt(l);
2785
2785
  return ie.decode(f);
2786
2786
  }
2787
- function Pr(e) {
2787
+ function Or(e) {
2788
2788
  return e.slice(1, 33);
2789
2789
  }
2790
- var Ia = {};
2791
- D(Ia, {
2792
- NIP05_REGEX: () => Or,
2790
+ var ka = {};
2791
+ D(ka, {
2792
+ NIP05_REGEX: () => Pr,
2793
2793
  isValid: () => _a,
2794
2794
  queryProfile: () => Mr,
2795
- searchDomain: () => ka,
2795
+ searchDomain: () => Ia,
2796
2796
  useFetchImplementation: () => Ua
2797
2797
  });
2798
- var Or = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, Et;
2798
+ var Pr = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, mt;
2799
2799
  try {
2800
- Et = fetch;
2800
+ mt = fetch;
2801
2801
  } catch {
2802
2802
  }
2803
2803
  function Ua(e) {
2804
- Et = e;
2804
+ mt = e;
2805
2805
  }
2806
- async function ka(e, t = "") {
2806
+ async function Ia(e, t = "") {
2807
2807
  try {
2808
2808
  const n = `https://${e}/.well-known/nostr.json?name=${t}`;
2809
- return (await (await Et(n, { redirect: "error" })).json()).names;
2809
+ return (await (await mt(n, { redirect: "error" })).json()).names;
2810
2810
  } catch {
2811
2811
  return {};
2812
2812
  }
2813
2813
  }
2814
2814
  async function Mr(e) {
2815
2815
  var o;
2816
- const t = e.match(Or);
2816
+ const t = e.match(Pr);
2817
2817
  if (!t)
2818
2818
  return null;
2819
2819
  const [n, r = "_", i] = t;
2820
2820
  try {
2821
- const s = `https://${i}/.well-known/nostr.json?name=${r}`, c = await (await Et(s, { redirect: "error" })).json();
2822
- let a = c.names[r];
2823
- return a ? { pubkey: a, relays: (o = c.relays) == null ? void 0 : o[a] } : null;
2821
+ const s = `https://${i}/.well-known/nostr.json?name=${r}`, a = await (await mt(s, { redirect: "error" })).json();
2822
+ let c = a.names[r];
2823
+ return c ? { pubkey: c, relays: (o = a.relays) == null ? void 0 : o[c] } : null;
2824
2824
  } catch {
2825
2825
  return null;
2826
2826
  }
@@ -2846,19 +2846,19 @@ function $a(e) {
2846
2846
  relays: r[2] ? [r[2]] : []
2847
2847
  });
2848
2848
  for (let r = 0; r < n.length; r++) {
2849
- const i = n[r], [o, s, c, a] = i, l = {
2849
+ const i = n[r], [o, s, a, c] = i, l = {
2850
2850
  id: s,
2851
- relays: c ? [c] : []
2851
+ relays: a ? [a] : []
2852
2852
  }, f = r === 0, u = r === n.length - 1;
2853
- if (a === "root") {
2853
+ if (c === "root") {
2854
2854
  t.root = l;
2855
2855
  continue;
2856
2856
  }
2857
- if (a === "reply") {
2857
+ if (c === "reply") {
2858
2858
  t.reply = l;
2859
2859
  continue;
2860
2860
  }
2861
- if (a === "mention") {
2861
+ if (c === "mention") {
2862
2862
  t.mentions.push(l);
2863
2863
  continue;
2864
2864
  }
@@ -2876,7 +2876,7 @@ function $a(e) {
2876
2876
  }
2877
2877
  var Ta = {};
2878
2878
  D(Ta, {
2879
- fetchRelayInformation: () => Pa,
2879
+ fetchRelayInformation: () => Oa,
2880
2880
  useFetchImplementation: () => Ra
2881
2881
  });
2882
2882
  var Hr;
@@ -2887,13 +2887,13 @@ try {
2887
2887
  function Ra(e) {
2888
2888
  Hr = e;
2889
2889
  }
2890
- async function Pa(e) {
2890
+ async function Oa(e) {
2891
2891
  return await (await fetch(e.replace("ws://", "http://").replace("wss://", "https://"), {
2892
2892
  headers: { Accept: "application/nostr+json" }
2893
2893
  })).json();
2894
2894
  }
2895
- var Oa = {};
2896
- D(Oa, {
2895
+ var Pa = {};
2896
+ D(Pa, {
2897
2897
  getPow: () => qr,
2898
2898
  minePow: () => Ma
2899
2899
  });
@@ -2929,7 +2929,7 @@ D(Ha, {
2929
2929
  function qa(e, t, n, r) {
2930
2930
  return ae(
2931
2931
  {
2932
- kind: sn,
2932
+ kind: an,
2933
2933
  tags: [...e.tags ?? [], ["e", t.id, n], ["p", t.pubkey]],
2934
2934
  content: e.content === "" ? "" : JSON.stringify(t),
2935
2935
  created_at: e.created_at
@@ -2938,7 +2938,7 @@ function qa(e, t, n, r) {
2938
2938
  );
2939
2939
  }
2940
2940
  function Dr(e) {
2941
- if (e.kind !== sn)
2941
+ if (e.kind !== an)
2942
2942
  return;
2943
2943
  let t, n;
2944
2944
  for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
@@ -2962,21 +2962,21 @@ function Da(e, { skipVerification: t } = {}) {
2962
2962
  } catch {
2963
2963
  return;
2964
2964
  }
2965
- if (r.id === n.id && !(!t && !on(r)))
2965
+ if (r.id === n.id && !(!t && !sn(r)))
2966
2966
  return r;
2967
2967
  }
2968
2968
  var ja = {};
2969
2969
  D(ja, {
2970
- NOSTR_URI_REGEX: () => mt,
2970
+ NOSTR_URI_REGEX: () => Et,
2971
2971
  parse: () => Va,
2972
2972
  test: () => za
2973
2973
  });
2974
- var mt = new RegExp(`nostr:(${Tr.source})`);
2974
+ var Et = new RegExp(`nostr:(${Tr.source})`);
2975
2975
  function za(e) {
2976
- return typeof e == "string" && new RegExp(`^${mt.source}$`).test(e);
2976
+ return typeof e == "string" && new RegExp(`^${Et.source}$`).test(e);
2977
2977
  }
2978
2978
  function Va(e) {
2979
- const t = e.match(new RegExp(`^${mt.source}$`));
2979
+ const t = e.match(new RegExp(`^${Et.source}$`));
2980
2980
  if (!t)
2981
2981
  throw new Error(`Invalid Nostr URI: ${e}`);
2982
2982
  return {
@@ -2995,7 +2995,7 @@ function Fa(e, t, n) {
2995
2995
  return ae(
2996
2996
  {
2997
2997
  ...e,
2998
- kind: an,
2998
+ kind: cn,
2999
2999
  tags: [...e.tags ?? [], ...r, ["e", t.id], ["p", t.pubkey]],
3000
3000
  content: e.content ?? "+"
3001
3001
  },
@@ -3003,7 +3003,7 @@ function Fa(e, t, n) {
3003
3003
  );
3004
3004
  }
3005
3005
  function Wa(e) {
3006
- if (e.kind !== an)
3006
+ if (e.kind !== cn)
3007
3007
  return;
3008
3008
  let t, n;
3009
3009
  for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
@@ -3020,12 +3020,12 @@ function Wa(e) {
3020
3020
  var Ga = {};
3021
3021
  D(Ga, {
3022
3022
  matchAll: () => Ja,
3023
- regex: () => fn,
3023
+ regex: () => hn,
3024
3024
  replaceAll: () => Ya
3025
3025
  });
3026
- var fn = () => new RegExp(`\\b${mt.source}\\b`, "g");
3026
+ var hn = () => new RegExp(`\\b${Et.source}\\b`, "g");
3027
3027
  function* Ja(e) {
3028
- const t = e.matchAll(fn());
3028
+ const t = e.matchAll(hn());
3029
3029
  for (const n of t)
3030
3030
  try {
3031
3031
  const [r, i] = n;
@@ -3040,7 +3040,7 @@ function* Ja(e) {
3040
3040
  }
3041
3041
  }
3042
3042
  function Ya(e, t) {
3043
- return e.replaceAll(fn(), (n, r) => t({
3043
+ return e.replaceAll(hn(), (n, r) => t({
3044
3044
  uri: n,
3045
3045
  value: r,
3046
3046
  decoded: wt(r)
@@ -3064,7 +3064,7 @@ var Qa = (e, t) => {
3064
3064
  return;
3065
3065
  return ae(
3066
3066
  {
3067
- kind: Br,
3067
+ kind: Cr,
3068
3068
  tags: [...e.tags ?? []],
3069
3069
  content: n,
3070
3070
  created_at: e.created_at
@@ -3081,7 +3081,7 @@ var Qa = (e, t) => {
3081
3081
  return;
3082
3082
  return ae(
3083
3083
  {
3084
- kind: Cr,
3084
+ kind: Br,
3085
3085
  tags: [["e", e.channel_create_event_id], ...e.tags ?? []],
3086
3086
  content: n,
3087
3087
  created_at: e.created_at
@@ -3092,7 +3092,7 @@ var Qa = (e, t) => {
3092
3092
  const n = [["e", e.channel_create_event_id, e.relay_url, "root"]];
3093
3093
  return e.reply_to_channel_message_event_id && n.push(["e", e.reply_to_channel_message_event_id, e.relay_url, "reply"]), ae(
3094
3094
  {
3095
- kind: Ir,
3095
+ kind: kr,
3096
3096
  tags: [...n, ...e.tags ?? []],
3097
3097
  content: e.content,
3098
3098
  created_at: e.created_at
@@ -3126,7 +3126,7 @@ var Qa = (e, t) => {
3126
3126
  return;
3127
3127
  return ae(
3128
3128
  {
3129
- kind: kr,
3129
+ kind: Ir,
3130
3130
  tags: [["p", e.pubkey_to_mute], ...e.tags ?? []],
3131
3131
  content: n,
3132
3132
  created_at: e.created_at
@@ -3137,12 +3137,12 @@ var Qa = (e, t) => {
3137
3137
  D(ic, {
3138
3138
  EMOJI_SHORTCODE_REGEX: () => jr,
3139
3139
  matchAll: () => oc,
3140
- regex: () => hn,
3140
+ regex: () => dn,
3141
3141
  replaceAll: () => sc
3142
3142
  });
3143
- var jr = /:(\w+):/, hn = () => new RegExp(`\\B${jr.source}\\B`, "g");
3143
+ var jr = /:(\w+):/, dn = () => new RegExp(`\\B${jr.source}\\B`, "g");
3144
3144
  function* oc(e) {
3145
- const t = e.matchAll(hn());
3145
+ const t = e.matchAll(dn());
3146
3146
  for (const n of t)
3147
3147
  try {
3148
3148
  const [r, i] = n;
@@ -3156,7 +3156,7 @@ function* oc(e) {
3156
3156
  }
3157
3157
  }
3158
3158
  function sc(e, t) {
3159
- return e.replaceAll(hn(), (n, r) => t({
3159
+ return e.replaceAll(dn(), (n, r) => t({
3160
3160
  shortcode: n,
3161
3161
  name: r
3162
3162
  }));
@@ -3166,23 +3166,23 @@ D(ac, {
3166
3166
  useFetchImplementation: () => cc,
3167
3167
  validateGithub: () => lc
3168
3168
  });
3169
- var dn;
3169
+ var yn;
3170
3170
  try {
3171
- dn = fetch;
3171
+ yn = fetch;
3172
3172
  } catch {
3173
3173
  }
3174
3174
  function cc(e) {
3175
- dn = e;
3175
+ yn = e;
3176
3176
  }
3177
3177
  async function lc(e, t, n) {
3178
3178
  try {
3179
- return await (await dn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
3179
+ return await (await yn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
3180
3180
  } catch {
3181
3181
  return !1;
3182
3182
  }
3183
3183
  }
3184
- var z = {};
3185
- D(z, {
3184
+ var j = {};
3185
+ D(j, {
3186
3186
  decrypt: () => Jr,
3187
3187
  encrypt: () => Gr,
3188
3188
  getConversationKey: () => Zr,
@@ -3191,17 +3191,17 @@ D(z, {
3191
3191
  var zr = 1, Vr = 65535;
3192
3192
  function Zr(e, t) {
3193
3193
  const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
3194
- return nn(Se, n, "nip44-v2");
3194
+ return rn(Se, n, "nip44-v2");
3195
3195
  }
3196
3196
  function Fr(e, t) {
3197
- const n = Er(Se, e, t, 76);
3197
+ const n = mr(Se, e, t, 76);
3198
3198
  return {
3199
3199
  chacha_key: n.subarray(0, 32),
3200
3200
  chacha_nonce: n.subarray(32, 44),
3201
3201
  hmac_key: n.subarray(44, 76)
3202
3202
  };
3203
3203
  }
3204
- function yn(e) {
3204
+ function pn(e) {
3205
3205
  if (!Number.isSafeInteger(e) || e < 1)
3206
3206
  throw new Error("expected positive integer");
3207
3207
  if (e <= 32)
@@ -3216,12 +3216,12 @@ function uc(e) {
3216
3216
  return new DataView(t.buffer).setUint16(0, e, !1), t;
3217
3217
  }
3218
3218
  function fc(e) {
3219
- const t = te.encode(e), n = t.length, r = uc(n), i = new Uint8Array(yn(n) - n);
3219
+ const t = te.encode(e), n = t.length, r = uc(n), i = new Uint8Array(pn(n) - n);
3220
3220
  return dt(r, t, i);
3221
3221
  }
3222
3222
  function hc(e) {
3223
3223
  const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t);
3224
- if (t < zr || t > Vr || n.length !== t || e.length !== 2 + yn(t))
3224
+ if (t < zr || t > Vr || n.length !== t || e.length !== 2 + pn(t))
3225
3225
  throw new Error("invalid padding");
3226
3226
  return ie.decode(n);
3227
3227
  }
@@ -3258,12 +3258,12 @@ function dc(e) {
3258
3258
  };
3259
3259
  }
3260
3260
  function Gr(e, t, n = ir(32)) {
3261
- const { chacha_key: r, chacha_nonce: i, hmac_key: o } = Fr(t, n), s = fc(e), c = br(r, i, s), a = Wr(o, c, n);
3262
- return ue.encode(dt(new Uint8Array([2]), n, c, a));
3261
+ const { chacha_key: r, chacha_nonce: i, hmac_key: o } = Fr(t, n), s = fc(e), a = br(r, i, s), c = Wr(o, a, n);
3262
+ return ue.encode(dt(new Uint8Array([2]), n, a, c));
3263
3263
  }
3264
3264
  function Jr(e, t) {
3265
- const { nonce: n, ciphertext: r, mac: i } = dc(e), { chacha_key: o, chacha_nonce: s, hmac_key: c } = Fr(t, n), a = Wr(c, r, n);
3266
- if (!Ao(a, i))
3265
+ const { nonce: n, ciphertext: r, mac: i } = dc(e), { chacha_key: o, chacha_nonce: s, hmac_key: a } = Fr(t, n), c = Wr(a, r, n);
3266
+ if (!Ao(c, i))
3267
3267
  throw new Error("invalid MAC");
3268
3268
  const l = br(o, s, r);
3269
3269
  return hc(l);
@@ -3271,7 +3271,7 @@ function Jr(e, t) {
3271
3271
  var yc = {
3272
3272
  utils: {
3273
3273
  getConversationKey: Zr,
3274
- calcPaddedLen: yn
3274
+ calcPaddedLen: pn
3275
3275
  },
3276
3276
  encrypt: Gr,
3277
3277
  decrypt: Jr
@@ -3302,39 +3302,39 @@ async function wc(e, t, n) {
3302
3302
  }
3303
3303
  var bc = {};
3304
3304
  D(bc, {
3305
- getZapEndpoint: () => Ec,
3305
+ getZapEndpoint: () => mc,
3306
3306
  makeZapReceipt: () => Sc,
3307
- makeZapRequest: () => mc,
3307
+ makeZapRequest: () => Ec,
3308
3308
  useFetchImplementation: () => vc,
3309
3309
  validateZapRequest: () => xc
3310
3310
  });
3311
- var pn;
3311
+ var gn;
3312
3312
  try {
3313
- pn = fetch;
3313
+ gn = fetch;
3314
3314
  } catch {
3315
3315
  }
3316
3316
  function vc(e) {
3317
- pn = e;
3317
+ gn = e;
3318
3318
  }
3319
- async function Ec(e) {
3319
+ async function mc(e) {
3320
3320
  try {
3321
3321
  let t = "", { lud06: n, lud16: r } = JSON.parse(e.content);
3322
3322
  if (n) {
3323
- let { words: s } = De.decode(n, 1e3), c = De.fromWords(s);
3324
- t = ie.decode(c);
3323
+ let { words: s } = De.decode(n, 1e3), a = De.fromWords(s);
3324
+ t = ie.decode(a);
3325
3325
  } else if (r) {
3326
- let [s, c] = r.split("@");
3327
- t = new URL(`/.well-known/lnurlp/${s}`, `https://${c}`).toString();
3326
+ let [s, a] = r.split("@");
3327
+ t = new URL(`/.well-known/lnurlp/${s}`, `https://${a}`).toString();
3328
3328
  } else
3329
3329
  return null;
3330
- let o = await (await pn(t)).json();
3330
+ let o = await (await gn(t)).json();
3331
3331
  if (o.allowsNostr && o.nostrPubkey)
3332
3332
  return o.callback;
3333
3333
  } catch {
3334
3334
  }
3335
3335
  return null;
3336
3336
  }
3337
- function mc({
3337
+ function Ec({
3338
3338
  profile: e,
3339
3339
  event: t,
3340
3340
  amount: n,
@@ -3364,9 +3364,9 @@ function xc(e) {
3364
3364
  } catch {
3365
3365
  return "Invalid zap request JSON.";
3366
3366
  }
3367
- if (!mr(t))
3367
+ if (!Er(t))
3368
3368
  return "Zap request is not a valid Nostr event.";
3369
- if (!on(t))
3369
+ if (!sn(t))
3370
3370
  return "Invalid signature on zap request.";
3371
3371
  let n = t.tags.find(([o, s]) => o === "p" && s);
3372
3372
  if (!n)
@@ -3382,7 +3382,7 @@ function Sc({
3382
3382
  bolt11: n,
3383
3383
  paidAt: r
3384
3384
  }) {
3385
- let i = JSON.parse(e), o = i.tags.filter(([c]) => c === "e" || c === "p" || c === "a"), s = {
3385
+ let i = JSON.parse(e), o = i.tags.filter(([a]) => a === "e" || a === "p" || a === "a"), s = {
3386
3386
  kind: 9735,
3387
3387
  created_at: Math.round(r.getTime() / 1e3),
3388
3388
  content: "",
@@ -3393,7 +3393,7 @@ function Sc({
3393
3393
  var Ac = {};
3394
3394
  D(Ac, {
3395
3395
  getToken: () => Kc,
3396
- hashPayload: () => gn,
3396
+ hashPayload: () => wn,
3397
3397
  unpackEventFromToken: () => Xr,
3398
3398
  validateEvent: () => ii,
3399
3399
  validateEventKind: () => ei,
@@ -3406,7 +3406,7 @@ D(Ac, {
3406
3406
  var Yr = "Nostr ";
3407
3407
  async function Kc(e, t, n, r = !1, i) {
3408
3408
  const o = {
3409
- kind: cn,
3409
+ kind: ln,
3410
3410
  tags: [
3411
3411
  ["u", e],
3412
3412
  ["method", t]
@@ -3414,7 +3414,7 @@ async function Kc(e, t, n, r = !1, i) {
3414
3414
  created_at: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
3415
3415
  content: ""
3416
3416
  };
3417
- i && o.tags.push(["payload", gn(i)]);
3417
+ i && o.tags.push(["payload", wn(i)]);
3418
3418
  const s = await n(o);
3419
3419
  return (r ? Yr : "") + ue.encode(te.encode(JSON.stringify(s)));
3420
3420
  }
@@ -3439,7 +3439,7 @@ function Qr(e) {
3439
3439
  return e.created_at ? Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3) - e.created_at < 60 : !1;
3440
3440
  }
3441
3441
  function ei(e) {
3442
- return e.kind === cn;
3442
+ return e.kind === ln;
3443
3443
  }
3444
3444
  function ti(e, t) {
3445
3445
  const n = e.tags.find((r) => r[0] === "u");
@@ -3449,7 +3449,7 @@ function ni(e, t) {
3449
3449
  const n = e.tags.find((r) => r[0] === "method");
3450
3450
  return n ? n.length > 0 && n[1].toLowerCase() === t.toLowerCase() : !1;
3451
3451
  }
3452
- function gn(e) {
3452
+ function wn(e) {
3453
3453
  const t = Se(te.encode(JSON.stringify(e)));
3454
3454
  return M(t);
3455
3455
  }
@@ -3457,11 +3457,11 @@ function ri(e, t) {
3457
3457
  const n = e.tags.find((i) => i[0] === "payload");
3458
3458
  if (!n)
3459
3459
  return !1;
3460
- const r = gn(t);
3460
+ const r = wn(t);
3461
3461
  return n.length > 0 && n[1] === r;
3462
3462
  }
3463
3463
  async function ii(e, t, n, r) {
3464
- if (!on(e))
3464
+ if (!sn(e))
3465
3465
  throw new Error("Invalid nostr event, signature invalid");
3466
3466
  if (!ei(e))
3467
3467
  throw new Error("Invalid nostr event, kind invalid");
@@ -3476,7 +3476,7 @@ async function ii(e, t, n, r) {
3476
3476
  return !0;
3477
3477
  }
3478
3478
  const Me = 4, Tc = 100;
3479
- var Bc = /* @__PURE__ */ ((e) => (e[e.Us = 0] = "Us", e[e.Them = 1] = "Them", e))(Bc || {});
3479
+ var Cc = /* @__PURE__ */ ((e) => (e[e.Us = 0] = "Us", e[e.Them = 1] = "Them", e))(Cc || {});
3480
3480
  function Rc(e) {
3481
3481
  return JSON.stringify({
3482
3482
  rootKey: M(e.rootKey),
@@ -3499,10 +3499,16 @@ function Rc(e) {
3499
3499
  t,
3500
3500
  M(n)
3501
3501
  ])
3502
+ ),
3503
+ skippedHeaderKeys: Object.fromEntries(
3504
+ Object.entries(e.skippedHeaderKeys).map(([t, n]) => [
3505
+ t,
3506
+ n.map((r) => M(r))
3507
+ ])
3502
3508
  )
3503
3509
  });
3504
3510
  }
3505
- function Pc(e) {
3511
+ function Oc(e) {
3506
3512
  const t = JSON.parse(e);
3507
3513
  return {
3508
3514
  rootKey: W(t.rootKey),
@@ -3525,10 +3531,16 @@ function Pc(e) {
3525
3531
  n,
3526
3532
  W(r)
3527
3533
  ])
3534
+ ),
3535
+ skippedHeaderKeys: Object.fromEntries(
3536
+ Object.entries(t.skippedHeaderKeys || {}).map(([n, r]) => [
3537
+ n,
3538
+ r.map((i) => W(i))
3539
+ ])
3528
3540
  )
3529
3541
  };
3530
3542
  }
3531
- async function* Oc(e) {
3543
+ async function* Pc(e) {
3532
3544
  const t = [];
3533
3545
  let n = null;
3534
3546
  const r = e.onMessage((i) => {
@@ -3544,15 +3556,15 @@ async function* Oc(e) {
3544
3556
  }
3545
3557
  }
3546
3558
  function Re(e, t = new Uint8Array(32), n = 1) {
3547
- const r = nn(Se, e, t), i = [];
3559
+ const r = rn(Se, e, t), i = [];
3548
3560
  for (let o = 1; o <= n; o++)
3549
- i.push(Er(Se, r, new Uint8Array([o]), 32));
3561
+ i.push(mr(Se, r, new Uint8Array([o]), 32));
3550
3562
  return i;
3551
3563
  }
3552
- function Rn(e, t) {
3564
+ function Lt(e, t) {
3553
3565
  return `${e}:${t}`;
3554
3566
  }
3555
- const Cc = 1e3;
3567
+ const Bc = 1e3;
3556
3568
  class ct {
3557
3569
  // 1. CHANNEL PUBLIC INTERFACE
3558
3570
  constructor(t, n) {
@@ -3574,11 +3586,11 @@ class ct {
3574
3586
  * @returns A new Channel instance
3575
3587
  */
3576
3588
  static init(t, n, r, i, o, s) {
3577
- const c = Oe(), [a, l] = Re(o, z.getConversationKey(c, n), 2);
3589
+ const a = Pe(), [c, l] = Re(o, j.getConversationKey(a, n), 2);
3578
3590
  let f, u;
3579
- i ? (f = { publicKey: Ce(r), privateKey: r }, u = { publicKey: Ce(c), privateKey: c }) : u = { publicKey: Ce(r), privateKey: r };
3591
+ i ? (f = { publicKey: Be(r), privateKey: r }, u = { publicKey: Be(a), privateKey: a }) : u = { publicKey: Be(r), privateKey: r };
3580
3592
  const d = {
3581
- rootKey: i ? a : o,
3593
+ rootKey: i ? c : o,
3582
3594
  theirNostrPublicKey: n,
3583
3595
  ourCurrentNostrKey: f,
3584
3596
  ourNextNostrKey: u,
@@ -3587,7 +3599,8 @@ class ct {
3587
3599
  sendingChainMessageNumber: 0,
3588
3600
  receivingChainMessageNumber: 0,
3589
3601
  previousSendingChainMessageCount: 0,
3590
- skippedMessageKeys: {}
3602
+ skippedMessageKeys: {},
3603
+ skippedHeaderKeys: {}
3591
3604
  }, p = new ct(t, d);
3592
3605
  return s && (p.name = s), p;
3593
3606
  }
@@ -3600,7 +3613,7 @@ class ct {
3600
3613
  send(t) {
3601
3614
  if (!this.state.theirNostrPublicKey || !this.state.ourCurrentNostrKey)
3602
3615
  throw new Error("we are not the initiator, so we can't send the first message");
3603
- const [n, r] = this.ratchetEncrypt(t), i = z.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNostrPublicKey), o = z.encrypt(JSON.stringify(n), i);
3616
+ const [n, r] = this.ratchetEncrypt(t), i = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNostrPublicKey), o = j.encrypt(JSON.stringify(n), i);
3604
3617
  return ae({
3605
3618
  content: r,
3606
3619
  kind: Me,
@@ -3617,6 +3630,13 @@ class ct {
3617
3630
  const n = this.currentInternalSubscriptionId++;
3618
3631
  return this.internalSubscriptions.set(n, t), this.subscribeToNostrEvents(), () => this.internalSubscriptions.delete(n);
3619
3632
  }
3633
+ /**
3634
+ * Stop listening to incoming messages
3635
+ */
3636
+ close() {
3637
+ var t, n;
3638
+ (t = this.nostrUnsubscribe) == null || t.call(this), (n = this.nostrNextUnsubscribe) == null || n.call(this);
3639
+ }
3620
3640
  // 2. RATCHET FUNCTIONS
3621
3641
  ratchetEncrypt(t) {
3622
3642
  const [n, r] = Re(this.state.sendingChainKey, new Uint8Array([1]), 2);
@@ -3625,7 +3645,7 @@ class ct {
3625
3645
  nextPublicKey: this.state.ourNextNostrKey.publicKey,
3626
3646
  time: Date.now(),
3627
3647
  previousChainLength: this.state.previousSendingChainMessageCount
3628
- }, z.encrypt(t, r)];
3648
+ }, j.encrypt(t, r)];
3629
3649
  }
3630
3650
  ratchetDecrypt(t, n, r) {
3631
3651
  const i = this.trySkippedMessageKeys(t, n, r);
@@ -3634,44 +3654,54 @@ class ct {
3634
3654
  const [o, s] = Re(this.state.receivingChainKey, new Uint8Array([1]), 2);
3635
3655
  this.state.receivingChainKey = o, this.state.receivingChainMessageNumber++;
3636
3656
  try {
3637
- return z.decrypt(n, s);
3638
- } catch (c) {
3639
- throw console.error(this.name, "Decryption failed:", c, {
3657
+ return j.decrypt(n, s);
3658
+ } catch (a) {
3659
+ throw console.error(this.name, "Decryption failed:", a, {
3640
3660
  messageKey: M(s).slice(0, 4),
3641
3661
  receivingChainKey: M(this.state.receivingChainKey).slice(0, 4),
3642
3662
  sendingChainKey: this.state.sendingChainKey && M(this.state.sendingChainKey).slice(0, 4),
3643
3663
  rootKey: M(this.state.rootKey).slice(0, 4)
3644
- }), c;
3664
+ }), a;
3645
3665
  }
3646
3666
  }
3647
3667
  ratchetStep(t) {
3648
3668
  this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0, this.state.theirNostrPublicKey = t;
3649
- const n = z.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [r, i] = Re(this.state.rootKey, n, 2);
3669
+ const n = j.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [r, i] = Re(this.state.rootKey, n, 2);
3650
3670
  this.state.receivingChainKey = i, this.state.ourCurrentNostrKey = this.state.ourNextNostrKey;
3651
- const o = Oe();
3671
+ const o = Pe();
3652
3672
  this.state.ourNextNostrKey = {
3653
- publicKey: Ce(o),
3673
+ publicKey: Be(o),
3654
3674
  privateKey: o
3655
3675
  };
3656
- const s = z.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [c, a] = Re(r, s, 2);
3657
- this.state.rootKey = c, this.state.sendingChainKey = a;
3676
+ const s = j.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [a, c] = Re(r, s, 2);
3677
+ this.state.rootKey = a, this.state.sendingChainKey = c;
3658
3678
  }
3659
3679
  // 3. MESSAGE KEY FUNCTIONS
3660
3680
  skipMessageKeys(t, n) {
3661
- if (this.state.receivingChainMessageNumber + Cc < t)
3681
+ if (this.state.receivingChainMessageNumber + Bc < t)
3662
3682
  throw new Error("Too many skipped messages");
3663
3683
  for (; this.state.receivingChainMessageNumber < t; ) {
3664
3684
  const [r, i] = Re(this.state.receivingChainKey, new Uint8Array([1]), 2);
3665
3685
  this.state.receivingChainKey = r;
3666
- const o = Rn(n, this.state.receivingChainMessageNumber);
3667
- this.state.skippedMessageKeys[o] = i, this.state.receivingChainMessageNumber++;
3686
+ const o = Lt(n, this.state.receivingChainMessageNumber);
3687
+ if (this.state.skippedMessageKeys[o] = i, !this.state.skippedHeaderKeys[n]) {
3688
+ const s = [];
3689
+ if (this.state.ourCurrentNostrKey) {
3690
+ const c = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
3691
+ s.push(c);
3692
+ }
3693
+ const a = j.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
3694
+ s.push(a), this.state.skippedHeaderKeys[n] = s;
3695
+ }
3696
+ this.state.receivingChainMessageNumber++;
3668
3697
  }
3669
3698
  }
3670
3699
  trySkippedMessageKeys(t, n, r) {
3671
- const i = Rn(r, t.number);
3700
+ var o;
3701
+ const i = Lt(r, t.number);
3672
3702
  if (i in this.state.skippedMessageKeys) {
3673
- const o = this.state.skippedMessageKeys[i];
3674
- return delete this.state.skippedMessageKeys[i], z.decrypt(n, o);
3703
+ const s = this.state.skippedMessageKeys[i];
3704
+ return delete this.state.skippedMessageKeys[i], Object.keys(this.state.skippedMessageKeys).some((c) => c.startsWith(`${r}:`)) || (delete this.state.skippedHeaderKeys[r], (o = this.nostrUnsubscribe) == null || o.call(this), this.nostrUnsubscribe = void 0), j.decrypt(n, s);
3675
3705
  }
3676
3706
  return null;
3677
3707
  }
@@ -3679,28 +3709,38 @@ class ct {
3679
3709
  decryptHeader(t) {
3680
3710
  const n = t.tags[0][1];
3681
3711
  if (this.state.ourCurrentNostrKey) {
3682
- const i = z.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
3712
+ const o = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
3683
3713
  try {
3684
- return [JSON.parse(z.decrypt(n, i)), !1];
3714
+ return [JSON.parse(j.decrypt(n, o)), !1, !1];
3685
3715
  } catch {
3686
3716
  }
3687
3717
  }
3688
- const r = z.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
3718
+ const r = j.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
3689
3719
  try {
3690
- return [JSON.parse(z.decrypt(n, r)), !0];
3720
+ return [JSON.parse(j.decrypt(n, r)), !0, !1];
3691
3721
  } catch {
3692
3722
  }
3693
- throw new Error("Failed to decrypt header with both current and next secrets");
3723
+ const i = this.state.skippedHeaderKeys[t.pubkey];
3724
+ if (i)
3725
+ for (const o of i)
3726
+ try {
3727
+ return [JSON.parse(j.decrypt(n, o)), !1, !0];
3728
+ } catch {
3729
+ }
3730
+ throw new Error("Failed to decrypt header with current and skipped header keys");
3694
3731
  }
3695
3732
  handleNostrEvent(t) {
3696
- var o;
3697
- const [n, r] = this.decryptHeader(t);
3698
- this.state.theirNostrPublicKey !== n.nextPublicKey && (this.state.theirNostrPublicKey = n.nextPublicKey, (o = this.nostrUnsubscribe) == null || o.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
3699
- { authors: [this.state.theirNostrPublicKey], kinds: [Me] },
3700
- (s) => this.handleNostrEvent(s)
3701
- )), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey));
3702
- const i = this.ratchetDecrypt(n, t.content, t.pubkey);
3703
- this.internalSubscriptions.forEach((s) => s({ id: t.id, data: i, pubkey: n.nextPublicKey, time: n.time }));
3733
+ var s;
3734
+ const [n, r, i] = this.decryptHeader(t);
3735
+ if (!i)
3736
+ this.state.theirNostrPublicKey !== n.nextPublicKey && (this.state.theirNostrPublicKey = n.nextPublicKey, (s = this.nostrUnsubscribe) == null || s.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
3737
+ { authors: [this.state.theirNostrPublicKey], kinds: [Me] },
3738
+ (a) => this.handleNostrEvent(a)
3739
+ )), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey));
3740
+ else if (!(Lt(t.pubkey, n.number) in this.state.skippedMessageKeys))
3741
+ return;
3742
+ const o = this.ratchetDecrypt(n, t.content, t.pubkey);
3743
+ this.internalSubscriptions.forEach((a) => a({ id: t.id, data: o, pubkey: n.nextPublicKey, time: n.time }));
3704
3744
  }
3705
3745
  subscribeToNostrEvents() {
3706
3746
  if (this.nostrNextUnsubscribe) return;
@@ -3723,14 +3763,14 @@ new TextDecoder("utf-8");
3723
3763
  new TextEncoder();
3724
3764
  function et(e, t) {
3725
3765
  const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
3726
- return nn(Se, n, "nip44-v2");
3766
+ return rn(Se, n, "nip44-v2");
3727
3767
  }
3728
3768
  class nt {
3729
- constructor(t, n, r, i, o, s, c = []) {
3730
- this.inviterSessionPublicKey = t, this.linkSecret = n, this.inviter = r, this.inviterSessionPrivateKey = i, this.label = o, this.maxUses = s, this.usedBy = c;
3769
+ constructor(t, n, r, i, o, s, a = []) {
3770
+ this.inviterSessionPublicKey = t, this.linkSecret = n, this.inviter = r, this.inviterSessionPrivateKey = i, this.label = o, this.maxUses = s, this.usedBy = a;
3731
3771
  }
3732
3772
  static createNew(t, n, r) {
3733
- const i = Oe(), o = Ce(i), s = M(Oe());
3773
+ const i = Pe(), o = Be(i), s = M(Pe());
3734
3774
  return new nt(
3735
3775
  o,
3736
3776
  s,
@@ -3751,17 +3791,17 @@ class nt {
3751
3791
  } catch (u) {
3752
3792
  throw new Error("Invite data in URL hash is not valid JSON: " + u);
3753
3793
  }
3754
- const { inviter: s, sessionKey: c, linkSecret: a } = o;
3755
- if (!s || !c || !a)
3794
+ const { inviter: s, sessionKey: a, linkSecret: c } = o;
3795
+ if (!s || !a || !c)
3756
3796
  throw new Error("Missing required fields (inviter, sessionKey, linkSecret) in invite data.");
3757
- const l = Fe.decode(s), f = Fe.decode(c);
3797
+ const l = Fe.decode(s), f = Fe.decode(a);
3758
3798
  if (typeof l.data != "string")
3759
3799
  throw new Error("Decoded inviter is not a string");
3760
3800
  if (typeof f.data != "string")
3761
3801
  throw new Error("Decoded session key is not a string");
3762
3802
  return new nt(
3763
3803
  f.data,
3764
- a,
3804
+ c,
3765
3805
  l.data
3766
3806
  );
3767
3807
  }
@@ -3812,7 +3852,7 @@ class nt {
3812
3852
  * so the inviter can create the channel on their side.
3813
3853
  */
3814
3854
  async acceptInvite(t, n, r) {
3815
- const i = Oe(), o = Ce(i), s = this.inviter || this.inviterSessionPublicKey, c = W(this.linkSecret), a = ct.init(t, this.inviterSessionPublicKey, i, !0, c, void 0), l = Oe(), f = Ce(l), u = typeof r == "function" ? r : (g, h) => Promise.resolve(z.encrypt(g, et(r, h))), d = {
3855
+ const i = Pe(), o = Be(i), s = this.inviter || this.inviterSessionPublicKey, a = W(this.linkSecret), c = ct.init(t, this.inviterSessionPublicKey, i, !0, a, void 0), l = Pe(), f = Be(l), u = typeof r == "function" ? r : (g, h) => Promise.resolve(j.encrypt(g, et(r, h))), d = {
3816
3856
  pubkey: n,
3817
3857
  tags: [["secret", this.linkSecret]],
3818
3858
  content: await u(o, s),
@@ -3820,11 +3860,11 @@ class nt {
3820
3860
  }, p = {
3821
3861
  kind: Me,
3822
3862
  pubkey: f,
3823
- content: z.encrypt(JSON.stringify(d), et(l, this.inviterSessionPublicKey)),
3863
+ content: j.encrypt(JSON.stringify(d), et(l, this.inviterSessionPublicKey)),
3824
3864
  created_at: Math.floor(Date.now() / 1e3),
3825
3865
  tags: [["p", this.inviterSessionPublicKey]]
3826
3866
  };
3827
- return { channel: a, event: ae(p, l) };
3867
+ return { channel: c, event: ae(p, l) };
3828
3868
  }
3829
3869
  listen(t, n, r) {
3830
3870
  if (!this.inviterSessionPrivateKey)
@@ -3835,13 +3875,13 @@ class nt {
3835
3875
  };
3836
3876
  return n(i, async (o) => {
3837
3877
  try {
3838
- const s = await z.decrypt(o.content, et(this.inviterSessionPrivateKey, o.pubkey)), c = JSON.parse(s);
3839
- if (!c.tags || !c.tags.some(([p, g]) => p === "secret" && g === this.linkSecret)) {
3878
+ const s = await j.decrypt(o.content, et(this.inviterSessionPrivateKey, o.pubkey)), a = JSON.parse(s);
3879
+ if (!a.tags || !a.tags.some(([p, g]) => p === "secret" && g === this.linkSecret)) {
3840
3880
  console.error("Invalid secret from event", o);
3841
3881
  return;
3842
3882
  }
3843
- const l = await (typeof t == "function" ? t : (p, g) => Promise.resolve(z.decrypt(p, et(t, g))))(c.content, c.pubkey), f = W(this.linkSecret), u = o.id, d = ct.init(n, l, this.inviterSessionPrivateKey, !1, f, u);
3844
- r(d, c.pubkey);
3883
+ const l = await (typeof t == "function" ? t : (p, g) => Promise.resolve(j.decrypt(p, et(t, g))))(a.content, a.pubkey), f = W(this.linkSecret), u = o.id, d = ct.init(n, l, this.inviterSessionPrivateKey, !1, f, u);
3884
+ r(d, a.pubkey);
3845
3885
  } catch (s) {
3846
3886
  console.error("Error processing invite message:", s);
3847
3887
  }
@@ -3853,10 +3893,10 @@ export {
3853
3893
  Me as EVENT_KIND,
3854
3894
  nt as InviteLink,
3855
3895
  Tc as MAX_SKIP,
3856
- Bc as Sender,
3857
- Oc as createMessageStream,
3858
- Pc as deserializeChannelState,
3896
+ Cc as Sender,
3897
+ Pc as createMessageStream,
3898
+ Oc as deserializeChannelState,
3859
3899
  Re as kdf,
3860
3900
  Rc as serializeChannelState,
3861
- Rn as skippedMessageIndexKey
3901
+ Lt as skippedMessageIndexKey
3862
3902
  };