nostr-double-ratchet 0.0.13 → 0.0.15

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.
@@ -11,7 +11,7 @@ function zn(e, ...t) {
11
11
  if (t.length > 0 && !t.includes(e.length))
12
12
  throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`);
13
13
  }
14
- function mi(e) {
14
+ function Ei(e) {
15
15
  if (typeof e != "function" || typeof e.create != "function")
16
16
  throw new Error("Hash should be wrapped by utils.wrapConstructor");
17
17
  Kn(e.outputLen), Kn(e.blockLen);
@@ -22,28 +22,28 @@ function et(e, t = !0) {
22
22
  if (t && e.finished)
23
23
  throw new Error("Hash#digest() has already been called");
24
24
  }
25
- function Ei(e, t) {
25
+ function mi(e, t) {
26
26
  zn(e);
27
27
  const n = t.outputLen;
28
28
  if (e.length < n)
29
29
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
30
30
  }
31
- const Et = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
31
+ const mt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
32
32
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
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 Ai(e) {
36
+ function Si(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 = Ai(e)), !Vn(e))
42
+ if (typeof e == "string" && (e = Si(e)), !Vn(e))
43
43
  throw new Error(`expected Uint8Array, got ${typeof e}`);
44
44
  return e;
45
45
  }
46
- function Si(...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,22 +58,22 @@ let Wn = class {
58
58
  return this._cloneInto();
59
59
  }
60
60
  };
61
- function Ni(e) {
61
+ function Ai(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
  }
65
65
  function Zn(e = 32) {
66
- if (Et && typeof Et.getRandomValues == "function")
67
- return Et.getRandomValues(new Uint8Array(e));
66
+ if (mt && typeof mt.getRandomValues == "function")
67
+ return mt.getRandomValues(new Uint8Array(e));
68
68
  throw new Error("crypto.getRandomValues must be defined");
69
69
  }
70
70
  function Ki(e, t, n, r) {
71
71
  if (typeof e.setBigUint64 == "function")
72
72
  return e.setBigUint64(t, n, r);
73
- const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), a = Number(n & o), c = r ? 4 : 0, u = r ? 0 : 4;
74
- e.setUint32(t + c, s, r), e.setUint32(t + u, a, r);
73
+ const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
74
+ e.setUint32(t + a, o, r), e.setUint32(t + l, c, 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
  }
@@ -81,35 +81,35 @@ let ki = class extends Wn {
81
81
  et(this);
82
82
  const { view: n, buffer: r, blockLen: i } = this;
83
83
  t = Wt(t);
84
- const o = t.length;
85
- for (let s = 0; s < o; ) {
86
- const a = Math.min(i - this.pos, o - s);
87
- if (a === i) {
88
- const c = xt(t);
89
- for (; i <= o - s; s += i)
90
- this.process(c, s);
84
+ const s = t.length;
85
+ for (let o = 0; o < s; ) {
86
+ const c = Math.min(i - this.pos, s - o);
87
+ if (c === i) {
88
+ const a = xt(t);
89
+ for (; i <= s - o; o += i)
90
+ this.process(a, o);
91
91
  continue;
92
92
  }
93
- r.set(t.subarray(s, s + a), this.pos), this.pos += a, s += a, this.pos === i && (this.process(n, 0), this.pos = 0);
93
+ r.set(t.subarray(o, o + c), this.pos), this.pos += c, o += c, this.pos === i && (this.process(n, 0), this.pos = 0);
94
94
  }
95
95
  return this.length += t.length, this.roundClean(), this;
96
96
  }
97
97
  digestInto(t) {
98
- et(this), Ei(t, this), this.finished = !0;
99
- const { buffer: n, view: r, blockLen: i, isLE: o } = this;
100
- let { pos: s } = this;
101
- n[s++] = 128, this.buffer.subarray(s).fill(0), this.padOffset > i - s && (this.process(r, 0), s = 0);
102
- for (let l = s; l < i; l++)
103
- n[l] = 0;
104
- Ki(r, i - 8, BigInt(this.length * 8), o), this.process(r, 0);
105
- const a = xt(t), c = this.outputLen;
106
- if (c % 4)
98
+ et(this), mi(t, this), this.finished = !0;
99
+ const { buffer: n, view: r, blockLen: i, isLE: s } = this;
100
+ let { pos: o } = this;
101
+ n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
102
+ for (let u = o; u < i; u++)
103
+ n[u] = 0;
104
+ Ki(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
105
+ const c = xt(t), a = this.outputLen;
106
+ if (a % 4)
107
107
  throw new Error("_sha2: outputLen should be aligned to 32bit");
108
- const u = c / 4, f = this.get();
109
- if (u > f.length)
108
+ const l = a / 4, f = this.get();
109
+ if (l > f.length)
110
110
  throw new Error("_sha2: outputLen bigger than state");
111
- for (let l = 0; l < u; l++)
112
- a.setUint32(4 * l, f[l], o);
111
+ for (let u = 0; u < l; u++)
112
+ c.setUint32(4 * u, f[u], s);
113
113
  }
114
114
  digest() {
115
115
  const { buffer: t, outputLen: n } = this;
@@ -119,11 +119,11 @@ let ki = class extends Wn {
119
119
  }
120
120
  _cloneInto(t) {
121
121
  t || (t = new this.constructor()), t.set(...this.get());
122
- const { blockLen: n, buffer: r, length: i, finished: o, destroyed: s, pos: a } = this;
123
- return t.length = i, t.pos = a, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
122
+ const { blockLen: n, buffer: r, length: i, finished: s, destroyed: o, pos: c } = this;
123
+ return t.length = i, t.pos = c, 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, _i = /* @__PURE__ */ new Uint32Array([
127
127
  1116352408,
128
128
  1899447441,
129
129
  3049323471,
@@ -198,31 +198,31 @@ 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 Ui = 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
  }
205
205
  get() {
206
- const { A: t, B: n, C: r, D: i, E: o, F: s, G: a, H: c } = this;
207
- return [t, n, r, i, o, s, a, c];
206
+ const { A: t, B: n, C: r, D: i, E: s, F: o, G: c, H: a } = this;
207
+ return [t, n, r, i, s, o, c, a];
208
208
  }
209
209
  // prettier-ignore
210
- set(t, n, r, i, o, s, a, c) {
211
- this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = a | 0, this.H = c | 0;
210
+ set(t, n, r, i, s, o, c, a) {
211
+ this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = s | 0, this.F = o | 0, this.G = c | 0, this.H = a | 0;
212
212
  }
213
213
  process(t, n) {
214
- for (let l = 0; l < 16; l++, n += 4)
215
- ve[l] = t.getUint32(n, !1);
216
- for (let l = 16; l < 64; l++) {
217
- const g = ve[l - 15], b = ve[l - 2], p = re(g, 7) ^ re(g, 18) ^ g >>> 3, h = re(b, 17) ^ re(b, 19) ^ b >>> 10;
218
- ve[l] = h + ve[l - 7] + p + ve[l - 16] | 0;
214
+ for (let u = 0; u < 16; u++, n += 4)
215
+ ve[u] = t.getUint32(n, !1);
216
+ for (let u = 16; u < 64; u++) {
217
+ const g = ve[u - 15], b = ve[u - 2], p = re(g, 7) ^ re(g, 18) ^ g >>> 3, h = re(b, 17) ^ re(b, 19) ^ b >>> 10;
218
+ ve[u] = h + ve[u - 7] + p + ve[u - 16] | 0;
219
219
  }
220
- let { A: r, B: i, C: o, D: s, E: a, F: c, G: u, H: f } = this;
221
- for (let l = 0; l < 64; l++) {
222
- const g = re(a, 6) ^ re(a, 11) ^ re(a, 25), b = f + g + Bi(a, c, u) + Ui[l] + ve[l] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + Ci(r, i, o) | 0;
223
- f = u, u = c, c = a, a = s + b | 0, s = o, o = i, i = r, r = b + h | 0;
220
+ let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
221
+ for (let u = 0; u < 64; u++) {
222
+ const g = re(c, 6) ^ re(c, 11) ^ re(c, 25), b = f + g + Bi(c, a, l) + _i[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + ki(r, i, s) | 0;
223
+ f = l, l = a, a = c, c = o + b | 0, o = s, s = i, i = r, r = b + h | 0;
224
224
  }
225
- r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, u = u + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, a, c, u, f);
225
+ r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
226
226
  }
227
227
  roundClean() {
228
228
  ve.fill(0);
@@ -231,9 +231,9 @@ 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__ */ Ai(() => new Ui());
235
235
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
236
- const Gn = BigInt(0), st = BigInt(1), Ii = BigInt(2), at = (e) => e instanceof Uint8Array, Li = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
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) {
238
238
  if (!at(e))
239
239
  throw new Error("Uint8Array expected");
@@ -259,10 +259,10 @@ function De(e) {
259
259
  throw new Error("padded hex string expected, got unpadded hex of length " + t);
260
260
  const n = new Uint8Array(t / 2);
261
261
  for (let r = 0; r < n.length; r++) {
262
- const i = r * 2, o = e.slice(i, i + 2), s = Number.parseInt(o, 16);
263
- if (Number.isNaN(s) || s < 0)
262
+ const i = r * 2, s = e.slice(i, i + 2), o = Number.parseInt(s, 16);
263
+ if (Number.isNaN(o) || o < 0)
264
264
  throw new Error("Invalid byte sequence");
265
- n[r] = s;
265
+ n[r] = o;
266
266
  }
267
267
  return n;
268
268
  }
@@ -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 Se(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 Se(e, t).reverse();
281
+ return Ne(e, t).reverse();
282
282
  }
283
283
  function $i(e) {
284
284
  return De(Fn(e));
@@ -288,8 +288,8 @@ function W(e, t, n) {
288
288
  if (typeof t == "string")
289
289
  try {
290
290
  r = De(t);
291
- } catch (o) {
292
- throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`);
291
+ } catch (s) {
292
+ throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`);
293
293
  }
294
294
  else if (at(t))
295
295
  r = Uint8Array.from(t);
@@ -324,14 +324,14 @@ function Ri(e) {
324
324
  }
325
325
  function Oi(e) {
326
326
  let t;
327
- for (t = 0; e > Gn; e >>= st, t += 1)
327
+ for (t = 0; e > Gn; e >>= ot, t += 1)
328
328
  ;
329
329
  return t;
330
330
  }
331
331
  function Mi(e, t) {
332
- return e >> BigInt(t) & st;
332
+ return e >> BigInt(t) & ot;
333
333
  }
334
- const Hi = (e, t, n) => e | (n ? st : Gn) << BigInt(t), Jt = (e) => (Ii << BigInt(e - 1)) - st, At = (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, St = (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,32 +339,32 @@ 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 = At(e), i = At(e), o = 0;
343
- const s = () => {
344
- r.fill(1), i.fill(0), o = 0;
345
- }, a = (...l) => n(i, r, ...l), c = (l = At()) => {
346
- i = a(kn([0]), l), r = a(), l.length !== 0 && (i = a(kn([1]), l), r = a());
347
- }, u = () => {
348
- if (o++ >= 1e3)
342
+ let r = St(e), i = St(e), s = 0;
343
+ const o = () => {
344
+ r.fill(1), i.fill(0), s = 0;
345
+ }, c = (...u) => n(i, r, ...u), a = (u = St()) => {
346
+ i = c(Cn([0]), u), r = c(), u.length !== 0 && (i = c(Cn([1]), u), r = c());
347
+ }, l = () => {
348
+ if (s++ >= 1e3)
349
349
  throw new Error("drbg: tried 1000 values");
350
- let l = 0;
350
+ let u = 0;
351
351
  const g = [];
352
- for (; l < t; ) {
353
- r = a();
352
+ for (; u < t; ) {
353
+ r = c();
354
354
  const b = r.slice();
355
- g.push(b), l += r.length;
355
+ g.push(b), u += r.length;
356
356
  }
357
357
  return Ue(...g);
358
358
  };
359
- return (l, g) => {
360
- s(), c(l);
359
+ return (u, g) => {
360
+ o(), a(u);
361
361
  let b;
362
- for (; !(b = g(u())); )
363
- c();
364
- return s(), b;
362
+ for (; !(b = g(l())); )
363
+ a();
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",
@@ -375,19 +375,19 @@ const Pi = {
375
375
  field: (e, t) => t.Fp.isValid(e),
376
376
  hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen)
377
377
  };
378
- function Je(e, t, n = {}) {
379
- const r = (i, o, s) => {
380
- const a = Pi[o];
381
- if (typeof a != "function")
382
- throw new Error(`Invalid validator "${o}", expected function`);
383
- const c = e[i];
384
- if (!(s && c === void 0) && !a(c, e))
385
- throw new Error(`Invalid param ${String(i)}=${c} (${typeof c}), expected ${o}`);
378
+ function Ye(e, t, n = {}) {
379
+ const r = (i, s, o) => {
380
+ const c = Hi[s];
381
+ if (typeof c != "function")
382
+ throw new Error(`Invalid validator "${s}", expected function`);
383
+ const a = e[i];
384
+ if (!(o && a === void 0) && !c(a, e))
385
+ throw new Error(`Invalid param ${String(i)}=${a} (${typeof a}), expected ${s}`);
386
386
  };
387
- for (const [i, o] of Object.entries(t))
388
- r(i, o, !1);
389
- for (const [i, o] of Object.entries(n))
390
- r(i, o, !0);
387
+ for (const [i, s] of Object.entries(t))
388
+ r(i, s, !1);
389
+ for (const [i, s] of Object.entries(n))
390
+ r(i, s, !0);
391
391
  return e;
392
392
  }
393
393
  const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
@@ -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,15 +405,15 @@ const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
405
405
  equalBytes: Ti,
406
406
  hexToBytes: De,
407
407
  hexToNumber: Zt,
408
- numberToBytesBE: Se,
408
+ numberToBytesBE: Ne,
409
409
  numberToBytesLE: Ft,
410
410
  numberToHexUnpadded: Fn,
411
411
  numberToVarBytesBE: $i,
412
412
  utf8ToBytes: Ri,
413
- validateObject: Je
413
+ validateObject: Ye
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,65 +439,65 @@ 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, o = D;
442
+ let n = V(e, t), r = t, i = z, s = j;
443
443
  for (; n !== z; ) {
444
- const a = r / n, c = r % n, u = i - o * a;
445
- r = n, n = c, i = o, o = u;
444
+ const c = r / n, a = r % n, l = i - s * c;
445
+ r = n, n = a, 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 s = (e + D) / $t;
460
- return function(c, u) {
461
- const f = c.pow(u, s);
462
- if (!c.eql(c.sqr(f), u))
459
+ const o = (e + j) / $t;
460
+ return function(a, l) {
461
+ const f = a.pow(l, o);
462
+ if (!a.eql(a.sqr(f), l))
463
463
  throw new Error("Cannot find square root");
464
464
  return f;
465
465
  };
466
466
  }
467
- const o = (n + D) / ke;
468
- return function(a, c) {
469
- if (a.pow(c, t) === a.neg(a.ONE))
467
+ const s = (n + j) / Ce;
468
+ return function(c, a) {
469
+ if (c.pow(a, t) === c.neg(c.ONE))
470
470
  throw new Error("Cannot find square root");
471
- let u = r, f = a.pow(a.mul(a.ONE, i), n), l = a.pow(c, o), g = a.pow(c, n);
472
- for (; !a.eql(g, a.ONE); ) {
473
- if (a.eql(g, a.ZERO))
474
- return a.ZERO;
471
+ let l = r, f = c.pow(c.mul(c.ONE, i), n), u = c.pow(a, s), g = c.pow(a, n);
472
+ for (; !c.eql(g, c.ONE); ) {
473
+ if (c.eql(g, c.ZERO))
474
+ return c.ZERO;
475
475
  let b = 1;
476
- for (let h = a.sqr(g); b < u && !a.eql(h, a.ONE); b++)
477
- h = a.sqr(h);
478
- const p = a.pow(f, D << BigInt(u - b - 1));
479
- f = a.sqr(p), l = a.mul(l, p), g = a.mul(g, f), u = b;
476
+ for (let h = c.sqr(g); b < l && !c.eql(h, c.ONE); b++)
477
+ h = c.sqr(h);
478
+ const p = c.pow(f, j << BigInt(l - b - 1));
479
+ f = c.sqr(p), u = c.mul(u, p), g = c.mul(g, f), l = b;
480
480
  }
481
- return l;
481
+ return u;
482
482
  };
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
- const o = r.pow(i, t);
489
- if (!r.eql(r.sqr(o), i))
488
+ const s = r.pow(i, t);
489
+ if (!r.eql(r.sqr(s), i))
490
490
  throw new Error("Cannot find square root");
491
- return o;
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 o = r.mul(i, ke), s = r.pow(o, t), a = r.mul(i, s), c = r.mul(r.mul(a, ke), s), u = r.mul(a, r.sub(c, r.ONE));
498
- if (!r.eql(r.sqr(u), i))
497
+ const s = r.mul(i, Ce), o = r.pow(s, t), c = r.mul(i, o), a = r.mul(r.mul(c, Ce), o), l = r.mul(c, r.sub(a, r.ONE));
498
+ if (!r.eql(r.sqr(l), i))
499
499
  throw new Error("Cannot find square root");
500
- return u;
500
+ return l;
501
501
  };
502
502
  }
503
503
  return zi(e);
@@ -528,23 +528,23 @@ function Zi(e) {
528
528
  BYTES: "isSafeInteger",
529
529
  BITS: "isSafeInteger"
530
530
  }, n = Wi.reduce((r, i) => (r[i] = "function", r), t);
531
- return Je(e, n);
531
+ return Ye(e, n);
532
532
  }
533
533
  function Gi(e, t, n) {
534
534
  if (n < z)
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) {
546
- const n = new Array(t.length), r = t.reduce((o, s, a) => e.is0(s) ? o : (n[a] = o, e.mul(o, s)), e.ONE), i = e.inv(r);
547
- return t.reduceRight((o, s, a) => e.is0(s) ? o : (n[a] = e.mul(o, n[a]), e.mul(o, s)), i), n;
546
+ const n = new Array(t.length), r = t.reduce((s, o, c) => e.is0(o) ? s : (n[c] = s, e.mul(s, o)), e.ONE), i = e.inv(r);
547
+ return t.reduceRight((s, o, c) => e.is0(o) ? s : (n[c] = e.mul(s, n[c]), e.mul(s, o)), i), n;
548
548
  }
549
549
  function Yn(e, t) {
550
550
  const n = t !== void 0 ? t : e.toString(2).length, r = Math.ceil(n / 8);
@@ -553,51 +553,51 @@ function Yn(e, t) {
553
553
  function Ji(e, t, n = !1, r = {}) {
554
554
  if (e <= z)
555
555
  throw new Error(`Expected Field ORDER > 0, got ${e}`);
556
- const { nBitLength: i, nByteLength: o } = Yn(e, t);
557
- if (o > 2048)
556
+ const { nBitLength: i, nByteLength: s } = Yn(e, t);
557
+ if (s > 2048)
558
558
  throw new Error("Field lengths over 2048 bytes are not supported");
559
- const s = Vi(e), a = Object.freeze({
559
+ const o = Vi(e), c = Object.freeze({
560
560
  ORDER: e,
561
561
  BITS: i,
562
- BYTES: o,
562
+ BYTES: s,
563
563
  MASK: Jt(i),
564
564
  ZERO: z,
565
- ONE: D,
566
- create: (c) => V(c, e),
567
- isValid: (c) => {
568
- if (typeof c != "bigint")
569
- throw new Error(`Invalid field element: expected bigint, got ${typeof c}`);
570
- return z <= c && c < e;
565
+ ONE: j,
566
+ create: (a) => V(a, e),
567
+ isValid: (a) => {
568
+ if (typeof a != "bigint")
569
+ throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);
570
+ return z <= a && a < e;
571
571
  },
572
- is0: (c) => c === z,
573
- isOdd: (c) => (c & D) === D,
574
- neg: (c) => V(-c, e),
575
- eql: (c, u) => c === u,
576
- sqr: (c) => V(c * c, e),
577
- add: (c, u) => V(c + u, e),
578
- sub: (c, u) => V(c - u, e),
579
- mul: (c, u) => V(c * u, e),
580
- pow: (c, u) => Gi(a, c, u),
581
- div: (c, u) => V(c * Tt(u, e), e),
572
+ is0: (a) => a === z,
573
+ isOdd: (a) => (a & j) === j,
574
+ neg: (a) => V(-a, e),
575
+ eql: (a, l) => a === l,
576
+ sqr: (a) => V(a * a, e),
577
+ add: (a, l) => V(a + l, e),
578
+ sub: (a, l) => V(a - l, e),
579
+ mul: (a, l) => V(a * l, e),
580
+ pow: (a, l) => Gi(c, a, l),
581
+ div: (a, l) => V(a * Tt(l, e), e),
582
582
  // Same as above, but doesn't normalize
583
- sqrN: (c) => c * c,
584
- addN: (c, u) => c + u,
585
- subN: (c, u) => c - u,
586
- mulN: (c, u) => c * u,
587
- inv: (c) => Tt(c, e),
588
- sqrt: r.sqrt || ((c) => s(a, c)),
589
- invertBatch: (c) => Fi(a, c),
583
+ sqrN: (a) => a * a,
584
+ addN: (a, l) => a + l,
585
+ subN: (a, l) => a - l,
586
+ mulN: (a, l) => a * l,
587
+ inv: (a) => Tt(a, e),
588
+ sqrt: r.sqrt || ((a) => o(c, a)),
589
+ invertBatch: (a) => Fi(c, a),
590
590
  // TODO: do we really need constant cmov?
591
591
  // We don't have const-time bigints anyway, so probably will be not very useful
592
- cmov: (c, u, f) => f ? u : c,
593
- toBytes: (c) => n ? Ft(c, o) : Se(c, o),
594
- fromBytes: (c) => {
595
- if (c.length !== o)
596
- throw new Error(`Fp.fromBytes: expected ${o}, got ${c.length}`);
597
- return n ? Gt(c) : F(c);
592
+ cmov: (a, l, f) => f ? l : a,
593
+ toBytes: (a) => n ? Ft(a, s) : Ne(a, s),
594
+ fromBytes: (a) => {
595
+ if (a.length !== s)
596
+ throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);
597
+ return n ? Gt(a) : F(a);
598
598
  }
599
599
  });
600
- return Object.freeze(a);
600
+ return Object.freeze(c);
601
601
  }
602
602
  function Xn(e) {
603
603
  if (typeof e != "bigint")
@@ -610,30 +610,30 @@ function Qn(e) {
610
610
  return t + Math.ceil(t / 2);
611
611
  }
612
612
  function Yi(e, t, n = !1) {
613
- const r = e.length, i = Xn(t), o = Qn(t);
614
- if (r < 16 || r < o || r > 1024)
615
- throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);
616
- const s = n ? F(e) : Gt(e), a = V(s, t - D) + D;
617
- return n ? Ft(a, i) : Se(a, i);
613
+ const r = e.length, i = Xn(t), s = Qn(t);
614
+ if (r < 16 || r < s || r > 1024)
615
+ throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);
616
+ const o = n ? F(e) : Gt(e), c = V(o, t - j) + j;
617
+ return n ? Ft(c, i) : Ne(c, i);
618
618
  }
619
619
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
620
- const Xi = BigInt(0), St = BigInt(1);
620
+ const Xi = BigInt(0), Nt = BigInt(1);
621
621
  function Qi(e, t) {
622
- const n = (i, o) => {
623
- const s = o.negate();
624
- return i ? s : o;
622
+ const n = (i, s) => {
623
+ const o = s.negate();
624
+ return i ? o : s;
625
625
  }, r = (i) => {
626
- const o = Math.ceil(t / i) + 1, s = 2 ** (i - 1);
627
- return { windows: o, windowSize: s };
626
+ const s = Math.ceil(t / i) + 1, o = 2 ** (i - 1);
627
+ return { windows: s, windowSize: o };
628
628
  };
629
629
  return {
630
630
  constTimeNegate: n,
631
631
  // non-const time multiplication ladder
632
- unsafeLadder(i, o) {
633
- let s = e.ZERO, a = i;
634
- for (; o > Xi; )
635
- o & St && (s = s.add(a)), a = a.double(), o >>= St;
636
- return s;
632
+ unsafeLadder(i, s) {
633
+ let o = e.ZERO, c = i;
634
+ for (; s > Xi; )
635
+ s & Nt && (o = o.add(c)), c = c.double(), s >>= Nt;
636
+ return o;
637
637
  },
638
638
  /**
639
639
  * Creates a wNAF precomputation window. Used for caching.
@@ -645,16 +645,16 @@ function Qi(e, t) {
645
645
  * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
646
646
  * @returns precomputed point tables flattened to a single array
647
647
  */
648
- precomputeWindow(i, o) {
649
- const { windows: s, windowSize: a } = r(o), c = [];
650
- let u = i, f = u;
651
- for (let l = 0; l < s; l++) {
652
- f = u, c.push(f);
653
- for (let g = 1; g < a; g++)
654
- f = f.add(u), c.push(f);
655
- u = f.double();
648
+ precomputeWindow(i, s) {
649
+ const { windows: o, windowSize: c } = r(s), a = [];
650
+ let l = i, f = l;
651
+ for (let u = 0; u < o; u++) {
652
+ f = l, a.push(f);
653
+ for (let g = 1; g < c; g++)
654
+ f = f.add(l), a.push(f);
655
+ l = f.double();
656
656
  }
657
- return c;
657
+ return a;
658
658
  },
659
659
  /**
660
660
  * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
@@ -663,28 +663,28 @@ function Qi(e, t) {
663
663
  * @param n scalar (we don't check here, but should be less than curve order)
664
664
  * @returns real and fake (for const-time) points
665
665
  */
666
- wNAF(i, o, s) {
667
- const { windows: a, windowSize: c } = r(i);
668
- let u = e.ZERO, f = e.BASE;
669
- const l = BigInt(2 ** i - 1), g = 2 ** i, b = BigInt(i);
670
- for (let p = 0; p < a; p++) {
671
- const h = p * c;
672
- let d = Number(s & l);
673
- s >>= b, d > c && (d -= g, s += St);
674
- const y = h, E = h + Math.abs(d) - 1, N = p % 2 !== 0, _ = d < 0;
675
- d === 0 ? f = f.add(n(N, o[y])) : u = u.add(n(_, o[E]));
666
+ wNAF(i, s, o) {
667
+ const { windows: c, windowSize: a } = r(i);
668
+ let l = e.ZERO, f = e.BASE;
669
+ const u = BigInt(2 ** i - 1), g = 2 ** i, b = BigInt(i);
670
+ for (let p = 0; p < c; p++) {
671
+ const h = p * a;
672
+ let d = Number(o & u);
673
+ o >>= b, d > a && (d -= g, o += Nt);
674
+ const y = h, m = h + Math.abs(d) - 1, A = p % 2 !== 0, U = d < 0;
675
+ d === 0 ? f = f.add(n(A, s[y])) : l = l.add(n(U, s[m]));
676
676
  }
677
- return { p: u, f };
677
+ return { p: l, f };
678
678
  },
679
- wNAFCached(i, o, s, a) {
680
- const c = i._WINDOW_SIZE || 1;
681
- let u = o.get(i);
682
- return u || (u = this.precomputeWindow(i, c), c !== 1 && o.set(i, a(u))), this.wNAF(c, u, s);
679
+ wNAFCached(i, s, o, c) {
680
+ const a = i._WINDOW_SIZE || 1;
681
+ let l = s.get(i);
682
+ return l || (l = this.precomputeWindow(i, a), a !== 1 && s.set(i, c(l))), this.wNAF(a, l, o);
683
683
  }
684
684
  };
685
685
  }
686
686
  function er(e) {
687
- return Zi(e.Fp), Je(e, {
687
+ return Zi(e.Fp), Ye(e, {
688
688
  n: "bigint",
689
689
  h: "bigint",
690
690
  Gx: "field",
@@ -699,9 +699,9 @@ function er(e) {
699
699
  });
700
700
  }
701
701
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
702
- function eo(e) {
702
+ function es(e) {
703
703
  const t = er(e);
704
- Je(t, {
704
+ Ye(t, {
705
705
  a: "field",
706
706
  b: "field"
707
707
  }, {
@@ -722,7 +722,7 @@ function eo(e) {
722
722
  }
723
723
  return Object.freeze({ ...t });
724
724
  }
725
- const { bytesToNumberBE: to, hexToBytes: no } = qi, Be = {
725
+ const { bytesToNumberBE: ts, hexToBytes: ns } = qi, ke = {
726
726
  // asn.1 DER encoding utils
727
727
  Err: class extends Error {
728
728
  constructor(t = "") {
@@ -730,7 +730,7 @@ const { bytesToNumberBE: to, hexToBytes: no } = qi, Be = {
730
730
  }
731
731
  },
732
732
  _parseInt(e) {
733
- const { Err: t } = Be;
733
+ const { Err: t } = ke;
734
734
  if (e.length < 2 || e[0] !== 2)
735
735
  throw new t("Invalid signature integer tag");
736
736
  const n = e[1], r = e.subarray(2, n + 2);
@@ -740,10 +740,10 @@ const { bytesToNumberBE: to, hexToBytes: no } = qi, Be = {
740
740
  throw new t("Invalid signature integer: negative");
741
741
  if (r[0] === 0 && !(r[1] & 128))
742
742
  throw new t("Invalid signature integer: unnecessary leading zero");
743
- return { d: to(r), l: e.subarray(n + 2) };
743
+ return { d: ts(r), l: e.subarray(n + 2) };
744
744
  },
745
745
  toSig(e) {
746
- const { Err: t } = Be, n = typeof e == "string" ? no(e) : e;
746
+ const { Err: t } = ke, n = typeof e == "string" ? ns(e) : e;
747
747
  if (!(n instanceof Uint8Array))
748
748
  throw new Error("ui8a expected");
749
749
  let r = n.length;
@@ -751,64 +751,64 @@ const { bytesToNumberBE: to, hexToBytes: no } = qi, Be = {
751
751
  throw new t("Invalid signature tag");
752
752
  if (n[1] !== r - 2)
753
753
  throw new t("Invalid signature: incorrect length");
754
- const { d: i, l: o } = Be._parseInt(n.subarray(2)), { d: s, l: a } = Be._parseInt(o);
755
- if (a.length)
754
+ const { d: i, l: s } = ke._parseInt(n.subarray(2)), { d: o, l: c } = ke._parseInt(s);
755
+ if (c.length)
756
756
  throw new t("Invalid signature: left bytes after parsing");
757
- return { r: i, s };
757
+ return { r: i, s: o };
758
758
  },
759
759
  hexFromSig(e) {
760
- const t = (u) => Number.parseInt(u[0], 16) & 8 ? "00" + u : u, n = (u) => {
761
- const f = u.toString(16);
760
+ const t = (l) => Number.parseInt(l[0], 16) & 8 ? "00" + l : l, n = (l) => {
761
+ const f = l.toString(16);
762
762
  return f.length & 1 ? `0${f}` : f;
763
- }, r = t(n(e.s)), i = t(n(e.r)), o = r.length / 2, s = i.length / 2, a = n(o), c = n(s);
764
- return `30${n(s + o + 4)}02${c}${i}02${a}${r}`;
763
+ }, r = t(n(e.s)), i = t(n(e.r)), s = r.length / 2, o = i.length / 2, c = n(s), a = n(o);
764
+ return `30${n(o + s + 4)}02${a}${i}02${c}${r}`;
765
765
  }
766
766
  }, ae = BigInt(0), Y = BigInt(1);
767
767
  BigInt(2);
768
- const Un = BigInt(3);
768
+ const _n = BigInt(3);
769
769
  BigInt(4);
770
- function ro(e) {
771
- const t = eo(e), { Fp: n } = t, r = t.toBytes || ((p, h, d) => {
770
+ function rs(e) {
771
+ const t = es(e), { Fp: n } = t, r = t.toBytes || ((p, h, d) => {
772
772
  const y = h.toAffine();
773
773
  return Ue(Uint8Array.from([4]), n.toBytes(y.x), n.toBytes(y.y));
774
774
  }), i = t.fromBytes || ((p) => {
775
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
776
  return { x: d, y };
777
777
  });
778
- function o(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);
778
+ function s(p) {
779
+ const { a: h, b: d } = t, y = n.sqr(p), m = n.mul(y, p);
780
+ return n.add(n.add(m, n.mul(p, h)), d);
781
781
  }
782
- if (!n.eql(n.sqr(t.Gy), o(t.Gx)))
782
+ if (!n.eql(n.sqr(t.Gy), s(t.Gx)))
783
783
  throw new Error("bad generator point: equation left != right");
784
- function s(p) {
784
+ function o(p) {
785
785
  return typeof p == "bigint" && ae < p && p < t.n;
786
786
  }
787
- function a(p) {
788
- if (!s(p))
787
+ function c(p) {
788
+ if (!o(p))
789
789
  throw new Error("Expected valid bigint: 0 < bigint < curve.n");
790
790
  }
791
- function c(p) {
792
- const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: y, n: E } = t;
791
+ function a(p) {
792
+ const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: y, n: m } = t;
793
793
  if (h && typeof p != "bigint") {
794
794
  if (p instanceof Uint8Array && (p = qe(p)), typeof p != "string" || !h.includes(p.length))
795
795
  throw new Error("Invalid key");
796
796
  p = p.padStart(d * 2, "0");
797
797
  }
798
- let N;
798
+ let A;
799
799
  try {
800
- N = typeof p == "bigint" ? p : F(W("private key", p, d));
800
+ A = 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 && (A = V(A, m)), c(A), A;
805
805
  }
806
- const u = /* @__PURE__ */ new Map();
806
+ const l = /* @__PURE__ */ new Map();
807
807
  function f(p) {
808
- if (!(p instanceof l))
808
+ if (!(p instanceof u))
809
809
  throw new Error("ProjectivePoint expected");
810
810
  }
811
- class l {
811
+ class u {
812
812
  constructor(h, d, y) {
813
813
  if (this.px = h, this.py = d, this.pz = y, h == null || !n.isValid(h))
814
814
  throw new Error("x required");
@@ -823,10 +823,10 @@ function ro(e) {
823
823
  const { x: d, y } = h || {};
824
824
  if (!h || !n.isValid(d) || !n.isValid(y))
825
825
  throw new Error("invalid affine point");
826
- if (h instanceof l)
826
+ if (h instanceof u)
827
827
  throw new Error("projective point not allowed");
828
- const E = (N) => n.eql(N, n.ZERO);
829
- return E(d) && E(y) ? l.ZERO : new l(d, y, n.ONE);
828
+ const m = (A) => n.eql(A, n.ZERO);
829
+ return m(d) && m(y) ? u.ZERO : new u(d, y, n.ONE);
830
830
  }
831
831
  get x() {
832
832
  return this.toAffine().x;
@@ -842,23 +842,23 @@ function ro(e) {
842
842
  */
843
843
  static normalizeZ(h) {
844
844
  const d = n.invertBatch(h.map((y) => y.pz));
845
- return h.map((y, E) => y.toAffine(d[E])).map(l.fromAffine);
845
+ return h.map((y, m) => y.toAffine(d[m])).map(u.fromAffine);
846
846
  }
847
847
  /**
848
848
  * Converts hash string or Uint8Array to Point.
849
849
  * @param hex short/long ECDSA hex
850
850
  */
851
851
  static fromHex(h) {
852
- const d = l.fromAffine(i(W("pointHex", h)));
852
+ const d = u.fromAffine(i(W("pointHex", h)));
853
853
  return d.assertValidity(), d;
854
854
  }
855
855
  // Multiplies generator point by privateKey.
856
856
  static fromPrivateKey(h) {
857
- return l.BASE.multiply(c(h));
857
+ return u.BASE.multiply(a(h));
858
858
  }
859
859
  // "Private method", don't use it directly
860
860
  _setWindowSize(h) {
861
- this._WINDOW_SIZE = h, u.delete(this);
861
+ this._WINDOW_SIZE = h, l.delete(this);
862
862
  }
863
863
  // A point on curve is valid if it conforms to equation.
864
864
  assertValidity() {
@@ -870,8 +870,8 @@ function ro(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 y = n.sqr(d), E = o(h);
874
- if (!n.eql(y, E))
873
+ const y = n.sqr(d), m = s(h);
874
+ if (!n.eql(y, m))
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,23 +887,23 @@ function ro(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));
891
- return m && x;
890
+ const { px: d, py: y, pz: m } = this, { px: A, py: U, pz: B } = h, E = n.eql(n.mul(d, B), n.mul(A, m)), x = n.eql(n.mul(y, B), n.mul(U, m));
891
+ return E && x;
892
892
  }
893
893
  /**
894
894
  * Flips point to one corresponding to (x, -y) in Affine coordinates.
895
895
  */
896
896
  negate() {
897
- return new l(this.px, n.neg(this.py), this.pz);
897
+ return new u(this.px, n.neg(this.py), this.pz);
898
898
  }
899
899
  // Renes-Costello-Batina exception-free doubling formula.
900
900
  // There is 30% faster Jacobian formula, but it is not complete.
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, A = 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(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(N, _), U = n.add(U, U), A = n.mul(U, K), B = n.sub(B, A), x = n.mul(U, H), x = n.add(x, x), x = n.add(x, x), new l(B, m, x);
904
+ const { a: h, b: d } = t, y = n.mul(d, _n), { px: m, py: A, pz: U } = this;
905
+ let B = n.ZERO, E = n.ZERO, x = n.ZERO, S = n.mul(m, m), P = n.mul(A, A), _ = n.mul(U, U), K = n.mul(m, A);
906
+ return K = n.add(K, K), x = n.mul(m, U), x = n.add(x, x), B = n.mul(h, x), E = n.mul(y, _), E = n.add(B, E), B = n.sub(P, E), E = n.add(P, E), E = n.mul(B, E), B = n.mul(K, B), x = n.mul(y, x), _ = n.mul(h, _), K = n.sub(S, _), K = n.mul(h, K), K = n.add(K, x), x = n.add(S, S), S = n.add(x, S), S = n.add(S, _), S = n.mul(S, K), E = n.add(E, S), _ = n.mul(A, U), _ = n.add(_, _), S = n.mul(_, K), B = n.sub(B, S), x = n.mul(_, P), x = n.add(x, x), x = n.add(x, x), new u(B, E, 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,24 +911,24 @@ function ro(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, A = 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), A = n.mul(H, 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(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), A = n.mul(v, A), A = n.add(A, K), new l(m, x, A);
914
+ const { px: d, py: y, pz: m } = this, { px: A, py: U, pz: B } = h;
915
+ let E = n.ZERO, x = n.ZERO, S = n.ZERO;
916
+ const P = t.a, _ = n.mul(t.b, _n);
917
+ let K = n.mul(d, A), T = n.mul(y, U), R = n.mul(m, B), H = n.add(d, y), w = n.add(A, U);
918
+ H = n.mul(H, w), w = n.add(K, T), H = n.sub(H, w), w = n.add(d, m);
919
+ let v = n.add(A, B);
920
+ return w = n.mul(w, v), v = n.add(K, R), w = n.sub(w, v), v = n.add(y, m), E = n.add(U, B), v = n.mul(v, E), E = n.add(T, R), v = n.sub(v, E), S = n.mul(P, w), E = n.mul(_, R), S = n.add(E, S), E = n.sub(T, S), S = n.add(T, S), x = n.mul(E, S), T = n.add(K, K), T = n.add(T, K), R = n.mul(P, R), w = n.mul(_, 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), E = n.mul(H, E), E = n.sub(E, K), K = n.mul(H, T), S = n.mul(v, S), S = n.add(S, K), new u(E, x, S);
921
921
  }
922
922
  subtract(h) {
923
923
  return this.add(h.negate());
924
924
  }
925
925
  is0() {
926
- return this.equals(l.ZERO);
926
+ return this.equals(u.ZERO);
927
927
  }
928
928
  wNAF(h) {
929
- return b.wNAFCached(this, u, h, (d) => {
930
- const y = n.invertBatch(d.map((E) => E.pz));
931
- return d.map((E, N) => E.toAffine(y[N])).map(l.fromAffine);
929
+ return b.wNAFCached(this, l, h, (d) => {
930
+ const y = n.invertBatch(d.map((m) => m.pz));
931
+ return d.map((m, A) => m.toAffine(y[A])).map(u.fromAffine);
932
932
  });
933
933
  }
934
934
  /**
@@ -937,18 +937,18 @@ function ro(e) {
937
937
  * an exposed private key e.g. sig verification, which works over *public* keys.
938
938
  */
939
939
  multiplyUnsafe(h) {
940
- const d = l.ZERO;
940
+ const d = u.ZERO;
941
941
  if (h === ae)
942
942
  return d;
943
- if (a(h), h === Y)
943
+ if (c(h), h === Y)
944
944
  return this;
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, A = this;
949
- for (; N > ae || B > ae; )
950
- N & Y && (m = m.add(A)), B & Y && (x = x.add(A)), A = A.double(), N >>= Y, B >>= Y;
951
- return E && (m = m.negate()), _ && (x = x.negate()), x = new l(n.mul(x.px, y.beta), x.py, x.pz), m.add(x);
948
+ let { k1neg: m, k1: A, k2neg: U, k2: B } = y.splitScalar(h), E = d, x = d, S = this;
949
+ for (; A > ae || B > ae; )
950
+ A & Y && (E = E.add(S)), B & Y && (x = x.add(S)), S = S.double(), A >>= Y, B >>= Y;
951
+ return m && (E = E.negate()), U && (x = x.negate()), x = new u(n.mul(x.px, y.beta), x.py, x.pz), E.add(x);
952
952
  }
953
953
  /**
954
954
  * Constant time multiplication.
@@ -960,18 +960,18 @@ function ro(e) {
960
960
  * @returns New point
961
961
  */
962
962
  multiply(h) {
963
- a(h);
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: A, f: H } = this.wNAF(B), { p: U, f: K } = this.wNAF(x);
969
- A = b.constTimeNegate(_, A), U = b.constTimeNegate(m, U), U = new l(n.mul(U.px, N.beta), U.py, U.pz), y = A.add(U), E = H.add(K);
963
+ c(h);
964
+ let d = h, y, m;
965
+ const { endo: A } = t;
966
+ if (A) {
967
+ const { k1neg: U, k1: B, k2neg: E, k2: x } = A.splitScalar(d);
968
+ let { p: S, f: P } = this.wNAF(B), { p: _, f: K } = this.wNAF(x);
969
+ S = b.constTimeNegate(U, S), _ = b.constTimeNegate(E, _), _ = new u(n.mul(_.px, A.beta), _.py, _.pz), y = S.add(_), m = P.add(K);
970
970
  } else {
971
- const { p: _, f: B } = this.wNAF(d);
972
- y = _, E = B;
971
+ const { p: U, f: B } = this.wNAF(d);
972
+ y = U, m = B;
973
973
  }
974
- return l.normalizeZ([y, E])[0];
974
+ return u.normalizeZ([y, m])[0];
975
975
  }
976
976
  /**
977
977
  * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
@@ -980,54 +980,54 @@ function ro(e) {
980
980
  * @returns non-zero affine point
981
981
  */
982
982
  multiplyAndAddUnsafe(h, d, y) {
983
- const E = l.BASE, N = (B, m) => m === ae || m === Y || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), _ = N(this, d).add(N(h, y));
984
- return _.is0() ? void 0 : _;
983
+ const m = u.BASE, A = (B, E) => E === ae || E === Y || !B.equals(m) ? B.multiplyUnsafe(E) : B.multiply(E), U = A(this, d).add(A(h, y));
984
+ return U.is0() ? void 0 : U;
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));
992
- const _ = n.mul(d, h), B = n.mul(y, h), m = n.mul(E, h);
993
- if (N)
990
+ const { px: d, py: y, pz: m } = this, A = this.is0();
991
+ h == null && (h = A ? n.ONE : n.inv(m));
992
+ const U = n.mul(d, h), B = n.mul(y, h), E = n.mul(m, h);
993
+ if (A)
994
994
  return { x: n.ZERO, y: n.ZERO };
995
- if (!n.eql(m, n.ONE))
995
+ if (!n.eql(E, n.ONE))
996
996
  throw new Error("invZ was invalid");
997
- return { x: _, y: B };
997
+ return { x: U, y: B };
998
998
  }
999
999
  isTorsionFree() {
1000
1000
  const { h, isTorsionFree: d } = t;
1001
1001
  if (h === Y)
1002
1002
  return !0;
1003
1003
  if (d)
1004
- return d(l, this);
1004
+ return d(u, this);
1005
1005
  throw new Error("isTorsionFree() has not been declared for the elliptic curve");
1006
1006
  }
1007
1007
  clearCofactor() {
1008
1008
  const { h, clearCofactor: d } = t;
1009
- return h === Y ? this : d ? d(l, this) : this.multiplyUnsafe(t.h);
1009
+ return h === Y ? this : d ? d(u, this) : this.multiplyUnsafe(t.h);
1010
1010
  }
1011
1011
  toRawBytes(h = !0) {
1012
- return this.assertValidity(), r(l, this, h);
1012
+ return this.assertValidity(), r(u, this, h);
1013
1013
  }
1014
1014
  toHex(h = !0) {
1015
1015
  return qe(this.toRawBytes(h));
1016
1016
  }
1017
1017
  }
1018
- l.BASE = new l(t.Gx, t.Gy, n.ONE), l.ZERO = new l(n.ZERO, n.ONE, n.ZERO);
1019
- const g = t.nBitLength, b = Qi(l, t.endo ? Math.ceil(g / 2) : g);
1018
+ u.BASE = new u(t.Gx, t.Gy, n.ONE), u.ZERO = new u(n.ZERO, n.ONE, n.ZERO);
1019
+ const g = t.nBitLength, b = Qi(u, t.endo ? Math.ceil(g / 2) : g);
1020
1020
  return {
1021
1021
  CURVE: t,
1022
- ProjectivePoint: l,
1023
- normPrivateKeyToScalar: c,
1024
- weierstrassEquation: o,
1025
- isWithinCurveOrder: s
1022
+ ProjectivePoint: u,
1023
+ normPrivateKeyToScalar: a,
1024
+ weierstrassEquation: s,
1025
+ isWithinCurveOrder: o
1026
1026
  };
1027
1027
  }
1028
- function io(e) {
1028
+ function is(e) {
1029
1029
  const t = er(e);
1030
- return Je(t, {
1030
+ return Ye(t, {
1031
1031
  hash: "hash",
1032
1032
  hmac: "function",
1033
1033
  randomBytes: "function"
@@ -1037,62 +1037,62 @@ function io(e) {
1037
1037
  lowS: "boolean"
1038
1038
  }), Object.freeze({ lowS: !0, ...t });
1039
1039
  }
1040
- function oo(e) {
1041
- const t = io(e), { Fp: n, n: r } = t, i = n.BYTES + 1, o = 2 * n.BYTES + 1;
1042
- function s(w) {
1040
+ function ss(e) {
1041
+ const t = is(e), { Fp: n, n: r } = t, i = n.BYTES + 1, s = 2 * n.BYTES + 1;
1042
+ function o(w) {
1043
1043
  return ae < w && w < n.ORDER;
1044
1044
  }
1045
- function a(w) {
1045
+ function c(w) {
1046
1046
  return V(w, r);
1047
1047
  }
1048
- function c(w) {
1048
+ function a(w) {
1049
1049
  return Tt(w, r);
1050
1050
  }
1051
- const { ProjectivePoint: u, normPrivateKeyToScalar: f, weierstrassEquation: l, isWithinCurveOrder: g } = ro({
1051
+ const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: g } = rs({
1052
1052
  ...t,
1053
- toBytes(w, v, S) {
1054
- const C = v.toAffine(), k = n.toBytes(C.x), I = Ue;
1055
- return S ? 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, S = w[0], C = w.subarray(1);
1059
- if (v === i && (S === 2 || S === 3)) {
1060
- const k = F(C);
1061
- if (!s(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 = l(k);
1063
+ const I = u(C);
1064
1064
  let O = n.sqrt(I);
1065
1065
  const $ = (O & Y) === Y;
1066
- return (S & 1) === 1 !== $ && (O = n.neg(O)), { x: k, y: O };
1067
- } else if (v === o && S === 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
- throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`);
1071
+ throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`);
1072
1072
  }
1073
- }), b = (w) => qe(Se(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;
1077
1077
  }
1078
1078
  function h(w) {
1079
- return p(w) ? a(-w) : w;
1079
+ return p(w) ? c(-w) : w;
1080
1080
  }
1081
- const d = (w, v, S) => F(w.slice(v, S));
1081
+ const d = (w, v, N) => F(w.slice(v, N));
1082
1082
  class y {
1083
- constructor(v, S, C) {
1084
- this.r = v, this.s = S, 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 S = t.nByteLength;
1089
- return v = W("compactSignature", v, S * 2), new y(d(v, 0, S), d(v, S, 2 * S));
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: S, s: C } = Be.toSig(W("DER", v));
1095
- return new y(S, C);
1094
+ const { r: N, s: k } = ke.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 oo(e) {
1104
1104
  return new y(this.r, this.s, v);
1105
1105
  }
1106
1106
  recoverPublicKey(v) {
1107
- const { r: S, 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 ? S + t.n : S;
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 = u.fromHex($ + b(O)), ge = c(O), Ie = a(-I * ge), Ve = a(C * ge), we = u.BASE.multiplyAndAddUnsafe(Q, Ie, Ve);
1113
+ const $ = C & 1 ? "03" : "02", Q = l.fromHex($ + b(O)), ge = a(O), Le = c(-I * ge), Ve = c(k * ge), we = l.BASE.multiplyAndAddUnsafe(Q, Le, Ve);
1114
1114
  if (!we)
1115
1115
  throw new Error("point at infinify");
1116
1116
  return we.assertValidity(), we;
@@ -1120,14 +1120,14 @@ function oo(e) {
1120
1120
  return p(this.s);
1121
1121
  }
1122
1122
  normalizeS() {
1123
- return this.hasHighS() ? new y(this.r, a(-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() {
1127
1127
  return De(this.toDERHex());
1128
1128
  }
1129
1129
  toDERHex() {
1130
- return Be.hexFromSig({ r: this.r, s: this.s });
1130
+ return ke.hexFromSig({ r: this.r, s: this.s });
1131
1131
  }
1132
1132
  // padded bytes of r, then padded bytes of s
1133
1133
  toCompactRawBytes() {
@@ -1137,7 +1137,7 @@ function oo(e) {
1137
1137
  return b(this.r) + b(this.s);
1138
1138
  }
1139
1139
  }
1140
- const E = {
1140
+ const m = {
1141
1141
  isValidPrivateKey(w) {
1142
1142
  try {
1143
1143
  return f(w), !0;
@@ -1162,92 +1162,92 @@ function oo(e) {
1162
1162
  * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
1163
1163
  * fast.multiply(privKey); // much faster ECDH now
1164
1164
  */
1165
- precompute(w = 8, v = u.BASE) {
1165
+ precompute(w = 8, v = l.BASE) {
1166
1166
  return v._setWindowSize(w), v.multiply(BigInt(3)), v;
1167
1167
  }
1168
1168
  };
1169
- function N(w, v = !0) {
1170
- return u.fromPrivateKey(w).toRawBytes(v);
1169
+ function A(w, v = !0) {
1170
+ return l.fromPrivateKey(w).toRawBytes(v);
1171
1171
  }
1172
- function _(w) {
1173
- const v = w instanceof Uint8Array, S = typeof w == "string", C = (v || S) && w.length;
1174
- return v ? C === i || C === o : S ? C === 2 * i || C === 2 * o : w instanceof u;
1172
+ function U(w) {
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, S = !0) {
1177
- if (_(w))
1176
+ function B(w, v, N = !0) {
1177
+ if (U(w))
1178
1178
  throw new Error("first arg must be private key");
1179
- if (!_(v))
1179
+ if (!U(v))
1180
1180
  throw new Error("second arg must be public key");
1181
- return u.fromHex(v).multiply(f(w)).toRawBytes(S);
1181
+ return l.fromHex(v).multiply(f(w)).toRawBytes(N);
1182
1182
  }
1183
- const m = t.bits2int || function(w) {
1184
- const v = F(w), S = w.length * 8 - t.nBitLength;
1185
- return S > 0 ? v >> BigInt(S) : v;
1183
+ const E = t.bits2int || function(w) {
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
- return a(m(w));
1188
- }, A = Jt(t.nBitLength);
1189
- function H(w) {
1187
+ return c(E(w));
1188
+ }, S = 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 < A))
1192
+ if (!(ae <= w && w < S))
1193
1193
  throw new Error(`bigint expected < 2^${t.nBitLength}`);
1194
- return Se(w, t.nByteLength);
1194
+ return Ne(w, t.nByteLength);
1195
1195
  }
1196
- function U(w, v, S = K) {
1197
- if (["recovered", "canonical"].some((Ke) => Ke in S))
1196
+ function _(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: $ } = S;
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), Le = [P(ge), P(Q)];
1203
1203
  if ($ != null) {
1204
- const Ke = $ === !0 ? k(n.BYTES) : $;
1205
- Ie.push(W("extraEntropy", Ke));
1204
+ const Ke = $ === !0 ? C(n.BYTES) : $;
1205
+ Le.push(W("extraEntropy", Ke));
1206
1206
  }
1207
- const Ve = Ue(...Ie), we = Q;
1208
- function mt(Ke) {
1209
- const Le = m(Ke);
1210
- if (!g(Le))
1207
+ const Ve = Ue(...Le), we = Q;
1208
+ function Et(Ke) {
1209
+ const $e = E(Ke);
1210
+ if (!g($e))
1211
1211
  return;
1212
- const An = c(Le), $e = u.BASE.multiply(Le).toAffine(), ee = a($e.x);
1212
+ const Sn = a($e), Te = l.BASE.multiply($e).toAffine(), ee = c(Te.x);
1213
1213
  if (ee === ae)
1214
1214
  return;
1215
- const Te = a(An * a(we + ee * ge));
1216
- if (Te === ae)
1215
+ const Re = c(Sn * c(we + ee * ge));
1216
+ if (Re === ae)
1217
1217
  return;
1218
- let Sn = ($e.x === ee ? 0 : 2) | Number($e.y & Y), Nn = Te;
1219
- return I && p(Te) && (Nn = h(Te), Sn ^= 1), new y(ee, Nn, Sn);
1218
+ let Nn = (Te.x === ee ? 0 : 2) | Number(Te.y & Y), An = Re;
1219
+ return I && p(Re) && (An = h(Re), Nn ^= 1), new y(ee, An, Nn);
1220
1220
  }
1221
- return { seed: Ve, k2sig: mt };
1221
+ return { seed: Ve, k2sig: Et };
1222
1222
  }
1223
1223
  const K = { lowS: t.lowS, prehash: !1 }, T = { lowS: t.lowS, prehash: !1 };
1224
- function R(w, v, S = K) {
1225
- const { seed: C, k2sig: k } = U(w, v, S), I = t;
1226
- return Jn(I.hash.outputLen, I.nByteLength, I.hmac)(C, k);
1227
- }
1228
- u.BASE._setWindowSize(8);
1229
- function P(w, v, S, C = T) {
1230
- var $e;
1231
- const k = w;
1232
- if (v = W("msgHash", v), S = W("publicKey", S), "strict" in C)
1224
+ function R(w, v, N = K) {
1225
+ const { seed: k, k2sig: C } = _(w, v, N), I = t;
1226
+ return Jn(I.hash.outputLen, I.nByteLength, I.hmac)(k, C);
1227
+ }
1228
+ l.BASE._setWindowSize(8);
1229
+ function H(w, v, N, k = T) {
1230
+ var Te;
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
- if (!(ee instanceof Be.Err))
1241
+ if (!(ee instanceof ke.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;
1247
- $ = new y(ee, Te);
1245
+ else if (typeof C == "object" && typeof C.r == "bigint" && typeof C.s == "bigint") {
1246
+ const { r: ee, s: Re } = C;
1247
+ $ = new y(ee, Re);
1248
1248
  } else
1249
1249
  throw new Error("PARSE");
1250
- Q = u.fromHex(S);
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");
@@ -1256,35 +1256,35 @@ function oo(e) {
1256
1256
  if (I && $.hasHighS())
1257
1257
  return !1;
1258
1258
  O && (v = t.hash(v));
1259
- const { r: ge, s: Ie } = $, Ve = x(v), we = c(Ie), mt = a(Ve * we), Ke = a(ge * we), Le = ($e = u.BASE.multiplyAndAddUnsafe(Q, mt, Ke)) == null ? void 0 : $e.toAffine();
1260
- return Le ? a(Le.x) === ge : !1;
1259
+ const { r: ge, s: Le } = $, Ve = x(v), we = a(Le), Et = c(Ve * we), Ke = c(ge * we), $e = (Te = l.BASE.multiplyAndAddUnsafe(Q, Et, Ke)) == null ? void 0 : Te.toAffine();
1260
+ return $e ? c($e.x) === ge : !1;
1261
1261
  }
1262
1262
  return {
1263
1263
  CURVE: t,
1264
- getPublicKey: N,
1264
+ getPublicKey: A,
1265
1265
  getSharedSecret: B,
1266
1266
  sign: R,
1267
- verify: P,
1268
- ProjectivePoint: u,
1267
+ verify: H,
1268
+ ProjectivePoint: l,
1269
1269
  Signature: y,
1270
- utils: E
1270
+ utils: m
1271
1271
  };
1272
1272
  }
1273
1273
  let tr = class extends Wn {
1274
1274
  constructor(t, n) {
1275
- super(), this.finished = !1, this.destroyed = !1, mi(t);
1275
+ super(), this.finished = !1, this.destroyed = !1, Ei(t);
1276
1276
  const r = Wt(n);
1277
1277
  if (this.iHash = t.create(), typeof this.iHash.update != "function")
1278
1278
  throw new Error("Expected instance of class which extends utils.Hash");
1279
1279
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
1280
- const i = this.blockLen, o = new Uint8Array(i);
1281
- o.set(r.length > i ? t.create().update(r).digest() : r);
1282
- for (let s = 0; s < o.length; s++)
1283
- o[s] ^= 54;
1284
- this.iHash.update(o), this.oHash = t.create();
1285
- for (let s = 0; s < o.length; s++)
1286
- o[s] ^= 106;
1287
- this.oHash.update(o), o.fill(0);
1280
+ const i = this.blockLen, s = new Uint8Array(i);
1281
+ s.set(r.length > i ? t.create().update(r).digest() : r);
1282
+ for (let o = 0; o < s.length; o++)
1283
+ s[o] ^= 54;
1284
+ this.iHash.update(s), this.oHash = t.create();
1285
+ for (let o = 0; o < s.length; o++)
1286
+ s[o] ^= 106;
1287
+ this.oHash.update(s), s.fill(0);
1288
1288
  }
1289
1289
  update(t) {
1290
1290
  return et(this), this.iHash.update(t), this;
@@ -1298,8 +1298,8 @@ let tr = class extends Wn {
1298
1298
  }
1299
1299
  _cloneInto(t) {
1300
1300
  t || (t = Object.create(Object.getPrototypeOf(this), {}));
1301
- const { oHash: n, iHash: r, finished: i, destroyed: o, blockLen: s, outputLen: a } = this;
1302
- return t = t, t.finished = i, t.destroyed = o, t.blockLen = s, t.outputLen = a, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
1301
+ const { oHash: n, iHash: r, finished: i, destroyed: s, blockLen: o, outputLen: c } = this;
1302
+ return t = t, t.finished = i, t.destroyed = s, t.blockLen = o, t.outputLen = c, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
1303
1303
  }
1304
1304
  destroy() {
1305
1305
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
@@ -1308,26 +1308,26 @@ let tr = class extends Wn {
1308
1308
  const nr = (e, t, n) => new tr(e, t).update(n).digest();
1309
1309
  nr.create = (e, t) => new tr(e, t);
1310
1310
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1311
- function so(e) {
1311
+ function os(e) {
1312
1312
  return {
1313
1313
  hash: e,
1314
- hmac: (t, ...n) => nr(e, t, Si(...n)),
1314
+ hmac: (t, ...n) => nr(e, t, Ni(...n)),
1315
1315
  randomBytes: Zn
1316
1316
  };
1317
1317
  }
1318
- function ao(e, t) {
1319
- const n = (r) => oo({ ...e, ...so(r) });
1318
+ function as(e, t) {
1319
+ const n = (r) => ss({ ...e, ...os(r) });
1320
1320
  return Object.freeze({ ...n(t), create: n });
1321
1321
  }
1322
1322
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1323
- const ct = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), tt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), rr = BigInt(1), nt = BigInt(2), _n = (e, t) => (e + t / nt) / t;
1323
+ const ct = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), tt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), rr = BigInt(1), nt = BigInt(2), Un = (e, t) => (e + t / nt) / t;
1324
1324
  function ir(e) {
1325
- const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), o = BigInt(22), s = BigInt(23), a = BigInt(44), c = BigInt(88), u = e * e * e % t, f = u * u * e % t, l = J(f, n, t) * f % t, g = J(l, n, t) * f % t, b = J(g, nt, t) * u % t, p = J(b, i, t) * b % t, h = J(p, o, 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, s, t) * p % t, B = J(_, r, t) * u % t, m = J(B, nt, t);
1326
- if (!Rt.eql(Rt.sqr(m), 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 = 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, c, t) * h % t, y = J(d, a, t) * d % t, m = J(y, c, t) * h % t, A = J(m, n, t) * f % t, U = J(A, o, t) * p % t, B = J(U, r, t) * l % t, E = J(B, nt, t);
1326
+ if (!Rt.eql(Rt.sqr(E), e))
1327
1327
  throw new Error("Cannot find square root");
1328
- return m;
1328
+ return E;
1329
1329
  }
1330
- const Rt = Ji(ct, void 0, void 0, { sqrt: ir }), _e = ao({
1330
+ const Rt = Ji(ct, void 0, void 0, { sqrt: ir }), Ie = as({
1331
1331
  a: BigInt(0),
1332
1332
  b: BigInt(7),
1333
1333
  Fp: Rt,
@@ -1346,15 +1346,15 @@ const Rt = Ji(ct, void 0, void 0, { sqrt: ir }), _e = ao({
1346
1346
  endo: {
1347
1347
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
1348
1348
  splitScalar: (e) => {
1349
- const t = tt, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -rr * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), o = n, s = BigInt("0x100000000000000000000000000000000"), a = _n(o * e, t), c = _n(-r * e, t);
1350
- let u = V(e - a * n - c * i, t), f = V(-a * r - c * o, t);
1351
- const l = u > s, g = f > s;
1352
- if (l && (u = t - u), g && (f = t - f), u > s || f > s)
1349
+ const t = tt, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -rr * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = n, o = BigInt("0x100000000000000000000000000000000"), c = Un(s * e, t), a = Un(-r * e, t);
1350
+ let l = V(e - c * n - a * i, t), f = V(-c * r - a * s, t);
1351
+ const u = l > o, g = f > o;
1352
+ if (u && (l = t - l), g && (f = t - f), l > o || f > o)
1353
1353
  throw new Error("splitScalar: Endomorphism failed, k=" + e);
1354
- return { k1neg: l, k1: u, k2neg: g, k2: f };
1354
+ return { k1neg: u, k1: l, k2neg: g, k2: f };
1355
1355
  }
1356
1356
  }
1357
- }, Lt), lt = BigInt(0), or = (e) => typeof e == "bigint" && lt < e && e < ct, co = (e) => typeof e == "bigint" && lt < e && e < tt, In = {};
1357
+ }, Lt), ut = BigInt(0), sr = (e) => typeof e == "bigint" && ut < e && e < ct, cs = (e) => typeof e == "bigint" && ut < e && e < tt, In = {};
1358
1358
  function rt(e, ...t) {
1359
1359
  let n = In[e];
1360
1360
  if (n === void 0) {
@@ -1363,75 +1363,75 @@ 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) => Se(e, 32), Nt = (e) => V(e, ct), Ge = (e) => V(e, tt), Xt = _e.ProjectivePoint, lo = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
1366
+ const Yt = (e) => e.toRawBytes(!0).slice(1), Ot = (e) => Ne(e, 32), At = (e) => V(e, ct), Fe = (e) => V(e, tt), Xt = Ie.ProjectivePoint, us = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
1367
1367
  function Mt(e) {
1368
- let t = _e.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
1369
- return { scalar: n.hasEvenY() ? t : Ge(-t), bytes: Yt(n) };
1368
+ let t = Ie.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
1369
+ return { scalar: n.hasEvenY() ? t : Fe(-t), bytes: Yt(n) };
1370
1370
  }
1371
- function sr(e) {
1372
- if (!or(e))
1371
+ function or(e) {
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 = At(e * e), n = At(t * e + BigInt(7));
1375
1375
  let r = ir(n);
1376
- r % nt !== lt && (r = Nt(-r));
1376
+ r % nt !== ut && (r = At(-r));
1377
1377
  const i = new Xt(e, r, rr);
1378
1378
  return i.assertValidity(), i;
1379
1379
  }
1380
1380
  function ar(...e) {
1381
- return Ge(F(rt("BIP0340/challenge", ...e)));
1381
+ return Fe(F(rt("BIP0340/challenge", ...e)));
1382
1382
  }
1383
- function uo(e) {
1383
+ function ls(e) {
1384
1384
  return Mt(e).bytes;
1385
1385
  }
1386
- function fo(e, t, n = Zn(32)) {
1387
- const r = W("message", e), { bytes: i, scalar: o } = Mt(t), s = W("auxRand", n, 32), a = Ot(o ^ F(rt("BIP0340/aux", s))), c = rt("BIP0340/nonce", a, i, r), u = Ge(F(c));
1388
- if (u === lt)
1386
+ function fs(e, t, n = Zn(32)) {
1387
+ const r = W("message", e), { bytes: i, scalar: s } = Mt(t), o = W("auxRand", n, 32), c = Ot(s ^ F(rt("BIP0340/aux", o))), a = rt("BIP0340/nonce", c, i, r), l = Fe(F(a));
1388
+ if (l === ut)
1389
1389
  throw new Error("sign failed: k is zero");
1390
- const { bytes: f, scalar: l } = Mt(u), g = ar(f, i, r), b = new Uint8Array(64);
1391
- if (b.set(f, 0), b.set(Ot(Ge(l + g * o)), 32), !cr(b, r, i))
1390
+ const { bytes: f, scalar: u } = Mt(l), g = ar(f, i, r), b = new Uint8Array(64);
1391
+ if (b.set(f, 0), b.set(Ot(Fe(u + g * s)), 32), !cr(b, r, i))
1392
1392
  throw new Error("sign: Invalid signature produced");
1393
1393
  return b;
1394
1394
  }
1395
1395
  function cr(e, t, n) {
1396
- const r = W("signature", e, 64), i = W("message", t), o = W("publicKey", n, 32);
1396
+ const r = W("signature", e, 64), i = W("message", t), s = W("publicKey", n, 32);
1397
1397
  try {
1398
- const s = sr(F(o)), a = F(r.subarray(0, 32));
1399
- if (!or(a))
1398
+ const o = or(F(s)), c = F(r.subarray(0, 32));
1399
+ if (!sr(c))
1400
1400
  return !1;
1401
- const c = F(r.subarray(32, 64));
1402
- if (!co(c))
1401
+ const a = F(r.subarray(32, 64));
1402
+ if (!cs(a))
1403
1403
  return !1;
1404
- const u = ar(Ot(a), Yt(s), i), f = lo(s, c, Ge(-u));
1405
- return !(!f || !f.hasEvenY() || f.toAffine().x !== a);
1404
+ const l = ar(Ot(c), Yt(o), i), f = us(o, a, Fe(-l));
1405
+ return !(!f || !f.hasEvenY() || f.toAffine().x !== c);
1406
1406
  } catch {
1407
1407
  return !1;
1408
1408
  }
1409
1409
  }
1410
1410
  const We = {
1411
- getPublicKey: uo,
1412
- sign: fo,
1411
+ getPublicKey: ls,
1412
+ sign: fs,
1413
1413
  verify: cr,
1414
1414
  utils: {
1415
- randomPrivateKey: _e.utils.randomPrivateKey,
1416
- lift_x: sr,
1415
+ randomPrivateKey: Ie.utils.randomPrivateKey,
1416
+ lift_x: or,
1417
1417
  pointToBytes: Yt,
1418
- numberToBytesBE: Se,
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, ho = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1426
- if (!ho)
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
+ if (!hs)
1427
1427
  throw new Error("Non little-endian hardware is not supported");
1428
- const po = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1428
+ const ds = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1429
1429
  function M(e) {
1430
1430
  if (!Qt(e))
1431
1431
  throw new Error("Uint8Array expected");
1432
1432
  let t = "";
1433
1433
  for (let n = 0; n < e.length; n++)
1434
- t += po[e[n]];
1434
+ t += ds[e[n]];
1435
1435
  return t;
1436
1436
  }
1437
1437
  function G(e) {
@@ -1442,24 +1442,24 @@ function G(e) {
1442
1442
  throw new Error("padded hex string expected, got unpadded hex of length " + t);
1443
1443
  const n = new Uint8Array(t / 2);
1444
1444
  for (let r = 0; r < n.length; r++) {
1445
- const i = r * 2, o = e.slice(i, i + 2), s = Number.parseInt(o, 16);
1446
- if (Number.isNaN(s) || s < 0)
1445
+ const i = r * 2, s = e.slice(i, i + 2), o = Number.parseInt(s, 16);
1446
+ if (Number.isNaN(o) || o < 0)
1447
1447
  throw new Error("Invalid byte sequence");
1448
- n[r] = s;
1448
+ n[r] = o;
1449
1449
  }
1450
1450
  return n;
1451
1451
  }
1452
- function yo(e) {
1452
+ function ps(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
- function Fe(e) {
1458
- if (typeof e == "string" && (e = yo(e)), !Qt(e))
1457
+ function Je(e) {
1458
+ if (typeof e == "string" && (e = ps(e)), !Qt(e))
1459
1459
  throw new Error(`expected Uint8Array, got ${typeof e}`);
1460
1460
  return e;
1461
1461
  }
1462
- function ut(...e) {
1462
+ function lt(...e) {
1463
1463
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
1464
1464
  let n = 0;
1465
1465
  return e.forEach((r) => {
@@ -1468,14 +1468,14 @@ function ut(...e) {
1468
1468
  t.set(r, n), n += r.length;
1469
1469
  }), t;
1470
1470
  }
1471
- class lr {
1471
+ class ur {
1472
1472
  // Safe version that clones internal state
1473
1473
  clone() {
1474
1474
  return this._cloneInto();
1475
1475
  }
1476
1476
  }
1477
- function ur(e) {
1478
- const t = (r) => e().update(Fe(r)).digest(), n = e();
1477
+ function lr(e) {
1478
+ const t = (r) => e().update(Je(r)).digest(), n = e();
1479
1479
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
1480
1480
  }
1481
1481
  function fr(e = 32) {
@@ -1483,11 +1483,11 @@ 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
  }
1490
- function go(e) {
1490
+ function ys(e) {
1491
1491
  if (typeof e != "boolean")
1492
1492
  throw new Error(`Expected boolean, not ${e}`);
1493
1493
  }
@@ -1497,74 +1497,74 @@ function hr(e, ...t) {
1497
1497
  if (t.length > 0 && !t.includes(e.length))
1498
1498
  throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`);
1499
1499
  }
1500
- function wo(e) {
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
- function bo(e, t = !0) {
1505
+ function ws(e, t = !0) {
1506
1506
  if (e.destroyed)
1507
1507
  throw new Error("Hash instance has been destroyed");
1508
1508
  if (t && e.finished)
1509
1509
  throw new Error("Hash#digest() has already been called");
1510
1510
  }
1511
- function vo(e, t) {
1511
+ function bs(e, t) {
1512
1512
  hr(e);
1513
1513
  const n = t.outputLen;
1514
1514
  if (e.length < n)
1515
1515
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
1516
1516
  }
1517
- const oe = {
1518
- number: Ht,
1519
- bool: go,
1517
+ const se = {
1518
+ number: Pt,
1519
+ bool: ys,
1520
1520
  bytes: hr,
1521
- hash: wo,
1522
- exists: bo,
1523
- output: vo
1521
+ hash: gs,
1522
+ exists: ws,
1523
+ output: bs
1524
1524
  };
1525
- function mo(e, t, n, r) {
1525
+ function vs(e, t, n, r) {
1526
1526
  if (typeof e.setBigUint64 == "function")
1527
1527
  return e.setBigUint64(t, n, r);
1528
- const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), a = Number(n & o), c = r ? 4 : 0, u = r ? 0 : 4;
1529
- e.setUint32(t + c, s, r), e.setUint32(t + u, a, r);
1528
+ const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
1529
+ e.setUint32(t + a, o, r), e.setUint32(t + l, c, r);
1530
1530
  }
1531
- class Eo extends lr {
1531
+ class Es 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
- oe.exists(this);
1536
+ se.exists(this);
1537
1537
  const { view: n, buffer: r, blockLen: i } = this;
1538
- t = Fe(t);
1539
- const o = t.length;
1540
- for (let s = 0; s < o; ) {
1541
- const a = Math.min(i - this.pos, o - s);
1542
- if (a === i) {
1543
- const c = kt(t);
1544
- for (; i <= o - s; s += i)
1545
- this.process(c, s);
1538
+ t = Je(t);
1539
+ const s = t.length;
1540
+ for (let o = 0; o < s; ) {
1541
+ const c = Math.min(i - this.pos, s - o);
1542
+ if (c === i) {
1543
+ const a = Ct(t);
1544
+ for (; i <= s - o; o += i)
1545
+ this.process(a, o);
1546
1546
  continue;
1547
1547
  }
1548
- r.set(t.subarray(s, s + a), this.pos), this.pos += a, s += a, this.pos === i && (this.process(n, 0), this.pos = 0);
1548
+ r.set(t.subarray(o, o + c), this.pos), this.pos += c, o += c, this.pos === i && (this.process(n, 0), this.pos = 0);
1549
1549
  }
1550
1550
  return this.length += t.length, this.roundClean(), this;
1551
1551
  }
1552
1552
  digestInto(t) {
1553
- oe.exists(this), oe.output(t, this), this.finished = !0;
1554
- const { buffer: n, view: r, blockLen: i, isLE: o } = this;
1555
- let { pos: s } = this;
1556
- n[s++] = 128, this.buffer.subarray(s).fill(0), this.padOffset > i - s && (this.process(r, 0), s = 0);
1557
- for (let l = s; l < i; l++)
1558
- n[l] = 0;
1559
- mo(r, i - 8, BigInt(this.length * 8), o), this.process(r, 0);
1560
- const a = kt(t), c = this.outputLen;
1561
- if (c % 4)
1553
+ se.exists(this), se.output(t, this), this.finished = !0;
1554
+ const { buffer: n, view: r, blockLen: i, isLE: s } = this;
1555
+ let { pos: o } = this;
1556
+ n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
1557
+ for (let u = o; u < i; u++)
1558
+ n[u] = 0;
1559
+ vs(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
1560
+ const c = Ct(t), a = this.outputLen;
1561
+ if (a % 4)
1562
1562
  throw new Error("_sha2: outputLen should be aligned to 32bit");
1563
- const u = c / 4, f = this.get();
1564
- if (u > f.length)
1563
+ const l = a / 4, f = this.get();
1564
+ if (l > f.length)
1565
1565
  throw new Error("_sha2: outputLen bigger than state");
1566
- for (let l = 0; l < u; l++)
1567
- a.setUint32(4 * l, f[l], o);
1566
+ for (let u = 0; u < l; u++)
1567
+ c.setUint32(4 * u, f[u], s);
1568
1568
  }
1569
1569
  digest() {
1570
1570
  const { buffer: t, outputLen: n } = this;
@@ -1574,11 +1574,11 @@ class Eo extends lr {
1574
1574
  }
1575
1575
  _cloneInto(t) {
1576
1576
  t || (t = new this.constructor()), t.set(...this.get());
1577
- const { blockLen: n, buffer: r, length: i, finished: o, destroyed: s, pos: a } = this;
1578
- return t.length = i, t.pos = a, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
1577
+ const { blockLen: n, buffer: r, length: i, finished: s, destroyed: o, pos: c } = this;
1578
+ return t.length = i, t.pos = c, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
1579
1579
  }
1580
1580
  }
1581
- const xo = (e, t, n) => e & t ^ ~e & n, Ao = (e, t, n) => e & t ^ e & n ^ t & n, So = new Uint32Array([
1581
+ const ms = (e, t, n) => e & t ^ ~e & n, xs = (e, t, n) => e & t ^ e & n ^ t & n, Ss = new Uint32Array([
1582
1582
  1116352408,
1583
1583
  1899447441,
1584
1584
  3049323471,
@@ -1643,7 +1643,7 @@ const xo = (e, t, n) => e & t ^ ~e & n, Ao = (e, t, n) => e & t ^ e & n ^ t & n,
1643
1643
  2756734187,
1644
1644
  3204031479,
1645
1645
  3329325298
1646
- ]), me = new Uint32Array([
1646
+ ]), Ee = new Uint32Array([
1647
1647
  1779033703,
1648
1648
  3144134277,
1649
1649
  1013904242,
@@ -1652,54 +1652,54 @@ const xo = (e, t, n) => e & t ^ ~e & n, Ao = (e, t, n) => e & t ^ e & n ^ t & n,
1652
1652
  2600822924,
1653
1653
  528734635,
1654
1654
  1541459225
1655
- ]), Ee = new Uint32Array(64);
1656
- class dr extends Eo {
1655
+ ]), me = new Uint32Array(64);
1656
+ class dr extends Es {
1657
1657
  constructor() {
1658
- super(64, 32, 8, !1), this.A = me[0] | 0, this.B = me[1] | 0, this.C = me[2] | 0, this.D = me[3] | 0, this.E = me[4] | 0, this.F = me[5] | 0, this.G = me[6] | 0, this.H = me[7] | 0;
1658
+ super(64, 32, 8, !1), this.A = Ee[0] | 0, this.B = Ee[1] | 0, this.C = Ee[2] | 0, this.D = Ee[3] | 0, this.E = Ee[4] | 0, this.F = Ee[5] | 0, this.G = Ee[6] | 0, this.H = Ee[7] | 0;
1659
1659
  }
1660
1660
  get() {
1661
- const { A: t, B: n, C: r, D: i, E: o, F: s, G: a, H: c } = this;
1662
- return [t, n, r, i, o, s, a, c];
1661
+ const { A: t, B: n, C: r, D: i, E: s, F: o, G: c, H: a } = this;
1662
+ return [t, n, r, i, s, o, c, a];
1663
1663
  }
1664
1664
  // prettier-ignore
1665
- set(t, n, r, i, o, s, a, c) {
1666
- this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = a | 0, this.H = c | 0;
1665
+ set(t, n, r, i, s, o, c, a) {
1666
+ this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = s | 0, this.F = o | 0, this.G = c | 0, this.H = a | 0;
1667
1667
  }
1668
1668
  process(t, n) {
1669
- for (let l = 0; l < 16; l++, n += 4)
1670
- Ee[l] = t.getUint32(n, !1);
1671
- for (let l = 16; l < 64; l++) {
1672
- const g = Ee[l - 15], b = Ee[l - 2], p = ie(g, 7) ^ ie(g, 18) ^ g >>> 3, h = ie(b, 17) ^ ie(b, 19) ^ b >>> 10;
1673
- Ee[l] = h + Ee[l - 7] + p + Ee[l - 16] | 0;
1669
+ for (let u = 0; u < 16; u++, n += 4)
1670
+ me[u] = t.getUint32(n, !1);
1671
+ for (let u = 16; u < 64; u++) {
1672
+ const g = me[u - 15], b = me[u - 2], p = ie(g, 7) ^ ie(g, 18) ^ g >>> 3, h = ie(b, 17) ^ ie(b, 19) ^ b >>> 10;
1673
+ me[u] = h + me[u - 7] + p + me[u - 16] | 0;
1674
1674
  }
1675
- let { A: r, B: i, C: o, D: s, E: a, F: c, G: u, H: f } = this;
1676
- for (let l = 0; l < 64; l++) {
1677
- const g = ie(a, 6) ^ ie(a, 11) ^ ie(a, 25), b = f + g + xo(a, c, u) + So[l] + Ee[l] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + Ao(r, i, o) | 0;
1678
- f = u, u = c, c = a, a = s + b | 0, s = o, o = i, i = r, r = b + h | 0;
1675
+ let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
1676
+ for (let u = 0; u < 64; u++) {
1677
+ const g = ie(c, 6) ^ ie(c, 11) ^ ie(c, 25), b = f + g + ms(c, a, l) + Ss[u] + me[u] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + xs(r, i, s) | 0;
1678
+ f = l, l = a, a = c, c = o + b | 0, o = s, s = i, i = r, r = b + h | 0;
1679
1679
  }
1680
- r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, a = a + this.E | 0, c = c + this.F | 0, u = u + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, a, c, u, f);
1680
+ r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
1681
1681
  }
1682
1682
  roundClean() {
1683
- Ee.fill(0);
1683
+ me.fill(0);
1684
1684
  }
1685
1685
  destroy() {
1686
1686
  this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
1687
1687
  }
1688
1688
  }
1689
- class No 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
- const fe = ur(() => new dr());
1695
- ur(() => new No());
1694
+ const fe = lr(() => new dr());
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))
1699
1699
  throw new Error(`Wrong integer: ${e}`);
1700
1700
  }
1701
1701
  function de(...e) {
1702
- const t = (i, o) => (s) => i(o(s)), n = Array.from(e).reverse().reduce((i, o) => i ? t(i, o.encode) : o.encode, void 0), r = e.reduce((i, o) => i ? t(i, o.decode) : o.decode, void 0);
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
1705
  function pe(e) {
@@ -1791,31 +1791,31 @@ function Ln(e, t, n) {
1791
1791
  if (!e.length)
1792
1792
  return [];
1793
1793
  let r = 0;
1794
- const i = [], o = Array.from(e);
1795
- for (o.forEach((s) => {
1796
- if (ze(s), s < 0 || s >= t)
1797
- throw new Error(`Wrong integer: ${s}`);
1794
+ const i = [], s = Array.from(e);
1795
+ for (s.forEach((o) => {
1796
+ if (ze(o), o < 0 || o >= t)
1797
+ throw new Error(`Wrong integer: ${o}`);
1798
1798
  }); ; ) {
1799
- let s = 0, a = !0;
1800
- for (let c = r; c < o.length; c++) {
1801
- const u = o[c], f = t * s + u;
1802
- if (!Number.isSafeInteger(f) || t * s / t !== s || f - u !== t * s)
1799
+ let o = 0, c = !0;
1800
+ for (let a = r; a < s.length; a++) {
1801
+ const l = s[a], f = t * o + l;
1802
+ if (!Number.isSafeInteger(f) || t * o / t !== o || f - l !== t * o)
1803
1803
  throw new Error("convertRadix: carry overflow");
1804
- if (s = f % n, o[c] = Math.floor(f / n), !Number.isSafeInteger(o[c]) || o[c] * n + s !== f)
1804
+ if (o = f % n, s[a] = Math.floor(f / n), !Number.isSafeInteger(s[a]) || s[a] * n + o !== f)
1805
1805
  throw new Error("convertRadix: carry overflow");
1806
- if (a)
1807
- o[c] ? a = !1 : r = c;
1806
+ if (c)
1807
+ s[a] ? c = !1 : r = a;
1808
1808
  else continue;
1809
1809
  }
1810
- if (i.push(s), a)
1810
+ if (i.push(o), c)
1811
1811
  break;
1812
1812
  }
1813
- for (let s = 0; s < e.length - 1 && e[s] === 0; s++)
1813
+ for (let o = 0; o < e.length - 1 && e[o] === 0; o++)
1814
1814
  i.push(0);
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)
@@ -1824,24 +1824,24 @@ function Pt(e, t, n, r) {
1824
1824
  throw new Error(`convertRadix2: wrong to=${n}`);
1825
1825
  if (it(t, n) > 32)
1826
1826
  throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${it(t, n)}`);
1827
- let i = 0, o = 0;
1828
- const s = 2 ** n - 1, a = [];
1829
- for (const c of e) {
1830
- if (ze(c), c >= 2 ** t)
1831
- throw new Error(`convertRadix2: invalid data word=${c} from=${t}`);
1832
- if (i = i << t | c, o + t > 32)
1833
- throw new Error(`convertRadix2: carry overflow pos=${o} from=${t}`);
1834
- for (o += t; o >= n; o -= n)
1835
- a.push((i >> o - n & s) >>> 0);
1836
- i &= 2 ** o - 1;
1837
- }
1838
- if (i = i << n - o & s, !r && o >= t)
1827
+ let i = 0, s = 0;
1828
+ const o = 2 ** n - 1, c = [];
1829
+ for (const a of e) {
1830
+ if (ze(a), a >= 2 ** t)
1831
+ throw new Error(`convertRadix2: invalid data word=${a} from=${t}`);
1832
+ if (i = i << t | a, s + t > 32)
1833
+ throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);
1834
+ for (s += t; s >= n; s -= n)
1835
+ c.push((i >> s - n & o) >>> 0);
1836
+ i &= 2 ** s - 1;
1837
+ }
1838
+ if (i = i << n - s & o, !r && s >= t)
1839
1839
  throw new Error("Excess padding");
1840
1840
  if (!r && i)
1841
1841
  throw new Error(`Non-zero padding: ${i}`);
1842
- return r && o > 0 && a.push(i >>> 0), a;
1842
+ return r && s > 0 && c.push(i >>> 0), c;
1843
1843
  }
1844
- function Ko(e) {
1844
+ function As(e) {
1845
1845
  return ze(e), {
1846
1846
  encode: (t) => {
1847
1847
  if (!(t instanceof Uint8Array))
@@ -1855,7 +1855,7 @@ function Ko(e) {
1855
1855
  }
1856
1856
  };
1857
1857
  }
1858
- function Ne(e, t = !1) {
1858
+ function Ae(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 ko = de(Ne(4), pe("0123456789ABCDEF"), ye("")), Bo = 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("")), Co = de(Ne(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ft(6), ye("")), en = (e) => de(Ko(58), pe(e), ye("")), qt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1886
+ const Ks = de(Ae(4), pe("0123456789ABCDEF"), ye("")), Cs = de(Ae(5), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ft(5), ye(""));
1887
+ de(Ae(5), pe("0123456789ABCDEFGHIJKLMNOPQRSTUV"), ft(5), ye(""));
1888
+ de(Ae(5), pe("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), ye(""), pr((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
+ const he = de(Ae(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ft(6), ye("")), Bs = de(Ae(6), pe("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ft(6), ye("")), en = (e) => de(As(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], Uo = {
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) {
@@ -1901,11 +1901,11 @@ const Tn = [0, 2, 3, 5, 6, 7, 9, 10, 11], Uo = {
1901
1901
  decode(e) {
1902
1902
  let t = [];
1903
1903
  for (let n = 0; n < e.length; n += 11) {
1904
- const r = e.slice(n, n + 11), i = Tn.indexOf(r.length), o = qt.decode(r);
1905
- for (let s = 0; s < o.length - i; s++)
1906
- if (o[s] !== 0)
1904
+ const r = e.slice(n, n + 11), i = Tn.indexOf(r.length), s = qt.decode(r);
1905
+ for (let o = 0; o < s.length - i; o++)
1906
+ if (s[o] !== 0)
1907
1907
  throw new Error("base58xmr: wrong padding");
1908
- t = t.concat(Array.from(o.slice(o.length - i)));
1908
+ t = t.concat(Array.from(s.slice(s.length - i)));
1909
1909
  }
1910
1910
  return Uint8Array.from(t);
1911
1911
  }
@@ -1920,38 +1920,38 @@ function Ze(e) {
1920
1920
  function On(e, t, n = 1) {
1921
1921
  const r = e.length;
1922
1922
  let i = 1;
1923
- for (let o = 0; o < r; o++) {
1924
- const s = e.charCodeAt(o);
1925
- if (s < 33 || s > 126)
1923
+ for (let s = 0; s < r; s++) {
1924
+ const o = e.charCodeAt(s);
1925
+ if (o < 33 || o > 126)
1926
1926
  throw new Error(`Invalid prefix (${e})`);
1927
- i = Ze(i) ^ s >> 5;
1927
+ i = Ze(i) ^ o >> 5;
1928
1928
  }
1929
1929
  i = Ze(i);
1930
- for (let o = 0; o < r; o++)
1931
- i = Ze(i) ^ e.charCodeAt(o) & 31;
1932
- for (let o of t)
1933
- i = Ze(i) ^ o;
1934
- for (let o = 0; o < 6; o++)
1930
+ for (let s = 0; s < r; s++)
1931
+ i = Ze(i) ^ e.charCodeAt(s) & 31;
1932
+ for (let s of t)
1933
+ i = Ze(i) ^ s;
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, o = $n(r);
1940
- function s(f, l, g = 90) {
1939
+ const t = e === "bech32" ? 1 : 734539939, n = Ae(5), r = n.decode, i = n.encode, s = $n(r);
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}`);
1943
- if (!Array.isArray(l) || l.length && typeof l[0] != "number")
1944
- throw new Error(`bech32.encode words should be array of numbers, not ${typeof l}`);
1945
- const b = f.length + 7 + l.length;
1943
+ if (!Array.isArray(u) || u.length && typeof u[0] != "number")
1944
+ throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);
1945
+ const b = f.length + 7 + u.length;
1946
1946
  if (g !== !1 && b > g)
1947
1947
  throw new TypeError(`Length ${b} exceeds limit ${g}`);
1948
- return f = f.toLowerCase(), `${f}1${Dt.encode(l)}${On(f, l, t)}`;
1948
+ return f = f.toLowerCase(), `${f}1${Dt.encode(u)}${On(f, u, t)}`;
1949
1949
  }
1950
- function a(f, l = 90) {
1950
+ function c(f, u = 90) {
1951
1951
  if (typeof f != "string")
1952
1952
  throw new Error(`bech32.decode input should be string, not ${typeof f}`);
1953
- if (f.length < 8 || l !== !1 && f.length > l)
1954
- throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${l})`);
1953
+ if (f.length < 8 || u !== !1 && f.length > u)
1954
+ throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${u})`);
1955
1955
  const g = f.toLowerCase();
1956
1956
  if (f !== g && f !== f.toUpperCase())
1957
1957
  throw new Error("String must be lowercase or uppercase");
@@ -1967,33 +1967,33 @@ function gr(e) {
1967
1967
  throw new Error(`Invalid checksum in ${f}: expected "${y}"`);
1968
1968
  return { prefix: p, words: d };
1969
1969
  }
1970
- const c = $n(a);
1971
- function u(f) {
1972
- const { prefix: l, words: g } = a(f, !1);
1973
- return { prefix: l, words: g, bytes: r(g) };
1970
+ const a = $n(c);
1971
+ function l(f) {
1972
+ const { prefix: u, words: g } = c(f, !1);
1973
+ return { prefix: u, words: g, bytes: r(g) };
1974
1974
  }
1975
- return { encode: s, decode: a, decodeToBytes: u, decodeUnsafe: c, fromWords: r, fromWordsUnsafe: o, toWords: i };
1975
+ return { encode: o, decode: c, decodeToBytes: l, decodeUnsafe: a, fromWords: r, fromWordsUnsafe: s, toWords: i };
1976
1976
  }
1977
1977
  const je = gr("bech32");
1978
1978
  gr("bech32m");
1979
- const _o = {
1979
+ const _s = {
1980
1980
  encode: (e) => new TextDecoder().decode(e),
1981
1981
  decode: (e) => new TextEncoder().encode(e)
1982
- }, Io = de(Ne(4), pe("0123456789abcdef"), ye(""), pr((e) => {
1982
+ }, Us = de(Ae(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();
1986
- })), Lo = {
1987
- utf8: _o,
1988
- hex: Io,
1989
- base16: ko,
1990
- base32: Bo,
1986
+ })), Is = {
1987
+ utf8: _s,
1988
+ hex: Us,
1989
+ base16: Ks,
1990
+ base32: Cs,
1991
1991
  base64: he,
1992
- base64url: Co,
1992
+ base64url: Bs,
1993
1993
  base58: qt,
1994
- base58xmr: Uo
1994
+ base58xmr: ks
1995
1995
  };
1996
- `${Object.keys(Lo).join(", ")}`;
1996
+ `${Object.keys(Is).join(", ")}`;
1997
1997
  function Bt(e) {
1998
1998
  if (!Number.isSafeInteger(e) || e < 0)
1999
1999
  throw new Error(`positive integer expected, not ${e}`);
@@ -2002,25 +2002,25 @@ function Mn(e) {
2002
2002
  if (typeof e != "boolean")
2003
2003
  throw new Error(`boolean expected, not ${e}`);
2004
2004
  }
2005
- function $o(e) {
2005
+ function Ls(e) {
2006
2006
  return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array";
2007
2007
  }
2008
2008
  function ce(e, ...t) {
2009
- if (!$o(e))
2009
+ if (!Ls(e))
2010
2010
  throw new Error("Uint8Array expected");
2011
2011
  if (t.length > 0 && !t.includes(e.length))
2012
2012
  throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`);
2013
2013
  }
2014
2014
  /*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
2015
- const Z = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), To = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2016
- if (!To)
2015
+ const Z = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), $s = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2016
+ if (!$s)
2017
2017
  throw new Error("Non little-endian hardware is not supported");
2018
- function Ro(e, t) {
2018
+ function Ts(e, t) {
2019
2019
  if (t == null || typeof t != "object")
2020
2020
  throw new Error("options must be defined");
2021
2021
  return Object.assign(e, t);
2022
2022
  }
2023
- function Oo(e, t) {
2023
+ function Rs(e, t) {
2024
2024
  if (e.length !== t.length)
2025
2025
  return !1;
2026
2026
  let n = 0;
@@ -2028,9 +2028,9 @@ function Oo(e, t) {
2028
2028
  n |= e[r] ^ t[r];
2029
2029
  return n === 0;
2030
2030
  }
2031
- const Mo = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ae = 16, Ho = 283;
2031
+ const Os = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Se = 16, Ms = 283;
2032
2032
  function tn(e) {
2033
- return e << 1 ^ Ho & -(e >> 7);
2033
+ return e << 1 ^ Ms & -(e >> 7);
2034
2034
  }
2035
2035
  function He(e, t) {
2036
2036
  let n = 0;
@@ -2049,19 +2049,19 @@ 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
- })(), Po = /* @__PURE__ */ jt.map((e, t) => jt.indexOf(t)), qo = (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((u, f) => t(e[f])), r = n.map(Ct), i = r.map(Ct), o = i.map(Ct), s = new Uint32Array(256 * 256), a = new Uint32Array(256 * 256), c = new Uint16Array(256 * 256);
2057
- for (let u = 0; u < 256; u++)
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), c = new Uint32Array(256 * 256), a = new Uint16Array(256 * 256);
2057
+ for (let l = 0; l < 256; l++)
2058
2058
  for (let f = 0; f < 256; f++) {
2059
- const l = u * 256 + f;
2060
- s[l] = n[u] ^ r[f], a[l] = i[u] ^ o[f], c[l] = e[u] << 8 | e[f];
2059
+ const u = l * 256 + f;
2060
+ o[u] = n[l] ^ r[f], c[u] = i[l] ^ s[f], a[u] = e[l] << 8 | e[f];
2061
2061
  }
2062
- return { sbox: e, sbox2: c, T0: n, T1: r, T2: i, T3: o, T01: s, T23: a };
2062
+ return { sbox: e, sbox2: a, T0: n, T1: r, T2: i, T3: s, T01: o, T23: c };
2063
2063
  }
2064
- const nn = /* @__PURE__ */ wr(jt, (e) => He(e, 3) << 24 | e << 16 | e << 8 | He(e, 2)), br = /* @__PURE__ */ wr(Po, (e) => He(e, 11) << 24 | He(e, 13) << 16 | He(e, 9) << 8 | He(e, 14)), Do = /* @__PURE__ */ (() => {
2064
+ const nn = /* @__PURE__ */ wr(jt, (e) => He(e, 3) << 24 | e << 16 | e << 8 | He(e, 2)), br = /* @__PURE__ */ wr(Ps, (e) => He(e, 11) << 24 | He(e, 13) << 16 | He(e, 9) << 8 | He(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;
@@ -2072,81 +2072,81 @@ function vr(e) {
2072
2072
  const t = e.length;
2073
2073
  if (![16, 24, 32].includes(t))
2074
2074
  throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);
2075
- const { sbox2: n } = nn, r = Z(e), i = r.length, o = (a) => se(n, a, a, a, a), s = new Uint32Array(t + 28);
2076
- s.set(r);
2077
- for (let a = i; a < s.length; a++) {
2078
- let c = s[a - 1];
2079
- a % i === 0 ? c = o(qo(c)) ^ Do[a / i - 1] : i > 6 && a % i === 4 && (c = o(c)), s[a] = s[a - i] ^ c;
2075
+ const { sbox2: n } = nn, r = Z(e), i = r.length, s = (c) => oe(n, c, c, c, c), o = new Uint32Array(t + 28);
2076
+ o.set(r);
2077
+ for (let c = i; c < o.length; c++) {
2078
+ let a = o[c - 1];
2079
+ c % i === 0 ? a = s(Hs(a)) ^ qs[c / i - 1] : i > 6 && c % i === 4 && (a = s(a)), o[c] = o[c - i] ^ a;
2080
2080
  }
2081
- return s;
2081
+ return o;
2082
2082
  }
2083
- function jo(e) {
2084
- const t = vr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: o, T1: s, T2: a, T3: c } = br;
2085
- for (let u = 0; u < r; u += 4)
2083
+ function Ds(e) {
2084
+ const t = vr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: s, T1: o, T2: c, T3: a } = br;
2085
+ for (let l = 0; l < r; l += 4)
2086
2086
  for (let f = 0; f < 4; f++)
2087
- n[u + f] = t[r - u - 4 + f];
2087
+ n[l + f] = t[r - l - 4 + f];
2088
2088
  t.fill(0);
2089
- for (let u = 4; u < r - 4; u++) {
2090
- const f = n[u], l = se(i, f, f, f, f);
2091
- n[u] = o[l & 255] ^ s[l >>> 8 & 255] ^ a[l >>> 16 & 255] ^ c[l >>> 24];
2089
+ for (let l = 4; l < r - 4; l++) {
2090
+ const f = n[l], u = oe(i, f, f, f, f);
2091
+ n[l] = s[u & 255] ^ o[u >>> 8 & 255] ^ c[u >>> 16 & 255] ^ a[u >>> 24];
2092
2092
  }
2093
2093
  return n;
2094
2094
  }
2095
- function xe(e, t, n, r, i, o) {
2096
- return e[n << 8 & 65280 | r >>> 8 & 255] ^ t[i >>> 8 & 65280 | o >>> 24 & 255];
2095
+ function xe(e, t, n, r, i, s) {
2096
+ return e[n << 8 & 65280 | r >>> 8 & 255] ^ t[i >>> 8 & 65280 | s >>> 24 & 255];
2097
2097
  }
2098
- function se(e, t, n, r, i) {
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) {
2102
- const { sbox2: o, T01: s, T23: a } = nn;
2103
- let c = 0;
2104
- t ^= e[c++], n ^= e[c++], r ^= e[c++], i ^= e[c++];
2105
- const u = e.length / 4 - 2;
2106
- for (let p = 0; p < u; p++) {
2107
- const h = e[c++] ^ xe(s, a, t, n, r, i), d = e[c++] ^ xe(s, a, n, r, i, t), y = e[c++] ^ xe(s, a, r, i, t, n), E = e[c++] ^ xe(s, a, i, t, n, r);
2108
- t = h, n = d, r = y, i = E;
2109
- }
2110
- const f = e[c++] ^ se(o, t, n, r, i), l = e[c++] ^ se(o, n, r, i, t), g = e[c++] ^ se(o, r, i, t, n), b = e[c++] ^ se(o, i, t, n, r);
2111
- return { s0: f, s1: l, s2: g, s3: b };
2112
- }
2113
- function zo(e, t, n, r, i) {
2114
- const { sbox2: o, T01: s, T23: a } = br;
2115
- let c = 0;
2116
- t ^= e[c++], n ^= e[c++], r ^= e[c++], i ^= e[c++];
2117
- const u = e.length / 4 - 2;
2118
- for (let p = 0; p < u; p++) {
2119
- const h = e[c++] ^ xe(s, a, t, i, r, n), d = e[c++] ^ xe(s, a, n, t, i, r), y = e[c++] ^ xe(s, a, r, n, t, i), E = e[c++] ^ xe(s, a, i, r, n, t);
2120
- t = h, n = d, r = y, i = E;
2121
- }
2122
- const f = e[c++] ^ se(o, t, i, r, n), l = e[c++] ^ se(o, n, t, i, r), g = e[c++] ^ se(o, r, n, t, i), b = e[c++] ^ se(o, i, r, n, t);
2123
- return { s0: f, s1: l, s2: g, s3: b };
2124
- }
2125
- function mr(e, t) {
2101
+ function Pn(e, t, n, r, i) {
2102
+ const { sbox2: s, T01: o, T23: c } = nn;
2103
+ let a = 0;
2104
+ t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2105
+ const l = e.length / 4 - 2;
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), m = e[a++] ^ xe(o, c, i, t, n, r);
2108
+ t = h, n = d, r = y, i = m;
2109
+ }
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), b = e[a++] ^ oe(s, i, t, n, r);
2111
+ return { s0: f, s1: u, s2: g, s3: b };
2112
+ }
2113
+ function js(e, t, n, r, i) {
2114
+ const { sbox2: s, T01: o, T23: c } = br;
2115
+ let a = 0;
2116
+ t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2117
+ const l = e.length / 4 - 2;
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), m = e[a++] ^ xe(o, c, i, r, n, t);
2120
+ t = h, n = d, r = y, i = m;
2121
+ }
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), b = e[a++] ^ oe(s, i, r, n, t);
2123
+ return { s0: f, s1: u, s2: g, s3: b };
2124
+ }
2125
+ function Er(e, t) {
2126
2126
  if (!t)
2127
2127
  return new Uint8Array(e);
2128
2128
  if (ce(t), t.length < e)
2129
2129
  throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);
2130
2130
  return t;
2131
2131
  }
2132
- function Vo(e) {
2133
- if (ce(e), e.length % Ae !== 0)
2134
- throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ae}`);
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}`);
2135
2135
  }
2136
- function Wo(e, t, n) {
2136
+ function Vs(e, t, n) {
2137
2137
  let r = e.length;
2138
- const i = r % Ae;
2138
+ const i = r % Se;
2139
2139
  if (!t && i !== 0)
2140
2140
  throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");
2141
- const o = Z(e);
2141
+ const s = Z(e);
2142
2142
  if (t) {
2143
- let c = Ae - i;
2144
- c || (c = Ae), r = r + c;
2143
+ let a = Se - i;
2144
+ a || (a = Se), r = r + a;
2145
2145
  }
2146
- const s = mr(r, n), a = Z(s);
2147
- return { b: o, o: a, out: s };
2146
+ const o = Er(r, n), c = Z(o);
2147
+ return { b: s, o: c, out: o };
2148
2148
  }
2149
- function Zo(e, t) {
2149
+ function Ws(e, t) {
2150
2150
  if (!t)
2151
2151
  return e;
2152
2152
  const n = e.length;
@@ -2156,148 +2156,148 @@ function Zo(e, t) {
2156
2156
  if (r <= 0 || r > 16)
2157
2157
  throw new Error(`aes/pcks5: wrong padding byte: ${r}`);
2158
2158
  const i = e.subarray(0, -r);
2159
- for (let o = 0; o < r; o++)
2160
- if (e[n - o - 1] !== r)
2159
+ for (let s = 0; s < r; s++)
2160
+ if (e[n - s - 1] !== r)
2161
2161
  throw new Error("aes/pcks5: wrong padding");
2162
2162
  return i;
2163
2163
  }
2164
- function Go(e) {
2164
+ function Zs(e) {
2165
2165
  const t = new Uint8Array(16), n = Z(t);
2166
2166
  t.set(e);
2167
- const r = Ae - e.length;
2168
- for (let i = Ae - r; i < Ae; i++)
2167
+ const r = Se - e.length;
2168
+ for (let i = Se - r; i < Se; i++)
2169
2169
  t[i] = r;
2170
2170
  return n;
2171
2171
  }
2172
- const Er = /* @__PURE__ */ Mo({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) {
2172
+ const mr = /* @__PURE__ */ Os({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) {
2173
2173
  ce(t), ce(n, 16);
2174
2174
  const i = !r.disablePadding;
2175
2175
  return {
2176
- encrypt: (o, s) => {
2177
- const a = vr(t), { b: c, o: u, out: f } = Wo(o, i, s), l = Z(n);
2178
- let g = l[0], b = l[1], p = l[2], h = l[3], d = 0;
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), u[d++] = g, u[d++] = b, u[d++] = p, u[d++] = h;
2176
+ encrypt: (s, o) => {
2177
+ const c = vr(t), { b: a, o: l, out: f } = Vs(s, i, o), u = Z(n);
2178
+ let g = u[0], b = u[1], p = u[2], h = u[3], d = 0;
2179
+ for (; d + 4 <= a.length; )
2180
+ g ^= a[d + 0], b ^= a[d + 1], p ^= a[d + 2], h ^= a[d + 3], { s0: g, s1: b, s2: p, s3: h } = Pn(c, g, b, p, h), l[d++] = g, l[d++] = b, l[d++] = p, l[d++] = h;
2181
2181
  if (i) {
2182
- const y = Go(o.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), u[d++] = g, u[d++] = b, u[d++] = p, u[d++] = h;
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 } = Pn(c, g, b, p, h), l[d++] = g, l[d++] = b, l[d++] = p, l[d++] = h;
2184
2184
  }
2185
- return a.fill(0), f;
2185
+ return c.fill(0), f;
2186
2186
  },
2187
- decrypt: (o, s) => {
2188
- Vo(o);
2189
- const a = jo(t), c = Z(n), u = mr(o.length, s), f = Z(o), l = Z(u);
2190
- let g = c[0], b = c[1], p = c[2], h = c[3];
2187
+ decrypt: (s, o) => {
2188
+ zs(s);
2189
+ const c = Ds(t), a = Z(n), l = Er(s.length, o), f = Z(s), u = Z(l);
2190
+ let g = a[0], b = a[1], p = a[2], h = a[3];
2191
2191
  for (let d = 0; d + 4 <= f.length; ) {
2192
- const y = g, E = b, N = p, _ = h;
2192
+ const y = g, m = b, A = p, U = 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: A } = zo(a, g, b, p, h);
2195
- l[d++] = B ^ y, l[d++] = m ^ E, l[d++] = x ^ N, l[d++] = A ^ _;
2194
+ const { s0: B, s1: E, s2: x, s3: S } = js(c, g, b, p, h);
2195
+ u[d++] = B ^ y, u[d++] = E ^ m, u[d++] = x ^ A, u[d++] = S ^ U;
2196
2196
  }
2197
- return a.fill(0), Zo(u, i);
2197
+ return c.fill(0), Ws(l, i);
2198
2198
  }
2199
2199
  };
2200
- }), xr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Fo = xr("expand 16-byte k"), Jo = xr("expand 32-byte k"), Yo = Z(Fo), Ar = Z(Jo);
2201
- Ar.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), Sr = Z(Fs);
2201
+ Sr.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, Xo = 16, Sr = 2 ** 32 - 1, Pn = new Uint32Array();
2209
- function Qo(e, t, n, r, i, o, s, a) {
2210
- const c = i.length, u = new Uint8Array(Ye), f = Z(u), l = zt(i) && zt(o), g = l ? Z(i) : Pn, b = l ? Z(o) : Pn;
2211
- for (let p = 0; p < c; s++) {
2212
- if (e(t, n, r, f, s, a), s >= Sr)
2208
+ const Xe = 64, Ys = 16, Nr = 2 ** 32 - 1, Hn = new Uint32Array();
2209
+ function Xs(e, t, n, r, i, s, o, c) {
2210
+ const a = i.length, l = new Uint8Array(Xe), f = Z(l), u = zt(i) && zt(s), g = u ? Z(i) : Hn, b = u ? Z(s) : Hn;
2211
+ for (let p = 0; p < a; o++) {
2212
+ if (e(t, n, r, f, o, c), o >= Nr)
2213
2213
  throw new Error("arx: counter overflow");
2214
- const h = Math.min(Ye, c - p);
2215
- if (l && h === Ye) {
2214
+ const h = Math.min(Xe, a - p);
2215
+ if (u && h === Xe) {
2216
2216
  const d = p / 4;
2217
2217
  if (p % 4 !== 0)
2218
2218
  throw new Error("arx: invalid block position");
2219
- for (let y = 0, E; y < Xo; y++)
2220
- E = d + y, b[E] = g[E] ^ f[y];
2221
- p += Ye;
2219
+ for (let y = 0, m; y < Ys; y++)
2220
+ m = d + y, b[m] = g[m] ^ f[y];
2221
+ p += Xe;
2222
2222
  continue;
2223
2223
  }
2224
2224
  for (let d = 0, y; d < h; d++)
2225
- y = p + d, o[y] = i[y] ^ u[d];
2225
+ y = p + d, s[y] = i[y] ^ l[d];
2226
2226
  p += h;
2227
2227
  }
2228
2228
  }
2229
- function es(e, t) {
2230
- const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: o, rounds: s } = Ro({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t);
2229
+ function Qs(e, t) {
2230
+ const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: s, rounds: o } = Ts({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t);
2231
2231
  if (typeof e != "function")
2232
2232
  throw new Error("core must be a function");
2233
- return Bt(i), Bt(s), Mn(o), Mn(n), (a, c, u, f, l = 0) => {
2234
- ce(a), ce(c), ce(u);
2235
- const g = u.length;
2236
- if (f || (f = new Uint8Array(g)), ce(f), Bt(l), l < 0 || l >= Sr)
2233
+ return Bt(i), Bt(o), Mn(s), Mn(n), (c, a, l, f, u = 0) => {
2234
+ ce(c), ce(a), ce(l);
2235
+ const g = l.length;
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
- let p = a.length, h, d;
2241
+ let p = c.length, h, d;
2242
2242
  if (p === 32)
2243
- h = a.slice(), b.push(h), d = Ar;
2243
+ h = c.slice(), b.push(h), d = Sr;
2244
2244
  else if (p === 16 && n)
2245
- h = new Uint8Array(32), h.set(a), h.set(a, 16), d = Yo, b.push(h);
2245
+ h = new Uint8Array(32), h.set(c), h.set(c, 16), d = Js, b.push(h);
2246
2246
  else
2247
2247
  throw new Error(`arx: invalid 32-byte key, got length=${p}`);
2248
- zt(c) || (c = c.slice(), b.push(c));
2248
+ zt(a) || (a = a.slice(), b.push(a));
2249
2249
  const y = Z(h);
2250
2250
  if (r) {
2251
- if (c.length !== 24)
2251
+ if (a.length !== 24)
2252
2252
  throw new Error("arx: extended nonce must be 24 bytes");
2253
- r(d, y, Z(c.subarray(0, 16)), y), c = c.subarray(16);
2253
+ r(d, y, Z(a.subarray(0, 16)), y), a = a.subarray(16);
2254
2254
  }
2255
- const E = 16 - i;
2256
- if (E !== c.length)
2257
- throw new Error(`arx: nonce must be ${E} or 16 bytes`);
2258
- if (E !== 12) {
2259
- const _ = new Uint8Array(12);
2260
- _.set(c, o ? 0 : 12 - c.length), c = _, b.push(c);
2255
+ const m = 16 - i;
2256
+ if (m !== a.length)
2257
+ throw new Error(`arx: nonce must be ${m} or 16 bytes`);
2258
+ if (m !== 12) {
2259
+ const U = new Uint8Array(12);
2260
+ U.set(a, s ? 0 : 12 - a.length), a = U, b.push(a);
2261
2261
  }
2262
- const N = Z(c);
2263
- for (Qo(e, d, y, N, u, f, l, s); b.length > 0; )
2262
+ const A = Z(a);
2263
+ for (Xs(e, d, y, A, l, f, u, o); b.length > 0; )
2264
2264
  b.pop().fill(0);
2265
2265
  return f;
2266
2266
  };
2267
2267
  }
2268
- function ts(e, t, n, r, i, o = 20) {
2269
- let s = e[0], a = e[1], c = e[2], u = e[3], f = t[0], l = 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 = s, x = a, A = c, H = u, U = f, K = l, T = g, R = b, P = p, w = h, v = d, S = y, C = E, k = N, I = _, O = B;
2270
- for (let Q = 0; Q < o; 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), 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), H = H + R | 0, O = L(O ^ H, 16), S = S + O | 0, R = L(R ^ S, 12), H = H + R | 0, O = L(O ^ H, 8), S = S + O | 0, R = L(R ^ S, 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), S = S + C | 0, T = L(T ^ S, 12), x = x + T | 0, C = L(C ^ x, 8), S = S + C | 0, T = L(T ^ S, 7), A = A + R | 0, k = L(k ^ A, 16), P = P + k | 0, R = L(R ^ P, 12), A = A + R | 0, k = L(k ^ A, 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);
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], b = t[3], p = t[4], h = t[5], d = t[6], y = t[7], m = i, A = n[0], U = n[1], B = n[2], E = o, x = c, S = a, P = l, _ = f, K = u, T = g, R = b, H = p, w = h, v = d, N = y, k = m, C = A, I = U, O = B;
2270
+ for (let Q = 0; Q < s; Q += 2)
2271
+ E = E + _ | 0, k = L(k ^ E, 16), H = H + k | 0, _ = L(_ ^ H, 12), E = E + _ | 0, k = L(k ^ E, 8), H = H + k | 0, _ = L(_ ^ 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), 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), 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), E = E + K | 0, O = L(O ^ E, 16), v = v + O | 0, K = L(K ^ v, 12), E = E + K | 0, O = L(O ^ E, 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), S = S + R | 0, C = L(C ^ S, 16), H = H + C | 0, R = L(R ^ H, 12), S = S + R | 0, C = L(C ^ S, 8), H = H + C | 0, R = L(R ^ H, 7), P = P + _ | 0, I = L(I ^ P, 16), w = w + I | 0, _ = L(_ ^ w, 12), P = P + _ | 0, I = L(I ^ P, 8), w = w + I | 0, _ = L(_ ^ w, 7);
2272
2272
  let $ = 0;
2273
- r[$++] = s + m | 0, r[$++] = a + x | 0, r[$++] = c + A | 0, r[$++] = u + H | 0, r[$++] = f + U | 0, r[$++] = l + K | 0, r[$++] = g + T | 0, r[$++] = b + R | 0, r[$++] = p + P | 0, r[$++] = h + w | 0, r[$++] = d + v | 0, r[$++] = y + S | 0, r[$++] = E + C | 0, r[$++] = N + k | 0, r[$++] = _ + I | 0, r[$++] = B + O | 0;
2273
+ r[$++] = o + E | 0, r[$++] = c + x | 0, r[$++] = a + S | 0, r[$++] = l + P | 0, r[$++] = f + _ | 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[$++] = m + k | 0, r[$++] = A + C | 0, r[$++] = U + I | 0, r[$++] = B + O | 0;
2274
2274
  }
2275
- const Nr = /* @__PURE__ */ es(ts, {
2275
+ const Ar = /* @__PURE__ */ Qs(eo, {
2276
2276
  counterRight: !1,
2277
2277
  counterLength: 4,
2278
2278
  allowShortKeys: !1
2279
2279
  });
2280
- class Kr extends lr {
2280
+ class Kr extends ur {
2281
2281
  constructor(t, n) {
2282
- super(), this.finished = !1, this.destroyed = !1, oe.hash(t);
2283
- const r = Fe(n);
2282
+ super(), this.finished = !1, this.destroyed = !1, se.hash(t);
2283
+ const r = Je(n);
2284
2284
  if (this.iHash = t.create(), typeof this.iHash.update != "function")
2285
2285
  throw new Error("Expected instance of class which extends utils.Hash");
2286
2286
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
2287
- const i = this.blockLen, o = new Uint8Array(i);
2288
- o.set(r.length > i ? t.create().update(r).digest() : r);
2289
- for (let s = 0; s < o.length; s++)
2290
- o[s] ^= 54;
2291
- this.iHash.update(o), this.oHash = t.create();
2292
- for (let s = 0; s < o.length; s++)
2293
- o[s] ^= 106;
2294
- this.oHash.update(o), o.fill(0);
2287
+ const i = this.blockLen, s = new Uint8Array(i);
2288
+ s.set(r.length > i ? t.create().update(r).digest() : r);
2289
+ for (let o = 0; o < s.length; o++)
2290
+ s[o] ^= 54;
2291
+ this.iHash.update(s), this.oHash = t.create();
2292
+ for (let o = 0; o < s.length; o++)
2293
+ s[o] ^= 106;
2294
+ this.oHash.update(s), s.fill(0);
2295
2295
  }
2296
2296
  update(t) {
2297
- return oe.exists(this), this.iHash.update(t), this;
2297
+ return se.exists(this), this.iHash.update(t), this;
2298
2298
  }
2299
2299
  digestInto(t) {
2300
- oe.exists(this), oe.bytes(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
2300
+ se.exists(this), se.bytes(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
2301
2301
  }
2302
2302
  digest() {
2303
2303
  const t = new Uint8Array(this.oHash.outputLen);
@@ -2305,8 +2305,8 @@ class Kr extends lr {
2305
2305
  }
2306
2306
  _cloneInto(t) {
2307
2307
  t || (t = Object.create(Object.getPrototypeOf(this), {}));
2308
- const { oHash: n, iHash: r, finished: i, destroyed: o, blockLen: s, outputLen: a } = this;
2309
- return t = t, t.finished = i, t.destroyed = o, t.blockLen = s, t.outputLen = a, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
2308
+ const { oHash: n, iHash: r, finished: i, destroyed: s, blockLen: o, outputLen: c } = this;
2309
+ return t = t, t.finished = i, t.destroyed = s, t.blockLen = o, t.outputLen = c, t.oHash = n._cloneInto(t.oHash), t.iHash = r._cloneInto(t.iHash), t;
2310
2310
  }
2311
2311
  destroy() {
2312
2312
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
@@ -2315,25 +2315,25 @@ class Kr extends lr {
2315
2315
  const ht = (e, t, n) => new Kr(e, t).update(n).digest();
2316
2316
  ht.create = (e, t) => new Kr(e, t);
2317
2317
  function rn(e, t, n) {
2318
- return oe.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), ht(e, Fe(n), Fe(t));
2318
+ return se.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), ht(e, Je(n), Je(t));
2319
2319
  }
2320
- const Ut = new Uint8Array([0]), qn = new Uint8Array();
2321
- function kr(e, t, n, r = 32) {
2322
- if (oe.hash(e), oe.number(r), r > 255 * e.outputLen)
2320
+ const _t = new Uint8Array([0]), qn = new Uint8Array();
2321
+ function Cr(e, t, n, r = 32) {
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);
2325
2325
  n === void 0 && (n = qn);
2326
- const o = new Uint8Array(i * e.outputLen), s = ht.create(e, t), a = s._cloneInto(), c = new Uint8Array(s.outputLen);
2327
- for (let u = 0; u < i; u++)
2328
- Ut[0] = u + 1, a.update(u === 0 ? qn : c).update(n).update(Ut).digestInto(c), o.set(c, e.outputLen * u), s._cloneInto(a);
2329
- return s.destroy(), a.destroy(), c.fill(0), Ut.fill(0), o.slice(0, r);
2326
+ const s = new Uint8Array(i * e.outputLen), o = ht.create(e, t), c = o._cloneInto(), a = new Uint8Array(o.outputLen);
2327
+ for (let l = 0; l < i; l++)
2328
+ _t[0] = l + 1, c.update(l === 0 ? qn : a).update(n).update(_t).digestInto(a), s.set(a, e.outputLen * l), o._cloneInto(c);
2329
+ return o.destroy(), c.destroy(), a.fill(0), _t.fill(0), s.slice(0, r);
2330
2330
  }
2331
- var ns = Object.defineProperty, q = (e, t) => {
2331
+ var to = Object.defineProperty, D = (e, t) => {
2332
2332
  for (var n in t)
2333
- ns(e, n, { get: t[n], enumerable: !0 });
2334
- }, Re = Symbol("verified"), rs = (e) => e instanceof Object;
2335
- function on(e) {
2336
- if (!rs(e) || typeof e.kind != "number" || typeof e.content != "string" || typeof e.created_at != "number" || typeof e.pubkey != "string" || !e.pubkey.match(/^[a-f0-9]{64}$/) || !Array.isArray(e.tags))
2333
+ to(e, n, { get: t[n], enumerable: !0 });
2334
+ }, Oe = Symbol("verified"), no = (e) => e instanceof Object;
2335
+ function sn(e) {
2336
+ if (!no(e) || typeof e.kind != "number" || typeof e.content != "string" || typeof e.created_at != "number" || typeof e.pubkey != "string" || !e.pubkey.match(/^[a-f0-9]{64}$/) || !Array.isArray(e.tags))
2337
2337
  return !1;
2338
2338
  for (let t = 0; t < e.tags.length; t++) {
2339
2339
  let n = e.tags[t];
@@ -2345,38 +2345,38 @@ function on(e) {
2345
2345
  }
2346
2346
  return !0;
2347
2347
  }
2348
- var is = {};
2349
- q(is, {
2350
- Queue: () => cs,
2348
+ var ro = {};
2349
+ D(ro, {
2350
+ Queue: () => ao,
2351
2351
  QueueNode: () => Br,
2352
- binarySearch: () => sn,
2353
- insertEventIntoAscendingList: () => as,
2354
- insertEventIntoDescendingList: () => ss,
2355
- normalizeURL: () => os,
2356
- utf8Decoder: () => le,
2352
+ binarySearch: () => on,
2353
+ insertEventIntoAscendingList: () => oo,
2354
+ insertEventIntoDescendingList: () => so,
2355
+ normalizeURL: () => io,
2356
+ utf8Decoder: () => ue,
2357
2357
  utf8Encoder: () => ne
2358
2358
  });
2359
- var le = new TextDecoder("utf-8"), ne = new TextEncoder();
2360
- function os(e) {
2359
+ var ue = new TextDecoder("utf-8"), ne = new TextEncoder();
2360
+ function io(e) {
2361
2361
  e.indexOf("://") === -1 && (e = "wss://" + e);
2362
2362
  let t = new URL(e);
2363
2363
  return t.pathname = t.pathname.replace(/\/+/g, "/"), t.pathname.endsWith("/") && (t.pathname = t.pathname.slice(0, -1)), (t.port === "80" && t.protocol === "ws:" || t.port === "443" && t.protocol === "wss:") && (t.port = ""), t.searchParams.sort(), t.hash = "", t.toString();
2364
2364
  }
2365
- function ss(e, t) {
2366
- const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
2365
+ function so(e, t) {
2366
+ const [n, r] = on(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
2367
2367
  return r || e.splice(n, 0, t), e;
2368
2368
  }
2369
- function as(e, t) {
2370
- const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
2369
+ function oo(e, t) {
2370
+ const [n, r] = on(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
2371
2371
  return r || e.splice(n, 0, t), e;
2372
2372
  }
2373
- function sn(e, t) {
2373
+ function on(e, t) {
2374
2374
  let n = 0, r = e.length - 1;
2375
2375
  for (; n <= r; ) {
2376
- const i = Math.floor((n + r) / 2), o = t(e[i]);
2377
- if (o === 0)
2376
+ const i = Math.floor((n + r) / 2), s = t(e[i]);
2377
+ if (s === 0)
2378
2378
  return [i, !0];
2379
- o < 0 ? r = i - 1 : n = i + 1;
2379
+ s < 0 ? r = i - 1 : n = i + 1;
2380
2380
  }
2381
2381
  return [n, !1];
2382
2382
  }
@@ -2387,7 +2387,7 @@ var Br = class {
2387
2387
  te(this, "prev", null);
2388
2388
  this.value = e;
2389
2389
  }
2390
- }, cs = class {
2390
+ }, ao = class {
2391
2391
  constructor() {
2392
2392
  te(this, "first");
2393
2393
  te(this, "last");
@@ -2407,7 +2407,7 @@ var Br = class {
2407
2407
  const e = this.first;
2408
2408
  return this.first = e.next, e.value;
2409
2409
  }
2410
- }, ls = class {
2410
+ }, co = class {
2411
2411
  generateSecretKey() {
2412
2412
  return We.utils.randomPrivateKey();
2413
2413
  }
@@ -2416,152 +2416,152 @@ var Br = class {
2416
2416
  }
2417
2417
  finalizeEvent(e, t) {
2418
2418
  const n = e;
2419
- return n.pubkey = M(We.getPublicKey(t)), n.id = Qe(n), n.sig = M(We.sign(Qe(n), t)), n[Re] = !0, n;
2419
+ return n.pubkey = M(We.getPublicKey(t)), n.id = Ge(n), n.sig = M(We.sign(Ge(n), t)), n[Oe] = !0, n;
2420
2420
  }
2421
2421
  verifyEvent(e) {
2422
- if (typeof e[Re] == "boolean")
2423
- return e[Re];
2424
- const t = Qe(e);
2422
+ if (typeof e[Oe] == "boolean")
2423
+ return e[Oe];
2424
+ const t = Ge(e);
2425
2425
  if (t !== e.id)
2426
- return e[Re] = !1, !1;
2426
+ return e[Oe] = !1, !1;
2427
2427
  try {
2428
2428
  const n = We.verify(e.sig, t, e.pubkey);
2429
- return e[Re] = n, n;
2429
+ return e[Oe] = n, n;
2430
2430
  } catch {
2431
- return e[Re] = !1, !1;
2431
+ return e[Oe] = !1, !1;
2432
2432
  }
2433
2433
  }
2434
2434
  };
2435
- function us(e) {
2436
- if (!on(e))
2435
+ function uo(e) {
2436
+ if (!sn(e))
2437
2437
  throw new Error("can't serialize event with wrong or missing properties");
2438
2438
  return JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content]);
2439
2439
  }
2440
- function Qe(e) {
2441
- let t = fe(ne.encode(us(e)));
2440
+ function Ge(e) {
2441
+ let t = fe(ne.encode(uo(e)));
2442
2442
  return M(t);
2443
2443
  }
2444
- var dt = new ls(), Ce = dt.generateSecretKey, ue = dt.getPublicKey, X = dt.finalizeEvent, pt = dt.verifyEvent, fs = {};
2445
- q(fs, {
2444
+ var dt = new co(), _e = dt.generateSecretKey, le = dt.getPublicKey, X = dt.finalizeEvent, pt = dt.verifyEvent, lo = {};
2445
+ D(lo, {
2446
2446
  Application: () => da,
2447
- BadgeAward: () => ms,
2448
- BadgeDefinition: () => sa,
2449
- BlockedRelaysList: () => zs,
2450
- BookmarkList: () => qs,
2447
+ BadgeAward: () => Eo,
2448
+ BadgeDefinition: () => oa,
2449
+ BlockedRelaysList: () => zo,
2450
+ BookmarkList: () => qo,
2451
2451
  Bookmarksets: () => ra,
2452
- Calendar: () => ma,
2453
- CalendarEventRSVP: () => Ea,
2452
+ Calendar: () => Ea,
2453
+ CalendarEventRSVP: () => ma,
2454
2454
  ChannelCreation: () => $r,
2455
2455
  ChannelHideMessage: () => Or,
2456
2456
  ChannelMessage: () => Rr,
2457
2457
  ChannelMetadata: () => Tr,
2458
2458
  ChannelMuteUser: () => Mr,
2459
2459
  ClassifiedListing: () => ga,
2460
- ClientAuth: () => Pr,
2461
- CommunitiesList: () => Ds,
2462
- CommunityDefinition: () => Sa,
2463
- CommunityPostApproval: () => Us,
2464
- Contacts: () => ws,
2465
- CreateOrUpdateProduct: () => la,
2460
+ ClientAuth: () => Hr,
2461
+ CommunitiesList: () => Do,
2462
+ CommunityDefinition: () => Na,
2463
+ CommunityPostApproval: () => _o,
2464
+ Contacts: () => wo,
2465
+ CreateOrUpdateProduct: () => ua,
2466
2466
  CreateOrUpdateStall: () => ca,
2467
2467
  Curationsets: () => ia,
2468
2468
  Date: () => ba,
2469
- DirectMessageRelaysList: () => Gs,
2469
+ DirectMessageRelaysList: () => Go,
2470
2470
  DraftClassifiedListing: () => wa,
2471
2471
  DraftLong: () => fa,
2472
2472
  Emojisets: () => ha,
2473
- EncryptedDirectMessage: () => bs,
2474
- EventDeletion: () => vs,
2475
- FileMetadata: () => Ss,
2476
- FileServerPreference: () => Fs,
2473
+ EncryptedDirectMessage: () => bo,
2474
+ EventDeletion: () => vo,
2475
+ FileMetadata: () => No,
2476
+ FileServerPreference: () => Fo,
2477
2477
  Followsets: () => ea,
2478
- GenericRepost: () => xs,
2478
+ GenericRepost: () => xo,
2479
2479
  Genericlists: () => ta,
2480
- GiftWrap: () => Hr,
2481
- HTTPAuth: () => ln,
2482
- Handlerinformation: () => Aa,
2480
+ GiftWrap: () => Pr,
2481
+ HTTPAuth: () => un,
2482
+ Handlerinformation: () => Sa,
2483
2483
  Handlerrecommendation: () => xa,
2484
- Highlights: () => Os,
2485
- InterestsList: () => Ws,
2484
+ Highlights: () => Oo,
2485
+ InterestsList: () => Wo,
2486
2486
  Interestsets: () => aa,
2487
- JobFeedback: () => Ls,
2488
- JobRequest: () => _s,
2489
- JobResult: () => Is,
2490
- Label: () => Cs,
2491
- LightningPubRPC: () => Ys,
2492
- LiveChatMessage: () => Ns,
2487
+ JobFeedback: () => Lo,
2488
+ JobRequest: () => Uo,
2489
+ JobResult: () => Io,
2490
+ Label: () => ko,
2491
+ LightningPubRPC: () => Yo,
2492
+ LiveChatMessage: () => Ao,
2493
2493
  LiveEvent: () => pa,
2494
- LongFormArticle: () => ua,
2495
- Metadata: () => ps,
2496
- Mutelist: () => Ms,
2497
- NWCWalletInfo: () => Js,
2494
+ LongFormArticle: () => la,
2495
+ Metadata: () => po,
2496
+ Mutelist: () => Mo,
2497
+ NWCWalletInfo: () => Jo,
2498
2498
  NWCWalletRequest: () => qr,
2499
- NWCWalletResponse: () => Xs,
2500
- NostrConnect: () => Qs,
2501
- OpenTimestamps: () => As,
2502
- Pinlist: () => Hs,
2503
- PrivateDirectMessage: () => Es,
2504
- ProblemTracker: () => Ks,
2505
- ProfileBadges: () => oa,
2506
- PublicChatsList: () => js,
2499
+ NWCWalletResponse: () => Xo,
2500
+ NostrConnect: () => Qo,
2501
+ OpenTimestamps: () => So,
2502
+ Pinlist: () => Po,
2503
+ PrivateDirectMessage: () => mo,
2504
+ ProblemTracker: () => Ko,
2505
+ ProfileBadges: () => sa,
2506
+ PublicChatsList: () => jo,
2507
2507
  Reaction: () => cn,
2508
- RecommendRelay: () => gs,
2509
- RelayList: () => Ps,
2508
+ RecommendRelay: () => go,
2509
+ RelayList: () => Ho,
2510
2510
  Relaysets: () => na,
2511
- Report: () => ks,
2512
- Reporting: () => Bs,
2511
+ Report: () => Co,
2512
+ Reporting: () => Bo,
2513
2513
  Repost: () => an,
2514
2514
  Seal: () => Lr,
2515
- SearchRelaysList: () => Vs,
2516
- ShortTextNote: () => ys,
2515
+ SearchRelaysList: () => Vo,
2516
+ ShortTextNote: () => yo,
2517
2517
  Time: () => va,
2518
- UserEmojiList: () => Zs,
2518
+ UserEmojiList: () => Zo,
2519
2519
  UserStatuses: () => ya,
2520
- Zap: () => Rs,
2521
- ZapGoal: () => $s,
2522
- ZapRequest: () => Ts,
2523
- classifyKind: () => hs,
2524
- isEphemeralKind: () => _r,
2525
- isKind: () => ds,
2520
+ Zap: () => Ro,
2521
+ ZapGoal: () => $o,
2522
+ ZapRequest: () => To,
2523
+ classifyKind: () => fo,
2524
+ isEphemeralKind: () => Ur,
2525
+ isKind: () => ho,
2526
2526
  isParameterizedReplaceableKind: () => Ir,
2527
- isRegularKind: () => Cr,
2528
- isReplaceableKind: () => Ur
2527
+ isRegularKind: () => kr,
2528
+ isReplaceableKind: () => _r
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
- function Ur(e) {
2533
+ function _r(e) {
2534
2534
  return [0, 3].includes(e) || 1e4 <= e && e < 2e4;
2535
2535
  }
2536
- function _r(e) {
2536
+ function Ur(e) {
2537
2537
  return 2e4 <= e && e < 3e4;
2538
2538
  }
2539
2539
  function Ir(e) {
2540
2540
  return 3e4 <= e && e < 4e4;
2541
2541
  }
2542
- function hs(e) {
2543
- return Cr(e) ? "regular" : Ur(e) ? "replaceable" : _r(e) ? "ephemeral" : Ir(e) ? "parameterized" : "unknown";
2542
+ function fo(e) {
2543
+ return kr(e) ? "regular" : _r(e) ? "replaceable" : Ur(e) ? "ephemeral" : Ir(e) ? "parameterized" : "unknown";
2544
2544
  }
2545
- function ds(e, t) {
2545
+ function ho(e, t) {
2546
2546
  const n = t instanceof Array ? t : [t];
2547
- return on(e) && n.includes(e.kind) || !1;
2547
+ return sn(e) && n.includes(e.kind) || !1;
2548
2548
  }
2549
- var ps = 0, ys = 1, gs = 2, ws = 3, bs = 4, vs = 5, an = 6, cn = 7, ms = 8, Lr = 13, Es = 14, xs = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Mr = 44, As = 1040, Hr = 1059, Ss = 1063, Ns = 1311, Ks = 1971, ks = 1984, Bs = 1984, Cs = 1985, Us = 4550, _s = 5999, Is = 6999, Ls = 7e3, $s = 9041, Ts = 9734, Rs = 9735, Os = 9802, Ms = 1e4, Hs = 10001, Ps = 10002, qs = 10003, Ds = 10004, js = 10005, zs = 10006, Vs = 10007, Ws = 10015, Zs = 10030, Gs = 10050, Fs = 10096, Js = 13194, Ys = 21e3, Pr = 22242, qr = 23194, Xs = 23195, Qs = 24133, ln = 27235, ea = 3e4, ta = 30001, na = 30002, ra = 30003, ia = 30004, oa = 30008, sa = 30009, aa = 30015, ca = 30017, la = 30018, ua = 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, Sa = 34550, Na = {};
2550
- q(Na, {
2551
- getHex64: () => un,
2549
+ var po = 0, yo = 1, go = 2, wo = 3, bo = 4, vo = 5, an = 6, cn = 7, Eo = 8, Lr = 13, mo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Mr = 44, So = 1040, Pr = 1059, No = 1063, Ao = 1311, Ko = 1971, Co = 1984, Bo = 1984, ko = 1985, _o = 4550, Uo = 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, Ea = 31924, ma = 31925, xa = 31989, Sa = 31990, Na = 34550, Aa = {};
2550
+ D(Aa, {
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
- function un(e, t) {
2558
+ function ln(e, t) {
2559
2559
  let n = t.length + 3, r = e.indexOf(`"${t}":`) + n, i = e.slice(r).indexOf('"') + r + 1;
2560
2560
  return e.slice(i, i + 64);
2561
2561
  }
2562
2562
  function Dr(e, t) {
2563
- let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, i = e.slice(r), o = Math.min(i.indexOf(","), i.indexOf("}"));
2564
- return parseInt(i.slice(0, o), 10);
2563
+ let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, i = e.slice(r), s = Math.min(i.indexOf(","), i.indexOf("}"));
2564
+ return parseInt(i.slice(0, s), 10);
2565
2565
  }
2566
2566
  function Ka(e) {
2567
2567
  let t = e.slice(0, 22).indexOf('"EVENT"');
@@ -2573,25 +2573,25 @@ function Ka(e) {
2573
2573
  let r = t + 7 + 1 + n, i = e.slice(r + 1, 80).indexOf('"');
2574
2574
  if (i === -1)
2575
2575
  return null;
2576
- let o = r + 1 + i;
2577
- return e.slice(r + 1, o);
2576
+ let s = r + 1 + i;
2577
+ return e.slice(r + 1, s);
2578
2578
  }
2579
- function ka(e, t) {
2580
- return t === un(e, "id");
2579
+ function Ca(e, t) {
2580
+ return t === ln(e, "id");
2581
2581
  }
2582
2582
  function Ba(e, t) {
2583
- return t === un(e, "pubkey");
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
- var Ua = {};
2589
- q(Ua, {
2590
- makeAuthEvent: () => _a
2588
+ var _a = {};
2589
+ D(_a, {
2590
+ makeAuthEvent: () => Ua
2591
2591
  });
2592
- function _a(e, t) {
2592
+ function Ua(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
  });
@@ -2638,62 +2638,62 @@ function Ra(e) {
2638
2638
  return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t;
2639
2639
  }
2640
2640
  function yt(e) {
2641
- var i, o, s, a, c, u, f;
2641
+ var i, s, o, c, a, l, f;
2642
2642
  let { prefix: t, words: n } = je.decode(e, fn), r = new Uint8Array(je.fromWords(n));
2643
2643
  switch (t) {
2644
2644
  case "nprofile": {
2645
- let l = _t(r);
2646
- if (!((i = l[0]) != null && i[0]))
2645
+ let u = Ut(r);
2646
+ if (!((i = u[0]) != null && i[0]))
2647
2647
  throw new Error("missing TLV 0 for nprofile");
2648
- if (l[0][0].length !== 32)
2648
+ if (u[0][0].length !== 32)
2649
2649
  throw new Error("TLV 0 should be 32 bytes");
2650
2650
  return {
2651
2651
  type: "nprofile",
2652
2652
  data: {
2653
- pubkey: M(l[0][0]),
2654
- relays: l[1] ? l[1].map((g) => le.decode(g)) : []
2653
+ pubkey: M(u[0][0]),
2654
+ relays: u[1] ? u[1].map((g) => ue.decode(g)) : []
2655
2655
  }
2656
2656
  };
2657
2657
  }
2658
2658
  case "nevent": {
2659
- let l = _t(r);
2660
- if (!((o = l[0]) != null && o[0]))
2659
+ let u = Ut(r);
2660
+ if (!((s = u[0]) != null && s[0]))
2661
2661
  throw new Error("missing TLV 0 for nevent");
2662
- if (l[0][0].length !== 32)
2662
+ if (u[0][0].length !== 32)
2663
2663
  throw new Error("TLV 0 should be 32 bytes");
2664
- if (l[2] && l[2][0].length !== 32)
2664
+ if (u[2] && u[2][0].length !== 32)
2665
2665
  throw new Error("TLV 2 should be 32 bytes");
2666
- if (l[3] && l[3][0].length !== 4)
2666
+ if (u[3] && u[3][0].length !== 4)
2667
2667
  throw new Error("TLV 3 should be 4 bytes");
2668
2668
  return {
2669
2669
  type: "nevent",
2670
2670
  data: {
2671
- id: M(l[0][0]),
2672
- relays: l[1] ? l[1].map((g) => le.decode(g)) : [],
2673
- author: (s = l[2]) != null && s[0] ? M(l[2][0]) : void 0,
2674
- kind: (a = l[3]) != null && a[0] ? parseInt(M(l[3][0]), 16) : void 0
2671
+ id: M(u[0][0]),
2672
+ relays: u[1] ? u[1].map((g) => ue.decode(g)) : [],
2673
+ author: (o = u[2]) != null && o[0] ? M(u[2][0]) : void 0,
2674
+ kind: (c = u[3]) != null && c[0] ? parseInt(M(u[3][0]), 16) : void 0
2675
2675
  }
2676
2676
  };
2677
2677
  }
2678
2678
  case "naddr": {
2679
- let l = _t(r);
2680
- if (!((c = l[0]) != null && c[0]))
2679
+ let u = Ut(r);
2680
+ if (!((a = u[0]) != null && a[0]))
2681
2681
  throw new Error("missing TLV 0 for naddr");
2682
- if (!((u = l[2]) != null && u[0]))
2682
+ if (!((l = u[2]) != null && l[0]))
2683
2683
  throw new Error("missing TLV 2 for naddr");
2684
- if (l[2][0].length !== 32)
2684
+ if (u[2][0].length !== 32)
2685
2685
  throw new Error("TLV 2 should be 32 bytes");
2686
- if (!((f = l[3]) != null && f[0]))
2686
+ if (!((f = u[3]) != null && f[0]))
2687
2687
  throw new Error("missing TLV 3 for naddr");
2688
- if (l[3][0].length !== 4)
2688
+ if (u[3][0].length !== 4)
2689
2689
  throw new Error("TLV 3 should be 4 bytes");
2690
2690
  return {
2691
2691
  type: "naddr",
2692
2692
  data: {
2693
- identifier: le.decode(l[0][0]),
2694
- pubkey: M(l[2][0]),
2695
- kind: parseInt(M(l[3][0]), 16),
2696
- relays: l[1] ? l[1].map((g) => le.decode(g)) : []
2693
+ identifier: ue.decode(u[0][0]),
2694
+ pubkey: M(u[2][0]),
2695
+ kind: parseInt(M(u[3][0]), 16),
2696
+ relays: u[1] ? u[1].map((g) => ue.decode(g)) : []
2697
2697
  }
2698
2698
  };
2699
2699
  }
@@ -2706,13 +2706,13 @@ function yt(e) {
2706
2706
  throw new Error(`unknown prefix ${t}`);
2707
2707
  }
2708
2708
  }
2709
- function _t(e) {
2709
+ function Ut(e) {
2710
2710
  let t = {}, n = e;
2711
2711
  for (; n.length > 0; ) {
2712
- let r = n[0], i = n[1], o = n.slice(2, 2 + i);
2713
- if (n = n.slice(2 + i), o.length < i)
2712
+ let r = n[0], i = n[1], s = n.slice(2, 2 + i);
2713
+ if (n = n.slice(2 + i), s.length < i)
2714
2714
  throw new Error(`not enough data to read on TLV ${r}`);
2715
- t[r] = t[r] || [], t[r].push(o);
2715
+ t[r] = t[r] || [], t[r].push(s);
2716
2716
  }
2717
2717
  return t;
2718
2718
  }
@@ -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))
@@ -2765,31 +2765,31 @@ function hn(e) {
2765
2765
  let t = [];
2766
2766
  return Object.entries(e).reverse().forEach(([n, r]) => {
2767
2767
  r.forEach((i) => {
2768
- let o = new Uint8Array(i.length + 2);
2769
- o.set([parseInt(n)], 0), o.set([i.length], 1), o.set(i, 2), t.push(o);
2768
+ let s = new Uint8Array(i.length + 2);
2769
+ s.set([parseInt(n)], 0), s.set([i.length], 1), s.set(i, 2), t.push(s);
2770
2770
  });
2771
- }), ut(...t);
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
  });
2778
2778
  async function zr(e, t, n) {
2779
- const r = e instanceof Uint8Array ? M(e) : e, i = _e.getSharedSecret(r, "02" + t), o = Vr(i);
2780
- let s = Uint8Array.from(fr(16)), a = ne.encode(n), c = Er(o, s).encrypt(a), u = he.encode(new Uint8Array(c)), f = he.encode(new Uint8Array(s.buffer));
2781
- return `${u}?iv=${f}`;
2779
+ const r = e instanceof Uint8Array ? M(e) : e, i = Ie.getSharedSecret(r, "02" + t), s = Vr(i);
2780
+ let o = Uint8Array.from(fr(16)), c = ne.encode(n), a = mr(s, o).encrypt(c), l = he.encode(new Uint8Array(a)), f = he.encode(new Uint8Array(o.buffer));
2781
+ return `${l}?iv=${f}`;
2782
2782
  }
2783
2783
  async function za(e, t, n) {
2784
2784
  const r = e instanceof Uint8Array ? M(e) : e;
2785
- let [i, o] = n.split("?iv="), s = _e.getSharedSecret(r, "02" + t), a = Vr(s), c = he.decode(o), u = he.decode(i), f = Er(a, c).decrypt(u);
2786
- return le.decode(f);
2785
+ let [i, s] = n.split("?iv="), o = Ie.getSharedSecret(r, "02" + t), c = Vr(o), a = he.decode(s), l = he.decode(i), f = mr(c, a).decrypt(l);
2786
+ return ue.decode(f);
2787
2787
  }
2788
2788
  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,
@@ -2822,11 +2822,11 @@ async function Wr(e) {
2822
2822
  return null;
2823
2823
  const [, n = "_", r] = t;
2824
2824
  try {
2825
- const o = `https://${r}/.well-known/nostr.json?name=${n}`, s = await bt(o, { redirect: "manual" });
2826
- if (s.status !== 200)
2825
+ const s = `https://${r}/.well-known/nostr.json?name=${n}`, o = await bt(s, { redirect: "manual" });
2826
+ if (o.status !== 200)
2827
2827
  throw Error("Wrong response code");
2828
- const a = await s.json(), c = a.names[n];
2829
- return c ? { pubkey: c, relays: (i = a.relays) == null ? void 0 : i[c] } : null;
2828
+ const c = await o.json(), a = c.names[n];
2829
+ return a ? { pubkey: a, relays: (i = c.relays) == null ? void 0 : i[a] } : null;
2830
2830
  } catch {
2831
2831
  return null;
2832
2832
  }
@@ -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) {
@@ -2849,39 +2849,39 @@ function Ya(e) {
2849
2849
  };
2850
2850
  let n, r;
2851
2851
  for (let i = e.tags.length - 1; i >= 0; i--) {
2852
- const o = e.tags[i];
2853
- if (o[0] === "e" && o[1]) {
2854
- const [s, a, c, u, f] = o, l = {
2855
- id: a,
2856
- relays: c ? [c] : [],
2852
+ const s = e.tags[i];
2853
+ if (s[0] === "e" && s[1]) {
2854
+ const [o, c, a, l, f] = s, u = {
2855
+ id: c,
2856
+ relays: a ? [a] : [],
2857
2857
  author: f
2858
2858
  };
2859
- if (u === "root") {
2860
- t.root = l;
2859
+ if (l === "root") {
2860
+ t.root = u;
2861
2861
  continue;
2862
2862
  }
2863
- if (u === "reply") {
2864
- t.reply = l;
2863
+ if (l === "reply") {
2864
+ t.reply = u;
2865
2865
  continue;
2866
2866
  }
2867
- if (u === "mention") {
2868
- t.mentions.push(l);
2867
+ if (l === "mention") {
2868
+ t.mentions.push(u);
2869
2869
  continue;
2870
2870
  }
2871
- n ? r = l : n = l, t.mentions.push(l);
2871
+ n ? r = u : n = u, t.mentions.push(u);
2872
2872
  continue;
2873
2873
  }
2874
- if (o[0] === "q" && o[1]) {
2875
- const [s, a, c] = o;
2874
+ if (s[0] === "q" && s[1]) {
2875
+ const [o, c, a] = s;
2876
2876
  t.quotes.push({
2877
- id: a,
2878
- relays: c ? [c] : []
2877
+ id: c,
2878
+ relays: a ? [a] : []
2879
2879
  });
2880
2880
  }
2881
- if (o[0] === "p" && o[1]) {
2881
+ if (s[0] === "p" && s[1]) {
2882
2882
  t.profiles.push({
2883
- pubkey: o[1],
2884
- relays: o[2] ? [o[2]] : []
2883
+ pubkey: s[1],
2884
+ relays: s[2] ? [s[2]] : []
2885
2885
  });
2886
2886
  continue;
2887
2887
  }
@@ -2889,25 +2889,25 @@ function Ya(e) {
2889
2889
  return t.root || (t.root = r || n || t.reply), t.reply || (t.reply = n || t.root), [t.reply, t.root].forEach((i) => {
2890
2890
  if (!i)
2891
2891
  return;
2892
- let o = t.mentions.indexOf(i);
2893
- if (o !== -1 && t.mentions.splice(o, 1), i.author) {
2894
- let s = t.profiles.find((a) => a.pubkey === i.author);
2895
- s && s.relays && (i.relays || (i.relays = []), s.relays.forEach((a) => {
2896
- var c;
2897
- ((c = i.relays) == null ? void 0 : c.indexOf(a)) === -1 && i.relays.push(a);
2898
- }), s.relays = i.relays);
2892
+ let s = t.mentions.indexOf(i);
2893
+ if (s !== -1 && t.mentions.splice(s, 1), i.author) {
2894
+ let o = t.profiles.find((c) => c.pubkey === i.author);
2895
+ o && o.relays && (i.relays || (i.relays = []), o.relays.forEach((c) => {
2896
+ var a;
2897
+ ((a = i.relays) == null ? void 0 : a.indexOf(c)) === -1 && i.relays.push(c);
2898
+ }), o.relays = i.relays);
2899
2899
  }
2900
2900
  }), t.mentions.forEach((i) => {
2901
2901
  if (i.author) {
2902
- let o = t.profiles.find((s) => s.pubkey === i.author);
2903
- o && o.relays && (i.relays || (i.relays = []), o.relays.forEach((s) => {
2904
- i.relays.indexOf(s) === -1 && i.relays.push(s);
2905
- }), o.relays = i.relays);
2902
+ let s = t.profiles.find((o) => o.pubkey === i.author);
2903
+ s && s.relays && (i.relays || (i.relays = []), s.relays.forEach((o) => {
2904
+ i.relays.indexOf(o) === -1 && i.relays.push(o);
2905
+ }), s.relays = i.relays);
2906
2906
  }
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
@@ -2947,8 +2947,8 @@ function nc(e, t) {
2947
2947
  let n = 0;
2948
2948
  const r = e, i = ["nonce", n.toString(), t.toString()];
2949
2949
  for (r.tags.push(i); ; ) {
2950
- const o = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
2951
- if (o !== r.created_at && (n = 0, r.created_at = o), i[1] = (++n).toString(), r.id = Fr(r), Gr(r.id) >= t)
2950
+ const s = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
2951
+ if (s !== r.created_at && (n = 0, r.created_at = s), i[1] = (++n).toString(), r.id = Fr(r), Gr(r.id) >= t)
2952
2952
  break;
2953
2953
  }
2954
2954
  return r;
@@ -2959,9 +2959,9 @@ function Fr(e) {
2959
2959
  );
2960
2960
  }
2961
2961
  var rc = {};
2962
- q(rc, {
2962
+ D(rc, {
2963
2963
  finishRepostEvent: () => ic,
2964
- getRepostedEvent: () => oc,
2964
+ getRepostedEvent: () => sc,
2965
2965
  getRepostedEventPointer: () => Jr
2966
2966
  });
2967
2967
  function ic(e, t, n, r) {
@@ -2990,7 +2990,7 @@ function Jr(e) {
2990
2990
  author: n == null ? void 0 : n[1]
2991
2991
  };
2992
2992
  }
2993
- function oc(e, { skipVerification: t } = {}) {
2993
+ function sc(e, { skipVerification: t } = {}) {
2994
2994
  const n = Jr(e);
2995
2995
  if (n === void 0 || e.content === "")
2996
2996
  return;
@@ -3003,8 +3003,8 @@ function oc(e, { skipVerification: t } = {}) {
3003
3003
  if (r.id === n.id && !(!t && !pt(r)))
3004
3004
  return r;
3005
3005
  }
3006
- var sc = {};
3007
- q(sc, {
3006
+ var oc = {};
3007
+ D(oc, {
3008
3008
  NOSTR_URI_REGEX: () => vt,
3009
3009
  parse: () => cc,
3010
3010
  test: () => ac
@@ -3023,12 +3023,12 @@ function cc(e) {
3023
3023
  decoded: yt(t[1])
3024
3024
  };
3025
3025
  }
3026
- var lc = {};
3027
- q(lc, {
3028
- finishReactionEvent: () => uc,
3026
+ var uc = {};
3027
+ D(uc, {
3028
+ finishReactionEvent: () => lc,
3029
3029
  getReactedEventPointer: () => fc
3030
3030
  });
3031
- function uc(e, t, n) {
3031
+ function lc(e, t, n) {
3032
3032
  const r = t.tags.filter((i) => i.length >= 2 && (i[0] === "e" || i[0] === "p"));
3033
3033
  return X(
3034
3034
  {
@@ -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,12 +3085,12 @@ 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,
3092
3092
  channelMetadataEvent: () => wc,
3093
- channelMuteUserEvent: () => mc
3093
+ channelMuteUserEvent: () => Ec
3094
3094
  });
3095
3095
  var gc = (e, t) => {
3096
3096
  let n;
@@ -3154,7 +3154,7 @@ var gc = (e, t) => {
3154
3154
  },
3155
3155
  t
3156
3156
  );
3157
- }, mc = (e, t) => {
3157
+ }, Ec = (e, t) => {
3158
3158
  let n;
3159
3159
  if (typeof e.content == "object")
3160
3160
  n = JSON.stringify(e.content);
@@ -3171,12 +3171,12 @@ var gc = (e, t) => {
3171
3171
  },
3172
3172
  t
3173
3173
  );
3174
- }, Ec = {};
3175
- q(Ec, {
3174
+ }, mc = {};
3175
+ D(mc, {
3176
3176
  EMOJI_SHORTCODE_REGEX: () => Yr,
3177
3177
  matchAll: () => xc,
3178
3178
  regex: () => yn,
3179
- replaceAll: () => Ac
3179
+ replaceAll: () => Sc
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 Ac(e, t) {
3196
+ function Sc(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 Sc = {};
3203
- q(Sc, {
3204
- useFetchImplementation: () => Nc,
3202
+ var Nc = {};
3203
+ D(Nc, {
3204
+ useFetchImplementation: () => Ac,
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 Ac(e) {
3213
3213
  gn = e;
3214
3214
  }
3215
3215
  async function Kc(e, t, n) {
@@ -3219,20 +3219,20 @@ async function Kc(e, t, n) {
3219
3219
  return !1;
3220
3220
  }
3221
3221
  }
3222
- var j = {};
3223
- q(j, {
3224
- decrypt: () => mn,
3222
+ var q = {};
3223
+ D(q, {
3224
+ decrypt: () => En,
3225
3225
  encrypt: () => vn,
3226
3226
  getConversationKey: () => wn,
3227
- v2: () => _c
3227
+ v2: () => Uc
3228
3228
  });
3229
3229
  var Xr = 1, Qr = 65535;
3230
3230
  function wn(e, t) {
3231
- const n = _e.getSharedSecret(e, "02" + t).subarray(1, 33);
3231
+ const n = Ie.getSharedSecret(e, "02" + t).subarray(1, 33);
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,29 +3247,29 @@ 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);
3258
- return ut(r, t, i);
3257
+ const t = ne.encode(e), n = t.length, r = Cc(n), i = new Uint8Array(bn(n) - n);
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");
3264
- return le.decode(n);
3264
+ return ue.decode(n);
3265
3265
  }
3266
3266
  function ti(e, t, n) {
3267
3267
  if (n.length !== 32)
3268
3268
  throw new Error("AAD associated data must be 32 bytes");
3269
- const r = ut(n, t);
3269
+ const r = lt(n, t);
3270
3270
  return ht(fe, e, r);
3271
3271
  }
3272
- function Uc(e) {
3272
+ function _c(e) {
3273
3273
  if (typeof e != "string")
3274
3274
  throw new Error("payload must be a valid string");
3275
3275
  const t = e.length;
@@ -3280,8 +3280,8 @@ function Uc(e) {
3280
3280
  let n;
3281
3281
  try {
3282
3282
  n = he.decode(e);
3283
- } catch (o) {
3284
- throw new Error("invalid base64: " + o.message);
3283
+ } catch (s) {
3284
+ throw new Error("invalid base64: " + s.message);
3285
3285
  }
3286
3286
  const r = n.length;
3287
3287
  if (r < 99 || r > 65603)
@@ -3296,33 +3296,33 @@ 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: o } = ei(t, n), s = Bc(e), a = Nr(r, i, s), c = ti(o, a, n);
3300
- return he.encode(ut(new Uint8Array([2]), n, a, c));
3299
+ const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ei(t, n), o = Bc(e), c = Ar(r, i, o), a = ti(s, c, n);
3300
+ return he.encode(lt(new Uint8Array([2]), n, c, a));
3301
3301
  }
3302
- function mn(e, t) {
3303
- const { nonce: n, ciphertext: r, mac: i } = Uc(e), { chacha_key: o, chacha_nonce: s, hmac_key: a } = ei(t, n), c = ti(a, r, n);
3304
- if (!Oo(c, i))
3302
+ function En(e, t) {
3303
+ const { nonce: n, ciphertext: r, mac: i } = _c(e), { chacha_key: s, chacha_nonce: o, hmac_key: c } = ei(t, n), a = ti(c, r, n);
3304
+ if (!Rs(a, i))
3305
3305
  throw new Error("invalid MAC");
3306
- const u = Nr(o, s, r);
3307
- return Cc(u);
3306
+ const l = Ar(s, o, r);
3307
+ return kc(l);
3308
3308
  }
3309
- var _c = {
3309
+ var Uc = {
3310
3310
  utils: {
3311
3311
  getConversationKey: wn,
3312
3312
  calcPaddedLen: bn
3313
3313
  },
3314
3314
  encrypt: vn,
3315
- decrypt: mn
3315
+ decrypt: En
3316
3316
  }, Ic = {};
3317
- q(Ic, {
3317
+ D(Ic, {
3318
3318
  makeNwcRequestEvent: () => $c,
3319
3319
  parseConnectionString: () => Lc
3320
3320
  });
3321
3321
  function Lc(e) {
3322
- const { pathname: t, searchParams: n } = new URL(e), r = t, i = n.get("relay"), o = n.get("secret");
3323
- if (!r || !i || !o)
3322
+ const { pathname: t, searchParams: n } = new URL(e), r = t, i = n.get("relay"), s = n.get("secret");
3323
+ if (!r || !i || !s)
3324
3324
  throw new Error("invalid connection string");
3325
- return { pubkey: r, relay: i, secret: o };
3325
+ return { pubkey: r, relay: i, secret: s };
3326
3326
  }
3327
3327
  async function $c(e, t, n) {
3328
3328
  const i = await zr(t, e, JSON.stringify({
@@ -3330,44 +3330,44 @@ async function $c(e, t, n) {
3330
3330
  params: {
3331
3331
  invoice: n
3332
3332
  }
3333
- })), o = {
3333
+ })), s = {
3334
3334
  kind: qr,
3335
3335
  created_at: Math.round(Date.now() / 1e3),
3336
3336
  content: i,
3337
3337
  tags: [["p", e]]
3338
3338
  };
3339
- return X(o, t);
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
- var En;
3349
+ var mn;
3350
3350
  try {
3351
- En = fetch;
3351
+ mn = fetch;
3352
3352
  } catch {
3353
3353
  }
3354
3354
  function Rc(e) {
3355
- En = e;
3355
+ mn = e;
3356
3356
  }
3357
3357
  async function Oc(e) {
3358
3358
  try {
3359
3359
  let t = "", { lud06: n, lud16: r } = JSON.parse(e.content);
3360
3360
  if (n) {
3361
- let { words: s } = je.decode(n, 1e3), a = je.fromWords(s);
3362
- t = le.decode(a);
3361
+ let { words: o } = je.decode(n, 1e3), c = je.fromWords(o);
3362
+ t = ue.decode(c);
3363
3363
  } else if (r) {
3364
- let [s, a] = r.split("@");
3365
- t = new URL(`/.well-known/lnurlp/${s}`, `https://${a}`).toString();
3364
+ let [o, c] = r.split("@");
3365
+ t = new URL(`/.well-known/lnurlp/${o}`, `https://${c}`).toString();
3366
3366
  } else
3367
3367
  return null;
3368
- let o = await (await En(t)).json();
3369
- if (o.allowsNostr && o.nostrPubkey)
3370
- return o.callback;
3368
+ let s = await (await mn(t)).json();
3369
+ if (s.allowsNostr && s.nostrPubkey)
3370
+ return s.callback;
3371
3371
  } catch {
3372
3372
  }
3373
3373
  return null;
@@ -3383,7 +3383,7 @@ function Mc({
3383
3383
  throw new Error("amount not given");
3384
3384
  if (!e)
3385
3385
  throw new Error("profile not given");
3386
- let o = {
3386
+ let s = {
3387
3387
  kind: 9734,
3388
3388
  created_at: Math.round(Date.now() / 1e3),
3389
3389
  content: i,
@@ -3393,67 +3393,67 @@ function Mc({
3393
3393
  ["relays", ...r]
3394
3394
  ]
3395
3395
  };
3396
- return t && o.tags.push(["e", t]), o;
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);
3402
3402
  } catch {
3403
3403
  return "Invalid zap request JSON.";
3404
3404
  }
3405
- if (!on(t))
3405
+ if (!sn(t))
3406
3406
  return "Zap request is not a valid Nostr event.";
3407
3407
  if (!pt(t))
3408
3408
  return "Invalid signature on zap request.";
3409
- let n = t.tags.find(([o, s]) => o === "p" && s);
3409
+ let n = t.tags.find(([s, o]) => s === "p" && o);
3410
3410
  if (!n)
3411
3411
  return "Zap request doesn't have a 'p' tag.";
3412
3412
  if (!n[1].match(/^[a-f0-9]{64}$/))
3413
3413
  return "Zap request 'p' tag is not valid hex.";
3414
- let r = t.tags.find(([o, s]) => o === "e" && s);
3415
- return r && !r[1].match(/^[a-f0-9]{64}$/) ? "Zap request 'e' tag is not valid hex." : t.tags.find(([o, s]) => o === "relays" && s) ? null : "Zap request doesn't have a 'relays' tag.";
3414
+ let r = t.tags.find(([s, o]) => s === "e" && o);
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,
3421
3421
  paidAt: r
3422
3422
  }) {
3423
- let i = JSON.parse(e), o = i.tags.filter(([a]) => a === "e" || a === "p" || a === "a"), s = {
3423
+ let i = JSON.parse(e), s = i.tags.filter(([c]) => c === "e" || c === "p" || c === "a"), o = {
3424
3424
  kind: 9735,
3425
3425
  created_at: Math.round(r.getTime() / 1e3),
3426
3426
  content: "",
3427
- tags: [...o, ["P", i.pubkey], ["bolt11", n], ["description", e]]
3427
+ tags: [...s, ["P", i.pubkey], ["bolt11", n], ["description", e]]
3428
3428
  };
3429
- return t && s.tags.push(["preimage", t]), s;
3429
+ return t && o.tags.push(["preimage", t]), o;
3430
3430
  }
3431
3431
  var qc = {};
3432
- q(qc, {
3433
- createRumor: () => si,
3432
+ D(qc, {
3433
+ createRumor: () => oi,
3434
3434
  createSeal: () => ai,
3435
3435
  createWrap: () => ci,
3436
- unwrapEvent: () => li,
3436
+ unwrapEvent: () => ui,
3437
3437
  unwrapManyEvents: () => zc,
3438
3438
  wrapEvent: () => Vt,
3439
3439
  wrapManyEvents: () => jc
3440
3440
  });
3441
- var Dc = 2 * 24 * 60 * 60, ni = () => Math.round(Date.now() / 1e3), ri = () => Math.round(ni() - Math.random() * Dc), ii = (e, t) => wn(e, t), oi = (e, t, n) => vn(JSON.stringify(e), ii(t, n)), Dn = (e, t) => JSON.parse(mn(e.content, ii(t, e.pubkey)));
3442
- function si(e, t) {
3441
+ var Dc = 2 * 24 * 60 * 60, ni = () => Math.round(Date.now() / 1e3), ri = () => Math.round(ni() - Math.random() * Dc), ii = (e, t) => wn(e, t), si = (e, t, n) => vn(JSON.stringify(e), ii(t, n)), Dn = (e, t) => JSON.parse(En(e.content, ii(t, e.pubkey)));
3442
+ function oi(e, t) {
3443
3443
  const n = {
3444
3444
  created_at: ni(),
3445
3445
  content: "",
3446
3446
  tags: [],
3447
3447
  ...e,
3448
- pubkey: ue(t)
3448
+ pubkey: le(t)
3449
3449
  };
3450
- return n.id = Qe(n), n;
3450
+ return n.id = Ge(n), n;
3451
3451
  }
3452
3452
  function ai(e, t, n) {
3453
3453
  return X(
3454
3454
  {
3455
3455
  kind: Lr,
3456
- content: oi(e, t, n),
3456
+ content: si(e, t, n),
3457
3457
  created_at: ri(),
3458
3458
  tags: []
3459
3459
  },
@@ -3461,11 +3461,11 @@ function ai(e, t, n) {
3461
3461
  );
3462
3462
  }
3463
3463
  function ci(e, t) {
3464
- const n = Ce();
3464
+ const n = _e();
3465
3465
  return X(
3466
3466
  {
3467
- kind: Hr,
3468
- content: oi(e, n, t),
3467
+ kind: Pr,
3468
+ content: si(e, n, t),
3469
3469
  created_at: ri(),
3470
3470
  tags: [["p", t]]
3471
3471
  },
@@ -3473,29 +3473,29 @@ function ci(e, t) {
3473
3473
  );
3474
3474
  }
3475
3475
  function Vt(e, t, n) {
3476
- const r = si(e, t), i = ai(r, t, n);
3476
+ const r = oi(e, t), i = ai(r, t, n);
3477
3477
  return ci(i, n);
3478
3478
  }
3479
3479
  function jc(e, t, n) {
3480
3480
  if (!n || n.length === 0)
3481
3481
  throw new Error("At least one recipient is required.");
3482
- const r = ue(t), i = [Vt(e, t, r)];
3483
- return n.forEach((o) => {
3484
- i.push(Vt(e, t, o));
3482
+ const r = le(t), i = [Vt(e, t, r)];
3483
+ return n.forEach((s) => {
3484
+ i.push(Vt(e, t, s));
3485
3485
  }), i;
3486
3486
  }
3487
- function li(e, t) {
3487
+ function ui(e, t) {
3488
3488
  const n = Dn(e, t);
3489
3489
  return Dn(n, t);
3490
3490
  }
3491
3491
  function zc(e, t) {
3492
3492
  let n = [];
3493
3493
  return e.forEach((r) => {
3494
- n.push(li(r, t));
3494
+ n.push(ui(r, 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,
@@ -3507,10 +3507,10 @@ q(Vc, {
3507
3507
  validateEventUrlTag: () => pi,
3508
3508
  validateToken: () => Zc
3509
3509
  });
3510
- var ui = "Nostr ";
3510
+ var li = "Nostr ";
3511
3511
  async function Wc(e, t, n, r = !1, i) {
3512
- const o = {
3513
- kind: ln,
3512
+ const s = {
3513
+ kind: un,
3514
3514
  tags: [
3515
3515
  ["u", e],
3516
3516
  ["method", t]
@@ -3518,23 +3518,23 @@ async function Wc(e, t, n, r = !1, i) {
3518
3518
  created_at: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
3519
3519
  content: ""
3520
3520
  };
3521
- i && o.tags.push(["payload", xn(i)]);
3522
- const s = await n(o);
3523
- return (r ? ui : "") + he.encode(ne.encode(JSON.stringify(s)));
3521
+ i && s.tags.push(["payload", xn(i)]);
3522
+ const o = await n(s);
3523
+ return (r ? li : "") + he.encode(ne.encode(JSON.stringify(o)));
3524
3524
  }
3525
3525
  async function Zc(e, t, n) {
3526
- const r = await fi(e).catch((o) => {
3527
- throw o;
3526
+ const r = await fi(e).catch((s) => {
3527
+ throw s;
3528
3528
  });
3529
- return await wi(r, t, n).catch((o) => {
3530
- throw o;
3529
+ return await wi(r, t, n).catch((s) => {
3530
+ throw s;
3531
3531
  });
3532
3532
  }
3533
3533
  async function fi(e) {
3534
3534
  if (!e)
3535
3535
  throw new Error("Missing token");
3536
- e = e.replace(ui, "");
3537
- const t = le.decode(he.decode(e));
3536
+ e = e.replace(li, "");
3537
+ const t = ue.decode(he.decode(e));
3538
3538
  if (!t || t.length === 0 || !t.startsWith("{"))
3539
3539
  throw new Error("Invalid token");
3540
3540
  return JSON.parse(t);
@@ -3543,7 +3543,7 @@ function hi(e) {
3543
3543
  return e.created_at ? Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3) - e.created_at < 60 : !1;
3544
3544
  }
3545
3545
  function di(e) {
3546
- return e.kind === ln;
3546
+ return e.kind === un;
3547
3547
  }
3548
3548
  function pi(e, t) {
3549
3549
  const n = e.tags.find((r) => r[0] === "u");
@@ -3579,12 +3579,12 @@ 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, nl = 100;
3583
- var Gc = /* @__PURE__ */ ((e) => (e[e.Us = 0] = "Us", e[e.Them = 1] = "Them", e))(Gc || {});
3584
- function rl(e) {
3582
+ const Be = 30078, jn = 30078, Gc = 14, ru = 100;
3583
+ function iu(e) {
3585
3584
  return JSON.stringify({
3586
3585
  rootKey: M(e.rootKey),
3587
- theirNostrPublicKey: e.theirNostrPublicKey,
3586
+ theirCurrentNostrPublicKey: e.theirCurrentNostrPublicKey,
3587
+ theirNextNostrPublicKey: e.theirNextNostrPublicKey,
3588
3588
  ourCurrentNostrKey: e.ourCurrentNostrKey ? {
3589
3589
  publicKey: e.ourCurrentNostrKey.publicKey,
3590
3590
  privateKey: M(e.ourCurrentNostrKey.privateKey)
@@ -3612,11 +3612,12 @@ function rl(e) {
3612
3612
  )
3613
3613
  });
3614
3614
  }
3615
- function il(e) {
3615
+ function su(e) {
3616
3616
  const t = JSON.parse(e);
3617
3617
  return {
3618
3618
  rootKey: G(t.rootKey),
3619
- theirNostrPublicKey: t.theirNostrPublicKey,
3619
+ theirCurrentNostrPublicKey: t.theirCurrentNostrPublicKey,
3620
+ theirNextNostrPublicKey: t.theirNextNostrPublicKey,
3620
3621
  ourCurrentNostrKey: t.ourCurrentNostrKey ? {
3621
3622
  publicKey: t.ourCurrentNostrKey.publicKey,
3622
3623
  privateKey: G(t.ourCurrentNostrKey.privateKey)
@@ -3644,10 +3645,10 @@ function il(e) {
3644
3645
  )
3645
3646
  };
3646
3647
  }
3647
- async function* ol(e) {
3648
+ async function* ou(e) {
3648
3649
  const t = [];
3649
3650
  let n = null;
3650
- const r = e.onMessage((i) => {
3651
+ const r = e.onEvent((i) => {
3651
3652
  n ? (n(i), n = null) : t.push(i);
3652
3653
  });
3653
3654
  try {
@@ -3659,17 +3660,17 @@ async function* ol(e) {
3659
3660
  r();
3660
3661
  }
3661
3662
  }
3662
- function Oe(e, t = new Uint8Array(32), n = 1) {
3663
+ function Me(e, t = new Uint8Array(32), n = 1) {
3663
3664
  const r = rn(fe, e, t), i = [];
3664
- for (let o = 1; o <= n; o++)
3665
- i.push(kr(fe, r, new Uint8Array([o]), 32));
3665
+ for (let s = 1; s <= n; s++)
3666
+ i.push(Cr(fe, r, new Uint8Array([s]), 32));
3666
3667
  return i;
3667
3668
  }
3668
3669
  function It(e, t) {
3669
3670
  return `${e}:${t}`;
3670
3671
  }
3671
- const Fc = 1e3;
3672
- class ot {
3672
+ const Fc = 1e3, Jc = "0000000000000000000000000000000000000000000000000000000000000000";
3673
+ class st {
3673
3674
  // 1. CHANNEL PUBLIC INTERFACE
3674
3675
  constructor(t, n) {
3675
3676
  te(this, "nostrUnsubscribe");
@@ -3682,45 +3683,68 @@ class ot {
3682
3683
  /**
3683
3684
  * Initializes a new secure communication session
3684
3685
  * @param nostrSubscribe Function to subscribe to Nostr events
3685
- * @param theirNostrPublicKey The public key of the other party
3686
+ * @param theirNextNostrPublicKey The public key of the other party
3686
3687
  * @param ourCurrentPrivateKey Our current private key for Nostr
3687
3688
  * @param isInitiator Whether we are initiating the conversation (true) or responding (false)
3688
3689
  * @param sharedSecret Initial shared secret for securing the first message chain
3689
3690
  * @param name Optional name for the session (for debugging)
3690
3691
  * @returns A new Session instance
3691
3692
  */
3692
- static init(t, n, r, i, o, s) {
3693
- const a = Ce(), [c, u] = Oe(o, j.getConversationKey(a, n), 2);
3694
- let f, l;
3695
- i ? (f = { publicKey: ue(r), privateKey: r }, l = { publicKey: ue(a), privateKey: a }) : l = { publicKey: ue(r), privateKey: r };
3693
+ static init(t, n, r, i, s, o) {
3694
+ const c = _e(), [a, l] = Me(s, q.getConversationKey(c, n), 2);
3695
+ let f, u;
3696
+ i ? (f = { publicKey: le(r), privateKey: r }, u = { publicKey: le(c), privateKey: c }) : u = { publicKey: le(r), privateKey: r };
3696
3697
  const g = {
3697
- rootKey: i ? c : o,
3698
- theirNostrPublicKey: n,
3698
+ rootKey: i ? a : s,
3699
+ theirNextNostrPublicKey: n,
3699
3700
  ourCurrentNostrKey: f,
3700
- ourNextNostrKey: l,
3701
+ ourNextNostrKey: u,
3701
3702
  receivingChainKey: void 0,
3702
- sendingChainKey: i ? u : void 0,
3703
+ sendingChainKey: i ? l : void 0,
3703
3704
  sendingChainMessageNumber: 0,
3704
3705
  receivingChainMessageNumber: 0,
3705
3706
  previousSendingChainMessageCount: 0,
3706
3707
  skippedMessageKeys: {},
3707
3708
  skippedHeaderKeys: {}
3708
- }, b = new ot(t, g);
3709
- return s && (b.name = s), b;
3709
+ }, b = new st(t, g);
3710
+ return o && (b.name = o), b;
3710
3711
  }
3711
3712
  /**
3712
- * Sends an encrypted message through the session
3713
- * @param data The plaintext message to send
3713
+ * Sends a text message through the encrypted session
3714
+ * @param text The plaintext message to send
3714
3715
  * @returns A verified Nostr event containing the encrypted message
3715
3716
  * @throws Error if we are not the initiator and trying to send the first message
3716
3717
  */
3717
3718
  send(t) {
3718
- if (!this.state.theirNostrPublicKey || !this.state.ourCurrentNostrKey)
3719
+ return this.sendEvent({
3720
+ content: t,
3721
+ kind: Gc
3722
+ });
3723
+ }
3724
+ /**
3725
+ * Send a Nostr event through the encrypted session
3726
+ * @param event Partial Nostr event to send. Must be unsigned. Id and will be generated if not provided.
3727
+ * @returns A verified Nostr event containing the encrypted message
3728
+ * @throws Error if we are not the initiator and trying to send the first message
3729
+ */
3730
+ sendEvent(t) {
3731
+ if (!this.state.theirNextNostrPublicKey || !this.state.ourCurrentNostrKey)
3719
3732
  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), o = j.encrypt(JSON.stringify(n), i);
3733
+ if ("sig" in t)
3734
+ throw new Error("Event must be unsigned " + JSON.stringify(t));
3735
+ const n = {
3736
+ ...t,
3737
+ content: t.content || "",
3738
+ kind: t.kind || Be,
3739
+ created_at: t.created_at || Math.floor(Date.now() / 1e3),
3740
+ tags: t.tags || [],
3741
+ pubkey: t.pubkey || Jc
3742
+ };
3743
+ n.tags.some(([a]) => a === "ms") || n.tags.push(["ms", Date.now().toString()]), n.id = Ge(n);
3744
+ const [r, i] = this.ratchetEncrypt(JSON.stringify(t)), s = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNextNostrPublicKey), o = q.encrypt(JSON.stringify(r), s);
3721
3745
  return X({
3722
- content: r,
3723
- kind: Pe,
3746
+ content: i,
3747
+ kind: Be,
3724
3748
  tags: [["header", o]],
3725
3749
  created_at: Math.floor(Date.now() / 1e3)
3726
3750
  }, this.state.ourCurrentNostrKey.privateKey);
@@ -3730,7 +3754,7 @@ class ot {
3730
3754
  * @param callback Function to be called when a message is received
3731
3755
  * @returns Unsubscribe function to stop receiving messages
3732
3756
  */
3733
- onMessage(t) {
3757
+ onEvent(t) {
3734
3758
  const n = this.currentInternalSubscriptionId++;
3735
3759
  return this.internalSubscriptions.set(n, t), this.subscribeToNostrEvents(), () => this.internalSubscriptions.delete(n);
3736
3760
  }
@@ -3743,69 +3767,68 @@ class ot {
3743
3767
  }
3744
3768
  // 2. RATCHET FUNCTIONS
3745
3769
  ratchetEncrypt(t) {
3746
- const [n, r] = Oe(this.state.sendingChainKey, new Uint8Array([1]), 2);
3770
+ const [n, r] = Me(this.state.sendingChainKey, new Uint8Array([1]), 2);
3747
3771
  return this.state.sendingChainKey = n, [{
3748
3772
  number: this.state.sendingChainMessageNumber++,
3749
3773
  nextPublicKey: this.state.ourNextNostrKey.publicKey,
3750
- time: Date.now(),
3751
3774
  previousChainLength: this.state.previousSendingChainMessageCount
3752
- }, j.encrypt(t, r)];
3775
+ }, q.encrypt(t, r)];
3753
3776
  }
3754
3777
  ratchetDecrypt(t, n, r) {
3755
3778
  const i = this.trySkippedMessageKeys(t, n, r);
3756
3779
  if (i) return i;
3757
3780
  this.skipMessageKeys(t.number, r);
3758
- const [o, s] = Oe(this.state.receivingChainKey, new Uint8Array([1]), 2);
3759
- this.state.receivingChainKey = o, this.state.receivingChainMessageNumber++;
3781
+ const [s, o] = Me(this.state.receivingChainKey, new Uint8Array([1]), 2);
3782
+ this.state.receivingChainKey = s, this.state.receivingChainMessageNumber++;
3760
3783
  try {
3761
- return j.decrypt(n, s);
3762
- } catch (a) {
3763
- throw console.error(this.name, "Decryption failed:", a, {
3764
- messageKey: M(s).slice(0, 4),
3784
+ return q.decrypt(n, o);
3785
+ } catch (c) {
3786
+ throw console.error(this.name, "Decryption failed:", c, {
3787
+ messageKey: M(o).slice(0, 4),
3765
3788
  receivingChainKey: M(this.state.receivingChainKey).slice(0, 4),
3766
3789
  sendingChainKey: this.state.sendingChainKey && M(this.state.sendingChainKey).slice(0, 4),
3767
3790
  rootKey: M(this.state.rootKey).slice(0, 4)
3768
- }), a;
3791
+ }), c;
3769
3792
  }
3770
3793
  }
3771
3794
  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);
3795
+ this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0, this.state.theirNextNostrPublicKey = t;
3796
+ const n = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [r, i] = Me(this.state.rootKey, n, 2);
3774
3797
  this.state.receivingChainKey = i, this.state.ourCurrentNostrKey = this.state.ourNextNostrKey;
3775
- const o = Ce();
3798
+ const s = _e();
3776
3799
  this.state.ourNextNostrKey = {
3777
- publicKey: ue(o),
3778
- privateKey: o
3800
+ publicKey: le(s),
3801
+ privateKey: s
3779
3802
  };
3780
- const s = j.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [a, c] = Oe(r, s, 2);
3781
- this.state.rootKey = a, this.state.sendingChainKey = c;
3803
+ const o = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [c, a] = Me(r, o, 2);
3804
+ this.state.rootKey = c, this.state.sendingChainKey = a;
3782
3805
  }
3783
3806
  // 3. MESSAGE KEY FUNCTIONS
3784
3807
  skipMessageKeys(t, n) {
3785
3808
  if (this.state.receivingChainMessageNumber + Fc < t)
3786
3809
  throw new Error("Too many skipped messages");
3787
3810
  for (; this.state.receivingChainMessageNumber < t; ) {
3788
- const [r, i] = Oe(this.state.receivingChainKey, new Uint8Array([1]), 2);
3811
+ const [r, i] = Me(this.state.receivingChainKey, new Uint8Array([1]), 2);
3789
3812
  this.state.receivingChainKey = r;
3790
- const o = It(n, this.state.receivingChainMessageNumber);
3791
- if (this.state.skippedMessageKeys[o] = i, !this.state.skippedHeaderKeys[n]) {
3792
- const s = [];
3813
+ const s = It(n, this.state.receivingChainMessageNumber);
3814
+ if (this.state.skippedMessageKeys[s] = i, !this.state.skippedHeaderKeys[n]) {
3815
+ const o = [];
3793
3816
  if (this.state.ourCurrentNostrKey) {
3794
- const c = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
3795
- s.push(c);
3817
+ const a = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
3818
+ o.push(a);
3796
3819
  }
3797
- const a = j.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
3798
- s.push(a), this.state.skippedHeaderKeys[n] = s;
3820
+ const c = q.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
3821
+ o.push(c), this.state.skippedHeaderKeys[n] = o;
3799
3822
  }
3800
3823
  this.state.receivingChainMessageNumber++;
3801
3824
  }
3802
3825
  }
3803
3826
  trySkippedMessageKeys(t, n, r) {
3804
- var o;
3827
+ var s;
3805
3828
  const i = It(r, t.number);
3806
3829
  if (i in this.state.skippedMessageKeys) {
3807
- const s = 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], (o = this.nostrUnsubscribe) == null || o.call(this), this.nostrUnsubscribe = void 0), j.decrypt(n, s);
3830
+ const o = this.state.skippedMessageKeys[i];
3831
+ return delete this.state.skippedMessageKeys[i], Object.keys(this.state.skippedMessageKeys).some((a) => a.startsWith(`${r}:`)) || (delete this.state.skippedHeaderKeys[r], (s = this.nostrUnsubscribe) == null || s.call(this), this.nostrUnsubscribe = void 0), q.decrypt(n, o);
3809
3832
  }
3810
3833
  return null;
3811
3834
  }
@@ -3813,69 +3836,69 @@ class ot {
3813
3836
  decryptHeader(t) {
3814
3837
  const n = t.tags[0][1];
3815
3838
  if (this.state.ourCurrentNostrKey) {
3816
- const o = j.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
3839
+ const s = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
3817
3840
  try {
3818
- return [JSON.parse(j.decrypt(n, o)), !1, !1];
3841
+ return [JSON.parse(q.decrypt(n, s)), !1, !1];
3819
3842
  } catch {
3820
3843
  }
3821
3844
  }
3822
- const r = j.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
3845
+ const r = q.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
3823
3846
  try {
3824
- return [JSON.parse(j.decrypt(n, r)), !0, !1];
3847
+ return [JSON.parse(q.decrypt(n, r)), !0, !1];
3825
3848
  } catch {
3826
3849
  }
3827
3850
  const i = this.state.skippedHeaderKeys[t.pubkey];
3828
3851
  if (i)
3829
- for (const o of i)
3852
+ for (const s of i)
3830
3853
  try {
3831
- return [JSON.parse(j.decrypt(n, o)), !1, !0];
3854
+ return [JSON.parse(q.decrypt(n, s)), !1, !0];
3832
3855
  } catch {
3833
3856
  }
3834
3857
  throw new Error("Failed to decrypt header with current and skipped header keys");
3835
3858
  }
3836
3859
  handleNostrEvent(t) {
3837
- var s;
3860
+ var c;
3838
3861
  const [n, r, i] = this.decryptHeader(t);
3839
3862
  if (!i)
3840
- this.state.theirNostrPublicKey !== n.nextPublicKey && (this.state.theirNostrPublicKey = n.nextPublicKey, (s = this.nostrUnsubscribe) == null || s.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
3841
- { authors: [this.state.theirNostrPublicKey], kinds: [Pe] },
3863
+ this.state.theirNextNostrPublicKey !== n.nextPublicKey && (this.state.theirCurrentNostrPublicKey = this.state.theirNextNostrPublicKey, this.state.theirNextNostrPublicKey = n.nextPublicKey, (c = this.nostrUnsubscribe) == null || c.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
3864
+ { authors: [this.state.theirNextNostrPublicKey], kinds: [Be] },
3842
3865
  (a) => this.handleNostrEvent(a)
3843
3866
  )), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey));
3844
3867
  else if (!(It(t.pubkey, n.number) in this.state.skippedMessageKeys))
3845
3868
  return;
3846
- const o = this.ratchetDecrypt(n, t.content, t.pubkey);
3847
- this.internalSubscriptions.forEach((a) => a({ id: t.id, data: o, pubkey: n.nextPublicKey, time: n.time }));
3869
+ const s = this.ratchetDecrypt(n, t.content, t.pubkey), o = JSON.parse(s);
3870
+ this.internalSubscriptions.forEach((a) => a(o, t));
3848
3871
  }
3849
3872
  subscribeToNostrEvents() {
3850
3873
  if (this.nostrNextUnsubscribe) return;
3851
3874
  this.nostrNextUnsubscribe = this.nostrSubscribe(
3852
- { authors: [this.state.theirNostrPublicKey], kinds: [Pe] },
3875
+ { authors: [this.state.theirNextNostrPublicKey], kinds: [Be] },
3853
3876
  (n) => this.handleNostrEvent(n)
3854
3877
  );
3855
3878
  const t = Object.keys(this.state.skippedHeaderKeys);
3856
- t.length > 0 && (this.nostrUnsubscribe = this.nostrSubscribe(
3857
- { authors: t, kinds: [Pe] },
3879
+ this.state.theirCurrentNostrPublicKey && !t.includes(this.state.theirCurrentNostrPublicKey) && t.push(this.state.theirCurrentNostrPublicKey), this.nostrUnsubscribe = this.nostrSubscribe(
3880
+ { authors: t, kinds: [Be] },
3858
3881
  (n) => this.handleNostrEvent(n)
3859
- ));
3882
+ );
3860
3883
  }
3861
3884
  }
3862
3885
  new TextDecoder("utf-8");
3863
3886
  new TextEncoder();
3864
- function Xe(e, t) {
3865
- const n = _e.getSharedSecret(e, "02" + t).subarray(1, 33);
3887
+ function Qe(e, t) {
3888
+ const n = Ie.getSharedSecret(e, "02" + t).subarray(1, 33);
3866
3889
  return rn(fe, n, "nip44-v2");
3867
3890
  }
3868
- class Me {
3869
- constructor(t, n, r, i, o, s, a = []) {
3870
- this.inviterEphemeralPublicKey = t, this.linkSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.label = o, this.maxUses = s, this.usedBy = a;
3891
+ class Pe {
3892
+ constructor(t, n, r, i, s, o, c = []) {
3893
+ this.inviterEphemeralPublicKey = t, this.sharedSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.label = s, this.maxUses = o, this.usedBy = c;
3871
3894
  }
3872
3895
  static createNew(t, n, r) {
3873
3896
  if (!t)
3874
3897
  throw new Error("Inviter public key is required");
3875
- const i = Ce(), o = ue(i), s = M(Ce());
3876
- return new Me(
3877
- o,
3898
+ const i = _e(), s = le(i), o = M(_e());
3899
+ return new Pe(
3878
3900
  s,
3901
+ o,
3879
3902
  t,
3880
3903
  i,
3881
3904
  n,
@@ -3887,26 +3910,26 @@ class Me {
3887
3910
  if (!r)
3888
3911
  throw new Error("No invite data found in the URL hash.");
3889
3912
  const i = decodeURIComponent(r);
3890
- let o;
3913
+ let s;
3891
3914
  try {
3892
- o = JSON.parse(i);
3893
- } catch (u) {
3894
- throw new Error("Invite data in URL hash is not valid JSON: " + u);
3895
- }
3896
- const { inviter: s, ephemeralKey: a, linkSecret: c } = o;
3897
- if (!s || !a || !c)
3898
- throw new Error("Missing required fields (inviter, ephemeralKey, linkSecret) in invite data.");
3899
- return new Me(
3900
- a,
3915
+ s = JSON.parse(i);
3916
+ } catch (l) {
3917
+ throw new Error("Invite data in URL hash is not valid JSON: " + l);
3918
+ }
3919
+ const { inviter: o, ephemeralKey: c, sharedSecret: a } = s;
3920
+ if (!o || !c || !a)
3921
+ throw new Error("Missing required fields (inviter, ephemeralKey, sharedSecret) in invite data.");
3922
+ return new Pe(
3901
3923
  c,
3902
- s
3924
+ a,
3925
+ o
3903
3926
  );
3904
3927
  }
3905
3928
  static deserialize(t) {
3906
3929
  const n = JSON.parse(t);
3907
- return new Me(
3930
+ return new Pe(
3908
3931
  n.inviterEphemeralPublicKey,
3909
- n.linkSecret,
3932
+ n.sharedSecret,
3910
3933
  n.inviter,
3911
3934
  n.inviterEphemeralPrivateKey ? new Uint8Array(n.inviterEphemeralPrivateKey) : void 0,
3912
3935
  n.label,
@@ -3915,18 +3938,18 @@ class Me {
3915
3938
  );
3916
3939
  }
3917
3940
  static fromEvent(t) {
3918
- var s, a;
3941
+ var o, c;
3919
3942
  if (!t.sig)
3920
3943
  throw new Error("Event is not signed");
3921
3944
  if (!pt(t))
3922
3945
  throw new Error("Event signature is invalid");
3923
- const { tags: n } = t, r = (s = n.find(([c]) => c === "ephemeralKey")) == null ? void 0 : s[1], i = (a = n.find(([c]) => c === "linkSecret")) == null ? void 0 : a[1], o = t.pubkey;
3946
+ const { tags: n } = t, r = (o = n.find(([a]) => a === "ephemeralKey")) == null ? void 0 : o[1], i = (c = n.find(([a]) => a === "sharedSecret")) == null ? void 0 : c[1], s = t.pubkey;
3924
3947
  if (!r || !i)
3925
- throw new Error("Invalid invite event: missing session key or link secret");
3926
- return new Me(
3948
+ throw new Error("Invalid invite event: missing session key or sharedSecret");
3949
+ return new Pe(
3927
3950
  r,
3928
3951
  i,
3929
- o
3952
+ s
3930
3953
  );
3931
3954
  }
3932
3955
  static fromUser(t, n, r) {
@@ -3936,15 +3959,15 @@ class Me {
3936
3959
  limit: 1,
3937
3960
  "#d": ["nostr-double-ratchet/invite"]
3938
3961
  };
3939
- let o = 0;
3940
- return n(i, (a) => {
3941
- if (!(!a.created_at || a.created_at <= o)) {
3942
- o = a.created_at;
3962
+ let s = 0;
3963
+ return n(i, (c) => {
3964
+ if (!(!c.created_at || c.created_at <= s)) {
3965
+ s = c.created_at;
3943
3966
  try {
3944
- const c = Me.fromEvent(a);
3945
- r(c);
3946
- } catch (c) {
3947
- console.error("Error processing invite:", c, "event:", a);
3967
+ const a = Pe.fromEvent(c);
3968
+ r(a);
3969
+ } catch (a) {
3970
+ console.error("Error processing invite:", a, "event:", c);
3948
3971
  }
3949
3972
  }
3950
3973
  });
@@ -3955,7 +3978,7 @@ class Me {
3955
3978
  serialize() {
3956
3979
  return JSON.stringify({
3957
3980
  inviterEphemeralPublicKey: this.inviterEphemeralPublicKey,
3958
- linkSecret: this.linkSecret,
3981
+ sharedSecret: this.sharedSecret,
3959
3982
  inviter: this.inviter,
3960
3983
  inviterEphemeralPrivateKey: this.inviterEphemeralPrivateKey ? Array.from(this.inviterEphemeralPrivateKey) : void 0,
3961
3984
  label: this.label,
@@ -3970,9 +3993,9 @@ class Me {
3970
3993
  const n = {
3971
3994
  inviter: this.inviter,
3972
3995
  ephemeralKey: this.inviterEphemeralPublicKey,
3973
- linkSecret: this.linkSecret
3996
+ sharedSecret: this.sharedSecret
3974
3997
  }, r = new URL(t);
3975
- return r.hash = encodeURIComponent(JSON.stringify(n)), console.log("url", r.toString()), r.toString();
3998
+ return r.hash = encodeURIComponent(JSON.stringify(n)), r.toString();
3976
3999
  }
3977
4000
  getEvent() {
3978
4001
  return {
@@ -3980,7 +4003,7 @@ class Me {
3980
4003
  pubkey: this.inviter,
3981
4004
  content: "",
3982
4005
  created_at: Math.floor(Date.now() / 1e3),
3983
- tags: [["ephemeralKey", this.inviterEphemeralPublicKey], ["linkSecret", this.linkSecret], ["d", "nostr-double-ratchet/invite"]]
4006
+ tags: [["ephemeralKey", this.inviterEphemeralPublicKey], ["sharedSecret", this.sharedSecret], ["d", "nostr-double-ratchet/invite"]]
3984
4007
  };
3985
4008
  }
3986
4009
  /**
@@ -3999,58 +4022,58 @@ class Me {
3999
4022
  * so the inviter can create the session on their side.
4000
4023
  */
4001
4024
  async accept(t, n, r) {
4002
- const i = Ce(), o = ue(i), s = this.inviter || this.inviterEphemeralPublicKey, a = G(this.linkSecret), c = ot.init(t, this.inviterEphemeralPublicKey, i, !0, a, void 0), u = Ce(), f = ue(u), l = typeof r == "function" ? r : (p, h) => Promise.resolve(j.encrypt(p, Xe(r, h))), g = {
4025
+ const i = _e(), s = le(i), o = this.inviter || this.inviterEphemeralPublicKey, c = G(this.sharedSecret), a = st.init(t, this.inviterEphemeralPublicKey, i, !0, c, void 0), l = _e(), f = le(l), g = await (typeof r == "function" ? r : (h, d) => Promise.resolve(q.encrypt(h, Qe(r, d))))(s, o), b = {
4003
4026
  pubkey: n,
4004
- tags: [["secret", this.linkSecret]],
4005
- content: await l(o, s),
4027
+ tags: [["sharedSecret", this.sharedSecret]],
4028
+ content: await q.encrypt(g, c),
4006
4029
  created_at: Math.floor(Date.now() / 1e3)
4007
- }, b = {
4008
- kind: Pe,
4030
+ }, p = {
4031
+ kind: Be,
4009
4032
  pubkey: f,
4010
- content: j.encrypt(JSON.stringify(g), Xe(u, this.inviterEphemeralPublicKey)),
4033
+ content: q.encrypt(JSON.stringify(b), Qe(l, this.inviterEphemeralPublicKey)),
4011
4034
  created_at: Math.floor(Date.now() / 1e3),
4012
4035
  tags: [["p", this.inviterEphemeralPublicKey]]
4013
4036
  };
4014
- return { session: c, event: X(b, u) };
4037
+ return { session: a, event: X(p, l) };
4015
4038
  }
4016
4039
  listen(t, n, r) {
4017
4040
  if (!this.inviterEphemeralPrivateKey)
4018
4041
  throw new Error("Inviter session key is not available");
4019
4042
  const i = {
4020
- kinds: [Pe],
4043
+ kinds: [Be],
4021
4044
  "#p": [this.inviterEphemeralPublicKey]
4022
4045
  };
4023
- return n(i, async (o) => {
4046
+ return n(i, async (s) => {
4024
4047
  try {
4025
4048
  if (this.maxUses && this.usedBy.length >= this.maxUses) {
4026
4049
  console.error("Invite has reached maximum number of uses");
4027
4050
  return;
4028
4051
  }
4029
- const s = await j.decrypt(o.content, Xe(this.inviterEphemeralPrivateKey, o.pubkey)), a = JSON.parse(s);
4030
- if (!a.tags || !a.tags.some(([p, h]) => p === "secret" && h === this.linkSecret)) {
4031
- console.error("Invalid secret from event", o);
4052
+ const o = await q.decrypt(s.content, Qe(this.inviterEphemeralPrivateKey, s.pubkey)), c = JSON.parse(o);
4053
+ if (!c.tags || !c.tags.some(([h, d]) => h === "sharedSecret" && d === this.sharedSecret)) {
4054
+ console.error("Invalid secret from event", s);
4032
4055
  return;
4033
4056
  }
4034
- const c = typeof t == "function" ? t : (p, h) => Promise.resolve(j.decrypt(p, Xe(t, h))), u = a.pubkey;
4035
- this.usedBy.push(u);
4036
- const f = await c(a.content, u), l = G(this.linkSecret), g = o.id, b = ot.init(n, f, this.inviterEphemeralPrivateKey, !1, l, g);
4037
- r(b, u);
4038
- } catch (s) {
4039
- console.error("Error processing invite message:", s, "event", o);
4057
+ const a = G(this.sharedSecret), l = c.pubkey;
4058
+ this.usedBy.push(l);
4059
+ 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), b = s.id, p = st.init(n, g, this.inviterEphemeralPrivateKey, !1, a, b);
4060
+ r(p, l);
4061
+ } catch (o) {
4062
+ console.error("Error processing invite message:", o, "event", s);
4040
4063
  }
4041
4064
  });
4042
4065
  }
4043
4066
  }
4044
4067
  export {
4068
+ Gc as CHAT_MESSAGE_KIND,
4045
4069
  jn as INVITE_EVENT_KIND,
4046
- Me as Invite,
4047
- nl as MAX_SKIP,
4048
- Pe as MESSAGE_EVENT_KIND,
4049
- Gc as Sender,
4050
- ot as Session,
4051
- ol as createMessageStream,
4052
- il as deserializeSessionState,
4053
- Oe as kdf,
4054
- rl as serializeSessionState,
4070
+ Pe as Invite,
4071
+ ru as MAX_SKIP,
4072
+ Be as MESSAGE_EVENT_KIND,
4073
+ st as Session,
4074
+ ou as createEventStream,
4075
+ su as deserializeSessionState,
4076
+ Me as kdf,
4077
+ iu as serializeSessionState,
4055
4078
  It as skippedMessageIndexKey
4056
4079
  };