nostr-double-ratchet 0.0.12 → 0.0.14

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.
@@ -33,17 +33,17 @@ const Et = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.
33
33
  const Vn = (e) => e instanceof Uint8Array, xt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, xi = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
34
34
  if (!xi)
35
35
  throw new Error("Non little-endian hardware is not supported");
36
- function Si(e) {
36
+ function Ai(e) {
37
37
  if (typeof e != "string")
38
38
  throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
39
39
  return new Uint8Array(new TextEncoder().encode(e));
40
40
  }
41
41
  function Wt(e) {
42
- if (typeof e == "string" && (e = Si(e)), !Vn(e))
42
+ if (typeof e == "string" && (e = Ai(e)), !Vn(e))
43
43
  throw new Error(`expected Uint8Array, got ${typeof e}`);
44
44
  return e;
45
45
  }
46
- function Ai(...e) {
46
+ function Ni(...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) => {
@@ -58,7 +58,7 @@ let Wn = class {
58
58
  return this._cloneInto();
59
59
  }
60
60
  };
61
- function Ni(e) {
61
+ function Si(e) {
62
62
  const t = (r) => e().update(Wt(r)).digest(), n = e();
63
63
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
64
64
  }
@@ -73,7 +73,7 @@ function Ki(e, t, n, r) {
73
73
  const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), a = Number(n & s), c = r ? 4 : 0, l = r ? 0 : 4;
74
74
  e.setUint32(t + c, o, r), e.setUint32(t + l, a, r);
75
75
  }
76
- let ki = class extends Wn {
76
+ let Ci = class extends Wn {
77
77
  constructor(t, n, r, i) {
78
78
  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 = xt(this.buffer);
79
79
  }
@@ -123,7 +123,7 @@ let ki = class extends Wn {
123
123
  return t.length = i, t.pos = a, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
124
124
  }
125
125
  };
126
- const Bi = (e, t, n) => e & t ^ ~e & n, Ci = (e, t, n) => e & t ^ e & n ^ t & n, Ui = /* @__PURE__ */ new Uint32Array([
126
+ const Bi = (e, t, n) => e & t ^ ~e & n, ki = (e, t, n) => e & t ^ e & n ^ t & n, Ui = /* @__PURE__ */ new Uint32Array([
127
127
  1116352408,
128
128
  1899447441,
129
129
  3049323471,
@@ -198,7 +198,7 @@ const Bi = (e, t, n) => e & t ^ ~e & n, Ci = (e, t, n) => e & t ^ e & n ^ t & n,
198
198
  528734635,
199
199
  1541459225
200
200
  ]), ve = /* @__PURE__ */ new Uint32Array(64);
201
- let _i = class extends ki {
201
+ let _i = class extends Ci {
202
202
  constructor() {
203
203
  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;
204
204
  }
@@ -219,7 +219,7 @@ let _i = class extends ki {
219
219
  }
220
220
  let { A: r, B: i, C: s, D: o, E: a, F: c, G: l, H: f } = this;
221
221
  for (let u = 0; u < 64; u++) {
222
- const g = re(a, 6) ^ re(a, 11) ^ re(a, 25), b = f + g + Bi(a, c, l) + Ui[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + Ci(r, i, s) | 0;
222
+ const g = re(a, 6) ^ re(a, 11) ^ re(a, 25), b = f + g + Bi(a, c, l) + Ui[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + ki(r, i, s) | 0;
223
223
  f = l, l = c, c = a, a = o + b | 0, o = s, s = i, i = r, r = b + h | 0;
224
224
  }
225
225
  r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + 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, s, o, a, c, l, f);
@@ -231,7 +231,7 @@ let _i = class extends ki {
231
231
  this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
232
232
  }
233
233
  };
234
- const Lt = /* @__PURE__ */ Ni(() => new _i());
234
+ const Lt = /* @__PURE__ */ Si(() => new _i());
235
235
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
236
236
  const Gn = BigInt(0), ot = BigInt(1), Ii = BigInt(2), at = (e) => e instanceof Uint8Array, Li = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
237
237
  function qe(e) {
@@ -274,11 +274,11 @@ function Gt(e) {
274
274
  throw new Error("Uint8Array expected");
275
275
  return Zt(qe(Uint8Array.from(e).reverse()));
276
276
  }
277
- function Ae(e, t) {
277
+ function Ne(e, t) {
278
278
  return De(e.toString(16).padStart(t * 2, "0"));
279
279
  }
280
280
  function Ft(e, t) {
281
- return Ae(e, t).reverse();
281
+ return Ne(e, t).reverse();
282
282
  }
283
283
  function $i(e) {
284
284
  return De(Fn(e));
@@ -331,7 +331,7 @@ function Oi(e) {
331
331
  function Mi(e, t) {
332
332
  return e >> BigInt(t) & ot;
333
333
  }
334
- const Hi = (e, t, n) => e | (n ? ot : Gn) << BigInt(t), Jt = (e) => (Ii << BigInt(e - 1)) - ot, St = (e) => new Uint8Array(e), kn = (e) => Uint8Array.from(e);
334
+ const Pi = (e, t, n) => e | (n ? ot : Gn) << BigInt(t), Jt = (e) => (Ii << BigInt(e - 1)) - ot, At = (e) => new Uint8Array(e), Cn = (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");
@@ -339,11 +339,11 @@ function Jn(e, t, n) {
339
339
  throw new Error("qByteLen must be a number");
340
340
  if (typeof n != "function")
341
341
  throw new Error("hmacFn must be a function");
342
- let r = St(e), i = St(e), s = 0;
342
+ let r = At(e), i = At(e), s = 0;
343
343
  const o = () => {
344
344
  r.fill(1), i.fill(0), s = 0;
345
- }, a = (...u) => n(i, r, ...u), c = (u = St()) => {
346
- i = a(kn([0]), u), r = a(), u.length !== 0 && (i = a(kn([1]), u), r = a());
345
+ }, a = (...u) => n(i, r, ...u), c = (u = At()) => {
346
+ i = a(Cn([0]), u), r = a(), u.length !== 0 && (i = a(Cn([1]), u), r = a());
347
347
  }, l = () => {
348
348
  if (s++ >= 1e3)
349
349
  throw new Error("drbg: tried 1000 values");
@@ -364,7 +364,7 @@ function Jn(e, t, n) {
364
364
  return o(), b;
365
365
  };
366
366
  }
367
- const Pi = {
367
+ const Hi = {
368
368
  bigint: (e) => typeof e == "bigint",
369
369
  function: (e) => typeof e == "function",
370
370
  boolean: (e) => typeof e == "boolean",
@@ -377,7 +377,7 @@ const Pi = {
377
377
  };
378
378
  function Je(e, t, n = {}) {
379
379
  const r = (i, s, o) => {
380
- const a = Pi[s];
380
+ const a = Hi[s];
381
381
  if (typeof a != "function")
382
382
  throw new Error(`Invalid validator "${s}", expected function`);
383
383
  const c = e[i];
@@ -395,7 +395,7 @@ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
395
395
  bitGet: Mi,
396
396
  bitLen: Oi,
397
397
  bitMask: Jt,
398
- bitSet: Hi,
398
+ bitSet: Pi,
399
399
  bytesToHex: qe,
400
400
  bytesToNumberBE: F,
401
401
  bytesToNumberLE: Gt,
@@ -405,7 +405,7 @@ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
405
405
  equalBytes: Ti,
406
406
  hexToBytes: De,
407
407
  hexToNumber: Zt,
408
- numberToBytesBE: Ae,
408
+ numberToBytesBE: Ne,
409
409
  numberToBytesLE: Ft,
410
410
  numberToHexUnpadded: Fn,
411
411
  numberToVarBytesBE: $i,
@@ -413,7 +413,7 @@ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
413
413
  validateObject: Je
414
414
  }, Symbol.toStringTag, { value: "Module" }));
415
415
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
416
- const z = BigInt(0), D = BigInt(1), ke = BigInt(2), Di = BigInt(3), $t = BigInt(4), Bn = BigInt(5), Cn = BigInt(8);
416
+ const z = BigInt(0), j = BigInt(1), Ce = BigInt(2), Di = BigInt(3), $t = BigInt(4), Bn = BigInt(5), kn = BigInt(8);
417
417
  BigInt(9);
418
418
  BigInt(16);
419
419
  function V(e, t) {
@@ -423,11 +423,11 @@ function V(e, t) {
423
423
  function ji(e, t, n) {
424
424
  if (n <= z || t < z)
425
425
  throw new Error("Expected power/modulo > 0");
426
- if (n === D)
426
+ if (n === j)
427
427
  return z;
428
- let r = D;
428
+ let r = j;
429
429
  for (; t > z; )
430
- t & D && (r = r * e % n), e = e * e % n, t >>= D;
430
+ t & j && (r = r * e % n), e = e * e % n, t >>= j;
431
431
  return r;
432
432
  }
433
433
  function J(e, t, n) {
@@ -439,24 +439,24 @@ function J(e, t, n) {
439
439
  function Tt(e, t) {
440
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 = z, s = D;
442
+ let n = V(e, t), r = t, i = z, s = j;
443
443
  for (; n !== z; ) {
444
444
  const a = r / n, c = r % n, l = i - s * a;
445
445
  r = n, n = c, i = s, s = l;
446
446
  }
447
- if (r !== D)
447
+ if (r !== j)
448
448
  throw new Error("invert: does not exist");
449
449
  return V(i, t);
450
450
  }
451
451
  function zi(e) {
452
- const t = (e - D) / ke;
452
+ const t = (e - j) / Ce;
453
453
  let n, r, i;
454
- for (n = e - D, r = 0; n % ke === z; n /= ke, r++)
454
+ for (n = e - j, r = 0; n % Ce === z; n /= Ce, r++)
455
455
  ;
456
- for (i = ke; i < e && ji(i, t, e) !== e - D; i++)
456
+ for (i = Ce; i < e && ji(i, t, e) !== e - j; i++)
457
457
  ;
458
458
  if (r === 1) {
459
- const o = (e + D) / $t;
459
+ const o = (e + j) / $t;
460
460
  return function(c, l) {
461
461
  const f = c.pow(l, o);
462
462
  if (!c.eql(c.sqr(f), l))
@@ -464,7 +464,7 @@ function zi(e) {
464
464
  return f;
465
465
  };
466
466
  }
467
- const s = (n + D) / ke;
467
+ const s = (n + j) / Ce;
468
468
  return function(a, c) {
469
469
  if (a.pow(c, t) === a.neg(a.ONE))
470
470
  throw new Error("Cannot find square root");
@@ -475,7 +475,7 @@ function zi(e) {
475
475
  let b = 1;
476
476
  for (let h = a.sqr(g); b < l && !a.eql(h, a.ONE); b++)
477
477
  h = a.sqr(h);
478
- const p = a.pow(f, D << BigInt(l - b - 1));
478
+ const p = a.pow(f, j << BigInt(l - b - 1));
479
479
  f = a.sqr(p), u = a.mul(u, p), g = a.mul(g, f), l = b;
480
480
  }
481
481
  return u;
@@ -483,7 +483,7 @@ function zi(e) {
483
483
  }
484
484
  function Vi(e) {
485
485
  if (e % $t === Di) {
486
- const t = (e + D) / $t;
486
+ const t = (e + j) / $t;
487
487
  return function(r, i) {
488
488
  const s = r.pow(i, t);
489
489
  if (!r.eql(r.sqr(s), i))
@@ -491,10 +491,10 @@ function Vi(e) {
491
491
  return s;
492
492
  };
493
493
  }
494
- if (e % Cn === Bn) {
495
- const t = (e - Bn) / Cn;
494
+ if (e % kn === Bn) {
495
+ const t = (e - Bn) / kn;
496
496
  return function(r, i) {
497
- const s = r.mul(i, ke), o = r.pow(s, t), a = r.mul(i, o), c = r.mul(r.mul(a, ke), o), l = r.mul(a, r.sub(c, r.ONE));
497
+ const s = r.mul(i, Ce), o = r.pow(s, t), a = r.mul(i, o), c = r.mul(r.mul(a, Ce), o), 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;
@@ -535,11 +535,11 @@ function Gi(e, t, n) {
535
535
  throw new Error("Expected power > 0");
536
536
  if (n === z)
537
537
  return e.ONE;
538
- if (n === D)
538
+ if (n === j)
539
539
  return t;
540
540
  let r = e.ONE, i = t;
541
541
  for (; n > z; )
542
- n & D && (r = e.mul(r, i)), i = e.sqr(i), n >>= D;
542
+ n & j && (r = e.mul(r, i)), i = e.sqr(i), n >>= j;
543
543
  return r;
544
544
  }
545
545
  function Fi(e, t) {
@@ -562,7 +562,7 @@ function Ji(e, t, n = !1, r = {}) {
562
562
  BYTES: s,
563
563
  MASK: Jt(i),
564
564
  ZERO: z,
565
- ONE: D,
565
+ ONE: j,
566
566
  create: (c) => V(c, e),
567
567
  isValid: (c) => {
568
568
  if (typeof c != "bigint")
@@ -570,7 +570,7 @@ function Ji(e, t, n = !1, r = {}) {
570
570
  return z <= c && c < e;
571
571
  },
572
572
  is0: (c) => c === z,
573
- isOdd: (c) => (c & D) === D,
573
+ isOdd: (c) => (c & j) === j,
574
574
  neg: (c) => V(-c, e),
575
575
  eql: (c, l) => c === l,
576
576
  sqr: (c) => V(c * c, e),
@@ -590,7 +590,7 @@ function Ji(e, t, n = !1, r = {}) {
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
592
  cmov: (c, l, f) => f ? l : c,
593
- toBytes: (c) => n ? Ft(c, s) : Ae(c, s),
593
+ toBytes: (c) => n ? Ft(c, s) : Ne(c, s),
594
594
  fromBytes: (c) => {
595
595
  if (c.length !== s)
596
596
  throw new Error(`Fp.fromBytes: expected ${s}, got ${c.length}`);
@@ -613,11 +613,11 @@ function Yi(e, t, n = !1) {
613
613
  const r = e.length, i = Xn(t), s = Qn(t);
614
614
  if (r < 16 || r < s || r > 1024)
615
615
  throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);
616
- const o = n ? F(e) : Gt(e), a = V(o, t - D) + D;
617
- return n ? Ft(a, i) : Ae(a, i);
616
+ const o = n ? F(e) : Gt(e), a = V(o, t - j) + j;
617
+ return n ? Ft(a, i) : Ne(a, i);
618
618
  }
619
619
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
620
- const Xi = BigInt(0), At = BigInt(1);
620
+ const Xi = BigInt(0), Nt = BigInt(1);
621
621
  function Qi(e, t) {
622
622
  const n = (i, s) => {
623
623
  const o = s.negate();
@@ -632,7 +632,7 @@ function Qi(e, t) {
632
632
  unsafeLadder(i, s) {
633
633
  let o = e.ZERO, a = i;
634
634
  for (; s > Xi; )
635
- s & At && (o = o.add(a)), a = a.double(), s >>= At;
635
+ s & Nt && (o = o.add(a)), a = a.double(), s >>= Nt;
636
636
  return o;
637
637
  },
638
638
  /**
@@ -670,9 +670,9 @@ function Qi(e, t) {
670
670
  for (let p = 0; p < a; p++) {
671
671
  const h = p * c;
672
672
  let d = Number(o & u);
673
- o >>= b, d > c && (d -= g, o += At);
674
- const y = h, E = h + Math.abs(d) - 1, N = p % 2 !== 0, _ = d < 0;
675
- d === 0 ? f = f.add(n(N, s[y])) : l = l.add(n(_, s[E]));
673
+ o >>= b, d > c && (d -= g, o += Nt);
674
+ const y = h, E = h + Math.abs(d) - 1, S = p % 2 !== 0, _ = d < 0;
675
+ d === 0 ? f = f.add(n(S, s[y])) : l = l.add(n(_, s[E]));
676
676
  }
677
677
  return { p: l, f };
678
678
  },
@@ -795,13 +795,13 @@ function rs(e) {
795
795
  throw new Error("Invalid key");
796
796
  p = p.padStart(d * 2, "0");
797
797
  }
798
- let N;
798
+ let S;
799
799
  try {
800
- N = typeof p == "bigint" ? p : F(W("private key", p, d));
800
+ S = typeof p == "bigint" ? p : F(W("private key", p, d));
801
801
  } catch {
802
802
  throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof p}`);
803
803
  }
804
- return y && (N = V(N, E)), a(N), N;
804
+ return y && (S = V(S, E)), a(S), S;
805
805
  }
806
806
  const l = /* @__PURE__ */ new Map();
807
807
  function f(p) {
@@ -825,7 +825,7 @@ function rs(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 E = (N) => n.eql(N, n.ZERO);
828
+ const E = (S) => n.eql(S, n.ZERO);
829
829
  return E(d) && E(y) ? u.ZERO : new u(d, y, n.ONE);
830
830
  }
831
831
  get x() {
@@ -887,7 +887,7 @@ function rs(e) {
887
887
  */
888
888
  equals(h) {
889
889
  f(h);
890
- const { px: d, py: y, pz: E } = this, { px: N, py: _, pz: B } = h, m = n.eql(n.mul(d, B), n.mul(N, E)), x = n.eql(n.mul(y, B), n.mul(_, E));
890
+ const { px: d, py: y, pz: E } = this, { px: S, py: _, pz: B } = h, m = n.eql(n.mul(d, B), n.mul(S, E)), x = n.eql(n.mul(y, B), n.mul(_, E));
891
891
  return m && x;
892
892
  }
893
893
  /**
@@ -901,9 +901,9 @@ function rs(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: d } = t, y = n.mul(d, Un), { px: E, py: N, pz: _ } = this;
905
- let B = n.ZERO, m = n.ZERO, x = n.ZERO, S = n.mul(E, E), H = n.mul(N, N), U = n.mul(_, _), K = n.mul(E, N);
906
- return K = n.add(K, K), x = n.mul(E, _), x = n.add(x, x), B = n.mul(h, x), m = n.mul(y, U), m = n.add(B, m), B = n.sub(H, m), m = n.add(H, m), m = n.mul(B, m), B = n.mul(K, B), x = n.mul(y, x), U = n.mul(h, U), K = n.sub(S, U), K = n.mul(h, K), K = n.add(K, x), x = n.add(S, S), S = n.add(x, S), S = n.add(S, U), S = n.mul(S, K), m = n.add(m, S), U = n.mul(N, _), U = n.add(U, U), S = n.mul(U, K), B = n.sub(B, S), x = n.mul(U, H), x = n.add(x, x), x = n.add(x, x), new u(B, m, x);
904
+ const { a: h, b: d } = t, y = n.mul(d, Un), { px: E, py: S, pz: _ } = this;
905
+ let B = n.ZERO, m = n.ZERO, x = n.ZERO, A = n.mul(E, E), P = n.mul(S, S), U = n.mul(_, _), K = n.mul(E, S);
906
+ return K = n.add(K, K), x = n.mul(E, _), x = n.add(x, x), B = n.mul(h, x), m = n.mul(y, U), m = n.add(B, m), B = n.sub(P, m), m = n.add(P, m), m = n.mul(B, m), B = n.mul(K, B), x = n.mul(y, x), U = n.mul(h, U), K = n.sub(A, U), K = n.mul(h, K), K = n.add(K, x), x = n.add(A, A), A = n.add(x, A), A = n.add(A, U), A = n.mul(A, K), m = n.add(m, A), U = n.mul(S, _), U = n.add(U, U), A = n.mul(U, K), B = n.sub(B, A), 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 rs(e) {
911
911
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
912
912
  add(h) {
913
913
  f(h);
914
- const { px: d, py: y, pz: E } = this, { px: N, py: _, pz: B } = h;
915
- let m = n.ZERO, x = n.ZERO, S = n.ZERO;
916
- const H = t.a, U = n.mul(t.b, Un);
917
- let K = n.mul(d, N), T = n.mul(y, _), R = n.mul(E, B), P = n.add(d, y), w = n.add(N, _);
918
- P = n.mul(P, w), w = n.add(K, T), P = n.sub(P, w), w = n.add(d, E);
919
- let v = n.add(N, B);
920
- return w = n.mul(w, v), v = n.add(K, R), w = n.sub(w, v), v = n.add(y, E), m = n.add(_, B), v = n.mul(v, m), m = n.add(T, R), v = n.sub(v, m), S = n.mul(H, w), 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(K, K), T = n.add(T, K), R = n.mul(H, R), w = n.mul(U, w), T = n.add(T, R), R = n.sub(K, R), R = n.mul(H, R), w = n.add(w, R), K = n.mul(T, w), x = n.add(x, K), K = n.mul(v, w), m = n.mul(P, m), m = n.sub(m, K), K = n.mul(P, T), S = n.mul(v, S), S = n.add(S, K), new u(m, x, S);
914
+ const { px: d, py: y, pz: E } = this, { px: S, py: _, pz: B } = h;
915
+ let m = n.ZERO, x = n.ZERO, A = n.ZERO;
916
+ const P = t.a, U = n.mul(t.b, Un);
917
+ let K = n.mul(d, S), T = n.mul(y, _), R = n.mul(E, B), H = n.add(d, y), w = n.add(S, _);
918
+ H = n.mul(H, w), w = n.add(K, T), H = n.sub(H, w), w = n.add(d, E);
919
+ let v = n.add(S, B);
920
+ return w = n.mul(w, v), v = n.add(K, R), w = n.sub(w, v), v = n.add(y, E), m = n.add(_, B), v = n.mul(v, m), m = n.add(T, R), v = n.sub(v, m), A = n.mul(P, w), m = n.mul(U, R), A = n.add(m, A), m = n.sub(T, A), A = n.add(T, A), x = n.mul(m, A), T = n.add(K, K), T = n.add(T, K), R = n.mul(P, R), w = n.mul(U, w), T = n.add(T, R), R = n.sub(K, R), R = n.mul(P, R), w = n.add(w, R), K = n.mul(T, w), x = n.add(x, K), K = n.mul(v, w), m = n.mul(H, m), m = n.sub(m, K), K = n.mul(H, T), A = n.mul(v, A), A = n.add(A, K), new u(m, x, A);
921
921
  }
922
922
  subtract(h) {
923
923
  return this.add(h.negate());
@@ -928,7 +928,7 @@ function rs(e) {
928
928
  wNAF(h) {
929
929
  return b.wNAFCached(this, l, h, (d) => {
930
930
  const y = n.invertBatch(d.map((E) => E.pz));
931
- return d.map((E, N) => E.toAffine(y[N])).map(u.fromAffine);
931
+ return d.map((E, S) => E.toAffine(y[S])).map(u.fromAffine);
932
932
  });
933
933
  }
934
934
  /**
@@ -945,9 +945,9 @@ function rs(e) {
945
945
  const { endo: y } = t;
946
946
  if (!y)
947
947
  return b.unsafeLadder(this, h);
948
- let { k1neg: E, k1: N, k2neg: _, k2: B } = y.splitScalar(h), m = d, x = d, S = this;
949
- for (; N > ae || B > ae; )
950
- N & Y && (m = m.add(S)), B & Y && (x = x.add(S)), S = S.double(), N >>= Y, B >>= Y;
948
+ let { k1neg: E, k1: S, k2neg: _, k2: B } = y.splitScalar(h), m = d, x = d, A = this;
949
+ for (; S > ae || B > ae; )
950
+ S & Y && (m = m.add(A)), B & Y && (x = x.add(A)), A = A.double(), S >>= Y, B >>= Y;
951
951
  return E && (m = m.negate()), _ && (x = x.negate()), x = new u(n.mul(x.px, y.beta), x.py, x.pz), m.add(x);
952
952
  }
953
953
  /**
@@ -962,11 +962,11 @@ function rs(e) {
962
962
  multiply(h) {
963
963
  a(h);
964
964
  let d = h, y, E;
965
- const { endo: N } = t;
966
- if (N) {
967
- const { k1neg: _, k1: B, k2neg: m, k2: x } = N.splitScalar(d);
968
- let { p: S, f: H } = this.wNAF(B), { p: U, f: K } = this.wNAF(x);
969
- S = b.constTimeNegate(_, S), U = b.constTimeNegate(m, U), U = new u(n.mul(U.px, N.beta), U.py, U.pz), y = S.add(U), E = H.add(K);
965
+ const { endo: S } = t;
966
+ if (S) {
967
+ const { k1neg: _, k1: B, k2neg: m, k2: x } = S.splitScalar(d);
968
+ let { p: A, f: P } = this.wNAF(B), { p: U, f: K } = this.wNAF(x);
969
+ A = b.constTimeNegate(_, A), U = b.constTimeNegate(m, U), U = new u(n.mul(U.px, S.beta), U.py, U.pz), y = A.add(U), E = P.add(K);
970
970
  } else {
971
971
  const { p: _, f: B } = this.wNAF(d);
972
972
  y = _, E = B;
@@ -980,17 +980,17 @@ function rs(e) {
980
980
  * @returns non-zero affine point
981
981
  */
982
982
  multiplyAndAddUnsafe(h, d, y) {
983
- const E = u.BASE, N = (B, m) => m === ae || m === Y || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), _ = N(this, d).add(N(h, y));
983
+ const E = u.BASE, S = (B, m) => m === ae || m === Y || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), _ = S(this, d).add(S(h, y));
984
984
  return _.is0() ? void 0 : _;
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: d, py: y, pz: E } = this, N = this.is0();
991
- h == null && (h = N ? n.ONE : n.inv(E));
990
+ const { px: d, py: y, pz: E } = this, S = this.is0();
991
+ h == null && (h = S ? n.ONE : n.inv(E));
992
992
  const _ = n.mul(d, h), B = n.mul(y, h), m = n.mul(E, h);
993
- if (N)
993
+ if (S)
994
994
  return { x: n.ZERO, y: n.ZERO };
995
995
  if (!n.eql(m, n.ONE))
996
996
  throw new Error("invZ was invalid");
@@ -1050,27 +1050,27 @@ function ss(e) {
1050
1050
  }
1051
1051
  const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: g } = rs({
1052
1052
  ...t,
1053
- toBytes(w, v, A) {
1054
- const C = v.toAffine(), k = n.toBytes(C.x), I = Ue;
1055
- return A ? I(Uint8Array.from([v.hasEvenY() ? 2 : 3]), k) : I(Uint8Array.from([4]), k, n.toBytes(C.y));
1053
+ toBytes(w, v, N) {
1054
+ const k = v.toAffine(), C = n.toBytes(k.x), I = Ue;
1055
+ return N ? I(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : I(Uint8Array.from([4]), C, n.toBytes(k.y));
1056
1056
  },
1057
1057
  fromBytes(w) {
1058
- const v = w.length, A = w[0], C = w.subarray(1);
1059
- if (v === i && (A === 2 || A === 3)) {
1060
- const k = F(C);
1061
- if (!o(k))
1058
+ const v = w.length, N = w[0], k = w.subarray(1);
1059
+ if (v === i && (N === 2 || N === 3)) {
1060
+ const C = F(k);
1061
+ if (!o(C))
1062
1062
  throw new Error("Point is not on curve");
1063
- const I = u(k);
1063
+ const I = u(C);
1064
1064
  let O = n.sqrt(I);
1065
1065
  const $ = (O & Y) === Y;
1066
- return (A & 1) === 1 !== $ && (O = n.neg(O)), { x: k, y: O };
1067
- } else if (v === s && A === 4) {
1068
- const k = n.fromBytes(C.subarray(0, n.BYTES)), I = n.fromBytes(C.subarray(n.BYTES, 2 * n.BYTES));
1069
- return { x: k, y: I };
1066
+ return (N & 1) === 1 !== $ && (O = n.neg(O)), { x: C, y: O };
1067
+ } else if (v === s && N === 4) {
1068
+ const C = n.fromBytes(k.subarray(0, n.BYTES)), I = n.fromBytes(k.subarray(n.BYTES, 2 * n.BYTES));
1069
+ return { x: C, y: I };
1070
1070
  } else
1071
1071
  throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`);
1072
1072
  }
1073
- }), b = (w) => qe(Ae(w, t.nByteLength));
1073
+ }), b = (w) => qe(Ne(w, t.nByteLength));
1074
1074
  function p(w) {
1075
1075
  const v = r >> Y;
1076
1076
  return w > v;
@@ -1078,21 +1078,21 @@ function ss(e) {
1078
1078
  function h(w) {
1079
1079
  return p(w) ? a(-w) : w;
1080
1080
  }
1081
- const d = (w, v, A) => F(w.slice(v, A));
1081
+ const d = (w, v, N) => F(w.slice(v, N));
1082
1082
  class y {
1083
- constructor(v, A, C) {
1084
- this.r = v, this.s = A, this.recovery = C, this.assertValidity();
1083
+ constructor(v, N, k) {
1084
+ this.r = v, this.s = N, this.recovery = k, this.assertValidity();
1085
1085
  }
1086
1086
  // pair (bytes of r, bytes of s)
1087
1087
  static fromCompact(v) {
1088
- const A = t.nByteLength;
1089
- return v = W("compactSignature", v, A * 2), new y(d(v, 0, A), d(v, A, 2 * A));
1088
+ const N = t.nByteLength;
1089
+ return v = W("compactSignature", v, N * 2), new y(d(v, 0, N), d(v, N, 2 * N));
1090
1090
  }
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: C } = Be.toSig(W("DER", v));
1095
- return new y(A, C);
1094
+ const { r: N, s: k } = Be.toSig(W("DER", v));
1095
+ return new y(N, k);
1096
1096
  }
1097
1097
  assertValidity() {
1098
1098
  if (!g(this.r))
@@ -1104,13 +1104,13 @@ function ss(e) {
1104
1104
  return new y(this.r, this.s, v);
1105
1105
  }
1106
1106
  recoverPublicKey(v) {
1107
- const { r: A, s: C, recovery: k } = this, I = x(W("msgHash", v));
1108
- if (k == null || ![0, 1, 2, 3].includes(k))
1107
+ const { r: N, s: k, recovery: C } = this, I = x(W("msgHash", v));
1108
+ if (C == null || ![0, 1, 2, 3].includes(C))
1109
1109
  throw new Error("recovery id invalid");
1110
- const O = k === 2 || k === 3 ? A + t.n : A;
1110
+ const O = C === 2 || C === 3 ? N + t.n : N;
1111
1111
  if (O >= n.ORDER)
1112
1112
  throw new Error("recovery id 2 or 3 invalid");
1113
- const $ = k & 1 ? "03" : "02", Q = l.fromHex($ + b(O)), ge = c(O), Ie = a(-I * ge), Ve = a(C * ge), we = l.BASE.multiplyAndAddUnsafe(Q, Ie, Ve);
1113
+ const $ = C & 1 ? "03" : "02", Q = l.fromHex($ + b(O)), ge = c(O), Ie = a(-I * ge), Ve = a(k * ge), we = l.BASE.multiplyAndAddUnsafe(Q, Ie, Ve);
1114
1114
  if (!we)
1115
1115
  throw new Error("point at infinify");
1116
1116
  return we.assertValidity(), we;
@@ -1166,42 +1166,42 @@ function ss(e) {
1166
1166
  return v._setWindowSize(w), v.multiply(BigInt(3)), v;
1167
1167
  }
1168
1168
  };
1169
- function N(w, v = !0) {
1169
+ function S(w, v = !0) {
1170
1170
  return l.fromPrivateKey(w).toRawBytes(v);
1171
1171
  }
1172
1172
  function _(w) {
1173
- const v = w instanceof Uint8Array, A = typeof w == "string", C = (v || A) && w.length;
1174
- return v ? C === i || C === s : A ? C === 2 * i || C === 2 * s : w instanceof l;
1173
+ const v = w instanceof Uint8Array, N = typeof w == "string", k = (v || N) && w.length;
1174
+ return v ? k === i || k === s : N ? k === 2 * i || k === 2 * s : w instanceof l;
1175
1175
  }
1176
- function B(w, v, A = !0) {
1176
+ function B(w, v, N = !0) {
1177
1177
  if (_(w))
1178
1178
  throw new Error("first arg must be private key");
1179
1179
  if (!_(v))
1180
1180
  throw new Error("second arg must be public key");
1181
- return l.fromHex(v).multiply(f(w)).toRawBytes(A);
1181
+ return l.fromHex(v).multiply(f(w)).toRawBytes(N);
1182
1182
  }
1183
1183
  const m = t.bits2int || function(w) {
1184
- const v = F(w), A = w.length * 8 - t.nBitLength;
1185
- return A > 0 ? v >> BigInt(A) : v;
1184
+ const v = F(w), N = w.length * 8 - t.nBitLength;
1185
+ return N > 0 ? v >> BigInt(N) : v;
1186
1186
  }, x = t.bits2int_modN || function(w) {
1187
1187
  return a(m(w));
1188
- }, S = Jt(t.nBitLength);
1189
- function H(w) {
1188
+ }, A = Jt(t.nBitLength);
1189
+ function P(w) {
1190
1190
  if (typeof w != "bigint")
1191
1191
  throw new Error("bigint expected");
1192
- if (!(ae <= w && w < S))
1192
+ if (!(ae <= w && w < A))
1193
1193
  throw new Error(`bigint expected < 2^${t.nBitLength}`);
1194
- return Ae(w, t.nByteLength);
1194
+ return Ne(w, t.nByteLength);
1195
1195
  }
1196
- function U(w, v, A = K) {
1197
- if (["recovered", "canonical"].some((Ke) => Ke in A))
1196
+ function U(w, v, N = K) {
1197
+ if (["recovered", "canonical"].some((Ke) => Ke in N))
1198
1198
  throw new Error("sign() legacy options not supported");
1199
- const { hash: C, randomBytes: k } = t;
1200
- let { lowS: I, prehash: O, extraEntropy: $ } = A;
1201
- I == null && (I = !0), w = W("msgHash", w), O && (w = W("prehashed msgHash", C(w)));
1202
- const Q = x(w), ge = f(v), Ie = [H(ge), H(Q)];
1199
+ const { hash: k, randomBytes: C } = t;
1200
+ let { lowS: I, prehash: O, extraEntropy: $ } = N;
1201
+ I == null && (I = !0), w = W("msgHash", w), O && (w = W("prehashed msgHash", k(w)));
1202
+ const Q = x(w), ge = f(v), Ie = [P(ge), P(Q)];
1203
1203
  if ($ != null) {
1204
- const Ke = $ === !0 ? k(n.BYTES) : $;
1204
+ const Ke = $ === !0 ? C(n.BYTES) : $;
1205
1205
  Ie.push(W("extraEntropy", Ke));
1206
1206
  }
1207
1207
  const Ve = Ue(...Ie), we = Q;
@@ -1209,45 +1209,45 @@ function ss(e) {
1209
1209
  const Le = m(Ke);
1210
1210
  if (!g(Le))
1211
1211
  return;
1212
- const Sn = c(Le), $e = l.BASE.multiply(Le).toAffine(), ee = a($e.x);
1212
+ const An = c(Le), $e = l.BASE.multiply(Le).toAffine(), ee = a($e.x);
1213
1213
  if (ee === ae)
1214
1214
  return;
1215
- const Te = a(Sn * a(we + ee * ge));
1215
+ const Te = a(An * a(we + ee * ge));
1216
1216
  if (Te === ae)
1217
1217
  return;
1218
- let An = ($e.x === ee ? 0 : 2) | Number($e.y & Y), Nn = Te;
1219
- return I && p(Te) && (Nn = h(Te), An ^= 1), new y(ee, Nn, An);
1218
+ let Nn = ($e.x === ee ? 0 : 2) | Number($e.y & Y), Sn = Te;
1219
+ return I && p(Te) && (Sn = h(Te), Nn ^= 1), new y(ee, Sn, Nn);
1220
1220
  }
1221
1221
  return { seed: Ve, k2sig: mt };
1222
1222
  }
1223
1223
  const K = { lowS: t.lowS, prehash: !1 }, T = { lowS: t.lowS, prehash: !1 };
1224
- function R(w, v, A = K) {
1225
- const { seed: C, k2sig: k } = U(w, v, A), I = t;
1226
- return Jn(I.hash.outputLen, I.nByteLength, I.hmac)(C, k);
1224
+ function R(w, v, N = K) {
1225
+ const { seed: k, k2sig: C } = U(w, v, N), I = t;
1226
+ return Jn(I.hash.outputLen, I.nByteLength, I.hmac)(k, C);
1227
1227
  }
1228
1228
  l.BASE._setWindowSize(8);
1229
- function P(w, v, A, C = T) {
1229
+ function H(w, v, N, k = T) {
1230
1230
  var $e;
1231
- const k = w;
1232
- if (v = W("msgHash", v), A = W("publicKey", A), "strict" in C)
1231
+ const C = w;
1232
+ if (v = W("msgHash", v), N = W("publicKey", N), "strict" in k)
1233
1233
  throw new Error("options.strict was renamed to lowS");
1234
- const { lowS: I, prehash: O } = C;
1234
+ const { lowS: I, prehash: O } = k;
1235
1235
  let $, Q;
1236
1236
  try {
1237
- if (typeof k == "string" || k instanceof Uint8Array)
1237
+ if (typeof C == "string" || C instanceof Uint8Array)
1238
1238
  try {
1239
- $ = y.fromDER(k);
1239
+ $ = y.fromDER(C);
1240
1240
  } catch (ee) {
1241
1241
  if (!(ee instanceof Be.Err))
1242
1242
  throw ee;
1243
- $ = y.fromCompact(k);
1243
+ $ = y.fromCompact(C);
1244
1244
  }
1245
- else if (typeof k == "object" && typeof k.r == "bigint" && typeof k.s == "bigint") {
1246
- const { r: ee, s: Te } = k;
1245
+ else if (typeof C == "object" && typeof C.r == "bigint" && typeof C.s == "bigint") {
1246
+ const { r: ee, s: Te } = C;
1247
1247
  $ = new y(ee, Te);
1248
1248
  } else
1249
1249
  throw new Error("PARSE");
1250
- Q = l.fromHex(A);
1250
+ Q = l.fromHex(N);
1251
1251
  } catch (ee) {
1252
1252
  if (ee.message === "PARSE")
1253
1253
  throw new Error("signature must be Signature instance, Uint8Array or hex string");
@@ -1261,10 +1261,10 @@ function ss(e) {
1261
1261
  }
1262
1262
  return {
1263
1263
  CURVE: t,
1264
- getPublicKey: N,
1264
+ getPublicKey: S,
1265
1265
  getSharedSecret: B,
1266
1266
  sign: R,
1267
- verify: P,
1267
+ verify: H,
1268
1268
  ProjectivePoint: l,
1269
1269
  Signature: y,
1270
1270
  utils: E
@@ -1311,7 +1311,7 @@ nr.create = (e, t) => new tr(e, t);
1311
1311
  function os(e) {
1312
1312
  return {
1313
1313
  hash: e,
1314
- hmac: (t, ...n) => nr(e, t, Ai(...n)),
1314
+ hmac: (t, ...n) => nr(e, t, Ni(...n)),
1315
1315
  randomBytes: Zn
1316
1316
  };
1317
1317
  }
@@ -1322,7 +1322,7 @@ function as(e, t) {
1322
1322
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1323
1323
  const ct = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), tt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), rr = BigInt(1), nt = BigInt(2), _n = (e, t) => (e + t / nt) / t;
1324
1324
  function ir(e) {
1325
- const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = 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, g = J(u, n, t) * f % t, b = J(g, nt, t) * l % t, p = J(b, i, t) * b % t, h = J(p, s, t) * p % t, d = J(h, a, t) * h % t, y = J(d, c, t) * d % t, E = J(y, a, t) * h % t, N = J(E, n, t) * f % t, _ = J(N, o, t) * p % t, B = J(_, r, t) * l % t, m = J(B, nt, t);
1325
+ const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = 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, g = J(u, n, t) * f % t, b = J(g, nt, t) * l % t, p = J(b, i, t) * b % t, h = J(p, s, t) * p % t, d = J(h, a, t) * h % t, y = J(d, c, t) * d % t, E = J(y, a, t) * h % t, S = J(E, n, t) * f % t, _ = J(S, o, t) * p % t, B = J(_, r, t) * l % t, m = J(B, nt, t);
1326
1326
  if (!Rt.eql(Rt.sqr(m), e))
1327
1327
  throw new Error("Cannot find square root");
1328
1328
  return m;
@@ -1363,7 +1363,7 @@ function rt(e, ...t) {
1363
1363
  }
1364
1364
  return Lt(Ue(n, ...t));
1365
1365
  }
1366
- const Yt = (e) => e.toRawBytes(!0).slice(1), Ot = (e) => Ae(e, 32), Nt = (e) => V(e, ct), Ge = (e) => V(e, tt), Xt = _e.ProjectivePoint, us = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
1366
+ const Yt = (e) => e.toRawBytes(!0).slice(1), Ot = (e) => Ne(e, 32), St = (e) => V(e, ct), Ge = (e) => V(e, tt), Xt = _e.ProjectivePoint, us = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
1367
1367
  function Mt(e) {
1368
1368
  let t = _e.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
1369
1369
  return { scalar: n.hasEvenY() ? t : Ge(-t), bytes: Yt(n) };
@@ -1371,9 +1371,9 @@ function Mt(e) {
1371
1371
  function or(e) {
1372
1372
  if (!sr(e))
1373
1373
  throw new Error("bad x: need 0 < x < p");
1374
- const t = Nt(e * e), n = Nt(t * e + BigInt(7));
1374
+ const t = St(e * e), n = St(t * e + BigInt(7));
1375
1375
  let r = ir(n);
1376
- r % nt !== ut && (r = Nt(-r));
1376
+ r % nt !== ut && (r = St(-r));
1377
1377
  const i = new Xt(e, r, rr);
1378
1378
  return i.assertValidity(), i;
1379
1379
  }
@@ -1415,14 +1415,14 @@ const We = {
1415
1415
  randomPrivateKey: _e.utils.randomPrivateKey,
1416
1416
  lift_x: or,
1417
1417
  pointToBytes: Yt,
1418
- numberToBytesBE: Ae,
1418
+ numberToBytesBE: Ne,
1419
1419
  bytesToNumberBE: F,
1420
1420
  taggedHash: rt,
1421
1421
  mod: V
1422
1422
  }
1423
1423
  }, Kt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1424
1424
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1425
- const Qt = (e) => e instanceof Uint8Array, kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ie = (e, t) => e << 32 - t | e >>> t, hs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1425
+ const Qt = (e) => e instanceof Uint8Array, Ct = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ie = (e, t) => e << 32 - t | e >>> t, hs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1426
1426
  if (!hs)
1427
1427
  throw new Error("Non little-endian hardware is not supported");
1428
1428
  const ds = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
@@ -1483,7 +1483,7 @@ function fr(e = 32) {
1483
1483
  return Kt.getRandomValues(new Uint8Array(e));
1484
1484
  throw new Error("crypto.getRandomValues must be defined");
1485
1485
  }
1486
- function Ht(e) {
1486
+ function Pt(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 hr(e, ...t) {
1500
1500
  function gs(e) {
1501
1501
  if (typeof e != "function" || typeof e.create != "function")
1502
1502
  throw new Error("Hash should be wrapped by utils.wrapConstructor");
1503
- Ht(e.outputLen), Ht(e.blockLen);
1503
+ Pt(e.outputLen), Pt(e.blockLen);
1504
1504
  }
1505
1505
  function ws(e, t = !0) {
1506
1506
  if (e.destroyed)
@@ -1515,7 +1515,7 @@ function bs(e, t) {
1515
1515
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
1516
1516
  }
1517
1517
  const se = {
1518
- number: Ht,
1518
+ number: Pt,
1519
1519
  bool: ys,
1520
1520
  bytes: hr,
1521
1521
  hash: gs,
@@ -1530,7 +1530,7 @@ function vs(e, t, n, r) {
1530
1530
  }
1531
1531
  class ms extends ur {
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 = kt(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 = Ct(this.buffer);
1534
1534
  }
1535
1535
  update(t) {
1536
1536
  se.exists(this);
@@ -1540,7 +1540,7 @@ class ms extends ur {
1540
1540
  for (let o = 0; o < s; ) {
1541
1541
  const a = Math.min(i - this.pos, s - o);
1542
1542
  if (a === i) {
1543
- const c = kt(t);
1543
+ const c = Ct(t);
1544
1544
  for (; i <= s - o; o += i)
1545
1545
  this.process(c, o);
1546
1546
  continue;
@@ -1557,7 +1557,7 @@ class ms extends ur {
1557
1557
  for (let u = o; u < i; u++)
1558
1558
  n[u] = 0;
1559
1559
  vs(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
1560
- const a = kt(t), c = this.outputLen;
1560
+ const a = Ct(t), c = this.outputLen;
1561
1561
  if (c % 4)
1562
1562
  throw new Error("_sha2: outputLen should be aligned to 32bit");
1563
1563
  const l = c / 4, f = this.get();
@@ -1578,7 +1578,7 @@ class ms extends ur {
1578
1578
  return t.length = i, t.pos = a, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
1579
1579
  }
1580
1580
  }
1581
- const Es = (e, t, n) => e & t ^ ~e & n, xs = (e, t, n) => e & t ^ e & n ^ t & n, Ss = new Uint32Array([
1581
+ const Es = (e, t, n) => e & t ^ ~e & n, xs = (e, t, n) => e & t ^ e & n ^ t & n, As = new Uint32Array([
1582
1582
  1116352408,
1583
1583
  1899447441,
1584
1584
  3049323471,
@@ -1674,7 +1674,7 @@ class dr extends ms {
1674
1674
  }
1675
1675
  let { A: r, B: i, C: s, D: o, E: a, F: c, G: l, H: f } = this;
1676
1676
  for (let u = 0; u < 64; u++) {
1677
- const g = ie(a, 6) ^ ie(a, 11) ^ ie(a, 25), b = f + g + Es(a, c, l) + Ss[u] + Ee[u] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + xs(r, i, s) | 0;
1677
+ const g = ie(a, 6) ^ ie(a, 11) ^ ie(a, 25), b = f + g + Es(a, c, l) + As[u] + Ee[u] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + xs(r, i, s) | 0;
1678
1678
  f = l, l = c, c = a, a = o + b | 0, o = s, s = i, i = r, r = b + h | 0;
1679
1679
  }
1680
1680
  r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + 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, s, o, a, c, l, f);
@@ -1686,13 +1686,13 @@ class dr extends ms {
1686
1686
  this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
1687
1687
  }
1688
1688
  }
1689
- class As extends dr {
1689
+ class Ns extends dr {
1690
1690
  constructor() {
1691
1691
  super(), this.A = -1056596264, this.B = 914150663, this.C = 812702999, this.D = -150054599, this.E = -4191439, this.F = 1750603025, this.G = 1694076839, this.H = -1090891868, this.outputLen = 28;
1692
1692
  }
1693
1693
  }
1694
1694
  const fe = lr(() => new dr());
1695
- lr(() => new As());
1695
+ lr(() => new Ns());
1696
1696
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1697
1697
  function ze(e) {
1698
1698
  if (!Number.isSafeInteger(e))
@@ -1815,7 +1815,7 @@ function Ln(e, t, n) {
1815
1815
  return i.reverse();
1816
1816
  }
1817
1817
  const yr = (e, t) => t ? yr(t, e % t) : e, it = (e, t) => e + (t - yr(e, t));
1818
- function Pt(e, t, n, r) {
1818
+ function Ht(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)
@@ -1841,7 +1841,7 @@ function Pt(e, t, n, r) {
1841
1841
  throw new Error(`Non-zero padding: ${i}`);
1842
1842
  return r && s > 0 && a.push(i >>> 0), a;
1843
1843
  }
1844
- function Ns(e) {
1844
+ function Ss(e) {
1845
1845
  return ze(e), {
1846
1846
  encode: (t) => {
1847
1847
  if (!(t instanceof Uint8Array))
@@ -1855,7 +1855,7 @@ function Ns(e) {
1855
1855
  }
1856
1856
  };
1857
1857
  }
1858
- function Ne(e, t = !1) {
1858
+ function Se(e, t = !1) {
1859
1859
  if (ze(e), e <= 0 || e > 32)
1860
1860
  throw new Error("radix2: bits should be in (0..32]");
1861
1861
  if (it(8, e) > 32 || it(e, 8) > 32)
@@ -1864,12 +1864,12 @@ function Ne(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 Pt(Array.from(n), 8, e, !t);
1867
+ return Ht(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(Pt(n, e, 8, t));
1872
+ return Uint8Array.from(Ht(n, e, 8, t));
1873
1873
  }
1874
1874
  };
1875
1875
  }
@@ -1883,13 +1883,13 @@ function $n(e) {
1883
1883
  }
1884
1884
  };
1885
1885
  }
1886
- const Ks = de(Ne(4), pe("0123456789ABCDEF"), ye("")), ks = de(Ne(5), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ft(5), ye(""));
1887
- de(Ne(5), pe("0123456789ABCDEFGHIJKLMNOPQRSTUV"), ft(5), ye(""));
1888
- de(Ne(5), pe("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), ye(""), pr((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
- const he = de(Ne(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ft(6), ye("")), Bs = de(Ne(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ft(6), ye("")), en = (e) => de(Ns(58), pe(e), ye("")), qt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1886
+ const Ks = de(Se(4), pe("0123456789ABCDEF"), ye("")), Cs = de(Se(5), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ft(5), ye(""));
1887
+ de(Se(5), pe("0123456789ABCDEFGHIJKLMNOPQRSTUV"), ft(5), ye(""));
1888
+ de(Se(5), pe("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), ye(""), pr((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
+ const he = de(Se(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ft(6), ye("")), Bs = de(Se(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ft(6), ye("")), en = (e) => de(Ss(58), pe(e), ye("")), qt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
1890
  en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
1891
  en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1892
- const Tn = [0, 2, 3, 5, 6, 7, 9, 10, 11], Cs = {
1892
+ const Tn = [0, 2, 3, 5, 6, 7, 9, 10, 11], ks = {
1893
1893
  encode(e) {
1894
1894
  let t = "";
1895
1895
  for (let n = 0; n < e.length; n += 8) {
@@ -1933,10 +1933,10 @@ function On(e, t, n = 1) {
1933
1933
  i = Ze(i) ^ s;
1934
1934
  for (let s = 0; s < 6; s++)
1935
1935
  i = Ze(i);
1936
- return i ^= n, Dt.encode(Pt([i % 2 ** 30], 30, 5, !1));
1936
+ return i ^= n, Dt.encode(Ht([i % 2 ** 30], 30, 5, !1));
1937
1937
  }
1938
1938
  function gr(e) {
1939
- const t = e === "bech32" ? 1 : 734539939, n = Ne(5), r = n.decode, i = n.encode, s = $n(r);
1939
+ const t = e === "bech32" ? 1 : 734539939, n = Se(5), r = n.decode, i = n.encode, s = $n(r);
1940
1940
  function o(f, u, g = 90) {
1941
1941
  if (typeof f != "string")
1942
1942
  throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);
@@ -1979,7 +1979,7 @@ gr("bech32m");
1979
1979
  const Us = {
1980
1980
  encode: (e) => new TextDecoder().decode(e),
1981
1981
  decode: (e) => new TextEncoder().encode(e)
1982
- }, _s = de(Ne(4), pe("0123456789abcdef"), ye(""), pr((e) => {
1982
+ }, _s = de(Se(4), pe("0123456789abcdef"), ye(""), pr((e) => {
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();
@@ -1987,11 +1987,11 @@ const Us = {
1987
1987
  utf8: Us,
1988
1988
  hex: _s,
1989
1989
  base16: Ks,
1990
- base32: ks,
1990
+ base32: Cs,
1991
1991
  base64: he,
1992
1992
  base64url: Bs,
1993
1993
  base58: qt,
1994
- base58xmr: Cs
1994
+ base58xmr: ks
1995
1995
  };
1996
1996
  `${Object.keys(Is).join(", ")}`;
1997
1997
  function Bt(e) {
@@ -2028,11 +2028,11 @@ function Rs(e, t) {
2028
2028
  n |= e[r] ^ t[r];
2029
2029
  return n === 0;
2030
2030
  }
2031
- const Os = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Se = 16, Ms = 283;
2031
+ const Os = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ae = 16, Ms = 283;
2032
2032
  function tn(e) {
2033
2033
  return e << 1 ^ Ms & -(e >> 7);
2034
2034
  }
2035
- function He(e, t) {
2035
+ function Pe(e, t) {
2036
2036
  let n = 0;
2037
2037
  for (; t > 0; t >>= 1)
2038
2038
  n ^= e & -(t & 1), e = tn(e);
@@ -2049,11 +2049,11 @@ 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
- })(), Hs = /* @__PURE__ */ jt.map((e, t) => jt.indexOf(t)), Ps = (e) => e << 24 | e >>> 8, Ct = (e) => e << 8 | e >>> 24;
2052
+ })(), Ps = /* @__PURE__ */ jt.map((e, t) => jt.indexOf(t)), Hs = (e) => e << 24 | e >>> 8, kt = (e) => e << 8 | e >>> 24;
2053
2053
  function wr(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(Ct), i = r.map(Ct), s = i.map(Ct), o = new Uint32Array(256 * 256), a = new Uint32Array(256 * 256), c = new Uint16Array(256 * 256);
2056
+ const n = new Uint32Array(256).map((l, f) => t(e[f])), r = n.map(kt), i = r.map(kt), s = i.map(kt), o = 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;
@@ -2061,7 +2061,7 @@ function wr(e, t) {
2061
2061
  }
2062
2062
  return { sbox: e, sbox2: c, T0: n, T1: r, T2: i, T3: s, T01: o, T23: a };
2063
2063
  }
2064
- const nn = /* @__PURE__ */ wr(jt, (e) => He(e, 3) << 24 | e << 16 | e << 8 | He(e, 2)), br = /* @__PURE__ */ wr(Hs, (e) => He(e, 11) << 24 | He(e, 13) << 16 | He(e, 9) << 8 | He(e, 14)), qs = /* @__PURE__ */ (() => {
2064
+ const nn = /* @__PURE__ */ wr(jt, (e) => Pe(e, 3) << 24 | e << 16 | e << 8 | Pe(e, 2)), br = /* @__PURE__ */ wr(Ps, (e) => Pe(e, 11) << 24 | Pe(e, 13) << 16 | Pe(e, 9) << 8 | Pe(e, 14)), qs = /* @__PURE__ */ (() => {
2065
2065
  const e = new Uint8Array(16);
2066
2066
  for (let t = 0, n = 1; t < 16; t++, n = tn(n))
2067
2067
  e[t] = n;
@@ -2076,7 +2076,7 @@ function vr(e) {
2076
2076
  o.set(r);
2077
2077
  for (let a = i; a < o.length; a++) {
2078
2078
  let c = o[a - 1];
2079
- a % i === 0 ? c = s(Ps(c)) ^ qs[a / i - 1] : i > 6 && a % i === 4 && (c = s(c)), o[a] = o[a - i] ^ c;
2079
+ a % i === 0 ? c = s(Hs(c)) ^ qs[a / i - 1] : i > 6 && a % i === 4 && (c = s(c)), o[a] = o[a - i] ^ c;
2080
2080
  }
2081
2081
  return o;
2082
2082
  }
@@ -2098,7 +2098,7 @@ function xe(e, t, n, r, i, s) {
2098
2098
  function oe(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 Hn(e, t, n, r, i) {
2101
+ function Pn(e, t, n, r, i) {
2102
2102
  const { sbox2: s, T01: o, T23: a } = nn;
2103
2103
  let c = 0;
2104
2104
  t ^= e[c++], n ^= e[c++], r ^= e[c++], i ^= e[c++];
@@ -2130,18 +2130,18 @@ function mr(e, t) {
2130
2130
  return t;
2131
2131
  }
2132
2132
  function zs(e) {
2133
- if (ce(e), e.length % Se !== 0)
2134
- throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Se}`);
2133
+ if (ce(e), e.length % Ae !== 0)
2134
+ throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ae}`);
2135
2135
  }
2136
2136
  function Vs(e, t, n) {
2137
2137
  let r = e.length;
2138
- const i = r % Se;
2138
+ const i = r % Ae;
2139
2139
  if (!t && i !== 0)
2140
2140
  throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");
2141
2141
  const s = Z(e);
2142
2142
  if (t) {
2143
- let c = Se - i;
2144
- c || (c = Se), r = r + c;
2143
+ let c = Ae - i;
2144
+ c || (c = Ae), r = r + c;
2145
2145
  }
2146
2146
  const o = mr(r, n), a = Z(o);
2147
2147
  return { b: s, o: a, out: o };
@@ -2164,8 +2164,8 @@ function Ws(e, t) {
2164
2164
  function Zs(e) {
2165
2165
  const t = new Uint8Array(16), n = Z(t);
2166
2166
  t.set(e);
2167
- const r = Se - e.length;
2168
- for (let i = Se - r; i < Se; i++)
2167
+ const r = Ae - e.length;
2168
+ for (let i = Ae - r; i < Ae; i++)
2169
2169
  t[i] = r;
2170
2170
  return n;
2171
2171
  }
@@ -2177,10 +2177,10 @@ const Er = /* @__PURE__ */ Os({ blockSize: 16, nonceLength: 16 }, function(t, n,
2177
2177
  const a = vr(t), { b: c, o: l, out: f } = Vs(s, i, o), u = Z(n);
2178
2178
  let g = u[0], b = u[1], p = u[2], h = u[3], d = 0;
2179
2179
  for (; d + 4 <= c.length; )
2180
- g ^= c[d + 0], b ^= c[d + 1], p ^= c[d + 2], h ^= c[d + 3], { s0: g, s1: b, s2: p, s3: h } = Hn(a, g, b, p, h), l[d++] = g, l[d++] = b, l[d++] = p, l[d++] = h;
2180
+ g ^= c[d + 0], b ^= c[d + 1], p ^= c[d + 2], h ^= c[d + 3], { s0: g, s1: b, s2: p, s3: h } = Pn(a, g, b, p, h), l[d++] = g, l[d++] = b, l[d++] = p, l[d++] = h;
2181
2181
  if (i) {
2182
2182
  const y = Zs(s.subarray(d * 4));
2183
- g ^= y[0], b ^= y[1], p ^= y[2], h ^= y[3], { s0: g, s1: b, s2: p, s3: h } = Hn(a, g, b, p, h), l[d++] = g, l[d++] = b, l[d++] = p, l[d++] = h;
2183
+ g ^= y[0], b ^= y[1], p ^= y[2], h ^= y[3], { s0: g, s1: b, s2: p, s3: h } = Pn(a, g, b, p, h), l[d++] = g, l[d++] = b, l[d++] = p, l[d++] = h;
2184
2184
  }
2185
2185
  return a.fill(0), f;
2186
2186
  },
@@ -2189,27 +2189,27 @@ const Er = /* @__PURE__ */ Os({ blockSize: 16, nonceLength: 16 }, function(t, n,
2189
2189
  const a = Ds(t), c = Z(n), l = mr(s.length, o), f = Z(s), u = Z(l);
2190
2190
  let g = c[0], b = c[1], p = c[2], h = c[3];
2191
2191
  for (let d = 0; d + 4 <= f.length; ) {
2192
- const y = g, E = b, N = p, _ = h;
2192
+ const y = g, E = b, S = p, _ = h;
2193
2193
  g = f[d + 0], b = f[d + 1], p = f[d + 2], h = f[d + 3];
2194
- const { s0: B, s1: m, s2: x, s3: S } = js(a, g, b, p, h);
2195
- u[d++] = B ^ y, u[d++] = m ^ E, u[d++] = x ^ N, u[d++] = S ^ _;
2194
+ const { s0: B, s1: m, s2: x, s3: A } = js(a, g, b, p, h);
2195
+ u[d++] = B ^ y, u[d++] = m ^ E, u[d++] = x ^ S, u[d++] = A ^ _;
2196
2196
  }
2197
2197
  return a.fill(0), Ws(l, i);
2198
2198
  }
2199
2199
  };
2200
- }), xr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Gs = xr("expand 16-byte k"), Fs = xr("expand 32-byte k"), Js = Z(Gs), Sr = Z(Fs);
2201
- Sr.slice();
2200
+ }), xr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Gs = xr("expand 16-byte k"), Fs = xr("expand 32-byte k"), Js = Z(Gs), Ar = Z(Fs);
2201
+ Ar.slice();
2202
2202
  function L(e, t) {
2203
2203
  return e << t | e >>> 32 - t;
2204
2204
  }
2205
2205
  function zt(e) {
2206
2206
  return e.byteOffset % 4 === 0;
2207
2207
  }
2208
- const Ye = 64, Ys = 16, Ar = 2 ** 32 - 1, Pn = new Uint32Array();
2208
+ const Ye = 64, Ys = 16, Nr = 2 ** 32 - 1, Hn = new Uint32Array();
2209
2209
  function Xs(e, t, n, r, i, s, o, a) {
2210
- const c = i.length, l = new Uint8Array(Ye), f = Z(l), u = zt(i) && zt(s), g = u ? Z(i) : Pn, b = u ? Z(s) : Pn;
2210
+ const c = i.length, l = new Uint8Array(Ye), f = Z(l), u = zt(i) && zt(s), g = u ? Z(i) : Hn, b = u ? Z(s) : Hn;
2211
2211
  for (let p = 0; p < c; o++) {
2212
- if (e(t, n, r, f, o, a), o >= Ar)
2212
+ if (e(t, n, r, f, o, a), o >= Nr)
2213
2213
  throw new Error("arx: counter overflow");
2214
2214
  const h = Math.min(Ye, c - p);
2215
2215
  if (u && h === Ye) {
@@ -2233,14 +2233,14 @@ function Qs(e, t) {
2233
2233
  return Bt(i), Bt(o), Mn(s), Mn(n), (a, c, l, f, u = 0) => {
2234
2234
  ce(a), ce(c), ce(l);
2235
2235
  const g = l.length;
2236
- if (f || (f = new Uint8Array(g)), ce(f), Bt(u), u < 0 || u >= Ar)
2236
+ if (f || (f = new Uint8Array(g)), ce(f), Bt(u), u < 0 || u >= Nr)
2237
2237
  throw new Error("arx: counter overflow");
2238
2238
  if (f.length < g)
2239
2239
  throw new Error(`arx: output (${f.length}) is shorter than data (${g})`);
2240
2240
  const b = [];
2241
2241
  let p = a.length, h, d;
2242
2242
  if (p === 32)
2243
- h = a.slice(), b.push(h), d = Sr;
2243
+ h = a.slice(), b.push(h), d = Ar;
2244
2244
  else if (p === 16 && n)
2245
2245
  h = new Uint8Array(32), h.set(a), h.set(a, 16), d = Js, b.push(h);
2246
2246
  else
@@ -2259,20 +2259,20 @@ function Qs(e, t) {
2259
2259
  const _ = new Uint8Array(12);
2260
2260
  _.set(c, s ? 0 : 12 - c.length), c = _, b.push(c);
2261
2261
  }
2262
- const N = Z(c);
2263
- for (Xs(e, d, y, N, l, f, u, o); b.length > 0; )
2262
+ const S = Z(c);
2263
+ for (Xs(e, d, y, S, l, f, u, o); b.length > 0; )
2264
2264
  b.pop().fill(0);
2265
2265
  return f;
2266
2266
  };
2267
2267
  }
2268
2268
  function eo(e, t, n, r, i, s = 20) {
2269
- let o = e[0], a = e[1], c = e[2], l = e[3], f = t[0], u = t[1], g = t[2], b = t[3], p = t[4], h = t[5], d = t[6], y = t[7], E = i, N = n[0], _ = n[1], B = n[2], m = o, x = a, S = c, H = l, U = f, K = u, T = g, R = b, P = p, w = h, v = d, A = y, C = E, k = N, I = _, O = B;
2269
+ let o = e[0], a = e[1], c = e[2], l = e[3], f = t[0], u = t[1], g = t[2], b = t[3], p = t[4], h = t[5], d = t[6], y = t[7], E = i, S = n[0], _ = n[1], B = n[2], m = o, x = a, A = c, P = l, U = f, K = u, T = g, R = b, H = p, w = h, v = d, N = y, k = E, C = S, I = _, O = B;
2270
2270
  for (let Q = 0; Q < s; Q += 2)
2271
- m = m + U | 0, C = L(C ^ m, 16), P = P + C | 0, U = L(U ^ P, 12), m = m + U | 0, C = L(C ^ m, 8), P = P + C | 0, U = L(U ^ P, 7), x = x + K | 0, k = L(k ^ x, 16), w = w + k | 0, K = L(K ^ w, 12), x = x + K | 0, k = L(k ^ x, 8), w = w + k | 0, K = L(K ^ w, 7), S = S + T | 0, I = L(I ^ S, 16), v = v + I | 0, T = L(T ^ v, 12), S = S + T | 0, I = L(I ^ S, 8), v = v + I | 0, T = L(T ^ v, 7), H = H + R | 0, O = L(O ^ H, 16), A = A + O | 0, R = L(R ^ A, 12), H = H + R | 0, O = L(O ^ H, 8), A = A + O | 0, R = L(R ^ A, 7), m = m + K | 0, O = L(O ^ m, 16), v = v + O | 0, K = L(K ^ v, 12), m = m + K | 0, O = L(O ^ m, 8), v = v + O | 0, K = L(K ^ v, 7), x = x + T | 0, C = L(C ^ x, 16), A = A + C | 0, T = L(T ^ A, 12), x = x + T | 0, C = L(C ^ x, 8), A = A + C | 0, T = L(T ^ A, 7), S = S + R | 0, k = L(k ^ S, 16), P = P + k | 0, R = L(R ^ P, 12), S = S + R | 0, k = L(k ^ S, 8), P = P + k | 0, R = L(R ^ P, 7), H = H + U | 0, I = L(I ^ H, 16), w = w + I | 0, U = L(U ^ w, 12), H = H + U | 0, I = L(I ^ H, 8), w = w + I | 0, U = L(U ^ w, 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 + K | 0, C = L(C ^ x, 16), w = w + C | 0, K = L(K ^ w, 12), x = x + K | 0, C = L(C ^ x, 8), w = w + C | 0, K = L(K ^ w, 7), A = A + T | 0, I = L(I ^ A, 16), v = v + I | 0, T = L(T ^ v, 12), A = A + T | 0, I = L(I ^ A, 8), v = v + I | 0, T = L(T ^ v, 7), P = P + R | 0, O = L(O ^ P, 16), N = N + O | 0, R = L(R ^ N, 12), P = P + R | 0, O = L(O ^ P, 8), N = N + O | 0, R = L(R ^ N, 7), m = m + K | 0, O = L(O ^ m, 16), v = v + O | 0, K = L(K ^ v, 12), m = m + K | 0, O = L(O ^ m, 8), v = v + O | 0, K = L(K ^ v, 7), x = x + T | 0, k = L(k ^ x, 16), N = N + k | 0, T = L(T ^ N, 12), x = x + T | 0, k = L(k ^ x, 8), N = N + k | 0, T = L(T ^ N, 7), A = A + R | 0, C = L(C ^ A, 16), H = H + C | 0, R = L(R ^ H, 12), A = A + R | 0, C = L(C ^ A, 8), H = H + C | 0, R = L(R ^ H, 7), P = P + U | 0, I = L(I ^ P, 16), w = w + I | 0, U = L(U ^ w, 12), P = P + U | 0, I = L(I ^ P, 8), w = w + I | 0, U = L(U ^ w, 7);
2272
2272
  let $ = 0;
2273
- r[$++] = o + m | 0, r[$++] = a + x | 0, r[$++] = c + S | 0, r[$++] = l + H | 0, r[$++] = f + U | 0, r[$++] = u + K | 0, r[$++] = g + T | 0, r[$++] = b + R | 0, r[$++] = p + P | 0, r[$++] = h + w | 0, r[$++] = d + v | 0, r[$++] = y + A | 0, r[$++] = E + C | 0, r[$++] = N + k | 0, r[$++] = _ + I | 0, r[$++] = B + O | 0;
2273
+ r[$++] = o + m | 0, r[$++] = a + x | 0, r[$++] = c + A | 0, r[$++] = l + P | 0, r[$++] = f + U | 0, r[$++] = u + K | 0, r[$++] = g + T | 0, r[$++] = b + R | 0, r[$++] = p + H | 0, r[$++] = h + w | 0, r[$++] = d + v | 0, r[$++] = y + N | 0, r[$++] = E + k | 0, r[$++] = S + C | 0, r[$++] = _ + I | 0, r[$++] = B + O | 0;
2274
2274
  }
2275
- const Nr = /* @__PURE__ */ Qs(eo, {
2275
+ const Sr = /* @__PURE__ */ Qs(eo, {
2276
2276
  counterRight: !1,
2277
2277
  counterLength: 4,
2278
2278
  allowShortKeys: !1
@@ -2318,7 +2318,7 @@ function rn(e, t, n) {
2318
2318
  return se.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), ht(e, Fe(n), Fe(t));
2319
2319
  }
2320
2320
  const Ut = new Uint8Array([0]), qn = new Uint8Array();
2321
- function kr(e, t, n, r = 32) {
2321
+ function Cr(e, t, n, r = 32) {
2322
2322
  if (se.hash(e), se.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);
@@ -2328,7 +2328,7 @@ function kr(e, t, n, r = 32) {
2328
2328
  Ut[0] = l + 1, a.update(l === 0 ? qn : c).update(n).update(Ut).digestInto(c), s.set(c, e.outputLen * l), o._cloneInto(a);
2329
2329
  return o.destroy(), a.destroy(), c.fill(0), Ut.fill(0), s.slice(0, r);
2330
2330
  }
2331
- var to = Object.defineProperty, q = (e, t) => {
2331
+ var to = Object.defineProperty, D = (e, t) => {
2332
2332
  for (var n in t)
2333
2333
  to(e, n, { get: t[n], enumerable: !0 });
2334
2334
  }, Re = Symbol("verified"), no = (e) => e instanceof Object;
@@ -2346,7 +2346,7 @@ function sn(e) {
2346
2346
  return !0;
2347
2347
  }
2348
2348
  var ro = {};
2349
- q(ro, {
2349
+ D(ro, {
2350
2350
  Queue: () => ao,
2351
2351
  QueueNode: () => Br,
2352
2352
  binarySearch: () => on,
@@ -2441,8 +2441,8 @@ function Qe(e) {
2441
2441
  let t = fe(ne.encode(uo(e)));
2442
2442
  return M(t);
2443
2443
  }
2444
- var dt = new co(), Ce = dt.generateSecretKey, le = dt.getPublicKey, X = dt.finalizeEvent, pt = dt.verifyEvent, lo = {};
2445
- q(lo, {
2444
+ var dt = new co(), ke = dt.generateSecretKey, le = dt.getPublicKey, X = dt.finalizeEvent, pt = dt.verifyEvent, lo = {};
2445
+ D(lo, {
2446
2446
  Application: () => da,
2447
2447
  BadgeAward: () => mo,
2448
2448
  BadgeDefinition: () => oa,
@@ -2457,9 +2457,9 @@ q(lo, {
2457
2457
  ChannelMetadata: () => Tr,
2458
2458
  ChannelMuteUser: () => Mr,
2459
2459
  ClassifiedListing: () => ga,
2460
- ClientAuth: () => Pr,
2460
+ ClientAuth: () => Hr,
2461
2461
  CommunitiesList: () => Do,
2462
- CommunityDefinition: () => Aa,
2462
+ CommunityDefinition: () => Na,
2463
2463
  CommunityPostApproval: () => Uo,
2464
2464
  Contacts: () => wo,
2465
2465
  CreateOrUpdateProduct: () => ua,
@@ -2472,14 +2472,14 @@ q(lo, {
2472
2472
  Emojisets: () => ha,
2473
2473
  EncryptedDirectMessage: () => bo,
2474
2474
  EventDeletion: () => vo,
2475
- FileMetadata: () => Ao,
2475
+ FileMetadata: () => No,
2476
2476
  FileServerPreference: () => Fo,
2477
2477
  Followsets: () => ea,
2478
2478
  GenericRepost: () => xo,
2479
2479
  Genericlists: () => ta,
2480
- GiftWrap: () => Hr,
2480
+ GiftWrap: () => Pr,
2481
2481
  HTTPAuth: () => un,
2482
- Handlerinformation: () => Sa,
2482
+ Handlerinformation: () => Aa,
2483
2483
  Handlerrecommendation: () => xa,
2484
2484
  Highlights: () => Oo,
2485
2485
  InterestsList: () => Wo,
@@ -2487,9 +2487,9 @@ q(lo, {
2487
2487
  JobFeedback: () => Lo,
2488
2488
  JobRequest: () => _o,
2489
2489
  JobResult: () => Io,
2490
- Label: () => Co,
2490
+ Label: () => ko,
2491
2491
  LightningPubRPC: () => Yo,
2492
- LiveChatMessage: () => No,
2492
+ LiveChatMessage: () => So,
2493
2493
  LiveEvent: () => pa,
2494
2494
  LongFormArticle: () => la,
2495
2495
  Metadata: () => po,
@@ -2498,17 +2498,17 @@ q(lo, {
2498
2498
  NWCWalletRequest: () => qr,
2499
2499
  NWCWalletResponse: () => Xo,
2500
2500
  NostrConnect: () => Qo,
2501
- OpenTimestamps: () => So,
2502
- Pinlist: () => Ho,
2501
+ OpenTimestamps: () => Ao,
2502
+ Pinlist: () => Po,
2503
2503
  PrivateDirectMessage: () => Eo,
2504
2504
  ProblemTracker: () => Ko,
2505
2505
  ProfileBadges: () => sa,
2506
2506
  PublicChatsList: () => jo,
2507
2507
  Reaction: () => cn,
2508
2508
  RecommendRelay: () => go,
2509
- RelayList: () => Po,
2509
+ RelayList: () => Ho,
2510
2510
  Relaysets: () => na,
2511
- Report: () => ko,
2511
+ Report: () => Co,
2512
2512
  Reporting: () => Bo,
2513
2513
  Repost: () => an,
2514
2514
  Seal: () => Lr,
@@ -2524,10 +2524,10 @@ q(lo, {
2524
2524
  isEphemeralKind: () => _r,
2525
2525
  isKind: () => ho,
2526
2526
  isParameterizedReplaceableKind: () => Ir,
2527
- isRegularKind: () => Cr,
2527
+ isRegularKind: () => kr,
2528
2528
  isReplaceableKind: () => Ur
2529
2529
  });
2530
- function Cr(e) {
2530
+ function kr(e) {
2531
2531
  return 1e3 <= e && e < 1e4 || [1, 2, 4, 5, 6, 7, 8, 16, 40, 41, 42, 43, 44].includes(e);
2532
2532
  }
2533
2533
  function Ur(e) {
@@ -2540,19 +2540,19 @@ function Ir(e) {
2540
2540
  return 3e4 <= e && e < 4e4;
2541
2541
  }
2542
2542
  function fo(e) {
2543
- return Cr(e) ? "regular" : Ur(e) ? "replaceable" : _r(e) ? "ephemeral" : Ir(e) ? "parameterized" : "unknown";
2543
+ return kr(e) ? "regular" : Ur(e) ? "replaceable" : _r(e) ? "ephemeral" : Ir(e) ? "parameterized" : "unknown";
2544
2544
  }
2545
2545
  function ho(e, t) {
2546
2546
  const n = t instanceof Array ? t : [t];
2547
2547
  return sn(e) && n.includes(e.kind) || !1;
2548
2548
  }
2549
- var po = 0, yo = 1, go = 2, wo = 3, bo = 4, vo = 5, an = 6, cn = 7, mo = 8, Lr = 13, Eo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Mr = 44, So = 1040, Hr = 1059, Ao = 1063, No = 1311, Ko = 1971, ko = 1984, Bo = 1984, Co = 1985, Uo = 4550, _o = 5999, Io = 6999, Lo = 7e3, $o = 9041, To = 9734, Ro = 9735, Oo = 9802, Mo = 1e4, Ho = 10001, Po = 10002, qo = 10003, Do = 10004, jo = 10005, zo = 10006, Vo = 10007, Wo = 10015, Zo = 10030, Go = 10050, Fo = 10096, Jo = 13194, Yo = 21e3, Pr = 22242, qr = 23194, Xo = 23195, Qo = 24133, un = 27235, ea = 3e4, ta = 30001, na = 30002, ra = 30003, ia = 30004, sa = 30008, oa = 30009, aa = 30015, ca = 30017, ua = 30018, la = 30023, fa = 30024, ha = 30030, da = 30078, pa = 30311, ya = 30315, ga = 30402, wa = 30403, ba = 31922, va = 31923, ma = 31924, Ea = 31925, xa = 31989, Sa = 31990, Aa = 34550, Na = {};
2550
- q(Na, {
2549
+ var po = 0, yo = 1, go = 2, wo = 3, bo = 4, vo = 5, an = 6, cn = 7, mo = 8, Lr = 13, Eo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Mr = 44, Ao = 1040, Pr = 1059, No = 1063, So = 1311, Ko = 1971, Co = 1984, Bo = 1984, ko = 1985, Uo = 4550, _o = 5999, Io = 6999, Lo = 7e3, $o = 9041, To = 9734, Ro = 9735, Oo = 9802, Mo = 1e4, Po = 10001, Ho = 10002, qo = 10003, Do = 10004, jo = 10005, zo = 10006, Vo = 10007, Wo = 10015, Zo = 10030, Go = 10050, Fo = 10096, Jo = 13194, Yo = 21e3, Hr = 22242, qr = 23194, Xo = 23195, Qo = 24133, un = 27235, ea = 3e4, ta = 30001, na = 30002, ra = 30003, ia = 30004, sa = 30008, oa = 30009, aa = 30015, ca = 30017, ua = 30018, la = 30023, fa = 30024, ha = 30030, da = 30078, pa = 30311, ya = 30315, ga = 30402, wa = 30403, ba = 31922, va = 31923, ma = 31924, Ea = 31925, xa = 31989, Aa = 31990, Na = 34550, Sa = {};
2550
+ D(Sa, {
2551
2551
  getHex64: () => ln,
2552
2552
  getInt: () => Dr,
2553
2553
  getSubscriptionId: () => Ka,
2554
- matchEventId: () => ka,
2555
- matchEventKind: () => Ca,
2554
+ matchEventId: () => Ca,
2555
+ matchEventKind: () => ka,
2556
2556
  matchEventPubkey: () => Ba
2557
2557
  });
2558
2558
  function ln(e, t) {
@@ -2576,22 +2576,22 @@ function Ka(e) {
2576
2576
  let s = r + 1 + i;
2577
2577
  return e.slice(r + 1, s);
2578
2578
  }
2579
- function ka(e, t) {
2579
+ function Ca(e, t) {
2580
2580
  return t === ln(e, "id");
2581
2581
  }
2582
2582
  function Ba(e, t) {
2583
2583
  return t === ln(e, "pubkey");
2584
2584
  }
2585
- function Ca(e, t) {
2585
+ function ka(e, t) {
2586
2586
  return t === Dr(e, "kind");
2587
2587
  }
2588
2588
  var Ua = {};
2589
- q(Ua, {
2589
+ D(Ua, {
2590
2590
  makeAuthEvent: () => _a
2591
2591
  });
2592
2592
  function _a(e, t) {
2593
2593
  return {
2594
- kind: Pr,
2594
+ kind: Hr,
2595
2595
  created_at: Math.floor(Date.now() / 1e3),
2596
2596
  tags: [
2597
2597
  ["relay", e],
@@ -2611,7 +2611,7 @@ try {
2611
2611
  } catch {
2612
2612
  }
2613
2613
  var $a = {};
2614
- q($a, {
2614
+ D($a, {
2615
2615
  BECH32_REGEX: () => jr,
2616
2616
  Bech32MaxSize: () => fn,
2617
2617
  NostrTypeGuard: () => Ta,
@@ -2619,8 +2619,8 @@ q($a, {
2619
2619
  encodeBytes: () => wt,
2620
2620
  naddrEncode: () => Da,
2621
2621
  neventEncode: () => qa,
2622
- noteEncode: () => Ha,
2623
- nprofileEncode: () => Pa,
2622
+ noteEncode: () => Pa,
2623
+ nprofileEncode: () => Ha,
2624
2624
  npubEncode: () => Ma,
2625
2625
  nsecEncode: () => Oa
2626
2626
  });
@@ -2722,7 +2722,7 @@ function Oa(e) {
2722
2722
  function Ma(e) {
2723
2723
  return wt("npub", G(e));
2724
2724
  }
2725
- function Ha(e) {
2725
+ function Pa(e) {
2726
2726
  return wt("note", G(e));
2727
2727
  }
2728
2728
  function gt(e, t) {
@@ -2732,7 +2732,7 @@ function gt(e, t) {
2732
2732
  function wt(e, t) {
2733
2733
  return gt(e, t);
2734
2734
  }
2735
- function Pa(e) {
2735
+ function Ha(e) {
2736
2736
  let t = hn({
2737
2737
  0: [G(e.pubkey)],
2738
2738
  1: (e.relays || []).map((n) => ne.encode(n))
@@ -2771,7 +2771,7 @@ function hn(e) {
2771
2771
  }), lt(...t);
2772
2772
  }
2773
2773
  var ja = {};
2774
- q(ja, {
2774
+ D(ja, {
2775
2775
  decrypt: () => za,
2776
2776
  encrypt: () => zr
2777
2777
  });
@@ -2789,7 +2789,7 @@ function Vr(e) {
2789
2789
  return e.slice(1, 33);
2790
2790
  }
2791
2791
  var Va = {};
2792
- q(Va, {
2792
+ D(Va, {
2793
2793
  NIP05_REGEX: () => dn,
2794
2794
  isNip05: () => Wa,
2795
2795
  isValid: () => Fa,
@@ -2836,7 +2836,7 @@ async function Fa(e, t) {
2836
2836
  return n ? n.pubkey === e : !1;
2837
2837
  }
2838
2838
  var Ja = {};
2839
- q(Ja, {
2839
+ D(Ja, {
2840
2840
  parse: () => Ya
2841
2841
  });
2842
2842
  function Ya(e) {
@@ -2907,7 +2907,7 @@ function Ya(e) {
2907
2907
  }), t;
2908
2908
  }
2909
2909
  var Xa = {};
2910
- q(Xa, {
2910
+ D(Xa, {
2911
2911
  fetchRelayInformation: () => ec,
2912
2912
  useFetchImplementation: () => Qa
2913
2913
  });
@@ -2925,7 +2925,7 @@ async function ec(e) {
2925
2925
  })).json();
2926
2926
  }
2927
2927
  var tc = {};
2928
- q(tc, {
2928
+ D(tc, {
2929
2929
  fastEventHash: () => Fr,
2930
2930
  getPow: () => Gr,
2931
2931
  minePow: () => nc
@@ -2959,7 +2959,7 @@ function Fr(e) {
2959
2959
  );
2960
2960
  }
2961
2961
  var rc = {};
2962
- q(rc, {
2962
+ D(rc, {
2963
2963
  finishRepostEvent: () => ic,
2964
2964
  getRepostedEvent: () => sc,
2965
2965
  getRepostedEventPointer: () => Jr
@@ -3004,7 +3004,7 @@ function sc(e, { skipVerification: t } = {}) {
3004
3004
  return r;
3005
3005
  }
3006
3006
  var oc = {};
3007
- q(oc, {
3007
+ D(oc, {
3008
3008
  NOSTR_URI_REGEX: () => vt,
3009
3009
  parse: () => cc,
3010
3010
  test: () => ac
@@ -3024,7 +3024,7 @@ function cc(e) {
3024
3024
  };
3025
3025
  }
3026
3026
  var uc = {};
3027
- q(uc, {
3027
+ D(uc, {
3028
3028
  finishReactionEvent: () => lc,
3029
3029
  getReactedEventPointer: () => fc
3030
3030
  });
@@ -3056,7 +3056,7 @@ function fc(e) {
3056
3056
  };
3057
3057
  }
3058
3058
  var hc = {};
3059
- q(hc, {
3059
+ D(hc, {
3060
3060
  matchAll: () => dc,
3061
3061
  regex: () => pn,
3062
3062
  replaceAll: () => pc
@@ -3085,7 +3085,7 @@ function pc(e, t) {
3085
3085
  }));
3086
3086
  }
3087
3087
  var yc = {};
3088
- q(yc, {
3088
+ D(yc, {
3089
3089
  channelCreateEvent: () => gc,
3090
3090
  channelHideMessageEvent: () => vc,
3091
3091
  channelMessageEvent: () => bc,
@@ -3172,11 +3172,11 @@ var gc = (e, t) => {
3172
3172
  t
3173
3173
  );
3174
3174
  }, Ec = {};
3175
- q(Ec, {
3175
+ D(Ec, {
3176
3176
  EMOJI_SHORTCODE_REGEX: () => Yr,
3177
3177
  matchAll: () => xc,
3178
3178
  regex: () => yn,
3179
- replaceAll: () => Sc
3179
+ replaceAll: () => Ac
3180
3180
  });
3181
3181
  var Yr = /:(\w+):/, yn = () => new RegExp(`\\B${Yr.source}\\B`, "g");
3182
3182
  function* xc(e) {
@@ -3193,15 +3193,15 @@ function* xc(e) {
3193
3193
  } catch {
3194
3194
  }
3195
3195
  }
3196
- function Sc(e, t) {
3196
+ function Ac(e, t) {
3197
3197
  return e.replaceAll(yn(), (n, r) => t({
3198
3198
  shortcode: n,
3199
3199
  name: r
3200
3200
  }));
3201
3201
  }
3202
- var Ac = {};
3203
- q(Ac, {
3204
- useFetchImplementation: () => Nc,
3202
+ var Nc = {};
3203
+ D(Nc, {
3204
+ useFetchImplementation: () => Sc,
3205
3205
  validateGithub: () => Kc
3206
3206
  });
3207
3207
  var gn;
@@ -3209,7 +3209,7 @@ try {
3209
3209
  gn = fetch;
3210
3210
  } catch {
3211
3211
  }
3212
- function Nc(e) {
3212
+ function Sc(e) {
3213
3213
  gn = e;
3214
3214
  }
3215
3215
  async function Kc(e, t, n) {
@@ -3219,8 +3219,8 @@ async function Kc(e, t, n) {
3219
3219
  return !1;
3220
3220
  }
3221
3221
  }
3222
- var j = {};
3223
- q(j, {
3222
+ var q = {};
3223
+ D(q, {
3224
3224
  decrypt: () => mn,
3225
3225
  encrypt: () => vn,
3226
3226
  getConversationKey: () => wn,
@@ -3232,7 +3232,7 @@ function wn(e, t) {
3232
3232
  return rn(fe, n, "nip44-v2");
3233
3233
  }
3234
3234
  function ei(e, t) {
3235
- const n = kr(fe, e, t, 76);
3235
+ const n = Cr(fe, e, t, 76);
3236
3236
  return {
3237
3237
  chacha_key: n.subarray(0, 32),
3238
3238
  chacha_nonce: n.subarray(32, 44),
@@ -3247,17 +3247,17 @@ function bn(e) {
3247
3247
  const t = 1 << Math.floor(Math.log2(e - 1)) + 1, n = t <= 256 ? 32 : t / 8;
3248
3248
  return n * (Math.floor((e - 1) / n) + 1);
3249
3249
  }
3250
- function kc(e) {
3250
+ function Cc(e) {
3251
3251
  if (!Number.isSafeInteger(e) || e < Xr || e > Qr)
3252
3252
  throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");
3253
3253
  const t = new Uint8Array(2);
3254
3254
  return new DataView(t.buffer).setUint16(0, e, !1), t;
3255
3255
  }
3256
3256
  function Bc(e) {
3257
- const t = ne.encode(e), n = t.length, r = kc(n), i = new Uint8Array(bn(n) - n);
3257
+ const t = ne.encode(e), n = t.length, r = Cc(n), i = new Uint8Array(bn(n) - n);
3258
3258
  return lt(r, t, i);
3259
3259
  }
3260
- function Cc(e) {
3260
+ function kc(e) {
3261
3261
  const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t);
3262
3262
  if (t < Xr || t > Qr || n.length !== t || e.length !== 2 + bn(t))
3263
3263
  throw new Error("invalid padding");
@@ -3296,15 +3296,15 @@ function Uc(e) {
3296
3296
  };
3297
3297
  }
3298
3298
  function vn(e, t, n = fr(32)) {
3299
- const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ei(t, n), o = Bc(e), a = Nr(r, i, o), c = ti(s, a, n);
3299
+ const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ei(t, n), o = Bc(e), a = Sr(r, i, o), c = ti(s, a, n);
3300
3300
  return he.encode(lt(new Uint8Array([2]), n, a, c));
3301
3301
  }
3302
3302
  function mn(e, t) {
3303
3303
  const { nonce: n, ciphertext: r, mac: i } = Uc(e), { chacha_key: s, chacha_nonce: o, hmac_key: a } = ei(t, n), c = ti(a, r, n);
3304
3304
  if (!Rs(c, i))
3305
3305
  throw new Error("invalid MAC");
3306
- const l = Nr(s, o, r);
3307
- return Cc(l);
3306
+ const l = Sr(s, o, r);
3307
+ return kc(l);
3308
3308
  }
3309
3309
  var _c = {
3310
3310
  utils: {
@@ -3314,7 +3314,7 @@ var _c = {
3314
3314
  encrypt: vn,
3315
3315
  decrypt: mn
3316
3316
  }, Ic = {};
3317
- q(Ic, {
3317
+ D(Ic, {
3318
3318
  makeNwcRequestEvent: () => $c,
3319
3319
  parseConnectionString: () => Lc
3320
3320
  });
@@ -3339,12 +3339,12 @@ async function $c(e, t, n) {
3339
3339
  return X(s, t);
3340
3340
  }
3341
3341
  var Tc = {};
3342
- q(Tc, {
3342
+ D(Tc, {
3343
3343
  getZapEndpoint: () => Oc,
3344
- makeZapReceipt: () => Pc,
3344
+ makeZapReceipt: () => Hc,
3345
3345
  makeZapRequest: () => Mc,
3346
3346
  useFetchImplementation: () => Rc,
3347
- validateZapRequest: () => Hc
3347
+ validateZapRequest: () => Pc
3348
3348
  });
3349
3349
  var En;
3350
3350
  try {
@@ -3395,7 +3395,7 @@ function Mc({
3395
3395
  };
3396
3396
  return t && s.tags.push(["e", t]), s;
3397
3397
  }
3398
- function Hc(e) {
3398
+ function Pc(e) {
3399
3399
  let t;
3400
3400
  try {
3401
3401
  t = JSON.parse(e);
@@ -3414,7 +3414,7 @@ function Hc(e) {
3414
3414
  let r = t.tags.find(([s, o]) => s === "e" && o);
3415
3415
  return r && !r[1].match(/^[a-f0-9]{64}$/) ? "Zap request 'e' tag is not valid hex." : t.tags.find(([s, o]) => s === "relays" && o) ? null : "Zap request doesn't have a 'relays' tag.";
3416
3416
  }
3417
- function Pc({
3417
+ function Hc({
3418
3418
  zapRequest: e,
3419
3419
  preimage: t,
3420
3420
  bolt11: n,
@@ -3429,7 +3429,7 @@ function Pc({
3429
3429
  return t && o.tags.push(["preimage", t]), o;
3430
3430
  }
3431
3431
  var qc = {};
3432
- q(qc, {
3432
+ D(qc, {
3433
3433
  createRumor: () => oi,
3434
3434
  createSeal: () => ai,
3435
3435
  createWrap: () => ci,
@@ -3461,10 +3461,10 @@ function ai(e, t, n) {
3461
3461
  );
3462
3462
  }
3463
3463
  function ci(e, t) {
3464
- const n = Ce();
3464
+ const n = ke();
3465
3465
  return X(
3466
3466
  {
3467
- kind: Hr,
3467
+ kind: Pr,
3468
3468
  content: si(e, n, t),
3469
3469
  created_at: ri(),
3470
3470
  tags: [["p", t]]
@@ -3495,7 +3495,7 @@ function zc(e, t) {
3495
3495
  }), n.sort((r, i) => r.created_at - i.created_at), n;
3496
3496
  }
3497
3497
  var Vc = {};
3498
- q(Vc, {
3498
+ D(Vc, {
3499
3499
  getToken: () => Wc,
3500
3500
  hashPayload: () => xn,
3501
3501
  unpackEventFromToken: () => fi,
@@ -3579,12 +3579,13 @@ async function wi(e, t, n, r) {
3579
3579
  throw new Error("Invalid nostr event, payload tag does not match request body hash");
3580
3580
  return !0;
3581
3581
  }
3582
- const Pe = 4, jn = 30078, nu = 100;
3582
+ const He = 4, jn = 30078, nu = 100;
3583
3583
  var Gc = /* @__PURE__ */ ((e) => (e[e.Us = 0] = "Us", e[e.Them = 1] = "Them", e))(Gc || {});
3584
3584
  function ru(e) {
3585
3585
  return JSON.stringify({
3586
3586
  rootKey: M(e.rootKey),
3587
- theirNostrPublicKey: e.theirNostrPublicKey,
3587
+ theirCurrentNostrPublicKey: e.theirCurrentNostrPublicKey,
3588
+ theirNextNostrPublicKey: e.theirNextNostrPublicKey,
3588
3589
  ourCurrentNostrKey: e.ourCurrentNostrKey ? {
3589
3590
  publicKey: e.ourCurrentNostrKey.publicKey,
3590
3591
  privateKey: M(e.ourCurrentNostrKey.privateKey)
@@ -3616,7 +3617,8 @@ function iu(e) {
3616
3617
  const t = JSON.parse(e);
3617
3618
  return {
3618
3619
  rootKey: G(t.rootKey),
3619
- theirNostrPublicKey: t.theirNostrPublicKey,
3620
+ theirCurrentNostrPublicKey: t.theirCurrentNostrPublicKey,
3621
+ theirNextNostrPublicKey: t.theirNextNostrPublicKey,
3620
3622
  ourCurrentNostrKey: t.ourCurrentNostrKey ? {
3621
3623
  publicKey: t.ourCurrentNostrKey.publicKey,
3622
3624
  privateKey: G(t.ourCurrentNostrKey.privateKey)
@@ -3662,7 +3664,7 @@ async function* su(e) {
3662
3664
  function Oe(e, t = new Uint8Array(32), n = 1) {
3663
3665
  const r = rn(fe, e, t), i = [];
3664
3666
  for (let s = 1; s <= n; s++)
3665
- i.push(kr(fe, r, new Uint8Array([s]), 32));
3667
+ i.push(Cr(fe, r, new Uint8Array([s]), 32));
3666
3668
  return i;
3667
3669
  }
3668
3670
  function It(e, t) {
@@ -3682,7 +3684,7 @@ class st {
3682
3684
  /**
3683
3685
  * Initializes a new secure communication session
3684
3686
  * @param nostrSubscribe Function to subscribe to Nostr events
3685
- * @param theirNostrPublicKey The public key of the other party
3687
+ * @param theirNextNostrPublicKey The public key of the other party
3686
3688
  * @param ourCurrentPrivateKey Our current private key for Nostr
3687
3689
  * @param isInitiator Whether we are initiating the conversation (true) or responding (false)
3688
3690
  * @param sharedSecret Initial shared secret for securing the first message chain
@@ -3690,12 +3692,12 @@ class st {
3690
3692
  * @returns A new Session instance
3691
3693
  */
3692
3694
  static init(t, n, r, i, s, o) {
3693
- const a = Ce(), [c, l] = Oe(s, j.getConversationKey(a, n), 2);
3695
+ const a = ke(), [c, l] = Oe(s, q.getConversationKey(a, n), 2);
3694
3696
  let f, u;
3695
3697
  i ? (f = { publicKey: le(r), privateKey: r }, u = { publicKey: le(a), privateKey: a }) : u = { publicKey: le(r), privateKey: r };
3696
3698
  const g = {
3697
3699
  rootKey: i ? c : s,
3698
- theirNostrPublicKey: n,
3700
+ theirNextNostrPublicKey: n,
3699
3701
  ourCurrentNostrKey: f,
3700
3702
  ourNextNostrKey: u,
3701
3703
  receivingChainKey: void 0,
@@ -3715,12 +3717,12 @@ class st {
3715
3717
  * @throws Error if we are not the initiator and trying to send the first message
3716
3718
  */
3717
3719
  send(t) {
3718
- if (!this.state.theirNostrPublicKey || !this.state.ourCurrentNostrKey)
3720
+ if (!this.state.theirNextNostrPublicKey || !this.state.ourCurrentNostrKey)
3719
3721
  throw new Error("we are not the initiator, so we can't send the first message");
3720
- const [n, r] = this.ratchetEncrypt(t), i = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNostrPublicKey), s = j.encrypt(JSON.stringify(n), i);
3722
+ const [n, r] = this.ratchetEncrypt(t), i = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNextNostrPublicKey), s = q.encrypt(JSON.stringify(n), i);
3721
3723
  return X({
3722
3724
  content: r,
3723
- kind: Pe,
3725
+ kind: He,
3724
3726
  tags: [["header", s]],
3725
3727
  created_at: Math.floor(Date.now() / 1e3)
3726
3728
  }, this.state.ourCurrentNostrKey.privateKey);
@@ -3749,7 +3751,7 @@ class st {
3749
3751
  nextPublicKey: this.state.ourNextNostrKey.publicKey,
3750
3752
  time: Date.now(),
3751
3753
  previousChainLength: this.state.previousSendingChainMessageCount
3752
- }, j.encrypt(t, r)];
3754
+ }, q.encrypt(t, r)];
3753
3755
  }
3754
3756
  ratchetDecrypt(t, n, r) {
3755
3757
  const i = this.trySkippedMessageKeys(t, n, r);
@@ -3758,7 +3760,7 @@ class st {
3758
3760
  const [s, o] = Oe(this.state.receivingChainKey, new Uint8Array([1]), 2);
3759
3761
  this.state.receivingChainKey = s, this.state.receivingChainMessageNumber++;
3760
3762
  try {
3761
- return j.decrypt(n, o);
3763
+ return q.decrypt(n, o);
3762
3764
  } catch (a) {
3763
3765
  throw console.error(this.name, "Decryption failed:", a, {
3764
3766
  messageKey: M(o).slice(0, 4),
@@ -3769,15 +3771,15 @@ class st {
3769
3771
  }
3770
3772
  }
3771
3773
  ratchetStep(t) {
3772
- this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0, this.state.theirNostrPublicKey = t;
3773
- const n = j.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [r, i] = Oe(this.state.rootKey, n, 2);
3774
+ this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0, this.state.theirNextNostrPublicKey = t;
3775
+ const n = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [r, i] = Oe(this.state.rootKey, n, 2);
3774
3776
  this.state.receivingChainKey = i, this.state.ourCurrentNostrKey = this.state.ourNextNostrKey;
3775
- const s = Ce();
3777
+ const s = ke();
3776
3778
  this.state.ourNextNostrKey = {
3777
3779
  publicKey: le(s),
3778
3780
  privateKey: s
3779
3781
  };
3780
- const o = j.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [a, c] = Oe(r, o, 2);
3782
+ const o = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [a, c] = Oe(r, o, 2);
3781
3783
  this.state.rootKey = a, this.state.sendingChainKey = c;
3782
3784
  }
3783
3785
  // 3. MESSAGE KEY FUNCTIONS
@@ -3791,10 +3793,10 @@ class st {
3791
3793
  if (this.state.skippedMessageKeys[s] = i, !this.state.skippedHeaderKeys[n]) {
3792
3794
  const o = [];
3793
3795
  if (this.state.ourCurrentNostrKey) {
3794
- const c = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
3796
+ const c = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
3795
3797
  o.push(c);
3796
3798
  }
3797
- const a = j.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
3799
+ const a = q.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
3798
3800
  o.push(a), this.state.skippedHeaderKeys[n] = o;
3799
3801
  }
3800
3802
  this.state.receivingChainMessageNumber++;
@@ -3805,7 +3807,7 @@ class st {
3805
3807
  const i = It(r, t.number);
3806
3808
  if (i in this.state.skippedMessageKeys) {
3807
3809
  const o = this.state.skippedMessageKeys[i];
3808
- return delete this.state.skippedMessageKeys[i], Object.keys(this.state.skippedMessageKeys).some((c) => c.startsWith(`${r}:`)) || (delete this.state.skippedHeaderKeys[r], (s = this.nostrUnsubscribe) == null || s.call(this), this.nostrUnsubscribe = void 0), j.decrypt(n, o);
3810
+ return delete this.state.skippedMessageKeys[i], Object.keys(this.state.skippedMessageKeys).some((c) => c.startsWith(`${r}:`)) || (delete this.state.skippedHeaderKeys[r], (s = this.nostrUnsubscribe) == null || s.call(this), this.nostrUnsubscribe = void 0), q.decrypt(n, o);
3809
3811
  }
3810
3812
  return null;
3811
3813
  }
@@ -3813,22 +3815,22 @@ class st {
3813
3815
  decryptHeader(t) {
3814
3816
  const n = t.tags[0][1];
3815
3817
  if (this.state.ourCurrentNostrKey) {
3816
- const s = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
3818
+ const s = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
3817
3819
  try {
3818
- return [JSON.parse(j.decrypt(n, s)), !1, !1];
3820
+ return [JSON.parse(q.decrypt(n, s)), !1, !1];
3819
3821
  } catch {
3820
3822
  }
3821
3823
  }
3822
- const r = j.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
3824
+ const r = q.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
3823
3825
  try {
3824
- return [JSON.parse(j.decrypt(n, r)), !0, !1];
3826
+ return [JSON.parse(q.decrypt(n, r)), !0, !1];
3825
3827
  } catch {
3826
3828
  }
3827
3829
  const i = this.state.skippedHeaderKeys[t.pubkey];
3828
3830
  if (i)
3829
3831
  for (const s of i)
3830
3832
  try {
3831
- return [JSON.parse(j.decrypt(n, s)), !1, !0];
3833
+ return [JSON.parse(q.decrypt(n, s)), !1, !0];
3832
3834
  } catch {
3833
3835
  }
3834
3836
  throw new Error("Failed to decrypt header with current and skipped header keys");
@@ -3837,8 +3839,8 @@ class st {
3837
3839
  var o;
3838
3840
  const [n, r, i] = this.decryptHeader(t);
3839
3841
  if (!i)
3840
- 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(
3841
- { authors: [this.state.theirNostrPublicKey], kinds: [Pe] },
3842
+ this.state.theirNextNostrPublicKey !== n.nextPublicKey && (this.state.theirCurrentNostrPublicKey = this.state.theirNextNostrPublicKey, this.state.theirNextNostrPublicKey = n.nextPublicKey, (o = this.nostrUnsubscribe) == null || o.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
3843
+ { authors: [this.state.theirNextNostrPublicKey], kinds: [He] },
3842
3844
  (a) => this.handleNostrEvent(a)
3843
3845
  )), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey));
3844
3846
  else if (!(It(t.pubkey, n.number) in this.state.skippedMessageKeys))
@@ -3849,14 +3851,14 @@ class st {
3849
3851
  subscribeToNostrEvents() {
3850
3852
  if (this.nostrNextUnsubscribe) return;
3851
3853
  this.nostrNextUnsubscribe = this.nostrSubscribe(
3852
- { authors: [this.state.theirNostrPublicKey], kinds: [Pe] },
3854
+ { authors: [this.state.theirNextNostrPublicKey], kinds: [He] },
3853
3855
  (n) => this.handleNostrEvent(n)
3854
3856
  );
3855
3857
  const t = Object.keys(this.state.skippedHeaderKeys);
3856
- t.length > 0 && (this.nostrUnsubscribe = this.nostrSubscribe(
3857
- { authors: t, kinds: [Pe] },
3858
+ this.state.theirCurrentNostrPublicKey && !t.includes(this.state.theirCurrentNostrPublicKey) && t.push(this.state.theirCurrentNostrPublicKey), this.nostrUnsubscribe = this.nostrSubscribe(
3859
+ { authors: t, kinds: [He] },
3858
3860
  (n) => this.handleNostrEvent(n)
3859
- ));
3861
+ );
3860
3862
  }
3861
3863
  }
3862
3864
  new TextDecoder("utf-8");
@@ -3867,12 +3869,12 @@ function Xe(e, t) {
3867
3869
  }
3868
3870
  class Me {
3869
3871
  constructor(t, n, r, i, s, o, a = []) {
3870
- this.inviterSessionPublicKey = t, this.linkSecret = n, this.inviter = r, this.inviterSessionPrivateKey = i, this.label = s, this.maxUses = o, this.usedBy = a;
3872
+ this.inviterEphemeralPublicKey = t, this.sharedSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.label = s, this.maxUses = o, this.usedBy = a;
3871
3873
  }
3872
3874
  static createNew(t, n, r) {
3873
3875
  if (!t)
3874
3876
  throw new Error("Inviter public key is required");
3875
- const i = Ce(), s = le(i), o = M(Ce());
3877
+ const i = ke(), s = le(i), o = M(ke());
3876
3878
  return new Me(
3877
3879
  s,
3878
3880
  o,
@@ -3893,9 +3895,9 @@ class Me {
3893
3895
  } catch (l) {
3894
3896
  throw new Error("Invite data in URL hash is not valid JSON: " + l);
3895
3897
  }
3896
- const { inviter: o, sessionKey: a, linkSecret: c } = s;
3898
+ const { inviter: o, ephemeralKey: a, sharedSecret: c } = s;
3897
3899
  if (!o || !a || !c)
3898
- throw new Error("Missing required fields (inviter, sessionKey, linkSecret) in invite data.");
3900
+ throw new Error("Missing required fields (inviter, ephemeralKey, sharedSecret) in invite data.");
3899
3901
  return new Me(
3900
3902
  a,
3901
3903
  c,
@@ -3905,10 +3907,10 @@ class Me {
3905
3907
  static deserialize(t) {
3906
3908
  const n = JSON.parse(t);
3907
3909
  return new Me(
3908
- n.inviterSessionPublicKey,
3909
- n.linkSecret,
3910
+ n.inviterEphemeralPublicKey,
3911
+ n.sharedSecret,
3910
3912
  n.inviter,
3911
- n.inviterSessionPrivateKey ? new Uint8Array(n.inviterSessionPrivateKey) : void 0,
3913
+ n.inviterEphemeralPrivateKey ? new Uint8Array(n.inviterEphemeralPrivateKey) : void 0,
3912
3914
  n.label,
3913
3915
  n.maxUses,
3914
3916
  n.usedBy
@@ -3920,9 +3922,9 @@ class Me {
3920
3922
  throw new Error("Event is not signed");
3921
3923
  if (!pt(t))
3922
3924
  throw new Error("Event signature is invalid");
3923
- const { tags: n } = t, r = (o = n.find(([c]) => c === "sessionKey")) == null ? void 0 : o[1], i = (a = n.find(([c]) => c === "linkSecret")) == null ? void 0 : a[1], s = t.pubkey;
3925
+ const { tags: n } = t, r = (o = n.find(([c]) => c === "ephemeralKey")) == null ? void 0 : o[1], i = (a = n.find(([c]) => c === "sharedSecret")) == null ? void 0 : a[1], s = t.pubkey;
3924
3926
  if (!r || !i)
3925
- throw new Error("Invalid invite event: missing session key or link secret");
3927
+ throw new Error("Invalid invite event: missing session key or sharedSecret");
3926
3928
  return new Me(
3927
3929
  r,
3928
3930
  i,
@@ -3954,10 +3956,10 @@ class Me {
3954
3956
  */
3955
3957
  serialize() {
3956
3958
  return JSON.stringify({
3957
- inviterSessionPublicKey: this.inviterSessionPublicKey,
3958
- linkSecret: this.linkSecret,
3959
+ inviterEphemeralPublicKey: this.inviterEphemeralPublicKey,
3960
+ sharedSecret: this.sharedSecret,
3959
3961
  inviter: this.inviter,
3960
- inviterSessionPrivateKey: this.inviterSessionPrivateKey ? Array.from(this.inviterSessionPrivateKey) : void 0,
3962
+ inviterEphemeralPrivateKey: this.inviterEphemeralPrivateKey ? Array.from(this.inviterEphemeralPrivateKey) : void 0,
3961
3963
  label: this.label,
3962
3964
  maxUses: this.maxUses,
3963
3965
  usedBy: this.usedBy
@@ -3969,10 +3971,10 @@ class Me {
3969
3971
  getUrl(t = "https://iris.to") {
3970
3972
  const n = {
3971
3973
  inviter: this.inviter,
3972
- sessionKey: this.inviterSessionPublicKey,
3973
- linkSecret: this.linkSecret
3974
+ ephemeralKey: this.inviterEphemeralPublicKey,
3975
+ sharedSecret: this.sharedSecret
3974
3976
  }, r = new URL(t);
3975
- return r.hash = encodeURIComponent(JSON.stringify(n)), console.log("url", r.toString()), r.toString();
3977
+ return r.hash = encodeURIComponent(JSON.stringify(n)), r.toString();
3976
3978
  }
3977
3979
  getEvent() {
3978
3980
  return {
@@ -3980,7 +3982,7 @@ class Me {
3980
3982
  pubkey: this.inviter,
3981
3983
  content: "",
3982
3984
  created_at: Math.floor(Date.now() / 1e3),
3983
- tags: [["sessionKey", this.inviterSessionPublicKey], ["linkSecret", this.linkSecret], ["d", "nostr-double-ratchet/invite"]]
3985
+ tags: [["ephemeralKey", this.inviterEphemeralPublicKey], ["sharedSecret", this.sharedSecret], ["d", "nostr-double-ratchet/invite"]]
3984
3986
  };
3985
3987
  }
3986
3988
  /**
@@ -3999,26 +4001,26 @@ class Me {
3999
4001
  * so the inviter can create the session on their side.
4000
4002
  */
4001
4003
  async accept(t, n, r) {
4002
- const i = Ce(), s = le(i), o = this.inviter || this.inviterSessionPublicKey, a = G(this.linkSecret), c = st.init(t, this.inviterSessionPublicKey, i, !0, a, void 0), l = Ce(), f = le(l), u = typeof r == "function" ? r : (p, h) => Promise.resolve(j.encrypt(p, Xe(r, h))), g = {
4004
+ const i = ke(), s = le(i), o = this.inviter || this.inviterEphemeralPublicKey, a = G(this.sharedSecret), c = st.init(t, this.inviterEphemeralPublicKey, i, !0, a, void 0), l = ke(), f = le(l), g = await (typeof r == "function" ? r : (h, d) => Promise.resolve(q.encrypt(h, Xe(r, d))))(s, o), b = {
4003
4005
  pubkey: n,
4004
- tags: [["secret", this.linkSecret]],
4005
- content: await u(s, o),
4006
+ tags: [["sharedSecret", this.sharedSecret]],
4007
+ content: await q.encrypt(g, a),
4006
4008
  created_at: Math.floor(Date.now() / 1e3)
4007
- }, b = {
4008
- kind: Pe,
4009
+ }, p = {
4010
+ kind: He,
4009
4011
  pubkey: f,
4010
- content: j.encrypt(JSON.stringify(g), Xe(l, this.inviterSessionPublicKey)),
4012
+ content: q.encrypt(JSON.stringify(b), Xe(l, this.inviterEphemeralPublicKey)),
4011
4013
  created_at: Math.floor(Date.now() / 1e3),
4012
- tags: [["p", this.inviterSessionPublicKey]]
4014
+ tags: [["p", this.inviterEphemeralPublicKey]]
4013
4015
  };
4014
- return { session: c, event: X(b, l) };
4016
+ return { session: c, event: X(p, l) };
4015
4017
  }
4016
4018
  listen(t, n, r) {
4017
- if (!this.inviterSessionPrivateKey)
4019
+ if (!this.inviterEphemeralPrivateKey)
4018
4020
  throw new Error("Inviter session key is not available");
4019
4021
  const i = {
4020
- kinds: [Pe],
4021
- "#p": [this.inviterSessionPublicKey]
4022
+ kinds: [He],
4023
+ "#p": [this.inviterEphemeralPublicKey]
4022
4024
  };
4023
4025
  return n(i, async (s) => {
4024
4026
  try {
@@ -4026,15 +4028,15 @@ class Me {
4026
4028
  console.error("Invite has reached maximum number of uses");
4027
4029
  return;
4028
4030
  }
4029
- const o = await j.decrypt(s.content, Xe(this.inviterSessionPrivateKey, s.pubkey)), a = JSON.parse(o);
4030
- if (!a.tags || !a.tags.some(([p, h]) => p === "secret" && h === this.linkSecret)) {
4031
+ const o = await q.decrypt(s.content, Xe(this.inviterEphemeralPrivateKey, s.pubkey)), a = JSON.parse(o);
4032
+ if (!a.tags || !a.tags.some(([h, d]) => h === "sharedSecret" && d === this.sharedSecret)) {
4031
4033
  console.error("Invalid secret from event", s);
4032
4034
  return;
4033
4035
  }
4034
- const c = typeof t == "function" ? t : (p, h) => Promise.resolve(j.decrypt(p, Xe(t, h))), l = a.pubkey;
4036
+ const c = G(this.sharedSecret), l = a.pubkey;
4035
4037
  this.usedBy.push(l);
4036
- const f = await c(a.content, l), u = G(this.linkSecret), g = s.id, b = st.init(n, f, this.inviterSessionPrivateKey, !1, u, g);
4037
- r(b, l);
4038
+ const f = await q.decrypt(a.content, c), g = await (typeof t == "function" ? t : (h, d) => Promise.resolve(q.decrypt(h, Xe(t, d))))(f, l), b = s.id, p = st.init(n, g, this.inviterEphemeralPrivateKey, !1, c, b);
4039
+ r(p, l);
4038
4040
  } catch (o) {
4039
4041
  console.error("Error processing invite message:", o, "event", s);
4040
4042
  }
@@ -4045,7 +4047,7 @@ export {
4045
4047
  jn as INVITE_EVENT_KIND,
4046
4048
  Me as Invite,
4047
4049
  nu as MAX_SKIP,
4048
- Pe as MESSAGE_EVENT_KIND,
4050
+ He as MESSAGE_EVENT_KIND,
4049
4051
  Gc as Sender,
4050
4052
  st as Session,
4051
4053
  su as createMessageStream,