nostr-double-ratchet 0.0.25 → 0.0.26

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.
@@ -214,8 +214,8 @@ let Ii = class extends Ci {
214
214
  for (let u = 0; u < 16; u++, n += 4)
215
215
  ve[u] = t.getUint32(n, !1);
216
216
  for (let u = 16; u < 64; u++) {
217
- const g = ve[u - 15], w = ve[u - 2], y = re(g, 7) ^ re(g, 18) ^ g >>> 3, h = re(w, 17) ^ re(w, 19) ^ w >>> 10;
218
- ve[u] = h + ve[u - 7] + y + ve[u - 16] | 0;
217
+ const g = ve[u - 15], w = ve[u - 2], p = re(g, 7) ^ re(g, 18) ^ g >>> 3, h = re(w, 17) ^ re(w, 19) ^ w >>> 10;
218
+ ve[u] = h + ve[u - 7] + p + ve[u - 16] | 0;
219
219
  }
220
220
  let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
221
221
  for (let u = 0; u < 64; u++) {
@@ -475,8 +475,8 @@ function zi(e) {
475
475
  let w = 1;
476
476
  for (let h = c.sqr(g); w < l && !c.eql(h, c.ONE); w++)
477
477
  h = c.sqr(h);
478
- const y = c.pow(f, j << BigInt(l - w - 1));
479
- f = c.sqr(y), u = c.mul(u, y), g = c.mul(g, f), l = w;
478
+ const p = c.pow(f, j << BigInt(l - w - 1));
479
+ f = c.sqr(p), u = c.mul(u, p), g = c.mul(g, f), l = w;
480
480
  }
481
481
  return u;
482
482
  };
@@ -667,12 +667,12 @@ function Qi(e, t) {
667
667
  const { windows: c, windowSize: a } = r(i);
668
668
  let l = e.ZERO, f = e.BASE;
669
669
  const u = BigInt(2 ** i - 1), g = 2 ** i, w = BigInt(i);
670
- for (let y = 0; y < c; y++) {
671
- const h = y * a;
670
+ for (let p = 0; p < c; p++) {
671
+ const h = p * a;
672
672
  let d = Number(o & u);
673
673
  o >>= w, d > a && (d -= g, o += St);
674
- const p = h, E = h + Math.abs(d) - 1, S = y % 2 !== 0, I = d < 0;
675
- d === 0 ? f = f.add(n(S, s[p])) : l = l.add(n(I, s[E]));
674
+ const y = h, E = h + Math.abs(d) - 1, S = p % 2 !== 0, I = d < 0;
675
+ d === 0 ? f = f.add(n(S, s[y])) : l = l.add(n(I, s[E]));
676
676
  }
677
677
  return { p: l, f };
678
678
  },
@@ -768,65 +768,65 @@ BigInt(2);
768
768
  const kn = BigInt(3);
769
769
  BigInt(4);
770
770
  function rs(e) {
771
- const t = es(e), { Fp: n } = t, r = t.toBytes || ((y, h, d) => {
772
- const p = h.toAffine();
773
- return _e(Uint8Array.from([4]), n.toBytes(p.x), n.toBytes(p.y));
774
- }), i = t.fromBytes || ((y) => {
775
- const h = y.subarray(1), d = n.fromBytes(h.subarray(0, n.BYTES)), p = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
776
- return { x: d, y: p };
771
+ const t = es(e), { Fp: n } = t, r = t.toBytes || ((p, h, d) => {
772
+ const y = h.toAffine();
773
+ return _e(Uint8Array.from([4]), n.toBytes(y.x), n.toBytes(y.y));
774
+ }), i = t.fromBytes || ((p) => {
775
+ const h = p.subarray(1), d = n.fromBytes(h.subarray(0, n.BYTES)), y = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
776
+ return { x: d, y };
777
777
  });
778
- function s(y) {
779
- const { a: h, b: d } = t, p = n.sqr(y), E = n.mul(p, y);
780
- return n.add(n.add(E, n.mul(y, h)), d);
778
+ function s(p) {
779
+ const { a: h, b: d } = t, y = n.sqr(p), E = n.mul(y, p);
780
+ return n.add(n.add(E, n.mul(p, h)), d);
781
781
  }
782
782
  if (!n.eql(n.sqr(t.Gy), s(t.Gx)))
783
783
  throw new Error("bad generator point: equation left != right");
784
- function o(y) {
785
- return typeof y == "bigint" && ae < y && y < t.n;
784
+ function o(p) {
785
+ return typeof p == "bigint" && ae < p && p < t.n;
786
786
  }
787
- function c(y) {
788
- if (!o(y))
787
+ function c(p) {
788
+ if (!o(p))
789
789
  throw new Error("Expected valid bigint: 0 < bigint < curve.n");
790
790
  }
791
- function a(y) {
792
- const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: p, n: E } = t;
793
- if (h && typeof y != "bigint") {
794
- if (y instanceof Uint8Array && (y = De(y)), typeof y != "string" || !h.includes(y.length))
791
+ function a(p) {
792
+ const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: y, n: E } = t;
793
+ if (h && typeof p != "bigint") {
794
+ if (p instanceof Uint8Array && (p = De(p)), typeof p != "string" || !h.includes(p.length))
795
795
  throw new Error("Invalid key");
796
- y = y.padStart(d * 2, "0");
796
+ p = p.padStart(d * 2, "0");
797
797
  }
798
798
  let S;
799
799
  try {
800
- S = typeof y == "bigint" ? y : F(Z("private key", y, d));
800
+ S = typeof p == "bigint" ? p : F(Z("private key", p, d));
801
801
  } catch {
802
- throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof y}`);
802
+ throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof p}`);
803
803
  }
804
- return p && (S = W(S, E)), c(S), S;
804
+ return y && (S = W(S, E)), c(S), S;
805
805
  }
806
806
  const l = /* @__PURE__ */ new Map();
807
- function f(y) {
808
- if (!(y instanceof u))
807
+ function f(p) {
808
+ if (!(p instanceof u))
809
809
  throw new Error("ProjectivePoint expected");
810
810
  }
811
811
  class u {
812
- constructor(h, d, p) {
813
- if (this.px = h, this.py = d, this.pz = p, h == null || !n.isValid(h))
812
+ constructor(h, d, y) {
813
+ if (this.px = h, this.py = d, this.pz = y, h == null || !n.isValid(h))
814
814
  throw new Error("x required");
815
815
  if (d == null || !n.isValid(d))
816
816
  throw new Error("y required");
817
- if (p == null || !n.isValid(p))
817
+ if (y == null || !n.isValid(y))
818
818
  throw new Error("z required");
819
819
  }
820
820
  // Does not validate if the point is on-curve.
821
821
  // Use fromHex instead, or call assertValidity() later.
822
822
  static fromAffine(h) {
823
- const { x: d, y: p } = h || {};
824
- if (!h || !n.isValid(d) || !n.isValid(p))
823
+ const { x: d, y } = h || {};
824
+ if (!h || !n.isValid(d) || !n.isValid(y))
825
825
  throw new Error("invalid affine point");
826
826
  if (h instanceof u)
827
827
  throw new Error("projective point not allowed");
828
828
  const E = (S) => n.eql(S, n.ZERO);
829
- return E(d) && E(p) ? u.ZERO : new u(d, p, n.ONE);
829
+ return E(d) && E(y) ? u.ZERO : new u(d, y, n.ONE);
830
830
  }
831
831
  get x() {
832
832
  return this.toAffine().x;
@@ -841,8 +841,8 @@ function rs(e) {
841
841
  * Optimization: converts a list of projective points to a list of identical points with Z=1.
842
842
  */
843
843
  static normalizeZ(h) {
844
- const d = n.invertBatch(h.map((p) => p.pz));
845
- return h.map((p, E) => p.toAffine(d[E])).map(u.fromAffine);
844
+ const d = n.invertBatch(h.map((y) => y.pz));
845
+ return h.map((y, E) => y.toAffine(d[E])).map(u.fromAffine);
846
846
  }
847
847
  /**
848
848
  * Converts hash string or Uint8Array to Point.
@@ -870,8 +870,8 @@ function rs(e) {
870
870
  const { x: h, y: d } = this.toAffine();
871
871
  if (!n.isValid(h) || !n.isValid(d))
872
872
  throw new Error("bad point: x or y not FE");
873
- const p = n.sqr(d), E = s(h);
874
- if (!n.eql(p, E))
873
+ const y = n.sqr(d), E = s(h);
874
+ if (!n.eql(y, E))
875
875
  throw new Error("bad point: equation left != right");
876
876
  if (!this.isTorsionFree())
877
877
  throw new Error("bad point: not in prime-order subgroup");
@@ -887,7 +887,7 @@ function rs(e) {
887
887
  */
888
888
  equals(h) {
889
889
  f(h);
890
- const { px: d, py: p, pz: E } = this, { px: S, py: I, pz: B } = h, m = n.eql(n.mul(d, B), n.mul(S, E)), x = n.eql(n.mul(p, B), n.mul(I, E));
890
+ const { px: d, py: y, pz: E } = this, { px: S, py: I, pz: B } = h, m = n.eql(n.mul(d, B), n.mul(S, E)), x = n.eql(n.mul(y, B), n.mul(I, 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, p = n.mul(d, kn), { px: E, py: S, pz: I } = this;
904
+ const { a: h, b: d } = t, y = n.mul(d, kn), { px: E, py: S, pz: I } = this;
905
905
  let B = n.ZERO, m = n.ZERO, x = n.ZERO, K = n.mul(E, E), M = n.mul(S, S), _ = n.mul(I, I), A = n.mul(E, S);
906
- return A = n.add(A, A), x = n.mul(E, I), x = n.add(x, x), B = n.mul(h, x), m = n.mul(p, _), m = n.add(B, m), B = n.sub(M, m), m = n.add(M, m), m = n.mul(B, m), B = n.mul(A, B), x = n.mul(p, x), _ = n.mul(h, _), A = n.sub(K, _), A = n.mul(h, A), A = n.add(A, x), x = n.add(K, K), K = n.add(x, K), K = n.add(K, _), K = n.mul(K, A), m = n.add(m, K), _ = n.mul(S, I), _ = n.add(_, _), K = n.mul(_, A), B = n.sub(B, K), x = n.mul(_, M), x = n.add(x, x), x = n.add(x, x), new u(B, m, x);
906
+ return A = n.add(A, A), x = n.mul(E, I), x = n.add(x, x), B = n.mul(h, x), m = n.mul(y, _), m = n.add(B, m), B = n.sub(M, m), m = n.add(M, m), m = n.mul(B, m), B = n.mul(A, B), x = n.mul(y, x), _ = n.mul(h, _), A = n.sub(K, _), A = n.mul(h, A), A = n.add(A, x), x = n.add(K, K), K = n.add(x, K), K = n.add(K, _), K = n.mul(K, A), m = n.add(m, K), _ = n.mul(S, I), _ = n.add(_, _), K = n.mul(_, A), B = n.sub(B, K), x = n.mul(_, M), 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: p, pz: E } = this, { px: S, py: I, pz: B } = h;
914
+ const { px: d, py: y, pz: E } = this, { px: S, py: I, pz: B } = h;
915
915
  let m = n.ZERO, x = n.ZERO, K = n.ZERO;
916
916
  const M = t.a, _ = n.mul(t.b, kn);
917
- let A = n.mul(d, S), T = n.mul(p, I), R = n.mul(E, B), H = n.add(d, p), b = n.add(S, I);
917
+ let A = n.mul(d, S), T = n.mul(y, I), R = n.mul(E, B), H = n.add(d, y), b = n.add(S, I);
918
918
  H = n.mul(H, b), b = n.add(A, T), H = n.sub(H, b), b = n.add(d, E);
919
919
  let v = n.add(S, B);
920
- return b = n.mul(b, v), v = n.add(A, R), b = n.sub(b, v), v = n.add(p, E), m = n.add(I, B), v = n.mul(v, m), m = n.add(T, R), v = n.sub(v, m), K = n.mul(M, b), m = n.mul(_, R), K = n.add(m, K), m = n.sub(T, K), K = n.add(T, K), x = n.mul(m, K), T = n.add(A, A), T = n.add(T, A), R = n.mul(M, R), b = n.mul(_, b), T = n.add(T, R), R = n.sub(A, R), R = n.mul(M, R), b = n.add(b, R), A = n.mul(T, b), x = n.add(x, A), A = n.mul(v, b), m = n.mul(H, m), m = n.sub(m, A), A = n.mul(H, T), K = n.mul(v, K), K = n.add(K, A), new u(m, x, K);
920
+ return b = n.mul(b, v), v = n.add(A, R), b = n.sub(b, v), v = n.add(y, E), m = n.add(I, B), v = n.mul(v, m), m = n.add(T, R), v = n.sub(v, m), K = n.mul(M, b), m = n.mul(_, R), K = n.add(m, K), m = n.sub(T, K), K = n.add(T, K), x = n.mul(m, K), T = n.add(A, A), T = n.add(T, A), R = n.mul(M, R), b = n.mul(_, b), T = n.add(T, R), R = n.sub(A, R), R = n.mul(M, R), b = n.add(b, R), A = n.mul(T, b), x = n.add(x, A), A = n.mul(v, b), m = n.mul(H, m), m = n.sub(m, A), A = n.mul(H, T), K = n.mul(v, K), K = n.add(K, A), new u(m, x, K);
921
921
  }
922
922
  subtract(h) {
923
923
  return this.add(h.negate());
@@ -927,8 +927,8 @@ function rs(e) {
927
927
  }
928
928
  wNAF(h) {
929
929
  return w.wNAFCached(this, l, h, (d) => {
930
- const p = n.invertBatch(d.map((E) => E.pz));
931
- return d.map((E, S) => E.toAffine(p[S])).map(u.fromAffine);
930
+ const y = n.invertBatch(d.map((E) => E.pz));
931
+ return d.map((E, S) => E.toAffine(y[S])).map(u.fromAffine);
932
932
  });
933
933
  }
934
934
  /**
@@ -942,13 +942,13 @@ function rs(e) {
942
942
  return d;
943
943
  if (c(h), h === X)
944
944
  return this;
945
- const { endo: p } = t;
946
- if (!p)
945
+ const { endo: y } = t;
946
+ if (!y)
947
947
  return w.unsafeLadder(this, h);
948
- let { k1neg: E, k1: S, k2neg: I, k2: B } = p.splitScalar(h), m = d, x = d, K = this;
948
+ let { k1neg: E, k1: S, k2neg: I, k2: B } = y.splitScalar(h), m = d, x = d, K = this;
949
949
  for (; S > ae || B > ae; )
950
950
  S & X && (m = m.add(K)), B & X && (x = x.add(K)), K = K.double(), S >>= X, B >>= X;
951
- return E && (m = m.negate()), I && (x = x.negate()), x = new u(n.mul(x.px, p.beta), x.py, x.pz), m.add(x);
951
+ return E && (m = m.negate()), I && (x = x.negate()), x = new u(n.mul(x.px, y.beta), x.py, x.pz), m.add(x);
952
952
  }
953
953
  /**
954
954
  * Constant time multiplication.
@@ -961,17 +961,17 @@ function rs(e) {
961
961
  */
962
962
  multiply(h) {
963
963
  c(h);
964
- let d = h, p, E;
964
+ let d = h, y, E;
965
965
  const { endo: S } = t;
966
966
  if (S) {
967
967
  const { k1neg: I, k1: B, k2neg: m, k2: x } = S.splitScalar(d);
968
968
  let { p: K, f: M } = this.wNAF(B), { p: _, f: A } = this.wNAF(x);
969
- K = w.constTimeNegate(I, K), _ = w.constTimeNegate(m, _), _ = new u(n.mul(_.px, S.beta), _.py, _.pz), p = K.add(_), E = M.add(A);
969
+ K = w.constTimeNegate(I, K), _ = w.constTimeNegate(m, _), _ = new u(n.mul(_.px, S.beta), _.py, _.pz), y = K.add(_), E = M.add(A);
970
970
  } else {
971
971
  const { p: I, f: B } = this.wNAF(d);
972
- p = I, E = B;
972
+ y = I, E = B;
973
973
  }
974
- return u.normalizeZ([p, E])[0];
974
+ return u.normalizeZ([y, E])[0];
975
975
  }
976
976
  /**
977
977
  * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
@@ -979,17 +979,17 @@ function rs(e) {
979
979
  * The trick could be useful if both P and Q are not G (not in our case).
980
980
  * @returns non-zero affine point
981
981
  */
982
- multiplyAndAddUnsafe(h, d, p) {
983
- const E = u.BASE, S = (B, m) => m === ae || m === X || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), I = S(this, d).add(S(h, p));
982
+ multiplyAndAddUnsafe(h, d, y) {
983
+ const E = u.BASE, S = (B, m) => m === ae || m === X || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), I = S(this, d).add(S(h, y));
984
984
  return I.is0() ? void 0 : I;
985
985
  }
986
986
  // Converts Projective point to affine (x, y) coordinates.
987
987
  // Can accept precomputed Z^-1 - for example, from invertBatch.
988
988
  // (x, y, z) ∋ (x=x/z, y=y/z)
989
989
  toAffine(h) {
990
- const { px: d, py: p, pz: E } = this, S = this.is0();
990
+ const { px: d, py: y, pz: E } = this, S = this.is0();
991
991
  h == null && (h = S ? n.ONE : n.inv(E));
992
- const I = n.mul(d, h), B = n.mul(p, h), m = n.mul(E, h);
992
+ const I = n.mul(d, h), B = n.mul(y, h), m = n.mul(E, h);
993
993
  if (S)
994
994
  return { x: n.ZERO, y: n.ZERO };
995
995
  if (!n.eql(m, n.ONE))
@@ -1071,28 +1071,28 @@ function ss(e) {
1071
1071
  throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`);
1072
1072
  }
1073
1073
  }), w = (b) => De(Ne(b, t.nByteLength));
1074
- function y(b) {
1074
+ function p(b) {
1075
1075
  const v = r >> X;
1076
1076
  return b > v;
1077
1077
  }
1078
1078
  function h(b) {
1079
- return y(b) ? c(-b) : b;
1079
+ return p(b) ? c(-b) : b;
1080
1080
  }
1081
1081
  const d = (b, v, N) => F(b.slice(v, N));
1082
- class p {
1082
+ class y {
1083
1083
  constructor(v, N, k) {
1084
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
1088
  const N = t.nByteLength;
1089
- return v = Z("compactSignature", v, N * 2), new p(d(v, 0, N), d(v, N, 2 * N));
1089
+ return v = Z("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
1094
  const { r: N, s: k } = Be.toSig(Z("DER", v));
1095
- return new p(N, k);
1095
+ return new y(N, k);
1096
1096
  }
1097
1097
  assertValidity() {
1098
1098
  if (!g(this.r))
@@ -1101,7 +1101,7 @@ function ss(e) {
1101
1101
  throw new Error("s must be 0 < s < CURVE.n");
1102
1102
  }
1103
1103
  addRecoveryBit(v) {
1104
- return new p(this.r, this.s, v);
1104
+ return new y(this.r, this.s, v);
1105
1105
  }
1106
1106
  recoverPublicKey(v) {
1107
1107
  const { r: N, s: k, recovery: C } = this, U = x(Z("msgHash", v));
@@ -1117,10 +1117,10 @@ function ss(e) {
1117
1117
  }
1118
1118
  // Signatures should be low-s, to prevent malleability.
1119
1119
  hasHighS() {
1120
- return y(this.s);
1120
+ return p(this.s);
1121
1121
  }
1122
1122
  normalizeS() {
1123
- return this.hasHighS() ? new p(this.r, c(-this.s), this.recovery) : this;
1123
+ return this.hasHighS() ? new y(this.r, c(-this.s), this.recovery) : this;
1124
1124
  }
1125
1125
  // DER-encoded
1126
1126
  toDERRawBytes() {
@@ -1216,7 +1216,7 @@ function ss(e) {
1216
1216
  if (Te === ae)
1217
1217
  return;
1218
1218
  let Kn = ($e.x === te ? 0 : 2) | Number($e.y & X), Nn = Te;
1219
- return U && y(Te) && (Nn = h(Te), Kn ^= 1), new p(te, Nn, Kn);
1219
+ return U && p(Te) && (Nn = h(Te), Kn ^= 1), new y(te, Nn, Kn);
1220
1220
  }
1221
1221
  return { seed: We, k2sig: Et };
1222
1222
  }
@@ -1236,15 +1236,15 @@ function ss(e) {
1236
1236
  try {
1237
1237
  if (typeof C == "string" || C instanceof Uint8Array)
1238
1238
  try {
1239
- $ = p.fromDER(C);
1239
+ $ = y.fromDER(C);
1240
1240
  } catch (te) {
1241
1241
  if (!(te instanceof Be.Err))
1242
1242
  throw te;
1243
- $ = p.fromCompact(C);
1243
+ $ = y.fromCompact(C);
1244
1244
  }
1245
1245
  else if (typeof C == "object" && typeof C.r == "bigint" && typeof C.s == "bigint") {
1246
1246
  const { r: te, s: Te } = C;
1247
- $ = new p(te, Te);
1247
+ $ = new y(te, Te);
1248
1248
  } else
1249
1249
  throw new Error("PARSE");
1250
1250
  ee = l.fromHex(N);
@@ -1266,7 +1266,7 @@ function ss(e) {
1266
1266
  sign: R,
1267
1267
  verify: H,
1268
1268
  ProjectivePoint: l,
1269
- Signature: p,
1269
+ Signature: y,
1270
1270
  utils: E
1271
1271
  };
1272
1272
  }
@@ -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), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = Y(f, n, t) * f % t, g = Y(u, n, t) * f % t, w = Y(g, nt, t) * l % t, y = Y(w, i, t) * w % t, h = Y(y, s, t) * y % t, d = Y(h, c, t) * h % t, p = Y(d, a, t) * d % t, E = Y(p, c, t) * h % t, S = Y(E, n, t) * f % t, I = Y(S, o, t) * y % t, B = Y(I, r, t) * l % t, m = Y(B, nt, t);
1325
+ const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = Y(f, n, t) * f % t, g = Y(u, n, t) * f % t, w = Y(g, nt, t) * l % t, p = Y(w, i, t) * w % t, h = Y(p, s, t) * p % t, d = Y(h, c, t) * h % t, y = Y(d, a, t) * d % t, E = Y(y, c, t) * h % t, S = Y(E, n, t) * f % t, I = Y(S, o, t) * p % t, B = Y(I, r, t) * l % t, m = Y(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;
@@ -1449,13 +1449,13 @@ function z(e) {
1449
1449
  }
1450
1450
  return n;
1451
1451
  }
1452
- function ps(e) {
1452
+ function ys(e) {
1453
1453
  if (typeof e != "string")
1454
1454
  throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
1455
1455
  return new Uint8Array(new TextEncoder().encode(e));
1456
1456
  }
1457
1457
  function Je(e) {
1458
- if (typeof e == "string" && (e = ps(e)), !Qt(e))
1458
+ if (typeof e == "string" && (e = ys(e)), !Qt(e))
1459
1459
  throw new Error(`expected Uint8Array, got ${typeof e}`);
1460
1460
  return e;
1461
1461
  }
@@ -1487,7 +1487,7 @@ function Mt(e) {
1487
1487
  if (!Number.isSafeInteger(e) || e < 0)
1488
1488
  throw new Error(`Wrong positive integer: ${e}`);
1489
1489
  }
1490
- function ys(e) {
1490
+ function ps(e) {
1491
1491
  if (typeof e != "boolean")
1492
1492
  throw new Error(`Expected boolean, not ${e}`);
1493
1493
  }
@@ -1516,7 +1516,7 @@ function bs(e, t) {
1516
1516
  }
1517
1517
  const se = {
1518
1518
  number: Mt,
1519
- bool: ys,
1519
+ bool: ps,
1520
1520
  bytes: hr,
1521
1521
  hash: gs,
1522
1522
  exists: ws,
@@ -1669,8 +1669,8 @@ class dr extends ms {
1669
1669
  for (let u = 0; u < 16; u++, n += 4)
1670
1670
  Ee[u] = t.getUint32(n, !1);
1671
1671
  for (let u = 16; u < 64; u++) {
1672
- const g = Ee[u - 15], w = Ee[u - 2], y = ie(g, 7) ^ ie(g, 18) ^ g >>> 3, h = ie(w, 17) ^ ie(w, 19) ^ w >>> 10;
1673
- Ee[u] = h + Ee[u - 7] + y + Ee[u - 16] | 0;
1672
+ const g = Ee[u - 15], w = Ee[u - 2], p = ie(g, 7) ^ ie(g, 18) ^ g >>> 3, h = ie(w, 17) ^ ie(w, 19) ^ w >>> 10;
1673
+ Ee[u] = h + Ee[u - 7] + p + Ee[u - 16] | 0;
1674
1674
  }
1675
1675
  let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
1676
1676
  for (let u = 0; u < 64; u++) {
@@ -1702,7 +1702,7 @@ function de(...e) {
1702
1702
  const t = (i, s) => (o) => i(s(o)), n = Array.from(e).reverse().reduce((i, s) => i ? t(i, s.encode) : s.encode, void 0), r = e.reduce((i, s) => i ? t(i, s.decode) : s.decode, void 0);
1703
1703
  return { encode: n, decode: r };
1704
1704
  }
1705
- function pe(e) {
1705
+ function ye(e) {
1706
1706
  return {
1707
1707
  encode: (t) => {
1708
1708
  if (!Array.isArray(t) || t.length && typeof t[0] != "number")
@@ -1727,7 +1727,7 @@ function pe(e) {
1727
1727
  }
1728
1728
  };
1729
1729
  }
1730
- function ye(e = "") {
1730
+ function pe(e = "") {
1731
1731
  if (typeof e != "string")
1732
1732
  throw new Error("join separator should be string");
1733
1733
  return {
@@ -1776,7 +1776,7 @@ function ft(e, t = "=") {
1776
1776
  }
1777
1777
  };
1778
1778
  }
1779
- function pr(e) {
1779
+ function yr(e) {
1780
1780
  if (typeof e != "function")
1781
1781
  throw new Error("normalize fn should be function");
1782
1782
  return { encode: (t) => t, decode: (t) => e(t) };
@@ -1814,7 +1814,7 @@ function Un(e, t, n) {
1814
1814
  i.push(0);
1815
1815
  return i.reverse();
1816
1816
  }
1817
- const yr = (e, t) => t ? yr(t, e % t) : e, it = (e, t) => e + (t - yr(e, t));
1817
+ const pr = (e, t) => t ? pr(t, e % t) : e, it = (e, t) => e + (t - pr(e, t));
1818
1818
  function Ht(e, t, n, r) {
1819
1819
  if (!Array.isArray(e))
1820
1820
  throw new Error("convertRadix2: data should be array");
@@ -1883,10 +1883,10 @@ function Ln(e) {
1883
1883
  }
1884
1884
  };
1885
1885
  }
1886
- const As = 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");
1886
+ const As = de(Se(4), ye("0123456789ABCDEF"), pe("")), Cs = de(Se(5), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ft(5), pe(""));
1887
+ de(Se(5), ye("0123456789ABCDEFGHIJKLMNOPQRSTUV"), ft(5), pe(""));
1888
+ de(Se(5), ye("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), pe(""), yr((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
+ const he = de(Se(6), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ft(6), pe("")), Bs = de(Se(6), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ft(6), pe("")), en = (e) => de(Ss(58), ye(e), pe("")), qt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
1890
  en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
1891
  en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1892
1892
  const $n = [0, 2, 3, 5, 6, 7, 9, 10, 11], ks = {
@@ -1909,7 +1909,7 @@ const $n = [0, 2, 3, 5, 6, 7, 9, 10, 11], ks = {
1909
1909
  }
1910
1910
  return Uint8Array.from(t);
1911
1911
  }
1912
- }, Dt = de(pe("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), ye("")), Tn = [996825010, 642813549, 513874426, 1027748829, 705979059];
1912
+ }, Dt = de(ye("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), pe("")), Tn = [996825010, 642813549, 513874426, 1027748829, 705979059];
1913
1913
  function Ge(e) {
1914
1914
  const t = e >> 25;
1915
1915
  let n = (e & 33554431) << 5;
@@ -1959,13 +1959,13 @@ function gr(e) {
1959
1959
  const w = f.lastIndexOf("1");
1960
1960
  if (w === 0 || w === -1)
1961
1961
  throw new Error('Letter "1" must be present between prefix and data only');
1962
- const y = f.slice(0, w), h = f.slice(w + 1);
1962
+ const p = f.slice(0, w), h = f.slice(w + 1);
1963
1963
  if (h.length < 6)
1964
1964
  throw new Error("Data must be at least 6 characters long");
1965
- const d = Dt.decode(h).slice(0, -6), p = Rn(y, d, t);
1966
- if (!h.endsWith(p))
1967
- throw new Error(`Invalid checksum in ${f}: expected "${p}"`);
1968
- return { prefix: y, words: d };
1965
+ const d = Dt.decode(h).slice(0, -6), y = Rn(p, d, t);
1966
+ if (!h.endsWith(y))
1967
+ throw new Error(`Invalid checksum in ${f}: expected "${y}"`);
1968
+ return { prefix: p, words: d };
1969
1969
  }
1970
1970
  const a = Ln(c);
1971
1971
  function l(f) {
@@ -1979,7 +1979,7 @@ gr("bech32m");
1979
1979
  const _s = {
1980
1980
  encode: (e) => new TextDecoder().decode(e),
1981
1981
  decode: (e) => new TextEncoder().encode(e)
1982
- }, Is = de(Se(4), pe("0123456789abcdef"), ye(""), pr((e) => {
1982
+ }, Is = de(Se(4), ye("0123456789abcdef"), pe(""), yr((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();
@@ -2103,9 +2103,9 @@ function Pn(e, t, n, r, i) {
2103
2103
  let a = 0;
2104
2104
  t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2105
2105
  const l = e.length / 4 - 2;
2106
- for (let y = 0; y < l; y++) {
2107
- const h = e[a++] ^ xe(o, c, t, n, r, i), d = e[a++] ^ xe(o, c, n, r, i, t), p = e[a++] ^ xe(o, c, r, i, t, n), E = e[a++] ^ xe(o, c, i, t, n, r);
2108
- t = h, n = d, r = p, i = E;
2106
+ for (let p = 0; p < l; p++) {
2107
+ const h = e[a++] ^ xe(o, c, t, n, r, i), d = e[a++] ^ xe(o, c, n, r, i, t), y = e[a++] ^ xe(o, c, r, i, t, n), E = e[a++] ^ xe(o, c, i, t, n, r);
2108
+ t = h, n = d, r = y, i = E;
2109
2109
  }
2110
2110
  const f = e[a++] ^ oe(s, t, n, r, i), u = e[a++] ^ oe(s, n, r, i, t), g = e[a++] ^ oe(s, r, i, t, n), w = e[a++] ^ oe(s, i, t, n, r);
2111
2111
  return { s0: f, s1: u, s2: g, s3: w };
@@ -2115,9 +2115,9 @@ function js(e, t, n, r, i) {
2115
2115
  let a = 0;
2116
2116
  t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2117
2117
  const l = e.length / 4 - 2;
2118
- for (let y = 0; y < l; y++) {
2119
- const h = e[a++] ^ xe(o, c, t, i, r, n), d = e[a++] ^ xe(o, c, n, t, i, r), p = e[a++] ^ xe(o, c, r, n, t, i), E = e[a++] ^ xe(o, c, i, r, n, t);
2120
- t = h, n = d, r = p, i = E;
2118
+ for (let p = 0; p < l; p++) {
2119
+ const h = e[a++] ^ xe(o, c, t, i, r, n), d = e[a++] ^ xe(o, c, n, t, i, r), y = e[a++] ^ xe(o, c, r, n, t, i), E = e[a++] ^ xe(o, c, i, r, n, t);
2120
+ t = h, n = d, r = y, i = E;
2121
2121
  }
2122
2122
  const f = e[a++] ^ oe(s, t, i, r, n), u = e[a++] ^ oe(s, n, t, i, r), g = e[a++] ^ oe(s, r, n, t, i), w = e[a++] ^ oe(s, i, r, n, t);
2123
2123
  return { s0: f, s1: u, s2: g, s3: w };
@@ -2175,24 +2175,24 @@ const Er = /* @__PURE__ */ Os({ blockSize: 16, nonceLength: 16 }, function(t, n,
2175
2175
  return {
2176
2176
  encrypt: (s, o) => {
2177
2177
  const c = vr(t), { b: a, o: l, out: f } = Vs(s, i, o), u = G(n);
2178
- let g = u[0], w = u[1], y = u[2], h = u[3], d = 0;
2178
+ let g = u[0], w = u[1], p = u[2], h = u[3], d = 0;
2179
2179
  for (; d + 4 <= a.length; )
2180
- g ^= a[d + 0], w ^= a[d + 1], y ^= a[d + 2], h ^= a[d + 3], { s0: g, s1: w, s2: y, s3: h } = Pn(c, g, w, y, h), l[d++] = g, l[d++] = w, l[d++] = y, l[d++] = h;
2180
+ g ^= a[d + 0], w ^= a[d + 1], p ^= a[d + 2], h ^= a[d + 3], { s0: g, s1: w, s2: p, s3: h } = Pn(c, g, w, p, h), l[d++] = g, l[d++] = w, l[d++] = p, l[d++] = h;
2181
2181
  if (i) {
2182
- const p = Zs(s.subarray(d * 4));
2183
- g ^= p[0], w ^= p[1], y ^= p[2], h ^= p[3], { s0: g, s1: w, s2: y, s3: h } = Pn(c, g, w, y, h), l[d++] = g, l[d++] = w, l[d++] = y, l[d++] = h;
2182
+ const y = Zs(s.subarray(d * 4));
2183
+ g ^= y[0], w ^= y[1], p ^= y[2], h ^= y[3], { s0: g, s1: w, s2: p, s3: h } = Pn(c, g, w, p, h), l[d++] = g, l[d++] = w, l[d++] = p, l[d++] = h;
2184
2184
  }
2185
2185
  return c.fill(0), f;
2186
2186
  },
2187
2187
  decrypt: (s, o) => {
2188
2188
  zs(s);
2189
2189
  const c = Ds(t), a = G(n), l = mr(s.length, o), f = G(s), u = G(l);
2190
- let g = a[0], w = a[1], y = a[2], h = a[3];
2190
+ let g = a[0], w = a[1], p = a[2], h = a[3];
2191
2191
  for (let d = 0; d + 4 <= f.length; ) {
2192
- const p = g, E = w, S = y, I = h;
2193
- g = f[d + 0], w = f[d + 1], y = f[d + 2], h = f[d + 3];
2194
- const { s0: B, s1: m, s2: x, s3: K } = js(c, g, w, y, h);
2195
- u[d++] = B ^ p, u[d++] = m ^ E, u[d++] = x ^ S, u[d++] = K ^ I;
2192
+ const y = g, E = w, S = p, I = h;
2193
+ g = f[d + 0], w = f[d + 1], p = f[d + 2], h = f[d + 3];
2194
+ const { s0: B, s1: m, s2: x, s3: K } = js(c, g, w, p, h);
2195
+ u[d++] = B ^ y, u[d++] = m ^ E, u[d++] = x ^ S, u[d++] = K ^ I;
2196
2196
  }
2197
2197
  return c.fill(0), Ws(l, i);
2198
2198
  }
@@ -2208,22 +2208,22 @@ function zt(e) {
2208
2208
  const Xe = 64, Ys = 16, Nr = 2 ** 32 - 1, Mn = new Uint32Array();
2209
2209
  function Xs(e, t, n, r, i, s, o, c) {
2210
2210
  const a = i.length, l = new Uint8Array(Xe), f = G(l), u = zt(i) && zt(s), g = u ? G(i) : Mn, w = u ? G(s) : Mn;
2211
- for (let y = 0; y < a; o++) {
2211
+ for (let p = 0; p < a; o++) {
2212
2212
  if (e(t, n, r, f, o, c), o >= Nr)
2213
2213
  throw new Error("arx: counter overflow");
2214
- const h = Math.min(Xe, a - y);
2214
+ const h = Math.min(Xe, a - p);
2215
2215
  if (u && h === Xe) {
2216
- const d = y / 4;
2217
- if (y % 4 !== 0)
2216
+ const d = p / 4;
2217
+ if (p % 4 !== 0)
2218
2218
  throw new Error("arx: invalid block position");
2219
- for (let p = 0, E; p < Ys; p++)
2220
- E = d + p, w[E] = g[E] ^ f[p];
2221
- y += Xe;
2219
+ for (let y = 0, E; y < Ys; y++)
2220
+ E = d + y, w[E] = g[E] ^ f[y];
2221
+ p += Xe;
2222
2222
  continue;
2223
2223
  }
2224
- for (let d = 0, p; d < h; d++)
2225
- p = y + d, s[p] = i[p] ^ l[d];
2226
- y += h;
2224
+ for (let d = 0, y; d < h; d++)
2225
+ y = p + d, s[y] = i[y] ^ l[d];
2226
+ p += h;
2227
2227
  }
2228
2228
  }
2229
2229
  function Qs(e, t) {
@@ -2238,19 +2238,19 @@ function Qs(e, t) {
2238
2238
  if (f.length < g)
2239
2239
  throw new Error(`arx: output (${f.length}) is shorter than data (${g})`);
2240
2240
  const w = [];
2241
- let y = c.length, h, d;
2242
- if (y === 32)
2241
+ let p = c.length, h, d;
2242
+ if (p === 32)
2243
2243
  h = c.slice(), w.push(h), d = Kr;
2244
- else if (y === 16 && n)
2244
+ else if (p === 16 && n)
2245
2245
  h = new Uint8Array(32), h.set(c), h.set(c, 16), d = Js, w.push(h);
2246
2246
  else
2247
- throw new Error(`arx: invalid 32-byte key, got length=${y}`);
2247
+ throw new Error(`arx: invalid 32-byte key, got length=${p}`);
2248
2248
  zt(a) || (a = a.slice(), w.push(a));
2249
- const p = G(h);
2249
+ const y = G(h);
2250
2250
  if (r) {
2251
2251
  if (a.length !== 24)
2252
2252
  throw new Error("arx: extended nonce must be 24 bytes");
2253
- r(d, p, G(a.subarray(0, 16)), p), a = a.subarray(16);
2253
+ r(d, y, G(a.subarray(0, 16)), y), a = a.subarray(16);
2254
2254
  }
2255
2255
  const E = 16 - i;
2256
2256
  if (E !== a.length)
@@ -2260,17 +2260,17 @@ function Qs(e, t) {
2260
2260
  I.set(a, s ? 0 : 12 - a.length), a = I, w.push(a);
2261
2261
  }
2262
2262
  const S = G(a);
2263
- for (Xs(e, d, p, S, l, f, u, o); w.length > 0; )
2263
+ for (Xs(e, d, y, S, l, f, u, o); w.length > 0; )
2264
2264
  w.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], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], g = t[2], w = t[3], y = t[4], h = t[5], d = t[6], p = t[7], E = i, S = n[0], I = n[1], B = n[2], m = o, x = c, K = a, M = l, _ = f, A = u, T = g, R = w, H = y, b = h, v = d, N = p, k = E, C = S, U = I, O = B;
2269
+ let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], g = t[2], w = t[3], p = t[4], h = t[5], d = t[6], y = t[7], E = i, S = n[0], I = n[1], B = n[2], m = o, x = c, K = a, M = l, _ = f, A = u, T = g, R = w, H = p, b = h, v = d, N = y, k = E, C = S, U = I, O = B;
2270
2270
  for (let ee = 0; ee < s; ee += 2)
2271
2271
  m = m + _ | 0, k = L(k ^ m, 16), H = H + k | 0, _ = L(_ ^ H, 12), m = m + _ | 0, k = L(k ^ m, 8), H = H + k | 0, _ = L(_ ^ H, 7), x = x + A | 0, C = L(C ^ x, 16), b = b + C | 0, A = L(A ^ b, 12), x = x + A | 0, C = L(C ^ x, 8), b = b + C | 0, A = L(A ^ b, 7), K = K + T | 0, U = L(U ^ K, 16), v = v + U | 0, T = L(T ^ v, 12), K = K + T | 0, U = L(U ^ K, 8), v = v + U | 0, T = L(T ^ v, 7), M = M + R | 0, O = L(O ^ M, 16), N = N + O | 0, R = L(R ^ N, 12), M = M + R | 0, O = L(O ^ M, 8), N = N + O | 0, R = L(R ^ N, 7), m = m + A | 0, O = L(O ^ m, 16), v = v + O | 0, A = L(A ^ v, 12), m = m + A | 0, O = L(O ^ m, 8), v = v + O | 0, A = L(A ^ 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), K = K + R | 0, C = L(C ^ K, 16), H = H + C | 0, R = L(R ^ H, 12), K = K + R | 0, C = L(C ^ K, 8), H = H + C | 0, R = L(R ^ H, 7), M = M + _ | 0, U = L(U ^ M, 16), b = b + U | 0, _ = L(_ ^ b, 12), M = M + _ | 0, U = L(U ^ M, 8), b = b + U | 0, _ = L(_ ^ b, 7);
2272
2272
  let $ = 0;
2273
- r[$++] = o + m | 0, r[$++] = c + x | 0, r[$++] = a + K | 0, r[$++] = l + M | 0, r[$++] = f + _ | 0, r[$++] = u + A | 0, r[$++] = g + T | 0, r[$++] = w + R | 0, r[$++] = y + H | 0, r[$++] = h + b | 0, r[$++] = d + v | 0, r[$++] = p + N | 0, r[$++] = E + k | 0, r[$++] = S + C | 0, r[$++] = I + U | 0, r[$++] = B + O | 0;
2273
+ r[$++] = o + m | 0, r[$++] = c + x | 0, r[$++] = a + K | 0, r[$++] = l + M | 0, r[$++] = f + _ | 0, r[$++] = u + A | 0, r[$++] = g + T | 0, r[$++] = w + R | 0, r[$++] = p + H | 0, r[$++] = h + b | 0, r[$++] = d + v | 0, r[$++] = y + N | 0, r[$++] = E + k | 0, r[$++] = S + C | 0, r[$++] = I + U | 0, r[$++] = B + O | 0;
2274
2274
  }
2275
2275
  const Sr = /* @__PURE__ */ Qs(eo, {
2276
2276
  counterRight: !1,
@@ -2441,7 +2441,7 @@ function qe(e) {
2441
2441
  let t = fe(ne.encode(uo(e)));
2442
2442
  return P(t);
2443
2443
  }
2444
- var pt = new co(), ke = pt.generateSecretKey, le = pt.getPublicKey, Q = pt.finalizeEvent, yt = pt.verifyEvent, lo = {};
2444
+ var yt = new co(), ke = yt.generateSecretKey, le = yt.getPublicKey, Q = yt.finalizeEvent, pt = yt.verifyEvent, lo = {};
2445
2445
  D(lo, {
2446
2446
  Application: () => da,
2447
2447
  BadgeAward: () => mo,
@@ -2490,9 +2490,9 @@ D(lo, {
2490
2490
  Label: () => ko,
2491
2491
  LightningPubRPC: () => Yo,
2492
2492
  LiveChatMessage: () => So,
2493
- LiveEvent: () => pa,
2493
+ LiveEvent: () => ya,
2494
2494
  LongFormArticle: () => la,
2495
- Metadata: () => po,
2495
+ Metadata: () => yo,
2496
2496
  Mutelist: () => Po,
2497
2497
  NWCWalletInfo: () => Jo,
2498
2498
  NWCWalletRequest: () => qr,
@@ -2513,10 +2513,10 @@ D(lo, {
2513
2513
  Repost: () => on,
2514
2514
  Seal: () => Lr,
2515
2515
  SearchRelaysList: () => Vo,
2516
- ShortTextNote: () => yo,
2516
+ ShortTextNote: () => po,
2517
2517
  Time: () => va,
2518
2518
  UserEmojiList: () => Zo,
2519
- UserStatuses: () => ya,
2519
+ UserStatuses: () => pa,
2520
2520
  Zap: () => Ro,
2521
2521
  ZapGoal: () => $o,
2522
2522
  ZapRequest: () => To,
@@ -2546,7 +2546,7 @@ function ho(e, t) {
2546
2546
  const n = t instanceof Array ? t : [t];
2547
2547
  return dt(e) && n.includes(e.kind) || !1;
2548
2548
  }
2549
- var po = 0, yo = 1, go = 2, wo = 3, bo = 4, vo = 5, on = 6, an = 7, mo = 8, Lr = 13, Eo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Pr = 44, Ko = 1040, Mr = 1059, No = 1063, So = 1311, Ao = 1971, Co = 1984, Bo = 1984, ko = 1985, _o = 4550, Io = 5999, Uo = 6999, Lo = 7e3, $o = 9041, To = 9734, Ro = 9735, Oo = 9802, Po = 1e4, Mo = 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, cn = 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, Ka = 31990, Na = 34550, Sa = {};
2549
+ var yo = 0, po = 1, go = 2, wo = 3, bo = 4, vo = 5, on = 6, an = 7, mo = 8, Lr = 13, Eo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Pr = 44, Ko = 1040, Mr = 1059, No = 1063, So = 1311, Ao = 1971, Co = 1984, Bo = 1984, ko = 1985, _o = 4550, Io = 5999, Uo = 6999, Lo = 7e3, $o = 9041, To = 9734, Ro = 9735, Oo = 9802, Po = 1e4, Mo = 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, cn = 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, ya = 30311, pa = 30315, ga = 30402, wa = 30403, ba = 31922, va = 31923, ma = 31924, Ea = 31925, xa = 31989, Ka = 31990, Na = 34550, Sa = {};
2550
2550
  D(Sa, {
2551
2551
  getHex64: () => un,
2552
2552
  getInt: () => Dr,
@@ -3000,7 +3000,7 @@ function sc(e, { skipVerification: t } = {}) {
3000
3000
  } catch {
3001
3001
  return;
3002
3002
  }
3003
- if (r.id === n.id && !(!t && !yt(r)))
3003
+ if (r.id === n.id && !(!t && !pt(r)))
3004
3004
  return r;
3005
3005
  }
3006
3006
  var oc = {};
@@ -3059,7 +3059,7 @@ var hc = {};
3059
3059
  D(hc, {
3060
3060
  matchAll: () => dc,
3061
3061
  regex: () => dn,
3062
- replaceAll: () => pc
3062
+ replaceAll: () => yc
3063
3063
  });
3064
3064
  var dn = () => new RegExp(`\\b${mt.source}\\b`, "g");
3065
3065
  function* dc(e) {
@@ -3077,15 +3077,15 @@ function* dc(e) {
3077
3077
  } catch {
3078
3078
  }
3079
3079
  }
3080
- function pc(e, t) {
3080
+ function yc(e, t) {
3081
3081
  return e.replaceAll(dn(), (n, r) => t({
3082
3082
  uri: n,
3083
3083
  value: r,
3084
3084
  decoded: gt(r)
3085
3085
  }));
3086
3086
  }
3087
- var yc = {};
3088
- D(yc, {
3087
+ var pc = {};
3088
+ D(pc, {
3089
3089
  channelCreateEvent: () => gc,
3090
3090
  channelHideMessageEvent: () => vc,
3091
3091
  channelMessageEvent: () => bc,
@@ -3175,12 +3175,12 @@ var gc = (e, t) => {
3175
3175
  D(Ec, {
3176
3176
  EMOJI_SHORTCODE_REGEX: () => Yr,
3177
3177
  matchAll: () => xc,
3178
- regex: () => pn,
3178
+ regex: () => yn,
3179
3179
  replaceAll: () => Kc
3180
3180
  });
3181
- var Yr = /:(\w+):/, pn = () => new RegExp(`\\B${Yr.source}\\B`, "g");
3181
+ var Yr = /:(\w+):/, yn = () => new RegExp(`\\B${Yr.source}\\B`, "g");
3182
3182
  function* xc(e) {
3183
- const t = e.matchAll(pn());
3183
+ const t = e.matchAll(yn());
3184
3184
  for (const n of t)
3185
3185
  try {
3186
3186
  const [r, i] = n;
@@ -3194,7 +3194,7 @@ function* xc(e) {
3194
3194
  }
3195
3195
  }
3196
3196
  function Kc(e, t) {
3197
- return e.replaceAll(pn(), (n, r) => t({
3197
+ return e.replaceAll(yn(), (n, r) => t({
3198
3198
  shortcode: n,
3199
3199
  name: r
3200
3200
  }));
@@ -3204,17 +3204,17 @@ D(Nc, {
3204
3204
  useFetchImplementation: () => Sc,
3205
3205
  validateGithub: () => Ac
3206
3206
  });
3207
- var yn;
3207
+ var pn;
3208
3208
  try {
3209
- yn = fetch;
3209
+ pn = fetch;
3210
3210
  } catch {
3211
3211
  }
3212
3212
  function Sc(e) {
3213
- yn = e;
3213
+ pn = e;
3214
3214
  }
3215
3215
  async function Ac(e, t, n) {
3216
3216
  try {
3217
- return await (await yn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
3217
+ return await (await pn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
3218
3218
  } catch {
3219
3219
  return !1;
3220
3220
  }
@@ -3404,7 +3404,7 @@ function Mc(e) {
3404
3404
  }
3405
3405
  if (!dt(t))
3406
3406
  return "Zap request is not a valid Nostr event.";
3407
- if (!yt(t))
3407
+ if (!pt(t))
3408
3408
  return "Invalid signature on zap request.";
3409
3409
  let n = t.tags.find(([s, o]) => s === "p" && o);
3410
3410
  if (!n)
@@ -3501,10 +3501,10 @@ D(Vc, {
3501
3501
  unpackEventFromToken: () => fi,
3502
3502
  validateEvent: () => wi,
3503
3503
  validateEventKind: () => di,
3504
- validateEventMethodTag: () => yi,
3504
+ validateEventMethodTag: () => pi,
3505
3505
  validateEventPayloadTag: () => gi,
3506
3506
  validateEventTimestamp: () => hi,
3507
- validateEventUrlTag: () => pi,
3507
+ validateEventUrlTag: () => yi,
3508
3508
  validateToken: () => Zc
3509
3509
  });
3510
3510
  var li = "Nostr ";
@@ -3545,11 +3545,11 @@ function hi(e) {
3545
3545
  function di(e) {
3546
3546
  return e.kind === cn;
3547
3547
  }
3548
- function pi(e, t) {
3548
+ function yi(e, t) {
3549
3549
  const n = e.tags.find((r) => r[0] === "u");
3550
3550
  return n ? n.length > 0 && n[1] === t : !1;
3551
3551
  }
3552
- function yi(e, t) {
3552
+ function pi(e, t) {
3553
3553
  const n = e.tags.find((r) => r[0] === "method");
3554
3554
  return n ? n.length > 0 && n[1].toLowerCase() === t.toLowerCase() : !1;
3555
3555
  }
@@ -3565,15 +3565,15 @@ function gi(e, t) {
3565
3565
  return n.length > 0 && n[1] === r;
3566
3566
  }
3567
3567
  async function wi(e, t, n, r) {
3568
- if (!yt(e))
3568
+ if (!pt(e))
3569
3569
  throw new Error("Invalid nostr event, signature invalid");
3570
3570
  if (!di(e))
3571
3571
  throw new Error("Invalid nostr event, kind invalid");
3572
3572
  if (!hi(e))
3573
3573
  throw new Error("Invalid nostr event, created_at timestamp invalid");
3574
- if (!pi(e, t))
3574
+ if (!yi(e, t))
3575
3575
  throw new Error("Invalid nostr event, url tag invalid");
3576
- if (!yi(e, n))
3576
+ if (!pi(e, n))
3577
3577
  throw new Error("Invalid nostr event, method tag invalid");
3578
3578
  if (r && typeof r == "object" && Object.keys(r).length > 0 && !gi(e, r))
3579
3579
  throw new Error("Invalid nostr event, payload tag does not match request body hash");
@@ -3730,16 +3730,25 @@ class st {
3730
3730
  * @returns A new Session instance
3731
3731
  */
3732
3732
  static init(t, n, r, i, s, o) {
3733
- const c = ke(), [a, l] = Pe(s, q.getConversationKey(c, n), 2);
3734
- let f, u;
3735
- i ? (f = { publicKey: le(r), privateKey: r }, u = { publicKey: le(c), privateKey: c }) : u = { publicKey: le(r), privateKey: r };
3733
+ const c = ke();
3734
+ let a, l, f, u;
3735
+ i ? ([a, l] = Pe(s, q.getConversationKey(c, n), 2), f = {
3736
+ publicKey: le(r),
3737
+ privateKey: r
3738
+ }, u = {
3739
+ publicKey: le(c),
3740
+ privateKey: c
3741
+ }) : (a = s, l = void 0, f = void 0, u = {
3742
+ publicKey: le(r),
3743
+ privateKey: r
3744
+ });
3736
3745
  const g = {
3737
- rootKey: i ? a : s,
3746
+ rootKey: a,
3738
3747
  theirNextNostrPublicKey: n,
3739
3748
  ourCurrentNostrKey: f,
3740
3749
  ourNextNostrKey: u,
3741
3750
  receivingChainKey: void 0,
3742
- sendingChainKey: i ? l : void 0,
3751
+ sendingChainKey: l,
3743
3752
  sendingChainMessageNumber: 0,
3744
3753
  receivingChainMessageNumber: 0,
3745
3754
  previousSendingChainMessageCount: 0,
@@ -3845,22 +3854,24 @@ class st {
3845
3854
  }
3846
3855
  // 3. MESSAGE KEY FUNCTIONS
3847
3856
  skipMessageKeys(t, n) {
3848
- if (this.state.receivingChainMessageNumber + Jc < t)
3849
- throw new Error("Too many skipped messages");
3850
- if (!this.state.skippedKeys[n]) {
3851
- if (this.state.skippedKeys[n] = {
3852
- headerKeys: [],
3853
- messageKeys: {}
3854
- }, this.state.ourCurrentNostrKey) {
3855
- const i = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
3856
- this.state.skippedKeys[n].headerKeys.push(i);
3857
+ if (!(t <= this.state.receivingChainMessageNumber)) {
3858
+ if (t > this.state.receivingChainMessageNumber + Jc)
3859
+ throw new Error("Too many skipped messages");
3860
+ if (!this.state.skippedKeys[n]) {
3861
+ if (this.state.skippedKeys[n] = {
3862
+ headerKeys: [],
3863
+ messageKeys: {}
3864
+ }, this.state.ourCurrentNostrKey) {
3865
+ const i = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
3866
+ this.state.skippedKeys[n].headerKeys.push(i);
3867
+ }
3868
+ const r = q.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
3869
+ this.state.skippedKeys[n].headerKeys.push(r);
3870
+ }
3871
+ for (; this.state.receivingChainMessageNumber < t; ) {
3872
+ const [r, i] = Pe(this.state.receivingChainKey, new Uint8Array([1]), 2);
3873
+ this.state.receivingChainKey = r, this.state.skippedKeys[n].messageKeys[this.state.receivingChainMessageNumber] = i, this.state.receivingChainMessageNumber++;
3857
3874
  }
3858
- const r = q.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
3859
- this.state.skippedKeys[n].headerKeys.push(r);
3860
- }
3861
- for (; this.state.receivingChainMessageNumber < t; ) {
3862
- const [r, i] = Pe(this.state.receivingChainKey, new Uint8Array([1]), 2);
3863
- this.state.receivingChainKey = r, this.state.skippedKeys[n].messageKeys[this.state.receivingChainMessageNumber] = i, this.state.receivingChainMessageNumber++;
3864
3875
  }
3865
3876
  }
3866
3877
  trySkippedMessageKeys(t, n, r) {
@@ -3990,7 +4001,7 @@ class Me {
3990
4001
  var o, c;
3991
4002
  if (!t.sig)
3992
4003
  throw new Error("Event is not signed");
3993
- if (!yt(t))
4004
+ if (!pt(t))
3994
4005
  throw new Error("Event signature is invalid");
3995
4006
  const { tags: n } = t;
3996
4007
  if (!n)
@@ -4079,13 +4090,13 @@ class Me {
4079
4090
  * so the inviter can create the session on their side.
4080
4091
  */
4081
4092
  async accept(t, n, r) {
4082
- const i = ke(), s = le(i), o = this.inviter || this.inviterEphemeralPublicKey, c = z(this.sharedSecret), a = st.init(t, this.inviterEphemeralPublicKey, i, !0, c, void 0), f = await (typeof r == "function" ? r : (d, p) => Promise.resolve(q.encrypt(d, Qe(r, p))))(s, o), u = {
4093
+ const i = ke(), s = le(i), o = this.inviter || this.inviterEphemeralPublicKey, c = z(this.sharedSecret), a = st.init(t, this.inviterEphemeralPublicKey, i, !0, c, void 0), f = await (typeof r == "function" ? r : (d, y) => Promise.resolve(q.encrypt(d, Qe(r, y))))(s, o), u = {
4083
4094
  pubkey: n,
4084
4095
  content: await q.encrypt(f, c),
4085
4096
  created_at: Math.floor(Date.now() / 1e3)
4086
- }, g = JSON.stringify(u), w = ke(), y = le(w), h = {
4097
+ }, g = JSON.stringify(u), w = ke(), p = le(w), h = {
4087
4098
  kind: jn,
4088
- pubkey: y,
4099
+ pubkey: p,
4089
4100
  content: q.encrypt(g, Qe(w, this.inviterEphemeralPublicKey)),
4090
4101
  created_at: eu(),
4091
4102
  tags: [["p", this.inviterEphemeralPublicKey]]
@@ -4107,8 +4118,8 @@ class Me {
4107
4118
  }
4108
4119
  const o = await q.decrypt(s.content, Qe(this.inviterEphemeralPrivateKey, s.pubkey)), c = JSON.parse(o), a = z(this.sharedSecret), l = c.pubkey;
4109
4120
  this.usedBy.push(l);
4110
- const f = await q.decrypt(c.content, a), g = await (typeof t == "function" ? t : (h, d) => Promise.resolve(q.decrypt(h, Qe(t, d))))(f, l), w = s.id, y = st.init(n, g, this.inviterEphemeralPrivateKey, !1, a, w);
4111
- r(y, l);
4121
+ const f = await q.decrypt(c.content, a), g = await (typeof t == "function" ? t : (h, d) => Promise.resolve(q.decrypt(h, Qe(t, d))))(f, l), w = s.id, p = st.init(n, g, this.inviterEphemeralPrivateKey, !1, a, w);
4122
+ r(p, l);
4112
4123
  } catch (o) {
4113
4124
  console.error("Error processing invite message:", o, "event", s);
4114
4125
  }