nostr-double-ratchet 0.0.1 → 0.0.3

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.
@@ -1,6 +1,6 @@
1
1
  var oi = Object.defineProperty;
2
2
  var si = (e, t, n) => t in e ? oi(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var Q = (e, t, n) => si(e, typeof t != "symbol" ? t + "" : t, n);
3
+ var ee = (e, t, n) => si(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  function mn(e) {
5
5
  if (!Number.isSafeInteger(e) || e < 0)
6
6
  throw new Error(`Wrong positive integer: ${e}`);
@@ -16,7 +16,7 @@ function ai(e) {
16
16
  throw new Error("Hash should be wrapped by utils.wrapConstructor");
17
17
  mn(e.outputLen), mn(e.blockLen);
18
18
  }
19
- function it(e, t = !0) {
19
+ function rt(e, t = !0) {
20
20
  if (e.destroyed)
21
21
  throw new Error("Hash instance has been destroyed");
22
22
  if (t && e.finished)
@@ -28,18 +28,18 @@ function ci(e, t) {
28
28
  if (e.length < n)
29
29
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
30
30
  }
31
- const Bt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
31
+ const St = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
32
32
  /*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
33
- const On = (e) => e instanceof Uint8Array, Nt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), te = (e, t) => e << 32 - t | e >>> t, ui = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
34
- if (!ui)
33
+ const On = (e) => e instanceof Uint8Array, Kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ne = (e, t) => e << 32 - t | e >>> t, li = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
34
+ if (!li)
35
35
  throw new Error("Non little-endian hardware is not supported");
36
- function li(e) {
36
+ function ui(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
- function Zt(e) {
42
- if (typeof e == "string" && (e = li(e)), !On(e))
41
+ function zt(e) {
42
+ if (typeof e == "string" && (e = ui(e)), !On(e))
43
43
  throw new Error(`expected Uint8Array, got ${typeof e}`);
44
44
  return e;
45
45
  }
@@ -52,40 +52,40 @@ function fi(...e) {
52
52
  t.set(r, n), n += r.length;
53
53
  }), t;
54
54
  }
55
- let Hn = class {
55
+ let Mn = class {
56
56
  // Safe version that clones internal state
57
57
  clone() {
58
58
  return this._cloneInto();
59
59
  }
60
60
  };
61
61
  function hi(e) {
62
- const t = (r) => e().update(Zt(r)).digest(), n = e();
62
+ const t = (r) => e().update(zt(r)).digest(), n = e();
63
63
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
64
64
  }
65
- function Mn(e = 32) {
66
- if (Bt && typeof Bt.getRandomValues == "function")
67
- return Bt.getRandomValues(new Uint8Array(e));
65
+ function Hn(e = 32) {
66
+ if (St && typeof St.getRandomValues == "function")
67
+ return St.getRandomValues(new Uint8Array(e));
68
68
  throw new Error("crypto.getRandomValues must be defined");
69
69
  }
70
70
  function di(e, t, n, r) {
71
71
  if (typeof e.setBigUint64 == "function")
72
72
  return e.setBigUint64(t, n, r);
73
- const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), c = Number(n & o), a = r ? 4 : 0, u = r ? 0 : 4;
74
- e.setUint32(t + a, s, r), e.setUint32(t + u, c, r);
73
+ const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), c = Number(n & o), a = r ? 4 : 0, l = r ? 0 : 4;
74
+ e.setUint32(t + a, s, r), e.setUint32(t + l, c, r);
75
75
  }
76
- let gi = class extends Hn {
76
+ let yi = class extends Mn {
77
77
  constructor(t, n, r, i) {
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 = Nt(this.buffer);
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 = Kt(this.buffer);
79
79
  }
80
80
  update(t) {
81
- it(this);
81
+ rt(this);
82
82
  const { view: n, buffer: r, blockLen: i } = this;
83
- t = Zt(t);
83
+ t = zt(t);
84
84
  const o = t.length;
85
85
  for (let s = 0; s < o; ) {
86
86
  const c = Math.min(i - this.pos, o - s);
87
87
  if (c === i) {
88
- const a = Nt(t);
88
+ const a = Kt(t);
89
89
  for (; i <= o - s; s += i)
90
90
  this.process(a, s);
91
91
  continue;
@@ -95,21 +95,21 @@ let gi = class extends Hn {
95
95
  return this.length += t.length, this.roundClean(), this;
96
96
  }
97
97
  digestInto(t) {
98
- it(this), ci(t, this), this.finished = !0;
98
+ rt(this), ci(t, this), this.finished = !0;
99
99
  const { buffer: n, view: r, blockLen: i, isLE: o } = this;
100
100
  let { pos: s } = this;
101
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;
102
+ for (let u = s; u < i; u++)
103
+ n[u] = 0;
104
104
  di(r, i - 8, BigInt(this.length * 8), o), this.process(r, 0);
105
- const c = Nt(t), a = this.outputLen;
105
+ const c = Kt(t), a = this.outputLen;
106
106
  if (a % 4)
107
107
  throw new Error("_sha2: outputLen should be aligned to 32bit");
108
- const u = a / 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
- c.setUint32(4 * l, f[l], o);
111
+ for (let u = 0; u < l; u++)
112
+ c.setUint32(4 * u, f[u], o);
113
113
  }
114
114
  digest() {
115
115
  const { buffer: t, outputLen: n } = this;
@@ -123,7 +123,7 @@ let gi = class extends Hn {
123
123
  return t.length = i, t.pos = c, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
124
124
  }
125
125
  };
126
- const pi = (e, t, n) => e & t ^ ~e & n, yi = (e, t, n) => e & t ^ e & n ^ t & n, wi = /* @__PURE__ */ new Uint32Array([
126
+ const gi = (e, t, n) => e & t ^ ~e & n, pi = (e, t, n) => e & t ^ e & n ^ t & n, wi = /* @__PURE__ */ new Uint32Array([
127
127
  1116352408,
128
128
  1899447441,
129
129
  3049323471,
@@ -188,7 +188,7 @@ const pi = (e, t, n) => e & t ^ ~e & n, yi = (e, t, n) => e & t ^ e & n ^ t & n,
188
188
  2756734187,
189
189
  3204031479,
190
190
  3329325298
191
- ]), be = /* @__PURE__ */ new Uint32Array([
191
+ ]), pe = /* @__PURE__ */ new Uint32Array([
192
192
  1779033703,
193
193
  3144134277,
194
194
  1013904242,
@@ -197,10 +197,10 @@ const pi = (e, t, n) => e & t ^ ~e & n, yi = (e, t, n) => e & t ^ e & n ^ t & n,
197
197
  2600822924,
198
198
  528734635,
199
199
  1541459225
200
- ]), ve = /* @__PURE__ */ new Uint32Array(64);
201
- let bi = class extends gi {
200
+ ]), we = /* @__PURE__ */ new Uint32Array(64);
201
+ let bi = class extends yi {
202
202
  constructor() {
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;
203
+ super(64, 32, 8, !1), this.A = pe[0] | 0, this.B = pe[1] | 0, this.C = pe[2] | 0, this.D = pe[3] | 0, this.E = pe[4] | 0, this.F = pe[5] | 0, this.G = pe[6] | 0, this.H = pe[7] | 0;
204
204
  }
205
205
  get() {
206
206
  const { A: t, B: n, C: r, D: i, E: o, F: s, G: c, H: a } = this;
@@ -211,21 +211,21 @@ let bi = class extends gi {
211
211
  this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = c | 0, this.H = a | 0;
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 d = ve[l - 15], w = ve[l - 2], y = te(d, 7) ^ te(d, 18) ^ d >>> 3, h = te(w, 17) ^ te(w, 19) ^ w >>> 10;
218
- ve[l] = h + ve[l - 7] + y + ve[l - 16] | 0;
214
+ for (let u = 0; u < 16; u++, n += 4)
215
+ we[u] = t.getUint32(n, !1);
216
+ for (let u = 16; u < 64; u++) {
217
+ const d = we[u - 15], g = we[u - 2], w = ne(d, 7) ^ ne(d, 18) ^ d >>> 3, h = ne(g, 17) ^ ne(g, 19) ^ g >>> 10;
218
+ we[u] = h + we[u - 7] + w + we[u - 16] | 0;
219
219
  }
220
- let { A: r, B: i, C: o, D: s, E: c, F: a, G: u, H: f } = this;
221
- for (let l = 0; l < 64; l++) {
222
- const d = te(c, 6) ^ te(c, 11) ^ te(c, 25), w = f + d + pi(c, a, u) + wi[l] + ve[l] | 0, h = (te(r, 2) ^ te(r, 13) ^ te(r, 22)) + yi(r, i, o) | 0;
223
- f = u, u = a, a = c, c = s + w | 0, s = o, o = i, i = r, r = w + h | 0;
220
+ let { A: r, B: i, C: o, D: s, E: c, F: a, G: l, H: f } = this;
221
+ for (let u = 0; u < 64; u++) {
222
+ const d = ne(c, 6) ^ ne(c, 11) ^ ne(c, 25), g = f + d + gi(c, a, l) + wi[u] + we[u] | 0, h = (ne(r, 2) ^ ne(r, 13) ^ ne(r, 22)) + pi(r, i, o) | 0;
223
+ f = l, l = a, a = c, c = s + g | 0, s = o, o = i, i = r, r = g + h | 0;
224
224
  }
225
- r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, u = u + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, c, a, u, f);
225
+ r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, c, a, l, f);
226
226
  }
227
227
  roundClean() {
228
- ve.fill(0);
228
+ we.fill(0);
229
229
  }
230
230
  destroy() {
231
231
  this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
@@ -233,20 +233,20 @@ let bi = class extends gi {
233
233
  };
234
234
  const $t = /* @__PURE__ */ hi(() => new bi());
235
235
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
236
- const qn = BigInt(0), ft = BigInt(1), vi = BigInt(2), ht = (e) => e instanceof Uint8Array, xi = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
237
- function Me(e) {
238
- if (!ht(e))
236
+ const qn = BigInt(0), ut = BigInt(1), vi = BigInt(2), ft = (e) => e instanceof Uint8Array, mi = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
237
+ function He(e) {
238
+ if (!ft(e))
239
239
  throw new Error("Uint8Array expected");
240
240
  let t = "";
241
241
  for (let n = 0; n < e.length; n++)
242
- t += xi[e[n]];
242
+ t += mi[e[n]];
243
243
  return t;
244
244
  }
245
245
  function Dn(e) {
246
246
  const t = e.toString(16);
247
247
  return t.length & 1 ? `0${t}` : t;
248
248
  }
249
- function Ft(e) {
249
+ function Zt(e) {
250
250
  if (typeof e != "string")
251
251
  throw new Error("hex string expected, got " + typeof e);
252
252
  return BigInt(e === "" ? "0" : `0x${e}`);
@@ -266,24 +266,24 @@ function qe(e) {
266
266
  }
267
267
  return n;
268
268
  }
269
- function F(e) {
270
- return Ft(Me(e));
269
+ function W(e) {
270
+ return Zt(He(e));
271
271
  }
272
- function Wt(e) {
273
- if (!ht(e))
272
+ function Ft(e) {
273
+ if (!ft(e))
274
274
  throw new Error("Uint8Array expected");
275
- return Ft(Me(Uint8Array.from(e).reverse()));
275
+ return Zt(He(Uint8Array.from(e).reverse()));
276
276
  }
277
- function Be(e, t) {
277
+ function xe(e, t) {
278
278
  return qe(e.toString(16).padStart(t * 2, "0"));
279
279
  }
280
- function Gt(e, t) {
281
- return Be(e, t).reverse();
280
+ function Wt(e, t) {
281
+ return xe(e, t).reverse();
282
282
  }
283
- function mi(e) {
283
+ function Ei(e) {
284
284
  return qe(Dn(e));
285
285
  }
286
- function z(e, t, n) {
286
+ function Z(e, t, n) {
287
287
  let r;
288
288
  if (typeof t == "string")
289
289
  try {
@@ -291,7 +291,7 @@ function z(e, t, n) {
291
291
  } catch (o) {
292
292
  throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${o}`);
293
293
  }
294
- else if (ht(t))
294
+ else if (ft(t))
295
295
  r = Uint8Array.from(t);
296
296
  else
297
297
  throw new Error(`${e} must be hex string or Uint8Array`);
@@ -300,16 +300,16 @@ function z(e, t, n) {
300
300
  throw new Error(`${e} expected ${n} bytes, got ${i}`);
301
301
  return r;
302
302
  }
303
- function _e(...e) {
303
+ function Ie(...e) {
304
304
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
305
305
  let n = 0;
306
306
  return e.forEach((r) => {
307
- if (!ht(r))
307
+ if (!ft(r))
308
308
  throw new Error("Uint8Array expected");
309
309
  t.set(r, n), n += r.length;
310
310
  }), t;
311
311
  }
312
- function Ei(e, t) {
312
+ function xi(e, t) {
313
313
  if (e.length !== t.length)
314
314
  return !1;
315
315
  for (let n = 0; n < e.length; n++)
@@ -324,14 +324,14 @@ function Ai(e) {
324
324
  }
325
325
  function Si(e) {
326
326
  let t;
327
- for (t = 0; e > qn; e >>= ft, t += 1)
327
+ for (t = 0; e > qn; e >>= ut, t += 1)
328
328
  ;
329
329
  return t;
330
330
  }
331
- function Bi(e, t) {
332
- return e >> BigInt(t) & ft;
331
+ function Ki(e, t) {
332
+ return e >> BigInt(t) & ut;
333
333
  }
334
- const Ni = (e, t, n) => e | (n ? ft : qn) << BigInt(t), Jt = (e) => (vi << BigInt(e - 1)) - ft, Ct = (e) => new Uint8Array(e), En = (e) => Uint8Array.from(e);
334
+ const Bi = (e, t, n) => e | (n ? ut : qn) << BigInt(t), Gt = (e) => (vi << BigInt(e - 1)) - ut, Bt = (e) => new Uint8Array(e), En = (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 = Ct(e), i = Ct(e), o = 0;
342
+ let r = Bt(e), i = Bt(e), o = 0;
343
343
  const s = () => {
344
344
  r.fill(1), i.fill(0), o = 0;
345
- }, c = (...l) => n(i, r, ...l), a = (l = Ct()) => {
346
- i = c(En([0]), l), r = c(), l.length !== 0 && (i = c(En([1]), l), r = c());
347
- }, u = () => {
345
+ }, c = (...u) => n(i, r, ...u), a = (u = Bt()) => {
346
+ i = c(En([0]), u), r = c(), u.length !== 0 && (i = c(En([1]), u), r = c());
347
+ }, l = () => {
348
348
  if (o++ >= 1e3)
349
349
  throw new Error("drbg: tried 1000 values");
350
- let l = 0;
350
+ let u = 0;
351
351
  const d = [];
352
- for (; l < t; ) {
352
+ for (; u < t; ) {
353
353
  r = c();
354
- const w = r.slice();
355
- d.push(w), l += r.length;
354
+ const g = r.slice();
355
+ d.push(g), u += r.length;
356
356
  }
357
- return _e(...d);
357
+ return Ie(...d);
358
358
  };
359
- return (l, d) => {
360
- s(), a(l);
361
- let w;
362
- for (; !(w = d(u())); )
359
+ return (u, d) => {
360
+ s(), a(u);
361
+ let g;
362
+ for (; !(g = d(l())); )
363
363
  a();
364
- return s(), w;
364
+ return s(), g;
365
365
  };
366
366
  }
367
- const Ci = {
367
+ const Ni = {
368
368
  bigint: (e) => typeof e == "bigint",
369
369
  function: (e) => typeof e == "function",
370
370
  boolean: (e) => typeof e == "boolean",
@@ -375,9 +375,9 @@ const Ci = {
375
375
  field: (e, t) => t.Fp.isValid(e),
376
376
  hash: (e) => typeof e == "function" && Number.isSafeInteger(e.outputLen)
377
377
  };
378
- function Ye(e, t, n = {}) {
378
+ function Je(e, t, n = {}) {
379
379
  const r = (i, o, s) => {
380
- const c = Ci[o];
380
+ const c = Ni[o];
381
381
  if (typeof c != "function")
382
382
  throw new Error(`Invalid validator "${o}", expected function`);
383
383
  const a = e[i];
@@ -390,44 +390,44 @@ function Ye(e, t, n = {}) {
390
390
  r(i, o, !0);
391
391
  return e;
392
392
  }
393
- const Ui = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
393
+ const Ci = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
394
394
  __proto__: null,
395
- bitGet: Bi,
395
+ bitGet: Ki,
396
396
  bitLen: Si,
397
- bitMask: Jt,
398
- bitSet: Ni,
399
- bytesToHex: Me,
400
- bytesToNumberBE: F,
401
- bytesToNumberLE: Wt,
402
- concatBytes: _e,
397
+ bitMask: Gt,
398
+ bitSet: Bi,
399
+ bytesToHex: He,
400
+ bytesToNumberBE: W,
401
+ bytesToNumberLE: Ft,
402
+ concatBytes: Ie,
403
403
  createHmacDrbg: jn,
404
- ensureBytes: z,
405
- equalBytes: Ei,
404
+ ensureBytes: Z,
405
+ equalBytes: xi,
406
406
  hexToBytes: qe,
407
- hexToNumber: Ft,
408
- numberToBytesBE: Be,
409
- numberToBytesLE: Gt,
407
+ hexToNumber: Zt,
408
+ numberToBytesBE: xe,
409
+ numberToBytesLE: Wt,
410
410
  numberToHexUnpadded: Dn,
411
- numberToVarBytesBE: mi,
411
+ numberToVarBytesBE: Ei,
412
412
  utf8ToBytes: Ai,
413
- validateObject: Ye
413
+ validateObject: Je
414
414
  }, Symbol.toStringTag, { value: "Module" }));
415
415
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
416
- const j = BigInt(0), M = BigInt(1), Ie = BigInt(2), Ii = BigInt(3), Rt = BigInt(4), An = BigInt(5), Sn = BigInt(8);
416
+ const j = BigInt(0), q = BigInt(1), Be = BigInt(2), Ii = BigInt(3), Tt = BigInt(4), xn = BigInt(5), An = BigInt(8);
417
417
  BigInt(9);
418
418
  BigInt(16);
419
- function V(e, t) {
419
+ function z(e, t) {
420
420
  const n = e % t;
421
421
  return n >= j ? n : t + n;
422
422
  }
423
- function Ki(e, t, n) {
423
+ function Ui(e, t, n) {
424
424
  if (n <= j || t < j)
425
425
  throw new Error("Expected power/modulo > 0");
426
- if (n === M)
426
+ if (n === q)
427
427
  return j;
428
- let r = M;
428
+ let r = q;
429
429
  for (; t > j; )
430
- t & M && (r = r * e % n), e = e * e % n, t >>= M;
430
+ t & q && (r = r * e % n), e = e * e % n, t >>= q;
431
431
  return r;
432
432
  }
433
433
  function G(e, t, n) {
@@ -436,54 +436,54 @@ function G(e, t, n) {
436
436
  r *= r, r %= n;
437
437
  return r;
438
438
  }
439
- function Pt(e, t) {
439
+ function Rt(e, t) {
440
440
  if (e === j || t <= j)
441
441
  throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);
442
- let n = V(e, t), r = t, i = j, o = M;
442
+ let n = z(e, t), r = t, i = j, o = q;
443
443
  for (; n !== j; ) {
444
- const c = r / n, a = r % n, u = i - o * c;
445
- r = n, n = a, i = o, o = u;
444
+ const c = r / n, a = r % n, l = i - o * c;
445
+ r = n, n = a, i = o, o = l;
446
446
  }
447
- if (r !== M)
447
+ if (r !== q)
448
448
  throw new Error("invert: does not exist");
449
- return V(i, t);
449
+ return z(i, t);
450
450
  }
451
451
  function _i(e) {
452
- const t = (e - M) / Ie;
452
+ const t = (e - q) / Be;
453
453
  let n, r, i;
454
- for (n = e - M, r = 0; n % Ie === j; n /= Ie, r++)
454
+ for (n = e - q, r = 0; n % Be === j; n /= Be, r++)
455
455
  ;
456
- for (i = Ie; i < e && Ki(i, t, e) !== e - M; i++)
456
+ for (i = Be; i < e && Ui(i, t, e) !== e - q; i++)
457
457
  ;
458
458
  if (r === 1) {
459
- const s = (e + M) / Rt;
460
- return function(a, u) {
461
- const f = a.pow(u, s);
462
- if (!a.eql(a.sqr(f), u))
459
+ const s = (e + q) / Tt;
460
+ return function(a, l) {
461
+ const f = a.pow(l, s);
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 + M) / Ie;
467
+ const o = (n + q) / Be;
468
468
  return function(c, a) {
469
469
  if (c.pow(a, t) === c.neg(c.ONE))
470
470
  throw new Error("Cannot find square root");
471
- let u = r, f = c.pow(c.mul(c.ONE, i), n), l = c.pow(a, o), d = c.pow(a, n);
471
+ let l = r, f = c.pow(c.mul(c.ONE, i), n), u = c.pow(a, o), d = c.pow(a, n);
472
472
  for (; !c.eql(d, c.ONE); ) {
473
473
  if (c.eql(d, c.ZERO))
474
474
  return c.ZERO;
475
- let w = 1;
476
- for (let h = c.sqr(d); w < u && !c.eql(h, c.ONE); w++)
475
+ let g = 1;
476
+ for (let h = c.sqr(d); g < l && !c.eql(h, c.ONE); g++)
477
477
  h = c.sqr(h);
478
- const y = c.pow(f, M << BigInt(u - w - 1));
479
- f = c.sqr(y), l = c.mul(l, y), d = c.mul(d, f), u = w;
478
+ const w = c.pow(f, q << BigInt(l - g - 1));
479
+ f = c.sqr(w), u = c.mul(u, w), d = c.mul(d, f), l = g;
480
480
  }
481
- return l;
481
+ return u;
482
482
  };
483
483
  }
484
- function Li(e) {
485
- if (e % Rt === Ii) {
486
- const t = (e + M) / Rt;
484
+ function ki(e) {
485
+ if (e % Tt === Ii) {
486
+ const t = (e + q) / Tt;
487
487
  return function(r, i) {
488
488
  const o = r.pow(i, t);
489
489
  if (!r.eql(r.sqr(o), i))
@@ -491,18 +491,18 @@ function Li(e) {
491
491
  return o;
492
492
  };
493
493
  }
494
- if (e % Sn === An) {
495
- const t = (e - An) / Sn;
494
+ if (e % An === xn) {
495
+ const t = (e - xn) / An;
496
496
  return function(r, i) {
497
- const o = r.mul(i, Ie), s = r.pow(o, t), c = r.mul(i, s), a = r.mul(r.mul(c, Ie), s), u = r.mul(c, r.sub(a, r.ONE));
498
- if (!r.eql(r.sqr(u), i))
497
+ const o = r.mul(i, Be), s = r.pow(o, t), c = r.mul(i, s), a = r.mul(r.mul(c, Be), s), 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 _i(e);
504
504
  }
505
- const ki = [
505
+ const Li = [
506
506
  "create",
507
507
  "isValid",
508
508
  "is0",
@@ -521,25 +521,25 @@ const ki = [
521
521
  "mulN",
522
522
  "sqrN"
523
523
  ];
524
- function Ti(e) {
524
+ function $i(e) {
525
525
  const t = {
526
526
  ORDER: "bigint",
527
527
  MASK: "bigint",
528
528
  BYTES: "isSafeInteger",
529
529
  BITS: "isSafeInteger"
530
- }, n = ki.reduce((r, i) => (r[i] = "function", r), t);
531
- return Ye(e, n);
530
+ }, n = Li.reduce((r, i) => (r[i] = "function", r), t);
531
+ return Je(e, n);
532
532
  }
533
- function $i(e, t, n) {
533
+ function Ti(e, t, n) {
534
534
  if (n < j)
535
535
  throw new Error("Expected power > 0");
536
536
  if (n === j)
537
537
  return e.ONE;
538
- if (n === M)
538
+ if (n === q)
539
539
  return t;
540
540
  let r = e.ONE, i = t;
541
541
  for (; n > j; )
542
- n & M && (r = e.mul(r, i)), i = e.sqr(i), n >>= M;
542
+ n & q && (r = e.mul(r, i)), i = e.sqr(i), n >>= q;
543
543
  return r;
544
544
  }
545
545
  function Ri(e, t) {
@@ -556,45 +556,45 @@ function Pi(e, t, n = !1, r = {}) {
556
556
  const { nBitLength: i, nByteLength: o } = Vn(e, t);
557
557
  if (o > 2048)
558
558
  throw new Error("Field lengths over 2048 bytes are not supported");
559
- const s = Li(e), c = Object.freeze({
559
+ const s = ki(e), c = Object.freeze({
560
560
  ORDER: e,
561
561
  BITS: i,
562
562
  BYTES: o,
563
- MASK: Jt(i),
563
+ MASK: Gt(i),
564
564
  ZERO: j,
565
- ONE: M,
566
- create: (a) => V(a, e),
565
+ ONE: q,
566
+ create: (a) => z(a, e),
567
567
  isValid: (a) => {
568
568
  if (typeof a != "bigint")
569
569
  throw new Error(`Invalid field element: expected bigint, got ${typeof a}`);
570
570
  return j <= a && a < e;
571
571
  },
572
572
  is0: (a) => a === j,
573
- isOdd: (a) => (a & M) === M,
574
- neg: (a) => V(-a, e),
575
- eql: (a, u) => a === u,
576
- sqr: (a) => V(a * a, e),
577
- add: (a, u) => V(a + u, e),
578
- sub: (a, u) => V(a - u, e),
579
- mul: (a, u) => V(a * u, e),
580
- pow: (a, u) => $i(c, a, u),
581
- div: (a, u) => V(a * Pt(u, e), e),
573
+ isOdd: (a) => (a & q) === q,
574
+ neg: (a) => z(-a, e),
575
+ eql: (a, l) => a === l,
576
+ sqr: (a) => z(a * a, e),
577
+ add: (a, l) => z(a + l, e),
578
+ sub: (a, l) => z(a - l, e),
579
+ mul: (a, l) => z(a * l, e),
580
+ pow: (a, l) => Ti(c, a, l),
581
+ div: (a, l) => z(a * Rt(l, e), e),
582
582
  // Same as above, but doesn't normalize
583
583
  sqrN: (a) => a * a,
584
- addN: (a, u) => a + u,
585
- subN: (a, u) => a - u,
586
- mulN: (a, u) => a * u,
587
- inv: (a) => Pt(a, e),
584
+ addN: (a, l) => a + l,
585
+ subN: (a, l) => a - l,
586
+ mulN: (a, l) => a * l,
587
+ inv: (a) => Rt(a, e),
588
588
  sqrt: r.sqrt || ((a) => s(c, a)),
589
589
  invertBatch: (a) => Ri(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: (a, u, f) => f ? u : a,
593
- toBytes: (a) => n ? Gt(a, o) : Be(a, o),
592
+ cmov: (a, l, f) => f ? l : a,
593
+ toBytes: (a) => n ? Wt(a, o) : xe(a, o),
594
594
  fromBytes: (a) => {
595
595
  if (a.length !== o)
596
596
  throw new Error(`Fp.fromBytes: expected ${o}, got ${a.length}`);
597
- return n ? Wt(a) : F(a);
597
+ return n ? Ft(a) : W(a);
598
598
  }
599
599
  });
600
600
  return Object.freeze(c);
@@ -613,12 +613,12 @@ function Oi(e, t, n = !1) {
613
613
  const r = e.length, i = zn(t), o = Zn(t);
614
614
  if (r < 16 || r < o || r > 1024)
615
615
  throw new Error(`expected ${o}-1024 bytes of input, got ${r}`);
616
- const s = n ? F(e) : Wt(e), c = V(s, t - M) + M;
617
- return n ? Gt(c, i) : Be(c, i);
616
+ const s = n ? W(e) : Ft(e), c = z(s, t - q) + q;
617
+ return n ? Wt(c, i) : xe(c, i);
618
618
  }
619
619
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
620
- const Hi = BigInt(0), Ut = BigInt(1);
621
- function Mi(e, t) {
620
+ const Mi = BigInt(0), Nt = BigInt(1);
621
+ function Hi(e, t) {
622
622
  const n = (i, o) => {
623
623
  const s = o.negate();
624
624
  return i ? s : o;
@@ -631,8 +631,8 @@ function Mi(e, t) {
631
631
  // non-const time multiplication ladder
632
632
  unsafeLadder(i, o) {
633
633
  let s = e.ZERO, c = i;
634
- for (; o > Hi; )
635
- o & Ut && (s = s.add(c)), c = c.double(), o >>= Ut;
634
+ for (; o > Mi; )
635
+ o & Nt && (s = s.add(c)), c = c.double(), o >>= Nt;
636
636
  return s;
637
637
  },
638
638
  /**
@@ -647,12 +647,12 @@ function Mi(e, t) {
647
647
  */
648
648
  precomputeWindow(i, o) {
649
649
  const { windows: s, windowSize: c } = r(o), a = [];
650
- let u = i, f = u;
651
- for (let l = 0; l < s; l++) {
652
- f = u, a.push(f);
650
+ let l = i, f = l;
651
+ for (let u = 0; u < s; u++) {
652
+ f = l, a.push(f);
653
653
  for (let d = 1; d < c; d++)
654
- f = f.add(u), a.push(f);
655
- u = f.double();
654
+ f = f.add(l), a.push(f);
655
+ l = f.double();
656
656
  }
657
657
  return a;
658
658
  },
@@ -665,26 +665,26 @@ function Mi(e, t) {
665
665
  */
666
666
  wNAF(i, o, s) {
667
667
  const { windows: c, windowSize: a } = r(i);
668
- let u = e.ZERO, f = e.BASE;
669
- const l = BigInt(2 ** i - 1), d = 2 ** i, w = BigInt(i);
670
- for (let y = 0; y < c; y++) {
671
- const h = y * a;
672
- let g = Number(s & l);
673
- s >>= w, g > a && (g -= d, s += Ut);
674
- const p = h, m = h + Math.abs(g) - 1, B = y % 2 !== 0, _ = g < 0;
675
- g === 0 ? f = f.add(n(B, o[p])) : u = u.add(n(_, o[m]));
668
+ let l = e.ZERO, f = e.BASE;
669
+ const u = BigInt(2 ** i - 1), d = 2 ** i, g = BigInt(i);
670
+ for (let w = 0; w < c; w++) {
671
+ const h = w * a;
672
+ let y = Number(s & u);
673
+ s >>= g, y > a && (y -= d, s += Nt);
674
+ const p = h, E = h + Math.abs(y) - 1, K = w % 2 !== 0, _ = y < 0;
675
+ y === 0 ? f = f.add(n(K, o[p])) : l = l.add(n(_, o[E]));
676
676
  }
677
- return { p: u, f };
677
+ return { p: l, f };
678
678
  },
679
679
  wNAFCached(i, o, s, c) {
680
680
  const a = i._WINDOW_SIZE || 1;
681
- let u = o.get(i);
682
- return u || (u = this.precomputeWindow(i, a), a !== 1 && o.set(i, c(u))), this.wNAF(a, u, s);
681
+ let l = o.get(i);
682
+ return l || (l = this.precomputeWindow(i, a), a !== 1 && o.set(i, c(l))), this.wNAF(a, l, s);
683
683
  }
684
684
  };
685
685
  }
686
686
  function Fn(e) {
687
- return Ti(e.Fp), Ye(e, {
687
+ return $i(e.Fp), Je(e, {
688
688
  n: "bigint",
689
689
  h: "bigint",
690
690
  Gx: "field",
@@ -701,7 +701,7 @@ function Fn(e) {
701
701
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
702
702
  function qi(e) {
703
703
  const t = Fn(e);
704
- Ye(t, {
704
+ Je(t, {
705
705
  a: "field",
706
706
  b: "field"
707
707
  }, {
@@ -722,7 +722,7 @@ function qi(e) {
722
722
  }
723
723
  return Object.freeze({ ...t });
724
724
  }
725
- const { bytesToNumberBE: Di, hexToBytes: ji } = Ui, Ke = {
725
+ const { bytesToNumberBE: Di, hexToBytes: ji } = Ci, Ne = {
726
726
  // asn.1 DER encoding utils
727
727
  Err: class extends Error {
728
728
  constructor(t = "") {
@@ -730,7 +730,7 @@ const { bytesToNumberBE: Di, hexToBytes: ji } = Ui, Ke = {
730
730
  }
731
731
  },
732
732
  _parseInt(e) {
733
- const { Err: t } = Ke;
733
+ const { Err: t } = Ne;
734
734
  if (e.length < 2 || e[0] !== 2)
735
735
  throw new t("Invalid signature integer tag");
736
736
  const n = e[1], r = e.subarray(2, n + 2);
@@ -743,7 +743,7 @@ const { bytesToNumberBE: Di, hexToBytes: ji } = Ui, Ke = {
743
743
  return { d: Di(r), l: e.subarray(n + 2) };
744
744
  },
745
745
  toSig(e) {
746
- const { Err: t } = Ke, n = typeof e == "string" ? ji(e) : e;
746
+ const { Err: t } = Ne, n = typeof e == "string" ? ji(e) : e;
747
747
  if (!(n instanceof Uint8Array))
748
748
  throw new Error("ui8a expected");
749
749
  let r = n.length;
@@ -751,68 +751,68 @@ const { bytesToNumberBE: Di, hexToBytes: ji } = Ui, Ke = {
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 } = Ke._parseInt(n.subarray(2)), { d: s, l: c } = Ke._parseInt(o);
754
+ const { d: i, l: o } = Ne._parseInt(n.subarray(2)), { d: s, l: c } = Ne._parseInt(o);
755
755
  if (c.length)
756
756
  throw new t("Invalid signature: left bytes after parsing");
757
757
  return { r: i, s };
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
763
  }, r = t(n(e.s)), i = t(n(e.r)), o = r.length / 2, s = i.length / 2, c = n(o), a = n(s);
764
764
  return `30${n(s + o + 4)}02${a}${i}02${c}${r}`;
765
765
  }
766
- }, ue = BigInt(0), J = BigInt(1);
766
+ }, ce = BigInt(0), J = BigInt(1);
767
767
  BigInt(2);
768
- const Bn = BigInt(3);
768
+ const Sn = BigInt(3);
769
769
  BigInt(4);
770
770
  function Vi(e) {
771
- const t = qi(e), { Fp: n } = t, r = t.toBytes || ((y, h, g) => {
771
+ const t = qi(e), { Fp: n } = t, r = t.toBytes || ((w, h, y) => {
772
772
  const p = h.toAffine();
773
- return _e(Uint8Array.from([4]), n.toBytes(p.x), n.toBytes(p.y));
774
- }), i = t.fromBytes || ((y) => {
775
- const h = y.subarray(1), g = n.fromBytes(h.subarray(0, n.BYTES)), p = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
776
- return { x: g, y: p };
773
+ return Ie(Uint8Array.from([4]), n.toBytes(p.x), n.toBytes(p.y));
774
+ }), i = t.fromBytes || ((w) => {
775
+ const h = w.subarray(1), y = n.fromBytes(h.subarray(0, n.BYTES)), p = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
776
+ return { x: y, y: p };
777
777
  });
778
- function o(y) {
779
- const { a: h, b: g } = t, p = n.sqr(y), m = n.mul(p, y);
780
- return n.add(n.add(m, n.mul(y, h)), g);
778
+ function o(w) {
779
+ const { a: h, b: y } = t, p = n.sqr(w), E = n.mul(p, w);
780
+ return n.add(n.add(E, n.mul(w, h)), y);
781
781
  }
782
782
  if (!n.eql(n.sqr(t.Gy), o(t.Gx)))
783
783
  throw new Error("bad generator point: equation left != right");
784
- function s(y) {
785
- return typeof y == "bigint" && ue < y && y < t.n;
784
+ function s(w) {
785
+ return typeof w == "bigint" && ce < w && w < t.n;
786
786
  }
787
- function c(y) {
788
- if (!s(y))
787
+ function c(w) {
788
+ if (!s(w))
789
789
  throw new Error("Expected valid bigint: 0 < bigint < curve.n");
790
790
  }
791
- function a(y) {
792
- const { allowedPrivateKeyLengths: h, nByteLength: g, wrapPrivateKey: p, n: m } = t;
793
- if (h && typeof y != "bigint") {
794
- if (y instanceof Uint8Array && (y = Me(y)), typeof y != "string" || !h.includes(y.length))
791
+ function a(w) {
792
+ const { allowedPrivateKeyLengths: h, nByteLength: y, wrapPrivateKey: p, n: E } = t;
793
+ if (h && typeof w != "bigint") {
794
+ if (w instanceof Uint8Array && (w = He(w)), typeof w != "string" || !h.includes(w.length))
795
795
  throw new Error("Invalid key");
796
- y = y.padStart(g * 2, "0");
796
+ w = w.padStart(y * 2, "0");
797
797
  }
798
- let B;
798
+ let K;
799
799
  try {
800
- B = typeof y == "bigint" ? y : F(z("private key", y, g));
800
+ K = typeof w == "bigint" ? w : W(Z("private key", w, y));
801
801
  } catch {
802
- throw new Error(`private key must be ${g} bytes, hex or bigint, not ${typeof y}`);
802
+ throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof w}`);
803
803
  }
804
- return p && (B = V(B, m)), c(B), B;
804
+ return p && (K = z(K, E)), c(K), K;
805
805
  }
806
- const u = /* @__PURE__ */ new Map();
807
- function f(y) {
808
- if (!(y instanceof l))
806
+ const l = /* @__PURE__ */ new Map();
807
+ function f(w) {
808
+ if (!(w instanceof u))
809
809
  throw new Error("ProjectivePoint expected");
810
810
  }
811
- class l {
812
- constructor(h, g, p) {
813
- if (this.px = h, this.py = g, this.pz = p, h == null || !n.isValid(h))
811
+ class u {
812
+ constructor(h, y, p) {
813
+ if (this.px = h, this.py = y, this.pz = p, h == null || !n.isValid(h))
814
814
  throw new Error("x required");
815
- if (g == null || !n.isValid(g))
815
+ if (y == null || !n.isValid(y))
816
816
  throw new Error("y required");
817
817
  if (p == null || !n.isValid(p))
818
818
  throw new Error("z required");
@@ -820,13 +820,13 @@ function Vi(e) {
820
820
  // Does not validate if the point is on-curve.
821
821
  // Use fromHex instead, or call assertValidity() later.
822
822
  static fromAffine(h) {
823
- const { x: g, y: p } = h || {};
824
- if (!h || !n.isValid(g) || !n.isValid(p))
823
+ const { x: y, y: p } = h || {};
824
+ if (!h || !n.isValid(y) || !n.isValid(p))
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 m = (B) => n.eql(B, n.ZERO);
829
- return m(g) && m(p) ? l.ZERO : new l(g, p, n.ONE);
828
+ const E = (K) => n.eql(K, n.ZERO);
829
+ return E(y) && E(p) ? u.ZERO : new u(y, p, n.ONE);
830
830
  }
831
831
  get x() {
832
832
  return this.toAffine().x;
@@ -841,24 +841,24 @@ function Vi(e) {
841
841
  * Optimization: converts a list of projective points to a list of identical points with Z=1.
842
842
  */
843
843
  static normalizeZ(h) {
844
- const g = n.invertBatch(h.map((p) => p.pz));
845
- return h.map((p, m) => p.toAffine(g[m])).map(l.fromAffine);
844
+ const y = n.invertBatch(h.map((p) => p.pz));
845
+ return h.map((p, E) => p.toAffine(y[E])).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 g = l.fromAffine(i(z("pointHex", h)));
853
- return g.assertValidity(), g;
852
+ const y = u.fromAffine(i(Z("pointHex", h)));
853
+ return y.assertValidity(), y;
854
854
  }
855
855
  // Multiplies generator point by privateKey.
856
856
  static fromPrivateKey(h) {
857
- return l.BASE.multiply(a(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() {
@@ -867,11 +867,11 @@ function Vi(e) {
867
867
  return;
868
868
  throw new Error("bad point: ZERO");
869
869
  }
870
- const { x: h, y: g } = this.toAffine();
871
- if (!n.isValid(h) || !n.isValid(g))
870
+ const { x: h, y } = this.toAffine();
871
+ if (!n.isValid(h) || !n.isValid(y))
872
872
  throw new Error("bad point: x or y not FE");
873
- const p = n.sqr(g), m = o(h);
874
- if (!n.eql(p, m))
873
+ const p = n.sqr(y), E = o(h);
874
+ if (!n.eql(p, E))
875
875
  throw new Error("bad point: equation left != right");
876
876
  if (!this.isTorsionFree())
877
877
  throw new Error("bad point: not in prime-order subgroup");
@@ -887,23 +887,23 @@ function Vi(e) {
887
887
  */
888
888
  equals(h) {
889
889
  f(h);
890
- const { px: g, py: p, pz: m } = this, { px: B, py: _, pz: U } = h, x = n.eql(n.mul(g, U), n.mul(B, m)), E = n.eql(n.mul(p, U), n.mul(_, m));
891
- return x && E;
890
+ const { px: y, py: p, pz: E } = this, { px: K, py: _, pz: C } = h, m = n.eql(n.mul(y, C), n.mul(K, E)), x = n.eql(n.mul(p, C), n.mul(_, E));
891
+ return m && 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: g } = t, p = n.mul(g, Bn), { px: m, py: B, pz: _ } = this;
905
- let U = n.ZERO, x = n.ZERO, E = n.ZERO, A = n.mul(m, m), O = n.mul(B, B), K = n.mul(_, _), N = n.mul(m, B);
906
- return N = n.add(N, N), E = n.mul(m, _), E = n.add(E, E), U = n.mul(h, E), x = n.mul(p, K), x = n.add(U, x), U = n.sub(O, x), x = n.add(O, x), x = n.mul(U, x), U = n.mul(N, U), E = n.mul(p, E), K = n.mul(h, K), N = n.sub(A, K), N = n.mul(h, N), N = n.add(N, E), E = n.add(A, A), A = n.add(E, A), A = n.add(A, K), A = n.mul(A, N), x = n.add(x, A), K = n.mul(B, _), K = n.add(K, K), A = n.mul(K, N), U = n.sub(U, A), E = n.mul(K, O), E = n.add(E, E), E = n.add(E, E), new l(U, x, E);
904
+ const { a: h, b: y } = t, p = n.mul(y, Sn), { px: E, py: K, pz: _ } = this;
905
+ let C = n.ZERO, m = n.ZERO, x = n.ZERO, A = n.mul(E, E), O = n.mul(K, K), U = n.mul(_, _), B = n.mul(E, K);
906
+ return B = n.add(B, B), x = n.mul(E, _), x = n.add(x, x), C = n.mul(h, x), m = n.mul(p, U), m = n.add(C, m), C = n.sub(O, m), m = n.add(O, m), m = n.mul(C, m), C = n.mul(B, C), x = n.mul(p, x), U = n.mul(h, U), B = n.sub(A, U), B = n.mul(h, B), B = n.add(B, x), x = n.add(A, A), A = n.add(x, A), A = n.add(A, U), A = n.mul(A, B), m = n.add(m, A), U = n.mul(K, _), U = n.add(U, U), A = n.mul(U, B), C = n.sub(C, A), x = n.mul(U, O), x = n.add(x, x), x = n.add(x, x), new u(C, m, x);
907
907
  }
908
908
  // Renes-Costello-Batina exception-free addition formula.
909
909
  // There is 30% faster Jacobian formula, but it is not complete.
@@ -911,24 +911,24 @@ function Vi(e) {
911
911
  // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
912
912
  add(h) {
913
913
  f(h);
914
- const { px: g, py: p, pz: m } = this, { px: B, py: _, pz: U } = h;
915
- let x = n.ZERO, E = n.ZERO, A = n.ZERO;
916
- const O = t.a, K = n.mul(t.b, Bn);
917
- let N = n.mul(g, B), $ = n.mul(p, _), R = n.mul(m, U), H = n.add(g, p), b = n.add(B, _);
918
- H = n.mul(H, b), b = n.add(N, $), H = n.sub(H, b), b = n.add(g, m);
919
- let v = n.add(B, U);
920
- return b = n.mul(b, v), v = n.add(N, R), b = n.sub(b, v), v = n.add(p, m), x = n.add(_, U), v = n.mul(v, x), x = n.add($, R), v = n.sub(v, x), A = n.mul(O, b), x = n.mul(K, R), A = n.add(x, A), x = n.sub($, A), A = n.add($, A), E = n.mul(x, A), $ = n.add(N, N), $ = n.add($, N), R = n.mul(O, R), b = n.mul(K, b), $ = n.add($, R), R = n.sub(N, R), R = n.mul(O, R), b = n.add(b, R), N = n.mul($, b), E = n.add(E, N), N = n.mul(v, b), x = n.mul(H, x), x = n.sub(x, N), N = n.mul(H, $), A = n.mul(v, A), A = n.add(A, N), new l(x, E, A);
914
+ const { px: y, py: p, pz: E } = this, { px: K, py: _, pz: C } = h;
915
+ let m = n.ZERO, x = n.ZERO, A = n.ZERO;
916
+ const O = t.a, U = n.mul(t.b, Sn);
917
+ let B = n.mul(y, K), T = n.mul(p, _), R = n.mul(E, C), H = n.add(y, p), b = n.add(K, _);
918
+ H = n.mul(H, b), b = n.add(B, T), H = n.sub(H, b), b = n.add(y, E);
919
+ let v = n.add(K, C);
920
+ return b = n.mul(b, v), v = n.add(B, R), b = n.sub(b, v), v = n.add(p, E), m = n.add(_, C), v = n.mul(v, m), m = n.add(T, R), v = n.sub(v, m), A = n.mul(O, b), 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(B, B), T = n.add(T, B), R = n.mul(O, R), b = n.mul(U, b), T = n.add(T, R), R = n.sub(B, R), R = n.mul(O, R), b = n.add(b, R), B = n.mul(T, b), x = n.add(x, B), B = n.mul(v, b), m = n.mul(H, m), m = n.sub(m, B), B = n.mul(H, T), A = n.mul(v, A), A = n.add(A, B), new u(m, x, A);
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 w.wNAFCached(this, u, h, (g) => {
930
- const p = n.invertBatch(g.map((m) => m.pz));
931
- return g.map((m, B) => m.toAffine(p[B])).map(l.fromAffine);
929
+ return g.wNAFCached(this, l, h, (y) => {
930
+ const p = n.invertBatch(y.map((E) => E.pz));
931
+ return y.map((E, K) => E.toAffine(p[K])).map(u.fromAffine);
932
932
  });
933
933
  }
934
934
  /**
@@ -937,18 +937,18 @@ function Vi(e) {
937
937
  * an exposed private key e.g. sig verification, which works over *public* keys.
938
938
  */
939
939
  multiplyUnsafe(h) {
940
- const g = l.ZERO;
941
- if (h === ue)
942
- return g;
940
+ const y = u.ZERO;
941
+ if (h === ce)
942
+ return y;
943
943
  if (c(h), h === J)
944
944
  return this;
945
945
  const { endo: p } = t;
946
946
  if (!p)
947
- return w.unsafeLadder(this, h);
948
- let { k1neg: m, k1: B, k2neg: _, k2: U } = p.splitScalar(h), x = g, E = g, A = this;
949
- for (; B > ue || U > ue; )
950
- B & J && (x = x.add(A)), U & J && (E = E.add(A)), A = A.double(), B >>= J, U >>= J;
951
- return m && (x = x.negate()), _ && (E = E.negate()), E = new l(n.mul(E.px, p.beta), E.py, E.pz), x.add(E);
947
+ return g.unsafeLadder(this, h);
948
+ let { k1neg: E, k1: K, k2neg: _, k2: C } = p.splitScalar(h), m = y, x = y, A = this;
949
+ for (; K > ce || C > ce; )
950
+ K & J && (m = m.add(A)), C & J && (x = x.add(A)), A = A.double(), K >>= J, C >>= J;
951
+ return E && (m = m.negate()), _ && (x = x.negate()), x = new u(n.mul(x.px, p.beta), x.py, x.pz), m.add(x);
952
952
  }
953
953
  /**
954
954
  * Constant time multiplication.
@@ -961,17 +961,17 @@ function Vi(e) {
961
961
  */
962
962
  multiply(h) {
963
963
  c(h);
964
- let g = h, p, m;
965
- const { endo: B } = t;
966
- if (B) {
967
- const { k1neg: _, k1: U, k2neg: x, k2: E } = B.splitScalar(g);
968
- let { p: A, f: O } = this.wNAF(U), { p: K, f: N } = this.wNAF(E);
969
- A = w.constTimeNegate(_, A), K = w.constTimeNegate(x, K), K = new l(n.mul(K.px, B.beta), K.py, K.pz), p = A.add(K), m = O.add(N);
964
+ let y = h, p, E;
965
+ const { endo: K } = t;
966
+ if (K) {
967
+ const { k1neg: _, k1: C, k2neg: m, k2: x } = K.splitScalar(y);
968
+ let { p: A, f: O } = this.wNAF(C), { p: U, f: B } = this.wNAF(x);
969
+ A = g.constTimeNegate(_, A), U = g.constTimeNegate(m, U), U = new u(n.mul(U.px, K.beta), U.py, U.pz), p = A.add(U), E = O.add(B);
970
970
  } else {
971
- const { p: _, f: U } = this.wNAF(g);
972
- p = _, m = U;
971
+ const { p: _, f: C } = this.wNAF(y);
972
+ p = _, E = C;
973
973
  }
974
- return l.normalizeZ([p, m])[0];
974
+ return u.normalizeZ([p, E])[0];
975
975
  }
976
976
  /**
977
977
  * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
@@ -979,47 +979,47 @@ function Vi(e) {
979
979
  * The trick could be useful if both P and Q are not G (not in our case).
980
980
  * @returns non-zero affine point
981
981
  */
982
- multiplyAndAddUnsafe(h, g, p) {
983
- const m = l.BASE, B = (U, x) => x === ue || x === J || !U.equals(m) ? U.multiplyUnsafe(x) : U.multiply(x), _ = B(this, g).add(B(h, p));
982
+ multiplyAndAddUnsafe(h, y, p) {
983
+ const E = u.BASE, K = (C, m) => m === ce || m === J || !C.equals(E) ? C.multiplyUnsafe(m) : C.multiply(m), _ = K(this, y).add(K(h, p));
984
984
  return _.is0() ? void 0 : _;
985
985
  }
986
986
  // Converts Projective point to affine (x, y) coordinates.
987
987
  // Can accept precomputed Z^-1 - for example, from invertBatch.
988
988
  // (x, y, z) ∋ (x=x/z, y=y/z)
989
989
  toAffine(h) {
990
- const { px: g, py: p, pz: m } = this, B = this.is0();
991
- h == null && (h = B ? n.ONE : n.inv(m));
992
- const _ = n.mul(g, h), U = n.mul(p, h), x = n.mul(m, h);
993
- if (B)
990
+ const { px: y, py: p, pz: E } = this, K = this.is0();
991
+ h == null && (h = K ? n.ONE : n.inv(E));
992
+ const _ = n.mul(y, h), C = n.mul(p, h), m = n.mul(E, h);
993
+ if (K)
994
994
  return { x: n.ZERO, y: n.ZERO };
995
- if (!n.eql(x, n.ONE))
995
+ if (!n.eql(m, n.ONE))
996
996
  throw new Error("invZ was invalid");
997
- return { x: _, y: U };
997
+ return { x: _, y: C };
998
998
  }
999
999
  isTorsionFree() {
1000
- const { h, isTorsionFree: g } = t;
1000
+ const { h, isTorsionFree: y } = t;
1001
1001
  if (h === J)
1002
1002
  return !0;
1003
- if (g)
1004
- return g(l, this);
1003
+ if (y)
1004
+ return y(u, this);
1005
1005
  throw new Error("isTorsionFree() has not been declared for the elliptic curve");
1006
1006
  }
1007
1007
  clearCofactor() {
1008
- const { h, clearCofactor: g } = t;
1009
- return h === J ? this : g ? g(l, this) : this.multiplyUnsafe(t.h);
1008
+ const { h, clearCofactor: y } = t;
1009
+ return h === J ? this : y ? y(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
- return Me(this.toRawBytes(h));
1015
+ return He(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 d = t.nBitLength, w = Mi(l, t.endo ? Math.ceil(d / 2) : d);
1018
+ u.BASE = new u(t.Gx, t.Gy, n.ONE), u.ZERO = new u(n.ZERO, n.ONE, n.ZERO);
1019
+ const d = t.nBitLength, g = Hi(u, t.endo ? Math.ceil(d / 2) : d);
1020
1020
  return {
1021
1021
  CURVE: t,
1022
- ProjectivePoint: l,
1022
+ ProjectivePoint: u,
1023
1023
  normPrivateKeyToScalar: a,
1024
1024
  weierstrassEquation: o,
1025
1025
  isWithinCurveOrder: s
@@ -1027,7 +1027,7 @@ function Vi(e) {
1027
1027
  }
1028
1028
  function zi(e) {
1029
1029
  const t = Fn(e);
1030
- return Ye(t, {
1030
+ return Je(t, {
1031
1031
  hash: "hash",
1032
1032
  hmac: "function",
1033
1033
  randomBytes: "function"
@@ -1040,45 +1040,45 @@ function zi(e) {
1040
1040
  function Zi(e) {
1041
1041
  const t = zi(e), { Fp: n, n: r } = t, i = n.BYTES + 1, o = 2 * n.BYTES + 1;
1042
1042
  function s(b) {
1043
- return ue < b && b < n.ORDER;
1043
+ return ce < b && b < n.ORDER;
1044
1044
  }
1045
1045
  function c(b) {
1046
- return V(b, r);
1046
+ return z(b, r);
1047
1047
  }
1048
1048
  function a(b) {
1049
- return Pt(b, r);
1049
+ return Rt(b, r);
1050
1050
  }
1051
- const { ProjectivePoint: u, normPrivateKeyToScalar: f, weierstrassEquation: l, isWithinCurveOrder: d } = Vi({
1051
+ const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: d } = Vi({
1052
1052
  ...t,
1053
1053
  toBytes(b, v, S) {
1054
- const I = v.toAffine(), C = n.toBytes(I.x), L = _e;
1055
- return S ? L(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : L(Uint8Array.from([4]), C, n.toBytes(I.y));
1054
+ const I = v.toAffine(), N = n.toBytes(I.x), k = Ie;
1055
+ return S ? k(Uint8Array.from([v.hasEvenY() ? 2 : 3]), N) : k(Uint8Array.from([4]), N, n.toBytes(I.y));
1056
1056
  },
1057
1057
  fromBytes(b) {
1058
1058
  const v = b.length, S = b[0], I = b.subarray(1);
1059
1059
  if (v === i && (S === 2 || S === 3)) {
1060
- const C = F(I);
1061
- if (!s(C))
1060
+ const N = W(I);
1061
+ if (!s(N))
1062
1062
  throw new Error("Point is not on curve");
1063
- const L = l(C);
1064
- let P = n.sqrt(L);
1065
- const T = (P & J) === J;
1066
- return (S & 1) === 1 !== T && (P = n.neg(P)), { x: C, y: P };
1063
+ const k = u(N);
1064
+ let P = n.sqrt(k);
1065
+ const $ = (P & J) === J;
1066
+ return (S & 1) === 1 !== $ && (P = n.neg(P)), { x: N, y: P };
1067
1067
  } else if (v === o && S === 4) {
1068
- const C = n.fromBytes(I.subarray(0, n.BYTES)), L = n.fromBytes(I.subarray(n.BYTES, 2 * n.BYTES));
1069
- return { x: C, y: L };
1068
+ const N = n.fromBytes(I.subarray(0, n.BYTES)), k = n.fromBytes(I.subarray(n.BYTES, 2 * n.BYTES));
1069
+ return { x: N, y: k };
1070
1070
  } else
1071
1071
  throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`);
1072
1072
  }
1073
- }), w = (b) => Me(Be(b, t.nByteLength));
1074
- function y(b) {
1073
+ }), g = (b) => He(xe(b, t.nByteLength));
1074
+ function w(b) {
1075
1075
  const v = r >> J;
1076
1076
  return b > v;
1077
1077
  }
1078
1078
  function h(b) {
1079
- return y(b) ? c(-b) : b;
1079
+ return w(b) ? c(-b) : b;
1080
1080
  }
1081
- const g = (b, v, S) => F(b.slice(v, S));
1081
+ const y = (b, v, S) => W(b.slice(v, S));
1082
1082
  class p {
1083
1083
  constructor(v, S, I) {
1084
1084
  this.r = v, this.s = S, this.recovery = I, this.assertValidity();
@@ -1086,12 +1086,12 @@ function Zi(e) {
1086
1086
  // pair (bytes of r, bytes of s)
1087
1087
  static fromCompact(v) {
1088
1088
  const S = t.nByteLength;
1089
- return v = z("compactSignature", v, S * 2), new p(g(v, 0, S), g(v, S, 2 * S));
1089
+ return v = Z("compactSignature", v, S * 2), new p(y(v, 0, S), y(v, S, 2 * S));
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: I } = Ke.toSig(z("DER", v));
1094
+ const { r: S, s: I } = Ne.toSig(Z("DER", v));
1095
1095
  return new p(S, I);
1096
1096
  }
1097
1097
  assertValidity() {
@@ -1104,20 +1104,20 @@ function Zi(e) {
1104
1104
  return new p(this.r, this.s, v);
1105
1105
  }
1106
1106
  recoverPublicKey(v) {
1107
- const { r: S, s: I, recovery: C } = this, L = E(z("msgHash", v));
1108
- if (C == null || ![0, 1, 2, 3].includes(C))
1107
+ const { r: S, s: I, recovery: N } = this, k = x(Z("msgHash", v));
1108
+ if (N == null || ![0, 1, 2, 3].includes(N))
1109
1109
  throw new Error("recovery id invalid");
1110
- const P = C === 2 || C === 3 ? S + t.n : S;
1110
+ const P = N === 2 || N === 3 ? S + t.n : S;
1111
1111
  if (P >= n.ORDER)
1112
1112
  throw new Error("recovery id 2 or 3 invalid");
1113
- const T = C & 1 ? "03" : "02", Y = u.fromHex(T + w(P)), ye = a(P), ke = c(-L * ye), Ve = c(I * ye), we = u.BASE.multiplyAndAddUnsafe(Y, ke, Ve);
1114
- if (!we)
1113
+ const $ = N & 1 ? "03" : "02", X = l.fromHex($ + g(P)), ye = a(P), _e = c(-k * ye), Ve = c(I * ye), ge = l.BASE.multiplyAndAddUnsafe(X, _e, Ve);
1114
+ if (!ge)
1115
1115
  throw new Error("point at infinify");
1116
- return we.assertValidity(), we;
1116
+ return ge.assertValidity(), ge;
1117
1117
  }
1118
1118
  // Signatures should be low-s, to prevent malleability.
1119
1119
  hasHighS() {
1120
- return y(this.s);
1120
+ return w(this.s);
1121
1121
  }
1122
1122
  normalizeS() {
1123
1123
  return this.hasHighS() ? new p(this.r, c(-this.s), this.recovery) : this;
@@ -1127,17 +1127,17 @@ function Zi(e) {
1127
1127
  return qe(this.toDERHex());
1128
1128
  }
1129
1129
  toDERHex() {
1130
- return Ke.hexFromSig({ r: this.r, s: this.s });
1130
+ return Ne.hexFromSig({ r: this.r, s: this.s });
1131
1131
  }
1132
1132
  // padded bytes of r, then padded bytes of s
1133
1133
  toCompactRawBytes() {
1134
1134
  return qe(this.toCompactHex());
1135
1135
  }
1136
1136
  toCompactHex() {
1137
- return w(this.r) + w(this.s);
1137
+ return g(this.r) + g(this.s);
1138
1138
  }
1139
1139
  }
1140
- const m = {
1140
+ const E = {
1141
1141
  isValidPrivateKey(b) {
1142
1142
  try {
1143
1143
  return f(b), !0;
@@ -1162,118 +1162,118 @@ function Zi(e) {
1162
1162
  * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
1163
1163
  * fast.multiply(privKey); // much faster ECDH now
1164
1164
  */
1165
- precompute(b = 8, v = u.BASE) {
1165
+ precompute(b = 8, v = l.BASE) {
1166
1166
  return v._setWindowSize(b), v.multiply(BigInt(3)), v;
1167
1167
  }
1168
1168
  };
1169
- function B(b, v = !0) {
1170
- return u.fromPrivateKey(b).toRawBytes(v);
1169
+ function K(b, v = !0) {
1170
+ return l.fromPrivateKey(b).toRawBytes(v);
1171
1171
  }
1172
1172
  function _(b) {
1173
1173
  const v = b instanceof Uint8Array, S = typeof b == "string", I = (v || S) && b.length;
1174
- return v ? I === i || I === o : S ? I === 2 * i || I === 2 * o : b instanceof u;
1174
+ return v ? I === i || I === o : S ? I === 2 * i || I === 2 * o : b instanceof l;
1175
1175
  }
1176
- function U(b, v, S = !0) {
1176
+ function C(b, v, S = !0) {
1177
1177
  if (_(b))
1178
1178
  throw new Error("first arg must be private key");
1179
1179
  if (!_(v))
1180
1180
  throw new Error("second arg must be public key");
1181
- return u.fromHex(v).multiply(f(b)).toRawBytes(S);
1181
+ return l.fromHex(v).multiply(f(b)).toRawBytes(S);
1182
1182
  }
1183
- const x = t.bits2int || function(b) {
1184
- const v = F(b), S = b.length * 8 - t.nBitLength;
1183
+ const m = t.bits2int || function(b) {
1184
+ const v = W(b), S = b.length * 8 - t.nBitLength;
1185
1185
  return S > 0 ? v >> BigInt(S) : v;
1186
- }, E = t.bits2int_modN || function(b) {
1187
- return c(x(b));
1188
- }, A = Jt(t.nBitLength);
1186
+ }, x = t.bits2int_modN || function(b) {
1187
+ return c(m(b));
1188
+ }, A = Gt(t.nBitLength);
1189
1189
  function O(b) {
1190
1190
  if (typeof b != "bigint")
1191
1191
  throw new Error("bigint expected");
1192
- if (!(ue <= b && b < A))
1192
+ if (!(ce <= b && b < A))
1193
1193
  throw new Error(`bigint expected < 2^${t.nBitLength}`);
1194
- return Be(b, t.nByteLength);
1194
+ return xe(b, t.nByteLength);
1195
1195
  }
1196
- function K(b, v, S = N) {
1197
- if (["recovered", "canonical"].some((Ue) => Ue in S))
1196
+ function U(b, v, S = B) {
1197
+ if (["recovered", "canonical"].some((Ke) => Ke in S))
1198
1198
  throw new Error("sign() legacy options not supported");
1199
- const { hash: I, randomBytes: C } = t;
1200
- let { lowS: L, prehash: P, extraEntropy: T } = S;
1201
- L == null && (L = !0), b = z("msgHash", b), P && (b = z("prehashed msgHash", I(b)));
1202
- const Y = E(b), ye = f(v), ke = [O(ye), O(Y)];
1203
- if (T != null) {
1204
- const Ue = T === !0 ? C(n.BYTES) : T;
1205
- ke.push(z("extraEntropy", Ue));
1206
- }
1207
- const Ve = _e(...ke), we = Y;
1208
- function St(Ue) {
1209
- const Te = x(Ue);
1210
- if (!d(Te))
1199
+ const { hash: I, randomBytes: N } = t;
1200
+ let { lowS: k, prehash: P, extraEntropy: $ } = S;
1201
+ k == null && (k = !0), b = Z("msgHash", b), P && (b = Z("prehashed msgHash", I(b)));
1202
+ const X = x(b), ye = f(v), _e = [O(ye), O(X)];
1203
+ if ($ != null) {
1204
+ const Ke = $ === !0 ? N(n.BYTES) : $;
1205
+ _e.push(Z("extraEntropy", Ke));
1206
+ }
1207
+ const Ve = Ie(..._e), ge = X;
1208
+ function At(Ke) {
1209
+ const ke = m(Ke);
1210
+ if (!d(ke))
1211
1211
  return;
1212
- const bn = a(Te), $e = u.BASE.multiply(Te).toAffine(), X = c($e.x);
1213
- if (X === ue)
1212
+ const wn = a(ke), Le = l.BASE.multiply(ke).toAffine(), Q = c(Le.x);
1213
+ if (Q === ce)
1214
1214
  return;
1215
- const Re = c(bn * c(we + X * ye));
1216
- if (Re === ue)
1215
+ const $e = c(wn * c(ge + Q * ye));
1216
+ if ($e === ce)
1217
1217
  return;
1218
- let vn = ($e.x === X ? 0 : 2) | Number($e.y & J), xn = Re;
1219
- return L && y(Re) && (xn = h(Re), vn ^= 1), new p(X, xn, vn);
1218
+ let bn = (Le.x === Q ? 0 : 2) | Number(Le.y & J), vn = $e;
1219
+ return k && w($e) && (vn = h($e), bn ^= 1), new p(Q, vn, bn);
1220
1220
  }
1221
- return { seed: Ve, k2sig: St };
1221
+ return { seed: Ve, k2sig: At };
1222
1222
  }
1223
- const N = { lowS: t.lowS, prehash: !1 }, $ = { lowS: t.lowS, prehash: !1 };
1224
- function R(b, v, S = N) {
1225
- const { seed: I, k2sig: C } = K(b, v, S), L = t;
1226
- return jn(L.hash.outputLen, L.nByteLength, L.hmac)(I, C);
1223
+ const B = { lowS: t.lowS, prehash: !1 }, T = { lowS: t.lowS, prehash: !1 };
1224
+ function R(b, v, S = B) {
1225
+ const { seed: I, k2sig: N } = U(b, v, S), k = t;
1226
+ return jn(k.hash.outputLen, k.nByteLength, k.hmac)(I, N);
1227
1227
  }
1228
- u.BASE._setWindowSize(8);
1229
- function H(b, v, S, I = $) {
1230
- var $e;
1231
- const C = b;
1232
- if (v = z("msgHash", v), S = z("publicKey", S), "strict" in I)
1228
+ l.BASE._setWindowSize(8);
1229
+ function H(b, v, S, I = T) {
1230
+ var Le;
1231
+ const N = b;
1232
+ if (v = Z("msgHash", v), S = Z("publicKey", S), "strict" in I)
1233
1233
  throw new Error("options.strict was renamed to lowS");
1234
- const { lowS: L, prehash: P } = I;
1235
- let T, Y;
1234
+ const { lowS: k, prehash: P } = I;
1235
+ let $, X;
1236
1236
  try {
1237
- if (typeof C == "string" || C instanceof Uint8Array)
1237
+ if (typeof N == "string" || N instanceof Uint8Array)
1238
1238
  try {
1239
- T = p.fromDER(C);
1240
- } catch (X) {
1241
- if (!(X instanceof Ke.Err))
1242
- throw X;
1243
- T = p.fromCompact(C);
1239
+ $ = p.fromDER(N);
1240
+ } catch (Q) {
1241
+ if (!(Q instanceof Ne.Err))
1242
+ throw Q;
1243
+ $ = p.fromCompact(N);
1244
1244
  }
1245
- else if (typeof C == "object" && typeof C.r == "bigint" && typeof C.s == "bigint") {
1246
- const { r: X, s: Re } = C;
1247
- T = new p(X, Re);
1245
+ else if (typeof N == "object" && typeof N.r == "bigint" && typeof N.s == "bigint") {
1246
+ const { r: Q, s: $e } = N;
1247
+ $ = new p(Q, $e);
1248
1248
  } else
1249
1249
  throw new Error("PARSE");
1250
- Y = u.fromHex(S);
1251
- } catch (X) {
1252
- if (X.message === "PARSE")
1250
+ X = l.fromHex(S);
1251
+ } catch (Q) {
1252
+ if (Q.message === "PARSE")
1253
1253
  throw new Error("signature must be Signature instance, Uint8Array or hex string");
1254
1254
  return !1;
1255
1255
  }
1256
- if (L && T.hasHighS())
1256
+ if (k && $.hasHighS())
1257
1257
  return !1;
1258
1258
  P && (v = t.hash(v));
1259
- const { r: ye, s: ke } = T, Ve = E(v), we = a(ke), St = c(Ve * we), Ue = c(ye * we), Te = ($e = u.BASE.multiplyAndAddUnsafe(Y, St, Ue)) == null ? void 0 : $e.toAffine();
1260
- return Te ? c(Te.x) === ye : !1;
1259
+ const { r: ye, s: _e } = $, Ve = x(v), ge = a(_e), At = c(Ve * ge), Ke = c(ye * ge), ke = (Le = l.BASE.multiplyAndAddUnsafe(X, At, Ke)) == null ? void 0 : Le.toAffine();
1260
+ return ke ? c(ke.x) === ye : !1;
1261
1261
  }
1262
1262
  return {
1263
1263
  CURVE: t,
1264
- getPublicKey: B,
1265
- getSharedSecret: U,
1264
+ getPublicKey: K,
1265
+ getSharedSecret: C,
1266
1266
  sign: R,
1267
1267
  verify: H,
1268
- ProjectivePoint: u,
1268
+ ProjectivePoint: l,
1269
1269
  Signature: p,
1270
- utils: m
1270
+ utils: E
1271
1271
  };
1272
1272
  }
1273
- let Wn = class extends Hn {
1273
+ let Wn = class extends Mn {
1274
1274
  constructor(t, n) {
1275
1275
  super(), this.finished = !1, this.destroyed = !1, ai(t);
1276
- const r = Zt(n);
1276
+ const r = zt(n);
1277
1277
  if (this.iHash = t.create(), typeof this.iHash.update != "function")
1278
1278
  throw new Error("Expected instance of class which extends utils.Hash");
1279
1279
  this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
@@ -1287,10 +1287,10 @@ let Wn = class extends Hn {
1287
1287
  this.oHash.update(o), o.fill(0);
1288
1288
  }
1289
1289
  update(t) {
1290
- return it(this), this.iHash.update(t), this;
1290
+ return rt(this), this.iHash.update(t), this;
1291
1291
  }
1292
1292
  digestInto(t) {
1293
- it(this), Pn(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1293
+ rt(this), Pn(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
1294
1294
  }
1295
1295
  digest() {
1296
1296
  const t = new Uint8Array(this.oHash.outputLen);
@@ -1312,7 +1312,7 @@ function Fi(e) {
1312
1312
  return {
1313
1313
  hash: e,
1314
1314
  hmac: (t, ...n) => Gn(e, t, fi(...n)),
1315
- randomBytes: Mn
1315
+ randomBytes: Hn
1316
1316
  };
1317
1317
  }
1318
1318
  function Wi(e, t) {
@@ -1320,18 +1320,18 @@ function Wi(e, t) {
1320
1320
  return Object.freeze({ ...n(t), create: n });
1321
1321
  }
1322
1322
  /*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1323
- const dt = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), ot = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Jn = BigInt(1), st = BigInt(2), Nn = (e, t) => (e + t / st) / t;
1323
+ const ht = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), it = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), Jn = BigInt(1), ot = BigInt(2), Kn = (e, t) => (e + t / ot) / t;
1324
1324
  function Yn(e) {
1325
- const t = dt, n = BigInt(3), r = BigInt(6), i = BigInt(11), o = BigInt(22), s = BigInt(23), c = BigInt(44), a = BigInt(88), u = e * e * e % t, f = u * u * e % t, l = G(f, n, t) * f % t, d = G(l, n, t) * f % t, w = G(d, st, t) * u % t, y = G(w, i, t) * w % t, h = G(y, o, t) * y % t, g = G(h, c, t) * h % t, p = G(g, a, t) * g % t, m = G(p, c, t) * h % t, B = G(m, n, t) * f % t, _ = G(B, s, t) * y % t, U = G(_, r, t) * u % t, x = G(U, st, t);
1326
- if (!Ot.eql(Ot.sqr(x), e))
1325
+ const t = ht, n = BigInt(3), r = BigInt(6), i = BigInt(11), o = BigInt(22), s = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = G(f, n, t) * f % t, d = G(u, n, t) * f % t, g = G(d, ot, t) * l % t, w = G(g, i, t) * g % t, h = G(w, o, t) * w % t, y = G(h, c, t) * h % t, p = G(y, a, t) * y % t, E = G(p, c, t) * h % t, K = G(E, n, t) * f % t, _ = G(K, s, t) * w % t, C = G(_, r, t) * l % t, m = G(C, ot, t);
1326
+ if (!Pt.eql(Pt.sqr(m), e))
1327
1327
  throw new Error("Cannot find square root");
1328
- return x;
1328
+ return m;
1329
1329
  }
1330
- const Ot = Pi(dt, void 0, void 0, { sqrt: Yn }), Le = Wi({
1330
+ const Pt = Pi(ht, void 0, void 0, { sqrt: Yn }), Ue = Wi({
1331
1331
  a: BigInt(0),
1332
1332
  b: BigInt(7),
1333
- Fp: Ot,
1334
- n: ot,
1333
+ Fp: Pt,
1334
+ n: it,
1335
1335
  // Base point (x, y) aka generator point
1336
1336
  Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
1337
1337
  Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
@@ -1346,62 +1346,62 @@ const Ot = Pi(dt, void 0, void 0, { sqrt: Yn }), Le = Wi({
1346
1346
  endo: {
1347
1347
  beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
1348
1348
  splitScalar: (e) => {
1349
- const t = ot, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -Jn * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), o = n, s = BigInt("0x100000000000000000000000000000000"), c = Nn(o * e, t), a = Nn(-r * e, t);
1350
- let u = V(e - c * n - a * i, t), f = V(-c * r - a * o, t);
1351
- const l = u > s, d = f > s;
1352
- if (l && (u = t - u), d && (f = t - f), u > s || f > s)
1349
+ const t = it, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -Jn * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), o = n, s = BigInt("0x100000000000000000000000000000000"), c = Kn(o * e, t), a = Kn(-r * e, t);
1350
+ let l = z(e - c * n - a * i, t), f = z(-c * r - a * o, t);
1351
+ const u = l > s, d = f > s;
1352
+ if (u && (l = t - l), d && (f = t - f), l > s || f > s)
1353
1353
  throw new Error("splitScalar: Endomorphism failed, k=" + e);
1354
- return { k1neg: l, k1: u, k2neg: d, k2: f };
1354
+ return { k1neg: u, k1: l, k2neg: d, k2: f };
1355
1355
  }
1356
1356
  }
1357
- }, $t), gt = BigInt(0), Xn = (e) => typeof e == "bigint" && gt < e && e < dt, Gi = (e) => typeof e == "bigint" && gt < e && e < ot, Cn = {};
1358
- function at(e, ...t) {
1359
- let n = Cn[e];
1357
+ }, $t), dt = BigInt(0), Xn = (e) => typeof e == "bigint" && dt < e && e < ht, Gi = (e) => typeof e == "bigint" && dt < e && e < it, Bn = {};
1358
+ function st(e, ...t) {
1359
+ let n = Bn[e];
1360
1360
  if (n === void 0) {
1361
1361
  const r = $t(Uint8Array.from(e, (i) => i.charCodeAt(0)));
1362
- n = _e(r, r), Cn[e] = n;
1362
+ n = Ie(r, r), Bn[e] = n;
1363
1363
  }
1364
- return $t(_e(n, ...t));
1364
+ return $t(Ie(n, ...t));
1365
1365
  }
1366
- const Yt = (e) => e.toRawBytes(!0).slice(1), Ht = (e) => Be(e, 32), It = (e) => V(e, dt), Ge = (e) => V(e, ot), Xt = Le.ProjectivePoint, Ji = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
1366
+ const Jt = (e) => e.toRawBytes(!0).slice(1), Ot = (e) => xe(e, 32), Ct = (e) => z(e, ht), We = (e) => z(e, it), Yt = Ue.ProjectivePoint, Ji = (e, t, n) => Yt.BASE.multiplyAndAddUnsafe(e, t, n);
1367
1367
  function Mt(e) {
1368
- let t = Le.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
1369
- return { scalar: n.hasEvenY() ? t : Ge(-t), bytes: Yt(n) };
1368
+ let t = Ue.utils.normPrivateKeyToScalar(e), n = Yt.fromPrivateKey(t);
1369
+ return { scalar: n.hasEvenY() ? t : We(-t), bytes: Jt(n) };
1370
1370
  }
1371
1371
  function Qn(e) {
1372
1372
  if (!Xn(e))
1373
1373
  throw new Error("bad x: need 0 < x < p");
1374
- const t = It(e * e), n = It(t * e + BigInt(7));
1374
+ const t = Ct(e * e), n = Ct(t * e + BigInt(7));
1375
1375
  let r = Yn(n);
1376
- r % st !== gt && (r = It(-r));
1377
- const i = new Xt(e, r, Jn);
1376
+ r % ot !== dt && (r = Ct(-r));
1377
+ const i = new Yt(e, r, Jn);
1378
1378
  return i.assertValidity(), i;
1379
1379
  }
1380
1380
  function er(...e) {
1381
- return Ge(F(at("BIP0340/challenge", ...e)));
1381
+ return We(W(st("BIP0340/challenge", ...e)));
1382
1382
  }
1383
1383
  function Yi(e) {
1384
1384
  return Mt(e).bytes;
1385
1385
  }
1386
- function Xi(e, t, n = Mn(32)) {
1387
- const r = z("message", e), { bytes: i, scalar: o } = Mt(t), s = z("auxRand", n, 32), c = Ht(o ^ F(at("BIP0340/aux", s))), a = at("BIP0340/nonce", c, i, r), u = Ge(F(a));
1388
- if (u === gt)
1386
+ function Xi(e, t, n = Hn(32)) {
1387
+ const r = Z("message", e), { bytes: i, scalar: o } = Mt(t), s = Z("auxRand", n, 32), c = Ot(o ^ W(st("BIP0340/aux", s))), a = st("BIP0340/nonce", c, i, r), l = We(W(a));
1388
+ if (l === dt)
1389
1389
  throw new Error("sign failed: k is zero");
1390
- const { bytes: f, scalar: l } = Mt(u), d = er(f, i, r), w = new Uint8Array(64);
1391
- if (w.set(f, 0), w.set(Ht(Ge(l + d * o)), 32), !tr(w, r, i))
1390
+ const { bytes: f, scalar: u } = Mt(l), d = er(f, i, r), g = new Uint8Array(64);
1391
+ if (g.set(f, 0), g.set(Ot(We(u + d * o)), 32), !tr(g, r, i))
1392
1392
  throw new Error("sign: Invalid signature produced");
1393
- return w;
1393
+ return g;
1394
1394
  }
1395
1395
  function tr(e, t, n) {
1396
- const r = z("signature", e, 64), i = z("message", t), o = z("publicKey", n, 32);
1396
+ const r = Z("signature", e, 64), i = Z("message", t), o = Z("publicKey", n, 32);
1397
1397
  try {
1398
- const s = Qn(F(o)), c = F(r.subarray(0, 32));
1398
+ const s = Qn(W(o)), c = W(r.subarray(0, 32));
1399
1399
  if (!Xn(c))
1400
1400
  return !1;
1401
- const a = F(r.subarray(32, 64));
1401
+ const a = W(r.subarray(32, 64));
1402
1402
  if (!Gi(a))
1403
1403
  return !1;
1404
- const u = er(Ht(c), Yt(s), i), f = Ji(s, a, Ge(-u));
1404
+ const l = er(Ot(c), Jt(s), i), f = Ji(s, a, We(-l));
1405
1405
  return !(!f || !f.hasEvenY() || f.toAffine().x !== c);
1406
1406
  } catch {
1407
1407
  return !1;
@@ -1412,29 +1412,29 @@ const ze = {
1412
1412
  sign: Xi,
1413
1413
  verify: tr,
1414
1414
  utils: {
1415
- randomPrivateKey: Le.utils.randomPrivateKey,
1415
+ randomPrivateKey: Ue.utils.randomPrivateKey,
1416
1416
  lift_x: Qn,
1417
- pointToBytes: Yt,
1418
- numberToBytesBE: Be,
1419
- bytesToNumberBE: F,
1420
- taggedHash: at,
1421
- mod: V
1417
+ pointToBytes: Jt,
1418
+ numberToBytesBE: xe,
1419
+ bytesToNumberBE: W,
1420
+ taggedHash: st,
1421
+ mod: z
1422
1422
  }
1423
- }, Kt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
1423
+ }, It = 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, _t = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ne = (e, t) => e << 32 - t | e >>> t, Qi = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1425
+ const Xt = (e) => e instanceof Uint8Array, Ut = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, Qi = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
1426
1426
  if (!Qi)
1427
1427
  throw new Error("Non little-endian hardware is not supported");
1428
1428
  const eo = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
1429
- function D(e) {
1430
- if (!Qt(e))
1429
+ function M(e) {
1430
+ if (!Xt(e))
1431
1431
  throw new Error("Uint8Array expected");
1432
1432
  let t = "";
1433
1433
  for (let n = 0; n < e.length; n++)
1434
1434
  t += eo[e[n]];
1435
1435
  return t;
1436
1436
  }
1437
- function W(e) {
1437
+ function Y(e) {
1438
1438
  if (typeof e != "string")
1439
1439
  throw new Error("hex string expected, got " + typeof e);
1440
1440
  const t = e.length;
@@ -1454,16 +1454,16 @@ function to(e) {
1454
1454
  throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
1455
1455
  return new Uint8Array(new TextEncoder().encode(e));
1456
1456
  }
1457
- function Je(e) {
1458
- if (typeof e == "string" && (e = to(e)), !Qt(e))
1457
+ function Ge(e) {
1458
+ if (typeof e == "string" && (e = to(e)), !Xt(e))
1459
1459
  throw new Error(`expected Uint8Array, got ${typeof e}`);
1460
1460
  return e;
1461
1461
  }
1462
- function pt(...e) {
1462
+ function yt(...e) {
1463
1463
  const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
1464
1464
  let n = 0;
1465
1465
  return e.forEach((r) => {
1466
- if (!Qt(r))
1466
+ if (!Xt(r))
1467
1467
  throw new Error("Uint8Array expected");
1468
1468
  t.set(r, n), n += r.length;
1469
1469
  }), t;
@@ -1475,15 +1475,15 @@ class nr {
1475
1475
  }
1476
1476
  }
1477
1477
  function rr(e) {
1478
- const t = (r) => e().update(Je(r)).digest(), n = e();
1478
+ const t = (r) => e().update(Ge(r)).digest(), n = e();
1479
1479
  return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
1480
1480
  }
1481
1481
  function ir(e = 32) {
1482
- if (Kt && typeof Kt.getRandomValues == "function")
1483
- return Kt.getRandomValues(new Uint8Array(e));
1482
+ if (It && typeof It.getRandomValues == "function")
1483
+ return It.getRandomValues(new Uint8Array(e));
1484
1484
  throw new Error("crypto.getRandomValues must be defined");
1485
1485
  }
1486
- function qt(e) {
1486
+ function Ht(e) {
1487
1487
  if (!Number.isSafeInteger(e) || e < 0)
1488
1488
  throw new Error(`Wrong positive integer: ${e}`);
1489
1489
  }
@@ -1500,7 +1500,7 @@ function or(e, ...t) {
1500
1500
  function ro(e) {
1501
1501
  if (typeof e != "function" || typeof e.create != "function")
1502
1502
  throw new Error("Hash should be wrapped by utils.wrapConstructor");
1503
- qt(e.outputLen), qt(e.blockLen);
1503
+ Ht(e.outputLen), Ht(e.blockLen);
1504
1504
  }
1505
1505
  function io(e, t = !0) {
1506
1506
  if (e.destroyed)
@@ -1514,8 +1514,8 @@ function oo(e, t) {
1514
1514
  if (e.length < n)
1515
1515
  throw new Error(`digestInto() expects output buffer of length at least ${n}`);
1516
1516
  }
1517
- const ie = {
1518
- number: qt,
1517
+ const oe = {
1518
+ number: Ht,
1519
1519
  bool: no,
1520
1520
  bytes: or,
1521
1521
  hash: ro,
@@ -1525,22 +1525,22 @@ const ie = {
1525
1525
  function so(e, t, n, r) {
1526
1526
  if (typeof e.setBigUint64 == "function")
1527
1527
  return e.setBigUint64(t, n, r);
1528
- const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), c = Number(n & o), a = r ? 4 : 0, u = r ? 0 : 4;
1529
- e.setUint32(t + a, s, r), e.setUint32(t + u, c, r);
1528
+ const i = BigInt(32), o = BigInt(4294967295), s = Number(n >> i & o), c = Number(n & o), a = r ? 4 : 0, l = r ? 0 : 4;
1529
+ e.setUint32(t + a, s, r), e.setUint32(t + l, c, r);
1530
1530
  }
1531
1531
  class ao extends nr {
1532
1532
  constructor(t, n, r, i) {
1533
- super(), this.blockLen = t, this.outputLen = n, this.padOffset = r, this.isLE = i, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(t), this.view = _t(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 = Ut(this.buffer);
1534
1534
  }
1535
1535
  update(t) {
1536
- ie.exists(this);
1536
+ oe.exists(this);
1537
1537
  const { view: n, buffer: r, blockLen: i } = this;
1538
- t = Je(t);
1538
+ t = Ge(t);
1539
1539
  const o = t.length;
1540
1540
  for (let s = 0; s < o; ) {
1541
1541
  const c = Math.min(i - this.pos, o - s);
1542
1542
  if (c === i) {
1543
- const a = _t(t);
1543
+ const a = Ut(t);
1544
1544
  for (; i <= o - s; s += i)
1545
1545
  this.process(a, s);
1546
1546
  continue;
@@ -1550,21 +1550,21 @@ class ao extends nr {
1550
1550
  return this.length += t.length, this.roundClean(), this;
1551
1551
  }
1552
1552
  digestInto(t) {
1553
- ie.exists(this), ie.output(t, this), this.finished = !0;
1553
+ oe.exists(this), oe.output(t, this), this.finished = !0;
1554
1554
  const { buffer: n, view: r, blockLen: i, isLE: o } = this;
1555
1555
  let { pos: s } = this;
1556
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;
1557
+ for (let u = s; u < i; u++)
1558
+ n[u] = 0;
1559
1559
  so(r, i - 8, BigInt(this.length * 8), o), this.process(r, 0);
1560
- const c = _t(t), a = this.outputLen;
1560
+ const c = Ut(t), a = this.outputLen;
1561
1561
  if (a % 4)
1562
1562
  throw new Error("_sha2: outputLen should be aligned to 32bit");
1563
- const u = a / 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
- c.setUint32(4 * l, f[l], o);
1566
+ for (let u = 0; u < l; u++)
1567
+ c.setUint32(4 * u, f[u], o);
1568
1568
  }
1569
1569
  digest() {
1570
1570
  const { buffer: t, outputLen: n } = this;
@@ -1578,7 +1578,7 @@ class ao extends nr {
1578
1578
  return t.length = i, t.pos = c, t.finished = o, t.destroyed = s, i % n && t.buffer.set(r), t;
1579
1579
  }
1580
1580
  }
1581
- const co = (e, t, n) => e & t ^ ~e & n, uo = (e, t, n) => e & t ^ e & n ^ t & n, lo = new Uint32Array([
1581
+ const co = (e, t, n) => e & t ^ ~e & n, lo = (e, t, n) => e & t ^ e & n ^ t & n, uo = new Uint32Array([
1582
1582
  1116352408,
1583
1583
  1899447441,
1584
1584
  3049323471,
@@ -1643,7 +1643,7 @@ const co = (e, t, n) => e & t ^ ~e & n, uo = (e, t, n) => e & t ^ e & n ^ t & n,
1643
1643
  2756734187,
1644
1644
  3204031479,
1645
1645
  3329325298
1646
- ]), xe = new Uint32Array([
1646
+ ]), be = new Uint32Array([
1647
1647
  1779033703,
1648
1648
  3144134277,
1649
1649
  1013904242,
@@ -1652,10 +1652,10 @@ const co = (e, t, n) => e & t ^ ~e & n, uo = (e, t, n) => e & t ^ e & n ^ t & n,
1652
1652
  2600822924,
1653
1653
  528734635,
1654
1654
  1541459225
1655
- ]), me = new Uint32Array(64);
1655
+ ]), ve = new Uint32Array(64);
1656
1656
  class sr extends ao {
1657
1657
  constructor() {
1658
- super(64, 32, 8, !1), this.A = xe[0] | 0, this.B = xe[1] | 0, this.C = xe[2] | 0, this.D = xe[3] | 0, this.E = xe[4] | 0, this.F = xe[5] | 0, this.G = xe[6] | 0, this.H = xe[7] | 0;
1658
+ super(64, 32, 8, !1), this.A = be[0] | 0, this.B = be[1] | 0, this.C = be[2] | 0, this.D = be[3] | 0, this.E = be[4] | 0, this.F = be[5] | 0, this.G = be[6] | 0, this.H = be[7] | 0;
1659
1659
  }
1660
1660
  get() {
1661
1661
  const { A: t, B: n, C: r, D: i, E: o, F: s, G: c, H: a } = this;
@@ -1666,21 +1666,21 @@ class sr extends ao {
1666
1666
  this.A = t | 0, this.B = n | 0, this.C = r | 0, this.D = i | 0, this.E = o | 0, this.F = s | 0, this.G = c | 0, this.H = a | 0;
1667
1667
  }
1668
1668
  process(t, n) {
1669
- for (let l = 0; l < 16; l++, n += 4)
1670
- me[l] = t.getUint32(n, !1);
1671
- for (let l = 16; l < 64; l++) {
1672
- const d = me[l - 15], w = me[l - 2], y = ne(d, 7) ^ ne(d, 18) ^ d >>> 3, h = ne(w, 17) ^ ne(w, 19) ^ w >>> 10;
1673
- me[l] = h + me[l - 7] + y + me[l - 16] | 0;
1669
+ for (let u = 0; u < 16; u++, n += 4)
1670
+ ve[u] = t.getUint32(n, !1);
1671
+ for (let u = 16; u < 64; u++) {
1672
+ const d = ve[u - 15], g = ve[u - 2], w = re(d, 7) ^ re(d, 18) ^ d >>> 3, h = re(g, 17) ^ re(g, 19) ^ g >>> 10;
1673
+ ve[u] = h + ve[u - 7] + w + ve[u - 16] | 0;
1674
1674
  }
1675
- let { A: r, B: i, C: o, D: s, E: c, F: a, G: u, H: f } = this;
1676
- for (let l = 0; l < 64; l++) {
1677
- const d = ne(c, 6) ^ ne(c, 11) ^ ne(c, 25), w = f + d + co(c, a, u) + lo[l] + me[l] | 0, h = (ne(r, 2) ^ ne(r, 13) ^ ne(r, 22)) + uo(r, i, o) | 0;
1678
- f = u, u = a, a = c, c = s + w | 0, s = o, o = i, i = r, r = w + h | 0;
1675
+ let { A: r, B: i, C: o, D: s, E: c, F: a, G: l, H: f } = this;
1676
+ for (let u = 0; u < 64; u++) {
1677
+ const d = re(c, 6) ^ re(c, 11) ^ re(c, 25), g = f + d + co(c, a, l) + uo[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + lo(r, i, o) | 0;
1678
+ f = l, l = a, a = c, c = s + g | 0, s = o, o = i, i = r, r = g + h | 0;
1679
1679
  }
1680
- r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, u = u + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, c, a, u, f);
1680
+ r = r + this.A | 0, i = i + this.B | 0, o = o + this.C | 0, s = s + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, o, s, c, a, l, f);
1681
1681
  }
1682
1682
  roundClean() {
1683
- me.fill(0);
1683
+ ve.fill(0);
1684
1684
  }
1685
1685
  destroy() {
1686
1686
  this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
@@ -1691,18 +1691,18 @@ class fo extends sr {
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 Ne = rr(() => new sr());
1694
+ const Ae = rr(() => new sr());
1695
1695
  rr(() => new fo());
1696
1696
  /*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
1697
1697
  function je(e) {
1698
1698
  if (!Number.isSafeInteger(e))
1699
1699
  throw new Error(`Wrong integer: ${e}`);
1700
1700
  }
1701
- function de(...e) {
1701
+ function fe(...e) {
1702
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);
1703
1703
  return { encode: n, decode: r };
1704
1704
  }
1705
- function ge(e) {
1705
+ function he(e) {
1706
1706
  return {
1707
1707
  encode: (t) => {
1708
1708
  if (!Array.isArray(t) || t.length && typeof t[0] != "number")
@@ -1727,7 +1727,7 @@ function ge(e) {
1727
1727
  }
1728
1728
  };
1729
1729
  }
1730
- function pe(e = "") {
1730
+ function de(e = "") {
1731
1731
  if (typeof e != "string")
1732
1732
  throw new Error("join separator should be string");
1733
1733
  return {
@@ -1746,7 +1746,7 @@ function pe(e = "") {
1746
1746
  }
1747
1747
  };
1748
1748
  }
1749
- function yt(e, t = "=") {
1749
+ function gt(e, t = "=") {
1750
1750
  if (je(e), typeof t != "string")
1751
1751
  throw new Error("padding chr should be string");
1752
1752
  return {
@@ -1781,7 +1781,7 @@ function ar(e) {
1781
1781
  throw new Error("normalize fn should be function");
1782
1782
  return { encode: (t) => t, decode: (t) => e(t) };
1783
1783
  }
1784
- function Un(e, t, n) {
1784
+ function Nn(e, t, n) {
1785
1785
  if (t < 2)
1786
1786
  throw new Error(`convertRadix: wrong from=${t}, base cannot be less than 2`);
1787
1787
  if (n < 2)
@@ -1798,8 +1798,8 @@ function Un(e, t, n) {
1798
1798
  }); ; ) {
1799
1799
  let s = 0, c = !0;
1800
1800
  for (let a = r; a < o.length; a++) {
1801
- const u = o[a], f = t * s + u;
1802
- if (!Number.isSafeInteger(f) || t * s / t !== s || f - u !== t * s)
1801
+ const l = o[a], f = t * s + l;
1802
+ if (!Number.isSafeInteger(f) || t * s / t !== s || f - l !== t * s)
1803
1803
  throw new Error("convertRadix: carry overflow");
1804
1804
  if (s = f % n, o[a] = Math.floor(f / n), !Number.isSafeInteger(o[a]) || o[a] * n + s !== f)
1805
1805
  throw new Error("convertRadix: carry overflow");
@@ -1814,16 +1814,16 @@ function Un(e, t, n) {
1814
1814
  i.push(0);
1815
1815
  return i.reverse();
1816
1816
  }
1817
- const cr = (e, t) => t ? cr(t, e % t) : e, ct = (e, t) => e + (t - cr(e, t));
1818
- function Dt(e, t, n, r) {
1817
+ const cr = (e, t) => t ? cr(t, e % t) : e, at = (e, t) => e + (t - cr(e, t));
1818
+ function qt(e, t, n, r) {
1819
1819
  if (!Array.isArray(e))
1820
1820
  throw new Error("convertRadix2: data should be array");
1821
1821
  if (t <= 0 || t > 32)
1822
1822
  throw new Error(`convertRadix2: wrong from=${t}`);
1823
1823
  if (n <= 0 || n > 32)
1824
1824
  throw new Error(`convertRadix2: wrong to=${n}`);
1825
- if (ct(t, n) > 32)
1826
- throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${ct(t, n)}`);
1825
+ if (at(t, n) > 32)
1826
+ throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${at(t, n)}`);
1827
1827
  let i = 0, o = 0;
1828
1828
  const s = 2 ** n - 1, c = [];
1829
1829
  for (const a of e) {
@@ -1846,34 +1846,34 @@ function ho(e) {
1846
1846
  encode: (t) => {
1847
1847
  if (!(t instanceof Uint8Array))
1848
1848
  throw new Error("radix.encode input should be Uint8Array");
1849
- return Un(Array.from(t), 2 ** 8, e);
1849
+ return Nn(Array.from(t), 2 ** 8, e);
1850
1850
  },
1851
1851
  decode: (t) => {
1852
1852
  if (!Array.isArray(t) || t.length && typeof t[0] != "number")
1853
1853
  throw new Error("radix.decode input should be array of strings");
1854
- return Uint8Array.from(Un(t, e, 2 ** 8));
1854
+ return Uint8Array.from(Nn(t, e, 2 ** 8));
1855
1855
  }
1856
1856
  };
1857
1857
  }
1858
- function Ce(e, t = !1) {
1858
+ function Se(e, t = !1) {
1859
1859
  if (je(e), e <= 0 || e > 32)
1860
1860
  throw new Error("radix2: bits should be in (0..32]");
1861
- if (ct(8, e) > 32 || ct(e, 8) > 32)
1861
+ if (at(8, e) > 32 || at(e, 8) > 32)
1862
1862
  throw new Error("radix2: carry overflow");
1863
1863
  return {
1864
1864
  encode: (n) => {
1865
1865
  if (!(n instanceof Uint8Array))
1866
1866
  throw new Error("radix2.encode input should be Uint8Array");
1867
- return Dt(Array.from(n), 8, e, !t);
1867
+ return qt(Array.from(n), 8, e, !t);
1868
1868
  },
1869
1869
  decode: (n) => {
1870
1870
  if (!Array.isArray(n) || n.length && typeof n[0] != "number")
1871
1871
  throw new Error("radix2.decode input should be array of strings");
1872
- return Uint8Array.from(Dt(n, e, 8, t));
1872
+ return Uint8Array.from(qt(n, e, 8, t));
1873
1873
  }
1874
1874
  };
1875
1875
  }
1876
- function In(e) {
1876
+ function Cn(e) {
1877
1877
  if (typeof e != "function")
1878
1878
  throw new Error("unsafeWrapper fn should be function");
1879
1879
  return function(...t) {
@@ -1883,25 +1883,25 @@ function In(e) {
1883
1883
  }
1884
1884
  };
1885
1885
  }
1886
- const go = de(Ce(4), ge("0123456789ABCDEF"), pe("")), po = de(Ce(5), ge("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), yt(5), pe(""));
1887
- de(Ce(5), ge("0123456789ABCDEFGHIJKLMNOPQRSTUV"), yt(5), pe(""));
1888
- de(Ce(5), ge("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), pe(""), ar((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
- const he = de(Ce(6), ge("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), yt(6), pe("")), yo = de(Ce(6), ge("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), yt(6), pe("")), en = (e) => de(ho(58), ge(e), pe("")), ut = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
- en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
- en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1892
- const Kn = [0, 2, 3, 5, 6, 7, 9, 10, 11], wo = {
1886
+ const yo = fe(Se(4), he("0123456789ABCDEF"), de("")), go = fe(Se(5), he("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), gt(5), de(""));
1887
+ fe(Se(5), he("0123456789ABCDEFGHIJKLMNOPQRSTUV"), gt(5), de(""));
1888
+ fe(Se(5), he("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), de(""), ar((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
1889
+ const ue = fe(Se(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), gt(6), de("")), po = fe(Se(6), he("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), gt(6), de("")), Qt = (e) => fe(ho(58), he(e), de("")), ct = Qt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
1890
+ Qt("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
1891
+ Qt("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
1892
+ const In = [0, 2, 3, 5, 6, 7, 9, 10, 11], wo = {
1893
1893
  encode(e) {
1894
1894
  let t = "";
1895
1895
  for (let n = 0; n < e.length; n += 8) {
1896
1896
  const r = e.subarray(n, n + 8);
1897
- t += ut.encode(r).padStart(Kn[r.length], "1");
1897
+ t += ct.encode(r).padStart(In[r.length], "1");
1898
1898
  }
1899
1899
  return t;
1900
1900
  },
1901
1901
  decode(e) {
1902
1902
  let t = [];
1903
1903
  for (let n = 0; n < e.length; n += 11) {
1904
- const r = e.slice(n, n + 11), i = Kn.indexOf(r.length), o = ut.decode(r);
1904
+ const r = e.slice(n, n + 11), i = In.indexOf(r.length), o = ct.decode(r);
1905
1905
  for (let s = 0; s < o.length - i; s++)
1906
1906
  if (o[s] !== 0)
1907
1907
  throw new Error("base58xmr: wrong padding");
@@ -1909,15 +1909,15 @@ const Kn = [0, 2, 3, 5, 6, 7, 9, 10, 11], wo = {
1909
1909
  }
1910
1910
  return Uint8Array.from(t);
1911
1911
  }
1912
- }, jt = de(ge("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), pe("")), _n = [996825010, 642813549, 513874426, 1027748829, 705979059];
1912
+ }, Dt = fe(he("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), de("")), Un = [996825010, 642813549, 513874426, 1027748829, 705979059];
1913
1913
  function Ze(e) {
1914
1914
  const t = e >> 25;
1915
1915
  let n = (e & 33554431) << 5;
1916
- for (let r = 0; r < _n.length; r++)
1917
- (t >> r & 1) === 1 && (n ^= _n[r]);
1916
+ for (let r = 0; r < Un.length; r++)
1917
+ (t >> r & 1) === 1 && (n ^= Un[r]);
1918
1918
  return n;
1919
1919
  }
1920
- function Ln(e, t, n = 1) {
1920
+ function _n(e, t, n = 1) {
1921
1921
  const r = e.length;
1922
1922
  let i = 1;
1923
1923
  for (let o = 0; o < r; o++) {
@@ -1933,68 +1933,68 @@ function Ln(e, t, n = 1) {
1933
1933
  i = Ze(i) ^ o;
1934
1934
  for (let o = 0; o < 6; o++)
1935
1935
  i = Ze(i);
1936
- return i ^= n, jt.encode(Dt([i % 2 ** 30], 30, 5, !1));
1936
+ return i ^= n, Dt.encode(qt([i % 2 ** 30], 30, 5, !1));
1937
1937
  }
1938
- function ur(e) {
1939
- const t = e === "bech32" ? 1 : 734539939, n = Ce(5), r = n.decode, i = n.encode, o = In(r);
1940
- function s(f, l, d = 90) {
1938
+ function lr(e) {
1939
+ const t = e === "bech32" ? 1 : 734539939, n = Se(5), r = n.decode, i = n.encode, o = Cn(r);
1940
+ function s(f, u, d = 90) {
1941
1941
  if (typeof f != "string")
1942
1942
  throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);
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 w = f.length + 7 + l.length;
1946
- if (d !== !1 && w > d)
1947
- throw new TypeError(`Length ${w} exceeds limit ${d}`);
1948
- return f = f.toLowerCase(), `${f}1${jt.encode(l)}${Ln(f, l, t)}`;
1949
- }
1950
- function c(f, l = 90) {
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 g = f.length + 7 + u.length;
1946
+ if (d !== !1 && g > d)
1947
+ throw new TypeError(`Length ${g} exceeds limit ${d}`);
1948
+ return f = f.toLowerCase(), `${f}1${Dt.encode(u)}${_n(f, u, t)}`;
1949
+ }
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 d = f.toLowerCase();
1956
1956
  if (f !== d && f !== f.toUpperCase())
1957
1957
  throw new Error("String must be lowercase or uppercase");
1958
1958
  f = d;
1959
- const w = f.lastIndexOf("1");
1960
- if (w === 0 || w === -1)
1959
+ const g = f.lastIndexOf("1");
1960
+ if (g === 0 || g === -1)
1961
1961
  throw new Error('Letter "1" must be present between prefix and data only');
1962
- const y = f.slice(0, w), h = f.slice(w + 1);
1962
+ const w = f.slice(0, g), h = f.slice(g + 1);
1963
1963
  if (h.length < 6)
1964
1964
  throw new Error("Data must be at least 6 characters long");
1965
- const g = jt.decode(h).slice(0, -6), p = Ln(y, g, t);
1965
+ const y = Dt.decode(h).slice(0, -6), p = _n(w, y, t);
1966
1966
  if (!h.endsWith(p))
1967
1967
  throw new Error(`Invalid checksum in ${f}: expected "${p}"`);
1968
- return { prefix: y, words: g };
1968
+ return { prefix: w, words: y };
1969
1969
  }
1970
- const a = In(c);
1971
- function u(f) {
1972
- const { prefix: l, words: d } = c(f, !1);
1973
- return { prefix: l, words: d, bytes: r(d) };
1970
+ const a = Cn(c);
1971
+ function l(f) {
1972
+ const { prefix: u, words: d } = c(f, !1);
1973
+ return { prefix: u, words: d, bytes: r(d) };
1974
1974
  }
1975
- return { encode: s, decode: c, decodeToBytes: u, decodeUnsafe: a, fromWords: r, fromWordsUnsafe: o, toWords: i };
1975
+ return { encode: s, decode: c, decodeToBytes: l, decodeUnsafe: a, fromWords: r, fromWordsUnsafe: o, toWords: i };
1976
1976
  }
1977
- const De = ur("bech32");
1978
- ur("bech32m");
1977
+ const De = lr("bech32");
1978
+ lr("bech32m");
1979
1979
  const bo = {
1980
1980
  encode: (e) => new TextDecoder().decode(e),
1981
1981
  decode: (e) => new TextEncoder().encode(e)
1982
- }, vo = de(Ce(4), ge("0123456789abcdef"), pe(""), ar((e) => {
1982
+ }, vo = fe(Se(4), he("0123456789abcdef"), de(""), ar((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
- })), xo = {
1986
+ })), mo = {
1987
1987
  utf8: bo,
1988
1988
  hex: vo,
1989
- base16: go,
1990
- base32: po,
1991
- base64: he,
1992
- base64url: yo,
1993
- base58: ut,
1989
+ base16: yo,
1990
+ base32: go,
1991
+ base64: ue,
1992
+ base64url: po,
1993
+ base58: ct,
1994
1994
  base58xmr: wo
1995
1995
  };
1996
- `${Object.keys(xo).join(", ")}`;
1997
- function Lt(e) {
1996
+ `${Object.keys(mo).join(", ")}`;
1997
+ function _t(e) {
1998
1998
  if (!Number.isSafeInteger(e) || e < 0)
1999
1999
  throw new Error(`positive integer expected, not ${e}`);
2000
2000
  }
@@ -2002,18 +2002,18 @@ function kn(e) {
2002
2002
  if (typeof e != "boolean")
2003
2003
  throw new Error(`boolean expected, not ${e}`);
2004
2004
  }
2005
- function mo(e) {
2005
+ function Eo(e) {
2006
2006
  return e instanceof Uint8Array || e != null && typeof e == "object" && e.constructor.name === "Uint8Array";
2007
2007
  }
2008
2008
  function le(e, ...t) {
2009
- if (!mo(e))
2009
+ if (!Eo(e))
2010
2010
  throw new Error("Uint8Array expected");
2011
2011
  if (t.length > 0 && !t.includes(e.length))
2012
2012
  throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`);
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)), Eo = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2016
- if (!Eo)
2015
+ const F = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), xo = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2016
+ if (!xo)
2017
2017
  throw new Error("Non little-endian hardware is not supported");
2018
2018
  function Ao(e, t) {
2019
2019
  if (t == null || typeof t != "object")
@@ -2028,19 +2028,19 @@ function So(e, t) {
2028
2028
  n |= e[r] ^ t[r];
2029
2029
  return n === 0;
2030
2030
  }
2031
- const Bo = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Se = 16, No = 283;
2032
- function tn(e) {
2033
- return e << 1 ^ No & -(e >> 7);
2031
+ const Ko = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ee = 16, Bo = 283;
2032
+ function en(e) {
2033
+ return e << 1 ^ Bo & -(e >> 7);
2034
2034
  }
2035
- function Oe(e, t) {
2035
+ function Pe(e, t) {
2036
2036
  let n = 0;
2037
2037
  for (; t > 0; t >>= 1)
2038
- n ^= e & -(t & 1), e = tn(e);
2038
+ n ^= e & -(t & 1), e = en(e);
2039
2039
  return n;
2040
2040
  }
2041
- const Vt = /* @__PURE__ */ (() => {
2041
+ const jt = /* @__PURE__ */ (() => {
2042
2042
  let e = new Uint8Array(256);
2043
- for (let n = 0, r = 1; n < 256; n++, r ^= tn(r))
2043
+ for (let n = 0, r = 1; n < 256; n++, r ^= en(r))
2044
2044
  e[n] = r;
2045
2045
  const t = new Uint8Array(256);
2046
2046
  t[0] = 99;
@@ -2049,21 +2049,21 @@ const Vt = /* @__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
- })(), Co = /* @__PURE__ */ Vt.map((e, t) => Vt.indexOf(t)), Uo = (e) => e << 24 | e >>> 8, kt = (e) => e << 8 | e >>> 24;
2053
- function lr(e, t) {
2052
+ })(), No = /* @__PURE__ */ jt.map((e, t) => jt.indexOf(t)), Co = (e) => e << 24 | e >>> 8, kt = (e) => e << 8 | e >>> 24;
2053
+ function ur(e, t) {
2054
2054
  if (e.length !== 256)
2055
2055
  throw new Error("Wrong sbox length");
2056
- const n = new Uint32Array(256).map((u, f) => t(e[f])), r = n.map(kt), i = r.map(kt), o = i.map(kt), s = new Uint32Array(256 * 256), c = new Uint32Array(256 * 256), a = new Uint16Array(256 * 256);
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), o = i.map(kt), s = 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], c[l] = i[u] ^ o[f], a[l] = e[u] << 8 | e[f];
2059
+ const u = l * 256 + f;
2060
+ s[u] = n[l] ^ r[f], c[u] = i[l] ^ o[f], a[u] = e[l] << 8 | e[f];
2061
2061
  }
2062
2062
  return { sbox: e, sbox2: a, T0: n, T1: r, T2: i, T3: o, T01: s, T23: c };
2063
2063
  }
2064
- const nn = /* @__PURE__ */ lr(Vt, (e) => Oe(e, 3) << 24 | e << 16 | e << 8 | Oe(e, 2)), fr = /* @__PURE__ */ lr(Co, (e) => Oe(e, 11) << 24 | Oe(e, 13) << 16 | Oe(e, 9) << 8 | Oe(e, 14)), Io = /* @__PURE__ */ (() => {
2064
+ const tn = /* @__PURE__ */ ur(jt, (e) => Pe(e, 3) << 24 | e << 16 | e << 8 | Pe(e, 2)), fr = /* @__PURE__ */ ur(No, (e) => Pe(e, 11) << 24 | Pe(e, 13) << 16 | Pe(e, 9) << 8 | Pe(e, 14)), Io = /* @__PURE__ */ (() => {
2065
2065
  const e = new Uint8Array(16);
2066
- for (let t = 0, n = 1; t < 16; t++, n = tn(n))
2066
+ for (let t = 0, n = 1; t < 16; t++, n = en(n))
2067
2067
  e[t] = n;
2068
2068
  return e;
2069
2069
  })();
@@ -2072,55 +2072,55 @@ function hr(e) {
2072
2072
  const t = e.length;
2073
2073
  if (![16, 24, 32].includes(t))
2074
2074
  throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);
2075
- const { sbox2: n } = nn, r = Z(e), i = r.length, o = (c) => oe(n, c, c, c, c), s = new Uint32Array(t + 28);
2075
+ const { sbox2: n } = tn, r = F(e), i = r.length, o = (c) => se(n, c, c, c, c), s = new Uint32Array(t + 28);
2076
2076
  s.set(r);
2077
2077
  for (let c = i; c < s.length; c++) {
2078
2078
  let a = s[c - 1];
2079
- c % i === 0 ? a = o(Uo(a)) ^ Io[c / i - 1] : i > 6 && c % i === 4 && (a = o(a)), s[c] = s[c - i] ^ a;
2079
+ c % i === 0 ? a = o(Co(a)) ^ Io[c / i - 1] : i > 6 && c % i === 4 && (a = o(a)), s[c] = s[c - i] ^ a;
2080
2080
  }
2081
2081
  return s;
2082
2082
  }
2083
- function Ko(e) {
2084
- const t = hr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: o, T1: s, T2: c, T3: a } = fr;
2085
- for (let u = 0; u < r; u += 4)
2083
+ function Uo(e) {
2084
+ const t = hr(e), n = t.slice(), r = t.length, { sbox2: i } = tn, { T0: o, T1: s, T2: c, T3: a } = fr;
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 = oe(i, f, f, f, f);
2091
- n[u] = o[l & 255] ^ s[l >>> 8 & 255] ^ c[l >>> 16 & 255] ^ a[l >>> 24];
2089
+ for (let l = 4; l < r - 4; l++) {
2090
+ const f = n[l], u = se(i, f, f, f, f);
2091
+ n[l] = o[u & 255] ^ s[u >>> 8 & 255] ^ c[u >>> 16 & 255] ^ a[u >>> 24];
2092
2092
  }
2093
2093
  return n;
2094
2094
  }
2095
- function Ae(e, t, n, r, i, o) {
2095
+ function me(e, t, n, r, i, o) {
2096
2096
  return e[n << 8 & 65280 | r >>> 8 & 255] ^ t[i >>> 8 & 65280 | o >>> 24 & 255];
2097
2097
  }
2098
- function oe(e, t, n, r, i) {
2098
+ function se(e, t, n, r, i) {
2099
2099
  return e[t & 255 | n & 65280] | e[r >>> 16 & 255 | i >>> 16 & 65280] << 16;
2100
2100
  }
2101
- function Tn(e, t, n, r, i) {
2102
- const { sbox2: o, T01: s, T23: c } = nn;
2101
+ function Ln(e, t, n, r, i) {
2102
+ const { sbox2: o, T01: s, T23: c } = tn;
2103
2103
  let a = 0;
2104
2104
  t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2105
- const u = e.length / 4 - 2;
2106
- for (let y = 0; y < u; y++) {
2107
- const h = e[a++] ^ Ae(s, c, t, n, r, i), g = e[a++] ^ Ae(s, c, n, r, i, t), p = e[a++] ^ Ae(s, c, r, i, t, n), m = e[a++] ^ Ae(s, c, i, t, n, r);
2108
- t = h, n = g, r = p, i = m;
2105
+ const l = e.length / 4 - 2;
2106
+ for (let w = 0; w < l; w++) {
2107
+ const h = e[a++] ^ me(s, c, t, n, r, i), y = e[a++] ^ me(s, c, n, r, i, t), p = e[a++] ^ me(s, c, r, i, t, n), E = e[a++] ^ me(s, c, i, t, n, r);
2108
+ t = h, n = y, r = p, i = E;
2109
2109
  }
2110
- const f = e[a++] ^ oe(o, t, n, r, i), l = e[a++] ^ oe(o, n, r, i, t), d = e[a++] ^ oe(o, r, i, t, n), w = e[a++] ^ oe(o, i, t, n, r);
2111
- return { s0: f, s1: l, s2: d, s3: w };
2110
+ const f = e[a++] ^ se(o, t, n, r, i), u = e[a++] ^ se(o, n, r, i, t), d = e[a++] ^ se(o, r, i, t, n), g = e[a++] ^ se(o, i, t, n, r);
2111
+ return { s0: f, s1: u, s2: d, s3: g };
2112
2112
  }
2113
2113
  function _o(e, t, n, r, i) {
2114
2114
  const { sbox2: o, T01: s, T23: c } = fr;
2115
2115
  let a = 0;
2116
2116
  t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
2117
- const u = e.length / 4 - 2;
2118
- for (let y = 0; y < u; y++) {
2119
- const h = e[a++] ^ Ae(s, c, t, i, r, n), g = e[a++] ^ Ae(s, c, n, t, i, r), p = e[a++] ^ Ae(s, c, r, n, t, i), m = e[a++] ^ Ae(s, c, i, r, n, t);
2120
- t = h, n = g, r = p, i = m;
2117
+ const l = e.length / 4 - 2;
2118
+ for (let w = 0; w < l; w++) {
2119
+ const h = e[a++] ^ me(s, c, t, i, r, n), y = e[a++] ^ me(s, c, n, t, i, r), p = e[a++] ^ me(s, c, r, n, t, i), E = e[a++] ^ me(s, c, i, r, n, t);
2120
+ t = h, n = y, r = p, i = E;
2121
2121
  }
2122
- const f = e[a++] ^ oe(o, t, i, r, n), l = e[a++] ^ oe(o, n, t, i, r), d = e[a++] ^ oe(o, r, n, t, i), w = e[a++] ^ oe(o, i, r, n, t);
2123
- return { s0: f, s1: l, s2: d, s3: w };
2122
+ const f = e[a++] ^ se(o, t, i, r, n), u = e[a++] ^ se(o, n, t, i, r), d = e[a++] ^ se(o, r, n, t, i), g = e[a++] ^ se(o, i, r, n, t);
2123
+ return { s0: f, s1: u, s2: d, s3: g };
2124
2124
  }
2125
2125
  function dr(e, t) {
2126
2126
  if (!t)
@@ -2129,24 +2129,24 @@ function dr(e, t) {
2129
2129
  throw new Error(`aes: wrong destination length, expected at least ${e}, got: ${t.length}`);
2130
2130
  return t;
2131
2131
  }
2132
- function Lo(e) {
2133
- if (le(e), e.length % Se !== 0)
2134
- throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Se}`);
2132
+ function ko(e) {
2133
+ if (le(e), e.length % Ee !== 0)
2134
+ throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ee}`);
2135
2135
  }
2136
- function ko(e, t, n) {
2136
+ function Lo(e, t, n) {
2137
2137
  let r = e.length;
2138
- const i = r % Se;
2138
+ const i = r % Ee;
2139
2139
  if (!t && i !== 0)
2140
2140
  throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");
2141
- const o = Z(e);
2141
+ const o = F(e);
2142
2142
  if (t) {
2143
- let a = Se - i;
2144
- a || (a = Se), r = r + a;
2143
+ let a = Ee - i;
2144
+ a || (a = Ee), r = r + a;
2145
2145
  }
2146
- const s = dr(r, n), c = Z(s);
2146
+ const s = dr(r, n), c = F(s);
2147
2147
  return { b: o, o: c, out: s };
2148
2148
  }
2149
- function To(e, t) {
2149
+ function $o(e, t) {
2150
2150
  if (!t)
2151
2151
  return e;
2152
2152
  const n = e.length;
@@ -2161,116 +2161,116 @@ function To(e, t) {
2161
2161
  throw new Error("aes/pcks5: wrong padding");
2162
2162
  return i;
2163
2163
  }
2164
- function $o(e) {
2165
- const t = new Uint8Array(16), n = Z(t);
2164
+ function To(e) {
2165
+ const t = new Uint8Array(16), n = F(t);
2166
2166
  t.set(e);
2167
- const r = Se - e.length;
2168
- for (let i = Se - r; i < Se; i++)
2167
+ const r = Ee - e.length;
2168
+ for (let i = Ee - r; i < Ee; i++)
2169
2169
  t[i] = r;
2170
2170
  return n;
2171
2171
  }
2172
- const gr = /* @__PURE__ */ Bo({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) {
2172
+ const yr = /* @__PURE__ */ Ko({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) {
2173
2173
  le(t), le(n, 16);
2174
2174
  const i = !r.disablePadding;
2175
2175
  return {
2176
2176
  encrypt: (o, s) => {
2177
- const c = hr(t), { b: a, o: u, out: f } = ko(o, i, s), l = Z(n);
2178
- let d = l[0], w = l[1], y = l[2], h = l[3], g = 0;
2179
- for (; g + 4 <= a.length; )
2180
- d ^= a[g + 0], w ^= a[g + 1], y ^= a[g + 2], h ^= a[g + 3], { s0: d, s1: w, s2: y, s3: h } = Tn(c, d, w, y, h), u[g++] = d, u[g++] = w, u[g++] = y, u[g++] = h;
2177
+ const c = hr(t), { b: a, o: l, out: f } = Lo(o, i, s), u = F(n);
2178
+ let d = u[0], g = u[1], w = u[2], h = u[3], y = 0;
2179
+ for (; y + 4 <= a.length; )
2180
+ d ^= a[y + 0], g ^= a[y + 1], w ^= a[y + 2], h ^= a[y + 3], { s0: d, s1: g, s2: w, s3: h } = Ln(c, d, g, w, h), l[y++] = d, l[y++] = g, l[y++] = w, l[y++] = h;
2181
2181
  if (i) {
2182
- const p = $o(o.subarray(g * 4));
2183
- d ^= p[0], w ^= p[1], y ^= p[2], h ^= p[3], { s0: d, s1: w, s2: y, s3: h } = Tn(c, d, w, y, h), u[g++] = d, u[g++] = w, u[g++] = y, u[g++] = h;
2182
+ const p = To(o.subarray(y * 4));
2183
+ d ^= p[0], g ^= p[1], w ^= p[2], h ^= p[3], { s0: d, s1: g, s2: w, s3: h } = Ln(c, d, g, w, h), l[y++] = d, l[y++] = g, l[y++] = w, l[y++] = h;
2184
2184
  }
2185
2185
  return c.fill(0), f;
2186
2186
  },
2187
2187
  decrypt: (o, s) => {
2188
- Lo(o);
2189
- const c = Ko(t), a = Z(n), u = dr(o.length, s), f = Z(o), l = Z(u);
2190
- let d = a[0], w = a[1], y = a[2], h = a[3];
2191
- for (let g = 0; g + 4 <= f.length; ) {
2192
- const p = d, m = w, B = y, _ = h;
2193
- d = f[g + 0], w = f[g + 1], y = f[g + 2], h = f[g + 3];
2194
- const { s0: U, s1: x, s2: E, s3: A } = _o(c, d, w, y, h);
2195
- l[g++] = U ^ p, l[g++] = x ^ m, l[g++] = E ^ B, l[g++] = A ^ _;
2188
+ ko(o);
2189
+ const c = Uo(t), a = F(n), l = dr(o.length, s), f = F(o), u = F(l);
2190
+ let d = a[0], g = a[1], w = a[2], h = a[3];
2191
+ for (let y = 0; y + 4 <= f.length; ) {
2192
+ const p = d, E = g, K = w, _ = h;
2193
+ d = f[y + 0], g = f[y + 1], w = f[y + 2], h = f[y + 3];
2194
+ const { s0: C, s1: m, s2: x, s3: A } = _o(c, d, g, w, h);
2195
+ u[y++] = C ^ p, u[y++] = m ^ E, u[y++] = x ^ K, u[y++] = A ^ _;
2196
2196
  }
2197
- return c.fill(0), To(u, i);
2197
+ return c.fill(0), $o(l, i);
2198
2198
  }
2199
2199
  };
2200
- }), pr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Ro = pr("expand 16-byte k"), Po = pr("expand 32-byte k"), Oo = Z(Ro), yr = Z(Po);
2201
- yr.slice();
2202
- function k(e, t) {
2200
+ }), gr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Ro = gr("expand 16-byte k"), Po = gr("expand 32-byte k"), Oo = F(Ro), pr = F(Po);
2201
+ pr.slice();
2202
+ function L(e, t) {
2203
2203
  return e << t | e >>> 32 - t;
2204
2204
  }
2205
- function zt(e) {
2205
+ function Vt(e) {
2206
2206
  return e.byteOffset % 4 === 0;
2207
2207
  }
2208
- const Qe = 64, Ho = 16, wr = 2 ** 32 - 1, $n = new Uint32Array();
2209
- function Mo(e, t, n, r, i, o, s, c) {
2210
- const a = i.length, u = new Uint8Array(Qe), f = Z(u), l = zt(i) && zt(o), d = l ? Z(i) : $n, w = l ? Z(o) : $n;
2211
- for (let y = 0; y < a; s++) {
2208
+ const Xe = 64, Mo = 16, wr = 2 ** 32 - 1, $n = new Uint32Array();
2209
+ function Ho(e, t, n, r, i, o, s, c) {
2210
+ const a = i.length, l = new Uint8Array(Xe), f = F(l), u = Vt(i) && Vt(o), d = u ? F(i) : $n, g = u ? F(o) : $n;
2211
+ for (let w = 0; w < a; s++) {
2212
2212
  if (e(t, n, r, f, s, c), s >= wr)
2213
2213
  throw new Error("arx: counter overflow");
2214
- const h = Math.min(Qe, a - y);
2215
- if (l && h === Qe) {
2216
- const g = y / 4;
2217
- if (y % 4 !== 0)
2214
+ const h = Math.min(Xe, a - w);
2215
+ if (u && h === Xe) {
2216
+ const y = w / 4;
2217
+ if (w % 4 !== 0)
2218
2218
  throw new Error("arx: invalid block position");
2219
- for (let p = 0, m; p < Ho; p++)
2220
- m = g + p, w[m] = d[m] ^ f[p];
2221
- y += Qe;
2219
+ for (let p = 0, E; p < Mo; p++)
2220
+ E = y + p, g[E] = d[E] ^ f[p];
2221
+ w += Xe;
2222
2222
  continue;
2223
2223
  }
2224
- for (let g = 0, p; g < h; g++)
2225
- p = y + g, o[p] = i[p] ^ u[g];
2226
- y += h;
2224
+ for (let y = 0, p; y < h; y++)
2225
+ p = w + y, o[p] = i[p] ^ l[y];
2226
+ w += h;
2227
2227
  }
2228
2228
  }
2229
2229
  function qo(e, t) {
2230
2230
  const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: o, rounds: s } = Ao({ 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 Lt(i), Lt(s), kn(o), kn(n), (c, a, u, f, l = 0) => {
2234
- le(c), le(a), le(u);
2235
- const d = u.length;
2236
- if (f || (f = new Uint8Array(d)), le(f), Lt(l), l < 0 || l >= wr)
2233
+ return _t(i), _t(s), kn(o), kn(n), (c, a, l, f, u = 0) => {
2234
+ le(c), le(a), le(l);
2235
+ const d = l.length;
2236
+ if (f || (f = new Uint8Array(d)), le(f), _t(u), u < 0 || u >= wr)
2237
2237
  throw new Error("arx: counter overflow");
2238
2238
  if (f.length < d)
2239
2239
  throw new Error(`arx: output (${f.length}) is shorter than data (${d})`);
2240
- const w = [];
2241
- let y = c.length, h, g;
2242
- if (y === 32)
2243
- h = c.slice(), w.push(h), g = yr;
2244
- else if (y === 16 && n)
2245
- h = new Uint8Array(32), h.set(c), h.set(c, 16), g = Oo, w.push(h);
2240
+ const g = [];
2241
+ let w = c.length, h, y;
2242
+ if (w === 32)
2243
+ h = c.slice(), g.push(h), y = pr;
2244
+ else if (w === 16 && n)
2245
+ h = new Uint8Array(32), h.set(c), h.set(c, 16), y = Oo, g.push(h);
2246
2246
  else
2247
- throw new Error(`arx: invalid 32-byte key, got length=${y}`);
2248
- zt(a) || (a = a.slice(), w.push(a));
2249
- const p = Z(h);
2247
+ throw new Error(`arx: invalid 32-byte key, got length=${w}`);
2248
+ Vt(a) || (a = a.slice(), g.push(a));
2249
+ const p = F(h);
2250
2250
  if (r) {
2251
2251
  if (a.length !== 24)
2252
2252
  throw new Error("arx: extended nonce must be 24 bytes");
2253
- r(g, p, Z(a.subarray(0, 16)), p), a = a.subarray(16);
2253
+ r(y, p, F(a.subarray(0, 16)), p), a = a.subarray(16);
2254
2254
  }
2255
- const m = 16 - i;
2256
- if (m !== a.length)
2257
- throw new Error(`arx: nonce must be ${m} or 16 bytes`);
2258
- if (m !== 12) {
2255
+ const E = 16 - i;
2256
+ if (E !== a.length)
2257
+ throw new Error(`arx: nonce must be ${E} or 16 bytes`);
2258
+ if (E !== 12) {
2259
2259
  const _ = new Uint8Array(12);
2260
- _.set(a, o ? 0 : 12 - a.length), a = _, w.push(a);
2260
+ _.set(a, o ? 0 : 12 - a.length), a = _, g.push(a);
2261
2261
  }
2262
- const B = Z(a);
2263
- for (Mo(e, g, p, B, u, f, l, s); w.length > 0; )
2264
- w.pop().fill(0);
2262
+ const K = F(a);
2263
+ for (Ho(e, y, p, K, l, f, u, s); g.length > 0; )
2264
+ g.pop().fill(0);
2265
2265
  return f;
2266
2266
  };
2267
2267
  }
2268
2268
  function Do(e, t, n, r, i, o = 20) {
2269
- let s = e[0], c = e[1], a = e[2], u = e[3], f = t[0], l = t[1], d = t[2], w = t[3], y = t[4], h = t[5], g = t[6], p = t[7], m = i, B = n[0], _ = n[1], U = n[2], x = s, E = c, A = a, O = u, K = f, N = l, $ = d, R = w, H = y, b = h, v = g, S = p, I = m, C = B, L = _, P = U;
2270
- for (let Y = 0; Y < o; Y += 2)
2271
- x = x + K | 0, I = k(I ^ x, 16), H = H + I | 0, K = k(K ^ H, 12), x = x + K | 0, I = k(I ^ x, 8), H = H + I | 0, K = k(K ^ H, 7), E = E + N | 0, C = k(C ^ E, 16), b = b + C | 0, N = k(N ^ b, 12), E = E + N | 0, C = k(C ^ E, 8), b = b + C | 0, N = k(N ^ b, 7), A = A + $ | 0, L = k(L ^ A, 16), v = v + L | 0, $ = k($ ^ v, 12), A = A + $ | 0, L = k(L ^ A, 8), v = v + L | 0, $ = k($ ^ v, 7), O = O + R | 0, P = k(P ^ O, 16), S = S + P | 0, R = k(R ^ S, 12), O = O + R | 0, P = k(P ^ O, 8), S = S + P | 0, R = k(R ^ S, 7), x = x + N | 0, P = k(P ^ x, 16), v = v + P | 0, N = k(N ^ v, 12), x = x + N | 0, P = k(P ^ x, 8), v = v + P | 0, N = k(N ^ v, 7), E = E + $ | 0, I = k(I ^ E, 16), S = S + I | 0, $ = k($ ^ S, 12), E = E + $ | 0, I = k(I ^ E, 8), S = S + I | 0, $ = k($ ^ S, 7), A = A + R | 0, C = k(C ^ A, 16), H = H + C | 0, R = k(R ^ H, 12), A = A + R | 0, C = k(C ^ A, 8), H = H + C | 0, R = k(R ^ H, 7), O = O + K | 0, L = k(L ^ O, 16), b = b + L | 0, K = k(K ^ b, 12), O = O + K | 0, L = k(L ^ O, 8), b = b + L | 0, K = k(K ^ b, 7);
2272
- let T = 0;
2273
- r[T++] = s + x | 0, r[T++] = c + E | 0, r[T++] = a + A | 0, r[T++] = u + O | 0, r[T++] = f + K | 0, r[T++] = l + N | 0, r[T++] = d + $ | 0, r[T++] = w + R | 0, r[T++] = y + H | 0, r[T++] = h + b | 0, r[T++] = g + v | 0, r[T++] = p + S | 0, r[T++] = m + I | 0, r[T++] = B + C | 0, r[T++] = _ + L | 0, r[T++] = U + P | 0;
2269
+ let s = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], d = t[2], g = t[3], w = t[4], h = t[5], y = t[6], p = t[7], E = i, K = n[0], _ = n[1], C = n[2], m = s, x = c, A = a, O = l, U = f, B = u, T = d, R = g, H = w, b = h, v = y, S = p, I = E, N = K, k = _, P = C;
2270
+ for (let X = 0; X < o; X += 2)
2271
+ m = m + U | 0, I = L(I ^ m, 16), H = H + I | 0, U = L(U ^ H, 12), m = m + U | 0, I = L(I ^ m, 8), H = H + I | 0, U = L(U ^ H, 7), x = x + B | 0, N = L(N ^ x, 16), b = b + N | 0, B = L(B ^ b, 12), x = x + B | 0, N = L(N ^ x, 8), b = b + N | 0, B = L(B ^ b, 7), A = A + T | 0, k = L(k ^ A, 16), v = v + k | 0, T = L(T ^ v, 12), A = A + T | 0, k = L(k ^ A, 8), v = v + k | 0, T = L(T ^ v, 7), O = O + R | 0, P = L(P ^ O, 16), S = S + P | 0, R = L(R ^ S, 12), O = O + R | 0, P = L(P ^ O, 8), S = S + P | 0, R = L(R ^ S, 7), m = m + B | 0, P = L(P ^ m, 16), v = v + P | 0, B = L(B ^ v, 12), m = m + B | 0, P = L(P ^ m, 8), v = v + P | 0, B = L(B ^ v, 7), x = x + T | 0, I = L(I ^ x, 16), S = S + I | 0, T = L(T ^ S, 12), x = x + T | 0, I = L(I ^ x, 8), S = S + I | 0, T = L(T ^ S, 7), A = A + R | 0, N = L(N ^ A, 16), H = H + N | 0, R = L(R ^ H, 12), A = A + R | 0, N = L(N ^ A, 8), H = H + N | 0, R = L(R ^ H, 7), O = O + U | 0, k = L(k ^ O, 16), b = b + k | 0, U = L(U ^ b, 12), O = O + U | 0, k = L(k ^ O, 8), b = b + k | 0, U = L(U ^ b, 7);
2272
+ let $ = 0;
2273
+ r[$++] = s + m | 0, r[$++] = c + x | 0, r[$++] = a + A | 0, r[$++] = l + O | 0, r[$++] = f + U | 0, r[$++] = u + B | 0, r[$++] = d + T | 0, r[$++] = g + R | 0, r[$++] = w + H | 0, r[$++] = h + b | 0, r[$++] = y + v | 0, r[$++] = p + S | 0, r[$++] = E + I | 0, r[$++] = K + N | 0, r[$++] = _ + k | 0, r[$++] = C + P | 0;
2274
2274
  }
2275
2275
  const br = /* @__PURE__ */ qo(Do, {
2276
2276
  counterRight: !1,
@@ -2279,8 +2279,8 @@ const br = /* @__PURE__ */ qo(Do, {
2279
2279
  });
2280
2280
  class vr extends nr {
2281
2281
  constructor(t, n) {
2282
- super(), this.finished = !1, this.destroyed = !1, ie.hash(t);
2283
- const r = Je(n);
2282
+ super(), this.finished = !1, this.destroyed = !1, oe.hash(t);
2283
+ const r = Ge(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;
@@ -2294,10 +2294,10 @@ class vr extends nr {
2294
2294
  this.oHash.update(o), o.fill(0);
2295
2295
  }
2296
2296
  update(t) {
2297
- return ie.exists(this), this.iHash.update(t), this;
2297
+ return oe.exists(this), this.iHash.update(t), this;
2298
2298
  }
2299
2299
  digestInto(t) {
2300
- ie.exists(this), ie.bytes(t, this.outputLen), this.finished = !0, this.iHash.digestInto(t), this.oHash.update(t), this.oHash.digestInto(t), this.destroy();
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();
2301
2301
  }
2302
2302
  digest() {
2303
2303
  const t = new Uint8Array(this.oHash.outputLen);
@@ -2312,27 +2312,27 @@ class vr extends nr {
2312
2312
  this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
2313
2313
  }
2314
2314
  }
2315
- const wt = (e, t, n) => new vr(e, t).update(n).digest();
2316
- wt.create = (e, t) => new vr(e, t);
2317
- function rn(e, t, n) {
2318
- return ie.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), wt(e, Je(n), Je(t));
2315
+ const pt = (e, t, n) => new vr(e, t).update(n).digest();
2316
+ pt.create = (e, t) => new vr(e, t);
2317
+ function nn(e, t, n) {
2318
+ return oe.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), pt(e, Ge(n), Ge(t));
2319
2319
  }
2320
- const Tt = new Uint8Array([0]), Rn = new Uint8Array();
2321
- function xr(e, t, n, r = 32) {
2322
- if (ie.hash(e), ie.number(r), r > 255 * e.outputLen)
2320
+ const Lt = new Uint8Array([0]), Tn = new Uint8Array();
2321
+ function mr(e, t, n, r = 32) {
2322
+ if (oe.hash(e), oe.number(r), r > 255 * e.outputLen)
2323
2323
  throw new Error("Length should be <= 255*HashLen");
2324
2324
  const i = Math.ceil(r / e.outputLen);
2325
- n === void 0 && (n = Rn);
2326
- const o = new Uint8Array(i * e.outputLen), s = wt.create(e, t), c = s._cloneInto(), a = new Uint8Array(s.outputLen);
2327
- for (let u = 0; u < i; u++)
2328
- Tt[0] = u + 1, c.update(u === 0 ? Rn : a).update(n).update(Tt).digestInto(a), o.set(a, e.outputLen * u), s._cloneInto(c);
2329
- return s.destroy(), c.destroy(), a.fill(0), Tt.fill(0), o.slice(0, r);
2325
+ n === void 0 && (n = Tn);
2326
+ const o = new Uint8Array(i * e.outputLen), s = pt.create(e, t), c = s._cloneInto(), a = new Uint8Array(s.outputLen);
2327
+ for (let l = 0; l < i; l++)
2328
+ Lt[0] = l + 1, c.update(l === 0 ? Tn : a).update(n).update(Lt).digestInto(a), o.set(a, e.outputLen * l), s._cloneInto(c);
2329
+ return s.destroy(), c.destroy(), a.fill(0), Lt.fill(0), o.slice(0, r);
2330
2330
  }
2331
- var jo = Object.defineProperty, q = (e, t) => {
2331
+ var jo = Object.defineProperty, D = (e, t) => {
2332
2332
  for (var n in t)
2333
2333
  jo(e, n, { get: t[n], enumerable: !0 });
2334
- }, Pe = Symbol("verified"), Vo = (e) => e instanceof Object;
2335
- function mr(e) {
2334
+ }, Te = Symbol("verified"), Vo = (e) => e instanceof Object;
2335
+ function Er(e) {
2336
2336
  if (!Vo(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++) {
@@ -2346,31 +2346,31 @@ function mr(e) {
2346
2346
  return !0;
2347
2347
  }
2348
2348
  var zo = {};
2349
- q(zo, {
2349
+ D(zo, {
2350
2350
  Queue: () => Go,
2351
- QueueNode: () => Er,
2352
- binarySearch: () => on,
2351
+ QueueNode: () => xr,
2352
+ binarySearch: () => rn,
2353
2353
  insertEventIntoAscendingList: () => Wo,
2354
2354
  insertEventIntoDescendingList: () => Fo,
2355
2355
  normalizeURL: () => Zo,
2356
- utf8Decoder: () => re,
2357
- utf8Encoder: () => ee
2356
+ utf8Decoder: () => ie,
2357
+ utf8Encoder: () => te
2358
2358
  });
2359
- var re = new TextDecoder("utf-8"), ee = new TextEncoder();
2359
+ var ie = new TextDecoder("utf-8"), te = new TextEncoder();
2360
2360
  function Zo(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
2365
  function Fo(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);
2366
+ const [n, r] = rn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
2367
2367
  return r || e.splice(n, 0, t), e;
2368
2368
  }
2369
2369
  function Wo(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);
2370
+ const [n, r] = rn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
2371
2371
  return r || e.splice(n, 0, t), e;
2372
2372
  }
2373
- function on(e, t) {
2373
+ function rn(e, t) {
2374
2374
  let n = 0, r = e.length - 1;
2375
2375
  for (; n <= r; ) {
2376
2376
  const i = Math.floor((n + r) / 2), o = t(e[i]);
@@ -2380,21 +2380,21 @@ function on(e, t) {
2380
2380
  }
2381
2381
  return [n, !1];
2382
2382
  }
2383
- var Er = class {
2383
+ var xr = class {
2384
2384
  constructor(e) {
2385
- Q(this, "value");
2386
- Q(this, "next", null);
2387
- Q(this, "prev", null);
2385
+ ee(this, "value");
2386
+ ee(this, "next", null);
2387
+ ee(this, "prev", null);
2388
2388
  this.value = e;
2389
2389
  }
2390
2390
  }, Go = class {
2391
2391
  constructor() {
2392
- Q(this, "first");
2393
- Q(this, "last");
2392
+ ee(this, "first");
2393
+ ee(this, "last");
2394
2394
  this.first = null, this.last = null;
2395
2395
  }
2396
2396
  enqueue(e) {
2397
- const t = new Er(e);
2397
+ const t = new xr(e);
2398
2398
  return this.last ? this.last === this.first ? (this.last = t, this.last.prev = this.first, this.first.next = t) : (t.prev = this.last, this.last.next = t, this.last = t) : (this.first = t, this.last = t), !0;
2399
2399
  }
2400
2400
  dequeue() {
@@ -2412,55 +2412,55 @@ var Er = class {
2412
2412
  return ze.utils.randomPrivateKey();
2413
2413
  }
2414
2414
  getPublicKey(e) {
2415
- return D(ze.getPublicKey(e));
2415
+ return M(ze.getPublicKey(e));
2416
2416
  }
2417
2417
  finalizeEvent(e, t) {
2418
2418
  const n = e;
2419
- return n.pubkey = D(ze.getPublicKey(t)), n.id = nt(n), n.sig = D(ze.sign(nt(n), t)), n[Pe] = !0, n;
2419
+ return n.pubkey = M(ze.getPublicKey(t)), n.id = tt(n), n.sig = M(ze.sign(tt(n), t)), n[Te] = !0, n;
2420
2420
  }
2421
2421
  verifyEvent(e) {
2422
- if (typeof e[Pe] == "boolean")
2423
- return e[Pe];
2424
- const t = nt(e);
2422
+ if (typeof e[Te] == "boolean")
2423
+ return e[Te];
2424
+ const t = tt(e);
2425
2425
  if (t !== e.id)
2426
- return e[Pe] = !1, !1;
2426
+ return e[Te] = !1, !1;
2427
2427
  try {
2428
2428
  const n = ze.verify(e.sig, t, e.pubkey);
2429
- return e[Pe] = n, n;
2429
+ return e[Te] = n, n;
2430
2430
  } catch {
2431
- return e[Pe] = !1, !1;
2431
+ return e[Te] = !1, !1;
2432
2432
  }
2433
2433
  }
2434
2434
  };
2435
2435
  function Yo(e) {
2436
- if (!mr(e))
2436
+ if (!Er(e))
2437
2437
  throw new Error("can't serialize event with wrong or missing properties");
2438
2438
  return JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content]);
2439
2439
  }
2440
- function nt(e) {
2441
- let t = Ne(ee.encode(Yo(e)));
2442
- return D(t);
2440
+ function tt(e) {
2441
+ let t = Ae(te.encode(Yo(e)));
2442
+ return M(t);
2443
2443
  }
2444
- var bt = new Jo(), He = bt.generateSecretKey, Ee = bt.getPublicKey, se = bt.finalizeEvent, sn = bt.verifyEvent, Xo = {};
2445
- q(Xo, {
2444
+ var wt = new Jo(), Oe = wt.generateSecretKey, Ce = wt.getPublicKey, ae = wt.finalizeEvent, on = wt.verifyEvent, Xo = {};
2445
+ D(Xo, {
2446
2446
  Application: () => Xs,
2447
2447
  BadgeAward: () => as,
2448
2448
  BadgeDefinition: () => zs,
2449
- BlockedRelaysList: () => Ks,
2450
- BookmarkList: () => Cs,
2449
+ BlockedRelaysList: () => Us,
2450
+ BookmarkList: () => Ns,
2451
2451
  Bookmarksets: () => Ds,
2452
2452
  Calendar: () => oa,
2453
2453
  CalendarEventRSVP: () => sa,
2454
- ChannelCreation: () => Cr,
2455
- ChannelHideMessage: () => Kr,
2454
+ ChannelCreation: () => Nr,
2455
+ ChannelHideMessage: () => Ur,
2456
2456
  ChannelMessage: () => Ir,
2457
- ChannelMetadata: () => Ur,
2457
+ ChannelMetadata: () => Cr,
2458
2458
  ChannelMuteUser: () => _r,
2459
2459
  ClassifiedListing: () => ta,
2460
- ClientAuth: () => Lr,
2461
- CommunitiesList: () => Us,
2462
- CommunityDefinition: () => ua,
2463
- CommunityPostApproval: () => ys,
2460
+ ClientAuth: () => kr,
2461
+ CommunitiesList: () => Cs,
2462
+ CommunityDefinition: () => la,
2463
+ CommunityPostApproval: () => ps,
2464
2464
  Contacts: () => rs,
2465
2465
  CreateOrUpdateProduct: () => Ws,
2466
2466
  CreateOrUpdateStall: () => Fs,
@@ -2472,54 +2472,54 @@ q(Xo, {
2472
2472
  EncryptedDirectMessage: () => is,
2473
2473
  EncryptedDirectMessages: () => os,
2474
2474
  EventDeletion: () => ss,
2475
- FileMetadata: () => ls,
2476
- FileServerPreference: () => Ts,
2477
- Followsets: () => Hs,
2475
+ FileMetadata: () => us,
2476
+ FileServerPreference: () => $s,
2477
+ Followsets: () => Ms,
2478
2478
  GenericRepost: () => cs,
2479
- Genericlists: () => Ms,
2480
- HTTPAuth: () => un,
2479
+ Genericlists: () => Hs,
2480
+ HTTPAuth: () => cn,
2481
2481
  Handlerinformation: () => ca,
2482
2482
  Handlerrecommendation: () => aa,
2483
2483
  Highlights: () => As,
2484
- InterestsList: () => Ls,
2484
+ InterestsList: () => ks,
2485
2485
  Interestsets: () => Zs,
2486
2486
  JobFeedback: () => vs,
2487
2487
  JobRequest: () => ws,
2488
2488
  JobResult: () => bs,
2489
- Label: () => ps,
2489
+ Label: () => gs,
2490
2490
  LightningPubRPC: () => Rs,
2491
2491
  LiveChatMessage: () => fs,
2492
2492
  LiveEvent: () => Qs,
2493
2493
  LongFormArticle: () => Gs,
2494
2494
  Metadata: () => es,
2495
2495
  Mutelist: () => Ss,
2496
- NWCWalletInfo: () => $s,
2497
- NWCWalletRequest: () => kr,
2496
+ NWCWalletInfo: () => Ts,
2497
+ NWCWalletRequest: () => Lr,
2498
2498
  NWCWalletResponse: () => Ps,
2499
2499
  NostrConnect: () => Os,
2500
- OpenTimestamps: () => us,
2501
- Pinlist: () => Bs,
2500
+ OpenTimestamps: () => ls,
2501
+ Pinlist: () => Ks,
2502
2502
  ProblemTracker: () => hs,
2503
2503
  ProfileBadges: () => Vs,
2504
2504
  PublicChatsList: () => Is,
2505
- Reaction: () => cn,
2505
+ Reaction: () => an,
2506
2506
  RecommendRelay: () => ns,
2507
- RelayList: () => Ns,
2507
+ RelayList: () => Bs,
2508
2508
  Relaysets: () => qs,
2509
2509
  Report: () => ds,
2510
- Reporting: () => gs,
2511
- Repost: () => an,
2510
+ Reporting: () => ys,
2511
+ Repost: () => sn,
2512
2512
  SearchRelaysList: () => _s,
2513
2513
  ShortTextNote: () => ts,
2514
2514
  Time: () => ia,
2515
- UserEmojiList: () => ks,
2515
+ UserEmojiList: () => Ls,
2516
2516
  UserStatuses: () => ea,
2517
- Zap: () => Es,
2518
- ZapGoal: () => xs,
2519
- ZapRequest: () => ms,
2517
+ Zap: () => xs,
2518
+ ZapGoal: () => ms,
2519
+ ZapRequest: () => Es,
2520
2520
  classifyKind: () => Qo,
2521
- isEphemeralKind: () => Br,
2522
- isParameterizedReplaceableKind: () => Nr,
2521
+ isEphemeralKind: () => Kr,
2522
+ isParameterizedReplaceableKind: () => Br,
2523
2523
  isRegularKind: () => Ar,
2524
2524
  isReplaceableKind: () => Sr
2525
2525
  });
@@ -2529,29 +2529,29 @@ function Ar(e) {
2529
2529
  function Sr(e) {
2530
2530
  return [0, 3].includes(e) || 1e4 <= e && e < 2e4;
2531
2531
  }
2532
- function Br(e) {
2532
+ function Kr(e) {
2533
2533
  return 2e4 <= e && e < 3e4;
2534
2534
  }
2535
- function Nr(e) {
2535
+ function Br(e) {
2536
2536
  return 3e4 <= e && e < 4e4;
2537
2537
  }
2538
2538
  function Qo(e) {
2539
- return Ar(e) ? "regular" : Sr(e) ? "replaceable" : Br(e) ? "ephemeral" : Nr(e) ? "parameterized" : "unknown";
2539
+ return Ar(e) ? "regular" : Sr(e) ? "replaceable" : Kr(e) ? "ephemeral" : Br(e) ? "parameterized" : "unknown";
2540
2540
  }
2541
- var es = 0, ts = 1, ns = 2, rs = 3, is = 4, os = 4, ss = 5, an = 6, cn = 7, as = 8, cs = 16, Cr = 40, Ur = 41, Ir = 42, Kr = 43, _r = 44, us = 1040, ls = 1063, fs = 1311, hs = 1971, ds = 1984, gs = 1984, ps = 1985, ys = 4550, ws = 5999, bs = 6999, vs = 7e3, xs = 9041, ms = 9734, Es = 9735, As = 9802, Ss = 1e4, Bs = 10001, Ns = 10002, Cs = 10003, Us = 10004, Is = 10005, Ks = 10006, _s = 10007, Ls = 10015, ks = 10030, Ts = 10096, $s = 13194, Rs = 21e3, Lr = 22242, kr = 23194, Ps = 23195, Os = 24133, un = 27235, Hs = 3e4, Ms = 30001, qs = 30002, Ds = 30003, js = 30004, Vs = 30008, zs = 30009, Zs = 30015, Fs = 30017, Ws = 30018, Gs = 30023, Js = 30024, Ys = 30030, Xs = 30078, Qs = 30311, ea = 30315, ta = 30402, na = 30403, ra = 31922, ia = 31923, oa = 31924, sa = 31925, aa = 31989, ca = 31990, ua = 34550, la = {};
2542
- q(la, {
2541
+ var es = 0, ts = 1, ns = 2, rs = 3, is = 4, os = 4, ss = 5, sn = 6, an = 7, as = 8, cs = 16, Nr = 40, Cr = 41, Ir = 42, Ur = 43, _r = 44, ls = 1040, us = 1063, fs = 1311, hs = 1971, ds = 1984, ys = 1984, gs = 1985, ps = 4550, ws = 5999, bs = 6999, vs = 7e3, ms = 9041, Es = 9734, xs = 9735, As = 9802, Ss = 1e4, Ks = 10001, Bs = 10002, Ns = 10003, Cs = 10004, Is = 10005, Us = 10006, _s = 10007, ks = 10015, Ls = 10030, $s = 10096, Ts = 13194, Rs = 21e3, kr = 22242, Lr = 23194, Ps = 23195, Os = 24133, cn = 27235, Ms = 3e4, Hs = 30001, qs = 30002, Ds = 30003, js = 30004, Vs = 30008, zs = 30009, Zs = 30015, Fs = 30017, Ws = 30018, Gs = 30023, Js = 30024, Ys = 30030, Xs = 30078, Qs = 30311, ea = 30315, ta = 30402, na = 30403, ra = 31922, ia = 31923, oa = 31924, sa = 31925, aa = 31989, ca = 31990, la = 34550, ua = {};
2542
+ D(ua, {
2543
2543
  getHex64: () => ln,
2544
- getInt: () => Tr,
2544
+ getInt: () => $r,
2545
2545
  getSubscriptionId: () => fa,
2546
2546
  matchEventId: () => ha,
2547
- matchEventKind: () => ga,
2547
+ matchEventKind: () => ya,
2548
2548
  matchEventPubkey: () => da
2549
2549
  });
2550
2550
  function ln(e, t) {
2551
2551
  let n = t.length + 3, r = e.indexOf(`"${t}":`) + n, i = e.slice(r).indexOf('"') + r + 1;
2552
2552
  return e.slice(i, i + 64);
2553
2553
  }
2554
- function Tr(e, t) {
2554
+ function $r(e, t) {
2555
2555
  let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, i = e.slice(r), o = Math.min(i.indexOf(","), i.indexOf("}"));
2556
2556
  return parseInt(i.slice(0, o), 10);
2557
2557
  }
@@ -2574,16 +2574,16 @@ function ha(e, t) {
2574
2574
  function da(e, t) {
2575
2575
  return t === ln(e, "pubkey");
2576
2576
  }
2577
- function ga(e, t) {
2578
- return t === Tr(e, "kind");
2577
+ function ya(e, t) {
2578
+ return t === $r(e, "kind");
2579
2579
  }
2580
- var pa = {};
2581
- q(pa, {
2582
- makeAuthEvent: () => ya
2580
+ var ga = {};
2581
+ D(ga, {
2582
+ makeAuthEvent: () => pa
2583
2583
  });
2584
- function ya(e, t) {
2584
+ function pa(e, t) {
2585
2585
  return {
2586
- kind: Lr,
2586
+ kind: kr,
2587
2587
  created_at: Math.floor(Date.now() / 1e3),
2588
2588
  tags: [
2589
2589
  ["relay", e],
@@ -2603,30 +2603,30 @@ try {
2603
2603
  } catch {
2604
2604
  }
2605
2605
  var Fe = {};
2606
- q(Fe, {
2607
- BECH32_REGEX: () => $r,
2608
- Bech32MaxSize: () => fn,
2609
- decode: () => vt,
2610
- encodeBytes: () => xt,
2611
- naddrEncode: () => Ba,
2606
+ D(Fe, {
2607
+ BECH32_REGEX: () => Tr,
2608
+ Bech32MaxSize: () => un,
2609
+ decode: () => bt,
2610
+ encodeBytes: () => vt,
2611
+ naddrEncode: () => Ka,
2612
2612
  neventEncode: () => Sa,
2613
- noteEncode: () => Ea,
2613
+ noteEncode: () => xa,
2614
2614
  nprofileEncode: () => Aa,
2615
- npubEncode: () => ma,
2616
- nrelayEncode: () => Na,
2617
- nsecEncode: () => xa
2615
+ npubEncode: () => Ea,
2616
+ nrelayEncode: () => Ba,
2617
+ nsecEncode: () => ma
2618
2618
  });
2619
- var fn = 5e3, $r = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
2619
+ var un = 5e3, Tr = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
2620
2620
  function va(e) {
2621
2621
  const t = new Uint8Array(4);
2622
2622
  return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t;
2623
2623
  }
2624
- function vt(e) {
2625
- var i, o, s, c, a, u, f, l;
2626
- let { prefix: t, words: n } = De.decode(e, fn), r = new Uint8Array(De.fromWords(n));
2624
+ function bt(e) {
2625
+ var i, o, s, c, a, l, f, u;
2626
+ let { prefix: t, words: n } = De.decode(e, un), r = new Uint8Array(De.fromWords(n));
2627
2627
  switch (t) {
2628
2628
  case "nprofile": {
2629
- let d = et(r);
2629
+ let d = Qe(r);
2630
2630
  if (!((i = d[0]) != null && i[0]))
2631
2631
  throw new Error("missing TLV 0 for nprofile");
2632
2632
  if (d[0][0].length !== 32)
@@ -2634,13 +2634,13 @@ function vt(e) {
2634
2634
  return {
2635
2635
  type: "nprofile",
2636
2636
  data: {
2637
- pubkey: D(d[0][0]),
2638
- relays: d[1] ? d[1].map((w) => re.decode(w)) : []
2637
+ pubkey: M(d[0][0]),
2638
+ relays: d[1] ? d[1].map((g) => ie.decode(g)) : []
2639
2639
  }
2640
2640
  };
2641
2641
  }
2642
2642
  case "nevent": {
2643
- let d = et(r);
2643
+ let d = Qe(r);
2644
2644
  if (!((o = d[0]) != null && o[0]))
2645
2645
  throw new Error("missing TLV 0 for nevent");
2646
2646
  if (d[0][0].length !== 32)
@@ -2652,18 +2652,18 @@ function vt(e) {
2652
2652
  return {
2653
2653
  type: "nevent",
2654
2654
  data: {
2655
- id: D(d[0][0]),
2656
- relays: d[1] ? d[1].map((w) => re.decode(w)) : [],
2657
- author: (s = d[2]) != null && s[0] ? D(d[2][0]) : void 0,
2658
- kind: (c = d[3]) != null && c[0] ? parseInt(D(d[3][0]), 16) : void 0
2655
+ id: M(d[0][0]),
2656
+ relays: d[1] ? d[1].map((g) => ie.decode(g)) : [],
2657
+ author: (s = d[2]) != null && s[0] ? M(d[2][0]) : void 0,
2658
+ kind: (c = d[3]) != null && c[0] ? parseInt(M(d[3][0]), 16) : void 0
2659
2659
  }
2660
2660
  };
2661
2661
  }
2662
2662
  case "naddr": {
2663
- let d = et(r);
2663
+ let d = Qe(r);
2664
2664
  if (!((a = d[0]) != null && a[0]))
2665
2665
  throw new Error("missing TLV 0 for naddr");
2666
- if (!((u = d[2]) != null && u[0]))
2666
+ if (!((l = d[2]) != null && l[0]))
2667
2667
  throw new Error("missing TLV 2 for naddr");
2668
2668
  if (d[2][0].length !== 32)
2669
2669
  throw new Error("TLV 2 should be 32 bytes");
@@ -2674,32 +2674,32 @@ function vt(e) {
2674
2674
  return {
2675
2675
  type: "naddr",
2676
2676
  data: {
2677
- identifier: re.decode(d[0][0]),
2678
- pubkey: D(d[2][0]),
2679
- kind: parseInt(D(d[3][0]), 16),
2680
- relays: d[1] ? d[1].map((w) => re.decode(w)) : []
2677
+ identifier: ie.decode(d[0][0]),
2678
+ pubkey: M(d[2][0]),
2679
+ kind: parseInt(M(d[3][0]), 16),
2680
+ relays: d[1] ? d[1].map((g) => ie.decode(g)) : []
2681
2681
  }
2682
2682
  };
2683
2683
  }
2684
2684
  case "nrelay": {
2685
- let d = et(r);
2686
- if (!((l = d[0]) != null && l[0]))
2685
+ let d = Qe(r);
2686
+ if (!((u = d[0]) != null && u[0]))
2687
2687
  throw new Error("missing TLV 0 for nrelay");
2688
2688
  return {
2689
2689
  type: "nrelay",
2690
- data: re.decode(d[0][0])
2690
+ data: ie.decode(d[0][0])
2691
2691
  };
2692
2692
  }
2693
2693
  case "nsec":
2694
2694
  return { type: t, data: r };
2695
2695
  case "npub":
2696
2696
  case "note":
2697
- return { type: t, data: D(r) };
2697
+ return { type: t, data: M(r) };
2698
2698
  default:
2699
2699
  throw new Error(`unknown prefix ${t}`);
2700
2700
  }
2701
2701
  }
2702
- function et(e) {
2702
+ function Qe(e) {
2703
2703
  let t = {}, n = e;
2704
2704
  for (; n.length > 0; ) {
2705
2705
  let r = n[0], i = n[1], o = n.slice(2, 2 + i);
@@ -2709,56 +2709,56 @@ function et(e) {
2709
2709
  }
2710
2710
  return t;
2711
2711
  }
2712
- function xa(e) {
2713
- return xt("nsec", e);
2714
- }
2715
2712
  function ma(e) {
2716
- return xt("npub", W(e));
2713
+ return vt("nsec", e);
2717
2714
  }
2718
2715
  function Ea(e) {
2719
- return xt("note", W(e));
2716
+ return vt("npub", Y(e));
2717
+ }
2718
+ function xa(e) {
2719
+ return vt("note", Y(e));
2720
2720
  }
2721
- function Xe(e, t) {
2721
+ function Ye(e, t) {
2722
2722
  let n = De.toWords(t);
2723
- return De.encode(e, n, fn);
2723
+ return De.encode(e, n, un);
2724
2724
  }
2725
- function xt(e, t) {
2726
- return Xe(e, t);
2725
+ function vt(e, t) {
2726
+ return Ye(e, t);
2727
2727
  }
2728
2728
  function Aa(e) {
2729
2729
  let t = mt({
2730
- 0: [W(e.pubkey)],
2731
- 1: (e.relays || []).map((n) => ee.encode(n))
2730
+ 0: [Y(e.pubkey)],
2731
+ 1: (e.relays || []).map((n) => te.encode(n))
2732
2732
  });
2733
- return Xe("nprofile", t);
2733
+ return Ye("nprofile", t);
2734
2734
  }
2735
2735
  function Sa(e) {
2736
2736
  let t;
2737
2737
  e.kind !== void 0 && (t = va(e.kind));
2738
2738
  let n = mt({
2739
- 0: [W(e.id)],
2740
- 1: (e.relays || []).map((r) => ee.encode(r)),
2741
- 2: e.author ? [W(e.author)] : [],
2739
+ 0: [Y(e.id)],
2740
+ 1: (e.relays || []).map((r) => te.encode(r)),
2741
+ 2: e.author ? [Y(e.author)] : [],
2742
2742
  3: t ? [new Uint8Array(t)] : []
2743
2743
  });
2744
- return Xe("nevent", n);
2744
+ return Ye("nevent", n);
2745
2745
  }
2746
- function Ba(e) {
2746
+ function Ka(e) {
2747
2747
  let t = new ArrayBuffer(4);
2748
2748
  new DataView(t).setUint32(0, e.kind, !1);
2749
2749
  let n = mt({
2750
- 0: [ee.encode(e.identifier)],
2751
- 1: (e.relays || []).map((r) => ee.encode(r)),
2752
- 2: [W(e.pubkey)],
2750
+ 0: [te.encode(e.identifier)],
2751
+ 1: (e.relays || []).map((r) => te.encode(r)),
2752
+ 2: [Y(e.pubkey)],
2753
2753
  3: [new Uint8Array(t)]
2754
2754
  });
2755
- return Xe("naddr", n);
2755
+ return Ye("naddr", n);
2756
2756
  }
2757
- function Na(e) {
2757
+ function Ba(e) {
2758
2758
  let t = mt({
2759
- 0: [ee.encode(e)]
2759
+ 0: [te.encode(e)]
2760
2760
  });
2761
- return Xe("nrelay", t);
2761
+ return Ye("nrelay", t);
2762
2762
  }
2763
2763
  function mt(e) {
2764
2764
  let t = [];
@@ -2767,40 +2767,40 @@ function mt(e) {
2767
2767
  let o = new Uint8Array(i.length + 2);
2768
2768
  o.set([parseInt(n)], 0), o.set([i.length], 1), o.set(i, 2), t.push(o);
2769
2769
  });
2770
- }), pt(...t);
2770
+ }), yt(...t);
2771
2771
  }
2772
- var Ca = {};
2773
- q(Ca, {
2774
- decrypt: () => Ua,
2772
+ var Na = {};
2773
+ D(Na, {
2774
+ decrypt: () => Ca,
2775
2775
  encrypt: () => Rr
2776
2776
  });
2777
2777
  async function Rr(e, t, n) {
2778
- const r = e instanceof Uint8Array ? D(e) : e, i = Le.getSharedSecret(r, "02" + t), o = Pr(i);
2779
- let s = Uint8Array.from(ir(16)), c = ee.encode(n), a = gr(o, s).encrypt(c), u = he.encode(new Uint8Array(a)), f = he.encode(new Uint8Array(s.buffer));
2780
- return `${u}?iv=${f}`;
2778
+ const r = e instanceof Uint8Array ? M(e) : e, i = Ue.getSharedSecret(r, "02" + t), o = Pr(i);
2779
+ let s = Uint8Array.from(ir(16)), c = te.encode(n), a = yr(o, s).encrypt(c), l = ue.encode(new Uint8Array(a)), f = ue.encode(new Uint8Array(s.buffer));
2780
+ return `${l}?iv=${f}`;
2781
2781
  }
2782
- async function Ua(e, t, n) {
2783
- const r = e instanceof Uint8Array ? D(e) : e;
2784
- let [i, o] = n.split("?iv="), s = Le.getSharedSecret(r, "02" + t), c = Pr(s), a = he.decode(o), u = he.decode(i), f = gr(c, a).decrypt(u);
2785
- return re.decode(f);
2782
+ async function Ca(e, t, n) {
2783
+ const r = e instanceof Uint8Array ? M(e) : e;
2784
+ let [i, o] = n.split("?iv="), s = Ue.getSharedSecret(r, "02" + t), c = Pr(s), a = ue.decode(o), l = ue.decode(i), f = yr(c, a).decrypt(l);
2785
+ return ie.decode(f);
2786
2786
  }
2787
2787
  function Pr(e) {
2788
2788
  return e.slice(1, 33);
2789
2789
  }
2790
2790
  var Ia = {};
2791
- q(Ia, {
2791
+ D(Ia, {
2792
2792
  NIP05_REGEX: () => Or,
2793
- isValid: () => La,
2794
- queryProfile: () => Hr,
2793
+ isValid: () => ka,
2794
+ queryProfile: () => Mr,
2795
2795
  searchDomain: () => _a,
2796
- useFetchImplementation: () => Ka
2796
+ useFetchImplementation: () => Ua
2797
2797
  });
2798
2798
  var Or = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, Et;
2799
2799
  try {
2800
2800
  Et = fetch;
2801
2801
  } catch {
2802
2802
  }
2803
- function Ka(e) {
2803
+ function Ua(e) {
2804
2804
  Et = e;
2805
2805
  }
2806
2806
  async function _a(e, t = "") {
@@ -2811,7 +2811,7 @@ async function _a(e, t = "") {
2811
2811
  return {};
2812
2812
  }
2813
2813
  }
2814
- async function Hr(e) {
2814
+ async function Mr(e) {
2815
2815
  var o;
2816
2816
  const t = e.match(Or);
2817
2817
  if (!t)
@@ -2825,15 +2825,15 @@ async function Hr(e) {
2825
2825
  return null;
2826
2826
  }
2827
2827
  }
2828
- async function La(e, t) {
2829
- let n = await Hr(t);
2828
+ async function ka(e, t) {
2829
+ let n = await Mr(t);
2830
2830
  return n ? n.pubkey === e : !1;
2831
2831
  }
2832
- var ka = {};
2833
- q(ka, {
2834
- parse: () => Ta
2832
+ var La = {};
2833
+ D(La, {
2834
+ parse: () => $a
2835
2835
  });
2836
- function Ta(e) {
2836
+ function $a(e) {
2837
2837
  const t = {
2838
2838
  reply: void 0,
2839
2839
  root: void 0,
@@ -2846,46 +2846,46 @@ function Ta(e) {
2846
2846
  relays: r[2] ? [r[2]] : []
2847
2847
  });
2848
2848
  for (let r = 0; r < n.length; r++) {
2849
- const i = n[r], [o, s, c, a] = i, u = {
2849
+ const i = n[r], [o, s, c, a] = i, l = {
2850
2850
  id: s,
2851
2851
  relays: c ? [c] : []
2852
- }, f = r === 0, l = r === n.length - 1;
2852
+ }, f = r === 0, u = r === n.length - 1;
2853
2853
  if (a === "root") {
2854
- t.root = u;
2854
+ t.root = l;
2855
2855
  continue;
2856
2856
  }
2857
2857
  if (a === "reply") {
2858
- t.reply = u;
2858
+ t.reply = l;
2859
2859
  continue;
2860
2860
  }
2861
2861
  if (a === "mention") {
2862
- t.mentions.push(u);
2862
+ t.mentions.push(l);
2863
2863
  continue;
2864
2864
  }
2865
2865
  if (f) {
2866
- t.root = u;
2866
+ t.root = l;
2867
2867
  continue;
2868
2868
  }
2869
- if (l) {
2870
- t.reply = u;
2869
+ if (u) {
2870
+ t.reply = l;
2871
2871
  continue;
2872
2872
  }
2873
- t.mentions.push(u);
2873
+ t.mentions.push(l);
2874
2874
  }
2875
2875
  return t;
2876
2876
  }
2877
- var $a = {};
2878
- q($a, {
2877
+ var Ta = {};
2878
+ D(Ta, {
2879
2879
  fetchRelayInformation: () => Pa,
2880
2880
  useFetchImplementation: () => Ra
2881
2881
  });
2882
- var Mr;
2882
+ var Hr;
2883
2883
  try {
2884
- Mr = fetch;
2884
+ Hr = fetch;
2885
2885
  } catch {
2886
2886
  }
2887
2887
  function Ra(e) {
2888
- Mr = e;
2888
+ Hr = e;
2889
2889
  }
2890
2890
  async function Pa(e) {
2891
2891
  return await (await fetch(e.replace("ws://", "http://").replace("wss://", "https://"), {
@@ -2893,9 +2893,9 @@ async function Pa(e) {
2893
2893
  })).json();
2894
2894
  }
2895
2895
  var Oa = {};
2896
- q(Oa, {
2896
+ D(Oa, {
2897
2897
  getPow: () => qr,
2898
- minePow: () => Ha
2898
+ minePow: () => Ma
2899
2899
  });
2900
2900
  function qr(e) {
2901
2901
  let t = 0;
@@ -2910,26 +2910,26 @@ function qr(e) {
2910
2910
  }
2911
2911
  return t;
2912
2912
  }
2913
- function Ha(e, t) {
2913
+ function Ma(e, t) {
2914
2914
  let n = 0;
2915
2915
  const r = e, i = ["nonce", n.toString(), t.toString()];
2916
2916
  for (r.tags.push(i); ; ) {
2917
2917
  const o = Math.floor((/* @__PURE__ */ new Date()).getTime() / 1e3);
2918
- if (o !== r.created_at && (n = 0, r.created_at = o), i[1] = (++n).toString(), r.id = nt(r), qr(r.id) >= t)
2918
+ if (o !== r.created_at && (n = 0, r.created_at = o), i[1] = (++n).toString(), r.id = tt(r), qr(r.id) >= t)
2919
2919
  break;
2920
2920
  }
2921
2921
  return r;
2922
2922
  }
2923
- var Ma = {};
2924
- q(Ma, {
2923
+ var Ha = {};
2924
+ D(Ha, {
2925
2925
  finishRepostEvent: () => qa,
2926
2926
  getRepostedEvent: () => Da,
2927
2927
  getRepostedEventPointer: () => Dr
2928
2928
  });
2929
2929
  function qa(e, t, n, r) {
2930
- return se(
2930
+ return ae(
2931
2931
  {
2932
- kind: an,
2932
+ kind: sn,
2933
2933
  tags: [...e.tags ?? [], ["e", t.id, n], ["p", t.pubkey]],
2934
2934
  content: e.content === "" ? "" : JSON.stringify(t),
2935
2935
  created_at: e.created_at
@@ -2938,7 +2938,7 @@ function qa(e, t, n, r) {
2938
2938
  );
2939
2939
  }
2940
2940
  function Dr(e) {
2941
- if (e.kind !== an)
2941
+ if (e.kind !== sn)
2942
2942
  return;
2943
2943
  let t, n;
2944
2944
  for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
@@ -2962,40 +2962,40 @@ function Da(e, { skipVerification: t } = {}) {
2962
2962
  } catch {
2963
2963
  return;
2964
2964
  }
2965
- if (r.id === n.id && !(!t && !sn(r)))
2965
+ if (r.id === n.id && !(!t && !on(r)))
2966
2966
  return r;
2967
2967
  }
2968
2968
  var ja = {};
2969
- q(ja, {
2970
- NOSTR_URI_REGEX: () => At,
2969
+ D(ja, {
2970
+ NOSTR_URI_REGEX: () => xt,
2971
2971
  parse: () => za,
2972
2972
  test: () => Va
2973
2973
  });
2974
- var At = new RegExp(`nostr:(${$r.source})`);
2974
+ var xt = new RegExp(`nostr:(${Tr.source})`);
2975
2975
  function Va(e) {
2976
- return typeof e == "string" && new RegExp(`^${At.source}$`).test(e);
2976
+ return typeof e == "string" && new RegExp(`^${xt.source}$`).test(e);
2977
2977
  }
2978
2978
  function za(e) {
2979
- const t = e.match(new RegExp(`^${At.source}$`));
2979
+ const t = e.match(new RegExp(`^${xt.source}$`));
2980
2980
  if (!t)
2981
2981
  throw new Error(`Invalid Nostr URI: ${e}`);
2982
2982
  return {
2983
2983
  uri: t[0],
2984
2984
  value: t[1],
2985
- decoded: vt(t[1])
2985
+ decoded: bt(t[1])
2986
2986
  };
2987
2987
  }
2988
2988
  var Za = {};
2989
- q(Za, {
2989
+ D(Za, {
2990
2990
  finishReactionEvent: () => Fa,
2991
2991
  getReactedEventPointer: () => Wa
2992
2992
  });
2993
2993
  function Fa(e, t, n) {
2994
2994
  const r = t.tags.filter((i) => i.length >= 2 && (i[0] === "e" || i[0] === "p"));
2995
- return se(
2995
+ return ae(
2996
2996
  {
2997
2997
  ...e,
2998
- kind: cn,
2998
+ kind: an,
2999
2999
  tags: [...e.tags ?? [], ...r, ["e", t.id], ["p", t.pubkey]],
3000
3000
  content: e.content ?? "+"
3001
3001
  },
@@ -3003,7 +3003,7 @@ function Fa(e, t, n) {
3003
3003
  );
3004
3004
  }
3005
3005
  function Wa(e) {
3006
- if (e.kind !== cn)
3006
+ if (e.kind !== an)
3007
3007
  return;
3008
3008
  let t, n;
3009
3009
  for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
@@ -3018,21 +3018,21 @@ function Wa(e) {
3018
3018
  };
3019
3019
  }
3020
3020
  var Ga = {};
3021
- q(Ga, {
3021
+ D(Ga, {
3022
3022
  matchAll: () => Ja,
3023
- regex: () => hn,
3023
+ regex: () => fn,
3024
3024
  replaceAll: () => Ya
3025
3025
  });
3026
- var hn = () => new RegExp(`\\b${At.source}\\b`, "g");
3026
+ var fn = () => new RegExp(`\\b${xt.source}\\b`, "g");
3027
3027
  function* Ja(e) {
3028
- const t = e.matchAll(hn());
3028
+ const t = e.matchAll(fn());
3029
3029
  for (const n of t)
3030
3030
  try {
3031
3031
  const [r, i] = n;
3032
3032
  yield {
3033
3033
  uri: r,
3034
3034
  value: i,
3035
- decoded: vt(i),
3035
+ decoded: bt(i),
3036
3036
  start: n.index,
3037
3037
  end: n.index + r.length
3038
3038
  };
@@ -3040,14 +3040,14 @@ function* Ja(e) {
3040
3040
  }
3041
3041
  }
3042
3042
  function Ya(e, t) {
3043
- return e.replaceAll(hn(), (n, r) => t({
3043
+ return e.replaceAll(fn(), (n, r) => t({
3044
3044
  uri: n,
3045
3045
  value: r,
3046
- decoded: vt(r)
3046
+ decoded: bt(r)
3047
3047
  }));
3048
3048
  }
3049
3049
  var Xa = {};
3050
- q(Xa, {
3050
+ D(Xa, {
3051
3051
  channelCreateEvent: () => Qa,
3052
3052
  channelHideMessageEvent: () => nc,
3053
3053
  channelMessageEvent: () => tc,
@@ -3062,9 +3062,9 @@ var Qa = (e, t) => {
3062
3062
  n = e.content;
3063
3063
  else
3064
3064
  return;
3065
- return se(
3065
+ return ae(
3066
3066
  {
3067
- kind: Cr,
3067
+ kind: Nr,
3068
3068
  tags: [...e.tags ?? []],
3069
3069
  content: n,
3070
3070
  created_at: e.created_at
@@ -3079,9 +3079,9 @@ var Qa = (e, t) => {
3079
3079
  n = e.content;
3080
3080
  else
3081
3081
  return;
3082
- return se(
3082
+ return ae(
3083
3083
  {
3084
- kind: Ur,
3084
+ kind: Cr,
3085
3085
  tags: [["e", e.channel_create_event_id], ...e.tags ?? []],
3086
3086
  content: n,
3087
3087
  created_at: e.created_at
@@ -3090,7 +3090,7 @@ var Qa = (e, t) => {
3090
3090
  );
3091
3091
  }, tc = (e, t) => {
3092
3092
  const n = [["e", e.channel_create_event_id, e.relay_url, "root"]];
3093
- return e.reply_to_channel_message_event_id && n.push(["e", e.reply_to_channel_message_event_id, e.relay_url, "reply"]), se(
3093
+ return e.reply_to_channel_message_event_id && n.push(["e", e.reply_to_channel_message_event_id, e.relay_url, "reply"]), ae(
3094
3094
  {
3095
3095
  kind: Ir,
3096
3096
  tags: [...n, ...e.tags ?? []],
@@ -3107,9 +3107,9 @@ var Qa = (e, t) => {
3107
3107
  n = e.content;
3108
3108
  else
3109
3109
  return;
3110
- return se(
3110
+ return ae(
3111
3111
  {
3112
- kind: Kr,
3112
+ kind: Ur,
3113
3113
  tags: [["e", e.channel_message_event_id], ...e.tags ?? []],
3114
3114
  content: n,
3115
3115
  created_at: e.created_at
@@ -3124,7 +3124,7 @@ var Qa = (e, t) => {
3124
3124
  n = e.content;
3125
3125
  else
3126
3126
  return;
3127
- return se(
3127
+ return ae(
3128
3128
  {
3129
3129
  kind: _r,
3130
3130
  tags: [["p", e.pubkey_to_mute], ...e.tags ?? []],
@@ -3134,15 +3134,15 @@ var Qa = (e, t) => {
3134
3134
  t
3135
3135
  );
3136
3136
  }, ic = {};
3137
- q(ic, {
3137
+ D(ic, {
3138
3138
  EMOJI_SHORTCODE_REGEX: () => jr,
3139
3139
  matchAll: () => oc,
3140
- regex: () => dn,
3140
+ regex: () => hn,
3141
3141
  replaceAll: () => sc
3142
3142
  });
3143
- var jr = /:(\w+):/, dn = () => new RegExp(`\\B${jr.source}\\B`, "g");
3143
+ var jr = /:(\w+):/, hn = () => new RegExp(`\\B${jr.source}\\B`, "g");
3144
3144
  function* oc(e) {
3145
- const t = e.matchAll(dn());
3145
+ const t = e.matchAll(hn());
3146
3146
  for (const n of t)
3147
3147
  try {
3148
3148
  const [r, i] = n;
@@ -3156,52 +3156,52 @@ function* oc(e) {
3156
3156
  }
3157
3157
  }
3158
3158
  function sc(e, t) {
3159
- return e.replaceAll(dn(), (n, r) => t({
3159
+ return e.replaceAll(hn(), (n, r) => t({
3160
3160
  shortcode: n,
3161
3161
  name: r
3162
3162
  }));
3163
3163
  }
3164
3164
  var ac = {};
3165
- q(ac, {
3165
+ D(ac, {
3166
3166
  useFetchImplementation: () => cc,
3167
- validateGithub: () => uc
3167
+ validateGithub: () => lc
3168
3168
  });
3169
- var gn;
3169
+ var dn;
3170
3170
  try {
3171
- gn = fetch;
3171
+ dn = fetch;
3172
3172
  } catch {
3173
3173
  }
3174
3174
  function cc(e) {
3175
- gn = e;
3175
+ dn = e;
3176
3176
  }
3177
- async function uc(e, t, n) {
3177
+ async function lc(e, t, n) {
3178
3178
  try {
3179
- return await (await gn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
3179
+ return await (await dn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
3180
3180
  } catch {
3181
3181
  return !1;
3182
3182
  }
3183
3183
  }
3184
- var fe = {};
3185
- q(fe, {
3184
+ var V = {};
3185
+ D(V, {
3186
3186
  decrypt: () => Jr,
3187
3187
  encrypt: () => Gr,
3188
3188
  getConversationKey: () => Zr,
3189
- v2: () => gc
3189
+ v2: () => yc
3190
3190
  });
3191
3191
  var Vr = 1, zr = 65535;
3192
3192
  function Zr(e, t) {
3193
- const n = Le.getSharedSecret(e, "02" + t).subarray(1, 33);
3194
- return rn(Ne, n, "nip44-v2");
3193
+ const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
3194
+ return nn(Ae, n, "nip44-v2");
3195
3195
  }
3196
3196
  function Fr(e, t) {
3197
- const n = xr(Ne, e, t, 76);
3197
+ const n = mr(Ae, e, t, 76);
3198
3198
  return {
3199
3199
  chacha_key: n.subarray(0, 32),
3200
3200
  chacha_nonce: n.subarray(32, 44),
3201
3201
  hmac_key: n.subarray(44, 76)
3202
3202
  };
3203
3203
  }
3204
- function pn(e) {
3204
+ function yn(e) {
3205
3205
  if (!Number.isSafeInteger(e) || e < 1)
3206
3206
  throw new Error("expected positive integer");
3207
3207
  if (e <= 32)
@@ -3209,27 +3209,27 @@ function pn(e) {
3209
3209
  const t = 1 << Math.floor(Math.log2(e - 1)) + 1, n = t <= 256 ? 32 : t / 8;
3210
3210
  return n * (Math.floor((e - 1) / n) + 1);
3211
3211
  }
3212
- function lc(e) {
3212
+ function uc(e) {
3213
3213
  if (!Number.isSafeInteger(e) || e < Vr || e > zr)
3214
3214
  throw new Error("invalid plaintext size: must be between 1 and 65535 bytes");
3215
3215
  const t = new Uint8Array(2);
3216
3216
  return new DataView(t.buffer).setUint16(0, e, !1), t;
3217
3217
  }
3218
3218
  function fc(e) {
3219
- const t = ee.encode(e), n = t.length, r = lc(n), i = new Uint8Array(pn(n) - n);
3220
- return pt(r, t, i);
3219
+ const t = te.encode(e), n = t.length, r = uc(n), i = new Uint8Array(yn(n) - n);
3220
+ return yt(r, t, i);
3221
3221
  }
3222
3222
  function hc(e) {
3223
3223
  const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t);
3224
- if (t < Vr || t > zr || n.length !== t || e.length !== 2 + pn(t))
3224
+ if (t < Vr || t > zr || n.length !== t || e.length !== 2 + yn(t))
3225
3225
  throw new Error("invalid padding");
3226
- return re.decode(n);
3226
+ return ie.decode(n);
3227
3227
  }
3228
3228
  function Wr(e, t, n) {
3229
3229
  if (n.length !== 32)
3230
3230
  throw new Error("AAD associated data must be 32 bytes");
3231
- const r = pt(n, t);
3232
- return wt(Ne, e, r);
3231
+ const r = yt(n, t);
3232
+ return pt(Ae, e, r);
3233
3233
  }
3234
3234
  function dc(e) {
3235
3235
  if (typeof e != "string")
@@ -3241,7 +3241,7 @@ function dc(e) {
3241
3241
  throw new Error("unknown encryption version");
3242
3242
  let n;
3243
3243
  try {
3244
- n = he.decode(e);
3244
+ n = ue.decode(e);
3245
3245
  } catch (o) {
3246
3246
  throw new Error("invalid base64: " + o.message);
3247
3247
  }
@@ -3259,28 +3259,28 @@ function dc(e) {
3259
3259
  }
3260
3260
  function Gr(e, t, n = ir(32)) {
3261
3261
  const { chacha_key: r, chacha_nonce: i, hmac_key: o } = Fr(t, n), s = fc(e), c = br(r, i, s), a = Wr(o, c, n);
3262
- return he.encode(pt(new Uint8Array([2]), n, c, a));
3262
+ return ue.encode(yt(new Uint8Array([2]), n, c, a));
3263
3263
  }
3264
3264
  function Jr(e, t) {
3265
3265
  const { nonce: n, ciphertext: r, mac: i } = dc(e), { chacha_key: o, chacha_nonce: s, hmac_key: c } = Fr(t, n), a = Wr(c, r, n);
3266
3266
  if (!So(a, i))
3267
3267
  throw new Error("invalid MAC");
3268
- const u = br(o, s, r);
3269
- return hc(u);
3268
+ const l = br(o, s, r);
3269
+ return hc(l);
3270
3270
  }
3271
- var gc = {
3271
+ var yc = {
3272
3272
  utils: {
3273
3273
  getConversationKey: Zr,
3274
- calcPaddedLen: pn
3274
+ calcPaddedLen: yn
3275
3275
  },
3276
3276
  encrypt: Gr,
3277
3277
  decrypt: Jr
3278
- }, pc = {};
3279
- q(pc, {
3278
+ }, gc = {};
3279
+ D(gc, {
3280
3280
  makeNwcRequestEvent: () => wc,
3281
- parseConnectionString: () => yc
3281
+ parseConnectionString: () => pc
3282
3282
  });
3283
- function yc(e) {
3283
+ function pc(e) {
3284
3284
  const { pathname: t, searchParams: n } = new URL(e), r = t, i = n.get("relay"), o = n.get("secret");
3285
3285
  if (!r || !i || !o)
3286
3286
  throw new Error("invalid connection string");
@@ -3293,48 +3293,48 @@ async function wc(e, t, n) {
3293
3293
  invoice: n
3294
3294
  }
3295
3295
  })), o = {
3296
- kind: kr,
3296
+ kind: Lr,
3297
3297
  created_at: Math.round(Date.now() / 1e3),
3298
3298
  content: i,
3299
3299
  tags: [["p", e]]
3300
3300
  };
3301
- return se(o, t);
3301
+ return ae(o, t);
3302
3302
  }
3303
3303
  var bc = {};
3304
- q(bc, {
3305
- getZapEndpoint: () => xc,
3304
+ D(bc, {
3305
+ getZapEndpoint: () => mc,
3306
3306
  makeZapReceipt: () => Ac,
3307
- makeZapRequest: () => mc,
3307
+ makeZapRequest: () => Ec,
3308
3308
  useFetchImplementation: () => vc,
3309
- validateZapRequest: () => Ec
3309
+ validateZapRequest: () => xc
3310
3310
  });
3311
- var yn;
3311
+ var gn;
3312
3312
  try {
3313
- yn = fetch;
3313
+ gn = fetch;
3314
3314
  } catch {
3315
3315
  }
3316
3316
  function vc(e) {
3317
- yn = e;
3317
+ gn = e;
3318
3318
  }
3319
- async function xc(e) {
3319
+ async function mc(e) {
3320
3320
  try {
3321
3321
  let t = "", { lud06: n, lud16: r } = JSON.parse(e.content);
3322
3322
  if (n) {
3323
3323
  let { words: s } = De.decode(n, 1e3), c = De.fromWords(s);
3324
- t = re.decode(c);
3324
+ t = ie.decode(c);
3325
3325
  } else if (r) {
3326
3326
  let [s, c] = r.split("@");
3327
3327
  t = new URL(`/.well-known/lnurlp/${s}`, `https://${c}`).toString();
3328
3328
  } else
3329
3329
  return null;
3330
- let o = await (await yn(t)).json();
3330
+ let o = await (await gn(t)).json();
3331
3331
  if (o.allowsNostr && o.nostrPubkey)
3332
3332
  return o.callback;
3333
3333
  } catch {
3334
3334
  }
3335
3335
  return null;
3336
3336
  }
3337
- function mc({
3337
+ function Ec({
3338
3338
  profile: e,
3339
3339
  event: t,
3340
3340
  amount: n,
@@ -3357,16 +3357,16 @@ function mc({
3357
3357
  };
3358
3358
  return t && o.tags.push(["e", t]), o;
3359
3359
  }
3360
- function Ec(e) {
3360
+ function xc(e) {
3361
3361
  let t;
3362
3362
  try {
3363
3363
  t = JSON.parse(e);
3364
3364
  } catch {
3365
3365
  return "Invalid zap request JSON.";
3366
3366
  }
3367
- if (!mr(t))
3367
+ if (!Er(t))
3368
3368
  return "Zap request is not a valid Nostr event.";
3369
- if (!sn(t))
3369
+ if (!on(t))
3370
3370
  return "Invalid signature on zap request.";
3371
3371
  let n = t.tags.find(([o, s]) => o === "p" && s);
3372
3372
  if (!n)
@@ -3391,9 +3391,9 @@ function Ac({
3391
3391
  return t && s.tags.push(["preimage", t]), s;
3392
3392
  }
3393
3393
  var Sc = {};
3394
- q(Sc, {
3395
- getToken: () => Bc,
3396
- hashPayload: () => wn,
3394
+ D(Sc, {
3395
+ getToken: () => Kc,
3396
+ hashPayload: () => pn,
3397
3397
  unpackEventFromToken: () => Xr,
3398
3398
  validateEvent: () => ii,
3399
3399
  validateEventKind: () => ei,
@@ -3401,12 +3401,12 @@ q(Sc, {
3401
3401
  validateEventPayloadTag: () => ri,
3402
3402
  validateEventTimestamp: () => Qr,
3403
3403
  validateEventUrlTag: () => ti,
3404
- validateToken: () => Nc
3404
+ validateToken: () => Bc
3405
3405
  });
3406
3406
  var Yr = "Nostr ";
3407
- async function Bc(e, t, n, r = !1, i) {
3407
+ async function Kc(e, t, n, r = !1, i) {
3408
3408
  const o = {
3409
- kind: un,
3409
+ kind: cn,
3410
3410
  tags: [
3411
3411
  ["u", e],
3412
3412
  ["method", t]
@@ -3414,11 +3414,11 @@ async function Bc(e, t, n, r = !1, i) {
3414
3414
  created_at: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
3415
3415
  content: ""
3416
3416
  };
3417
- i && o.tags.push(["payload", wn(i)]);
3417
+ i && o.tags.push(["payload", pn(i)]);
3418
3418
  const s = await n(o);
3419
- return (r ? Yr : "") + he.encode(ee.encode(JSON.stringify(s)));
3419
+ return (r ? Yr : "") + ue.encode(te.encode(JSON.stringify(s)));
3420
3420
  }
3421
- async function Nc(e, t, n) {
3421
+ async function Bc(e, t, n) {
3422
3422
  const r = await Xr(e).catch((o) => {
3423
3423
  throw o;
3424
3424
  });
@@ -3430,7 +3430,7 @@ async function Xr(e) {
3430
3430
  if (!e)
3431
3431
  throw new Error("Missing token");
3432
3432
  e = e.replace(Yr, "");
3433
- const t = re.decode(he.decode(e));
3433
+ const t = ie.decode(ue.decode(e));
3434
3434
  if (!t || t.length === 0 || !t.startsWith("{"))
3435
3435
  throw new Error("Invalid token");
3436
3436
  return JSON.parse(t);
@@ -3439,7 +3439,7 @@ function Qr(e) {
3439
3439
  return e.created_at ? Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3) - e.created_at < 60 : !1;
3440
3440
  }
3441
3441
  function ei(e) {
3442
- return e.kind === un;
3442
+ return e.kind === cn;
3443
3443
  }
3444
3444
  function ti(e, t) {
3445
3445
  const n = e.tags.find((r) => r[0] === "u");
@@ -3449,19 +3449,19 @@ function ni(e, t) {
3449
3449
  const n = e.tags.find((r) => r[0] === "method");
3450
3450
  return n ? n.length > 0 && n[1].toLowerCase() === t.toLowerCase() : !1;
3451
3451
  }
3452
- function wn(e) {
3453
- const t = Ne(ee.encode(JSON.stringify(e)));
3454
- return D(t);
3452
+ function pn(e) {
3453
+ const t = Ae(te.encode(JSON.stringify(e)));
3454
+ return M(t);
3455
3455
  }
3456
3456
  function ri(e, t) {
3457
3457
  const n = e.tags.find((i) => i[0] === "payload");
3458
3458
  if (!n)
3459
3459
  return !1;
3460
- const r = wn(t);
3460
+ const r = pn(t);
3461
3461
  return n.length > 0 && n[1] === r;
3462
3462
  }
3463
3463
  async function ii(e, t, n, r) {
3464
- if (!sn(e))
3464
+ if (!on(e))
3465
3465
  throw new Error("Invalid nostr event, signature invalid");
3466
3466
  if (!ei(e))
3467
3467
  throw new Error("Invalid nostr event, kind invalid");
@@ -3475,60 +3475,60 @@ async function ii(e, t, n, r) {
3475
3475
  throw new Error("Invalid nostr event, payload tag does not match request body hash");
3476
3476
  return !0;
3477
3477
  }
3478
- const We = 4, Tc = 100;
3479
- var ae = /* @__PURE__ */ ((e) => (e[e.Us = 0] = "Us", e[e.Them = 1] = "Them", e))(ae || {}), ce = /* @__PURE__ */ ((e) => (e[e.Current = 0] = "Current", e[e.Next = 1] = "Next", e))(ce || {});
3480
- function $c(e) {
3478
+ const Me = 4, Tc = 100;
3479
+ var Nc = /* @__PURE__ */ ((e) => (e[e.Us = 0] = "Us", e[e.Them = 1] = "Them", e))(Nc || {});
3480
+ function Rc(e) {
3481
3481
  return JSON.stringify({
3482
- theirCurrentNostrPublicKey: e.theirCurrentNostrPublicKey,
3483
- ourCurrentNostrKey: {
3482
+ rootKey: M(e.rootKey),
3483
+ theirNostrPublicKey: e.theirNostrPublicKey,
3484
+ ourCurrentNostrKey: e.ourCurrentNostrKey ? {
3484
3485
  publicKey: e.ourCurrentNostrKey.publicKey,
3485
- privateKey: D(e.ourCurrentNostrKey.privateKey)
3486
- },
3486
+ privateKey: M(e.ourCurrentNostrKey.privateKey)
3487
+ } : void 0,
3487
3488
  ourNextNostrKey: {
3488
3489
  publicKey: e.ourNextNostrKey.publicKey,
3489
- privateKey: D(e.ourNextNostrKey.privateKey)
3490
+ privateKey: M(e.ourNextNostrKey.privateKey)
3490
3491
  },
3491
- receivingChainKey: D(e.receivingChainKey),
3492
- nextReceivingChainKey: D(e.nextReceivingChainKey),
3493
- sendingChainKey: D(e.sendingChainKey),
3492
+ receivingChainKey: e.receivingChainKey ? M(e.receivingChainKey) : void 0,
3493
+ sendingChainKey: e.sendingChainKey ? M(e.sendingChainKey) : void 0,
3494
3494
  sendingChainMessageNumber: e.sendingChainMessageNumber,
3495
3495
  receivingChainMessageNumber: e.receivingChainMessageNumber,
3496
3496
  previousSendingChainMessageCount: e.previousSendingChainMessageCount,
3497
3497
  skippedMessageKeys: Object.fromEntries(
3498
3498
  Object.entries(e.skippedMessageKeys).map(([t, n]) => [
3499
3499
  t,
3500
- D(n)
3500
+ M(n)
3501
3501
  ])
3502
3502
  )
3503
3503
  });
3504
3504
  }
3505
- function Rc(e) {
3505
+ function Pc(e) {
3506
3506
  const t = JSON.parse(e);
3507
3507
  return {
3508
- theirCurrentNostrPublicKey: t.theirCurrentNostrPublicKey,
3509
- ourCurrentNostrKey: {
3508
+ rootKey: Y(t.rootKey),
3509
+ theirNostrPublicKey: t.theirNostrPublicKey,
3510
+ ourCurrentNostrKey: t.ourCurrentNostrKey ? {
3510
3511
  publicKey: t.ourCurrentNostrKey.publicKey,
3511
- privateKey: W(t.ourCurrentNostrKey.privateKey)
3512
- },
3512
+ privateKey: Y(t.ourCurrentNostrKey.privateKey)
3513
+ } : void 0,
3513
3514
  ourNextNostrKey: {
3514
3515
  publicKey: t.ourNextNostrKey.publicKey,
3515
- privateKey: W(t.ourNextNostrKey.privateKey)
3516
+ privateKey: Y(t.ourNextNostrKey.privateKey)
3516
3517
  },
3517
- receivingChainKey: W(t.receivingChainKey),
3518
- nextReceivingChainKey: W(t.nextReceivingChainKey),
3519
- sendingChainKey: W(t.sendingChainKey),
3518
+ receivingChainKey: t.receivingChainKey ? Y(t.receivingChainKey) : void 0,
3519
+ sendingChainKey: t.sendingChainKey ? Y(t.sendingChainKey) : void 0,
3520
3520
  sendingChainMessageNumber: t.sendingChainMessageNumber,
3521
3521
  receivingChainMessageNumber: t.receivingChainMessageNumber,
3522
3522
  previousSendingChainMessageCount: t.previousSendingChainMessageCount,
3523
3523
  skippedMessageKeys: Object.fromEntries(
3524
3524
  Object.entries(t.skippedMessageKeys).map(([n, r]) => [
3525
3525
  n,
3526
- W(r)
3526
+ Y(r)
3527
3527
  ])
3528
3528
  )
3529
3529
  };
3530
3530
  }
3531
- async function* Pc(e) {
3531
+ async function* Oc(e) {
3532
3532
  const t = [];
3533
3533
  let n = null;
3534
3534
  const r = e.onMessage((i) => {
@@ -3543,108 +3543,167 @@ async function* Pc(e) {
3543
3543
  r();
3544
3544
  }
3545
3545
  }
3546
- function Cc(e, t = new Uint8Array(32)) {
3547
- const n = rn(Ne, e, t);
3548
- return xr(Ne, n, new Uint8Array([1]), 32);
3546
+ function Re(e, t = new Uint8Array(32), n = 1) {
3547
+ const r = nn(Ae, e, t), i = [];
3548
+ for (let o = 1; o <= n; o++)
3549
+ i.push(mr(Ae, r, new Uint8Array([o]), 32));
3550
+ return i;
3551
+ }
3552
+ function Rn(e, t) {
3553
+ return `${e}:${t}`;
3549
3554
  }
3555
+ const Cc = 1e3;
3550
3556
  class lt {
3551
3557
  constructor(t, n) {
3552
- Q(this, "nostrUnsubscribe");
3553
- Q(this, "nostrNextUnsubscribe");
3554
- Q(this, "currentInternalSubscriptionId", 0);
3555
- Q(this, "internalSubscriptions", /* @__PURE__ */ new Map());
3556
- Q(this, "name", Math.random().toString(36).substring(2, 6));
3558
+ ee(this, "nostrUnsubscribe");
3559
+ ee(this, "nostrNextUnsubscribe");
3560
+ ee(this, "internalSubscriptions", /* @__PURE__ */ new Map());
3561
+ ee(this, "currentInternalSubscriptionId", 0);
3562
+ ee(this, "name");
3557
3563
  this.nostrSubscribe = t, this.state = n, this.name = Math.random().toString(36).substring(2, 6);
3558
3564
  }
3559
3565
  /**
3560
- * To preserve forward secrecy, do not use long-term keys for channel initialization. Use e.g. InviteLink to exchange session keys.
3566
+ * @param sharedSecret optional, but useful to keep the first chain of messages secure. Unlike the Nostr keys, it can be forgotten after the 1st message in the chain.
3567
+ * @param isInitiator determines which chain key is used for sending vs receiving
3561
3568
  */
3562
- static init(t, n, r, i) {
3563
- const o = He(), s = {
3564
- theirCurrentNostrPublicKey: n,
3565
- ourCurrentNostrKey: { publicKey: Ee(r), privateKey: r },
3566
- ourNextNostrKey: { publicKey: Ee(o), privateKey: o },
3567
- receivingChainKey: new Uint8Array(),
3568
- nextReceivingChainKey: new Uint8Array(),
3569
- sendingChainKey: new Uint8Array(),
3569
+ static init(t, n, r, i = new Uint8Array(), o, s = !0) {
3570
+ const c = Oe(), [a, l] = Re(i, V.getConversationKey(c, n), 2);
3571
+ let f, u;
3572
+ s ? (f = { publicKey: Ce(r), privateKey: r }, u = { publicKey: Ce(c), privateKey: c }) : u = { publicKey: Ce(r), privateKey: r };
3573
+ const d = {
3574
+ rootKey: s ? a : i,
3575
+ theirNostrPublicKey: n,
3576
+ ourCurrentNostrKey: f,
3577
+ ourNextNostrKey: u,
3578
+ receivingChainKey: void 0,
3579
+ sendingChainKey: s ? l : void 0,
3570
3580
  sendingChainMessageNumber: 0,
3571
3581
  receivingChainMessageNumber: 0,
3572
3582
  previousSendingChainMessageCount: 0,
3573
3583
  skippedMessageKeys: {}
3574
- }, c = new lt(t, s);
3575
- return c.updateTheirCurrentNostrPublicKey(n), i && (c.name = i), c;
3584
+ }, g = new lt(t, d);
3585
+ return o && (g.name = o), console.log(g.name, "initial root key", M(d.rootKey).slice(0, 4)), g;
3576
3586
  }
3577
- updateTheirCurrentNostrPublicKey(t) {
3578
- this.state.theirCurrentNostrPublicKey = t, this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0, this.state.receivingChainKey = this.getNostrSenderKeypair(ae.Them, ce.Current).privateKey, this.state.nextReceivingChainKey = this.getNostrSenderKeypair(ae.Them, ce.Next).privateKey, this.state.sendingChainKey = this.getNostrSenderKeypair(ae.Us, ce.Current).privateKey;
3587
+ send(t) {
3588
+ if (!this.state.theirNostrPublicKey || !this.state.ourCurrentNostrKey)
3589
+ throw new Error("we are not the initiator, so we can't send the first message");
3590
+ const [n, r] = this.ratchetEncrypt(t), i = V.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNostrPublicKey), o = V.encrypt(JSON.stringify(n), i);
3591
+ return ae({
3592
+ content: r,
3593
+ kind: Me,
3594
+ tags: [["header", o]],
3595
+ created_at: Math.floor(Date.now() / 1e3)
3596
+ }, this.state.ourCurrentNostrKey.privateKey);
3579
3597
  }
3580
- rotateOurCurrentNostrKey() {
3581
- this.state.ourCurrentNostrKey = this.state.ourNextNostrKey;
3582
- const t = He();
3598
+ onMessage(t) {
3599
+ const n = this.currentInternalSubscriptionId++;
3600
+ return this.internalSubscriptions.set(n, t), this.subscribeToNostrEvents(), () => this.internalSubscriptions.delete(n);
3601
+ }
3602
+ ratchetEncrypt(t) {
3603
+ const [n, r] = Re(this.state.sendingChainKey, new Uint8Array([1]), 2);
3604
+ return this.state.sendingChainKey = n, [{
3605
+ number: this.state.sendingChainMessageNumber++,
3606
+ nextPublicKey: this.state.ourNextNostrKey.publicKey,
3607
+ time: Date.now(),
3608
+ previousChainLength: this.state.previousSendingChainMessageCount
3609
+ }, V.encrypt(t, r)];
3610
+ }
3611
+ ratchetDecrypt(t, n, r) {
3612
+ const i = this.trySkippedMessageKeys(t, n, r);
3613
+ if (i) return i;
3614
+ this.skipMessageKeys(t.number, r);
3615
+ const [o, s] = Re(this.state.receivingChainKey, new Uint8Array([1]), 2);
3616
+ this.state.receivingChainKey = o, this.state.receivingChainMessageNumber++;
3617
+ try {
3618
+ return V.decrypt(n, s);
3619
+ } catch (c) {
3620
+ throw console.error(this.name, "Decryption failed:", c, {
3621
+ messageKey: M(s).slice(0, 4),
3622
+ receivingChainKey: M(this.state.receivingChainKey).slice(0, 4),
3623
+ sendingChainKey: this.state.sendingChainKey && M(this.state.sendingChainKey).slice(0, 4),
3624
+ rootKey: M(this.state.rootKey).slice(0, 4)
3625
+ }), c;
3626
+ }
3627
+ }
3628
+ ratchetStep(t) {
3629
+ this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0, this.state.theirNostrPublicKey = t;
3630
+ const n = V.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [r, i] = Re(this.state.rootKey, n, 3);
3631
+ this.state.receivingChainKey = i, this.state.ourCurrentNostrKey = this.state.ourNextNostrKey;
3632
+ const o = Oe();
3583
3633
  this.state.ourNextNostrKey = {
3584
- publicKey: Ee(t),
3585
- privateKey: t
3634
+ publicKey: Ce(o),
3635
+ privateKey: o
3586
3636
  };
3637
+ const s = V.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNostrPublicKey), [c, a] = Re(r, s, 3);
3638
+ this.state.rootKey = c, this.state.sendingChainKey = a;
3587
3639
  }
3588
- getNostrSenderKeypair(t, n) {
3589
- if (t === ae.Us && n === ce.Next)
3590
- throw new Error("We don't have their next key");
3591
- const r = n === ce.Current ? this.state.ourCurrentNostrKey.privateKey : this.state.ourNextNostrKey.privateKey, i = this.state.theirCurrentNostrPublicKey, o = t === ae.Us ? Ee(r) : i, s = Cc(fe.getConversationKey(r, i), W(o));
3592
- return {
3593
- publicKey: Ee(s),
3594
- privateKey: s
3595
- };
3640
+ skipMessageKeys(t, n) {
3641
+ if (this.state.receivingChainMessageNumber + Cc < t)
3642
+ throw new Error("Too many skipped messages");
3643
+ for (; this.state.receivingChainMessageNumber < t; ) {
3644
+ const [r, i] = Re(this.state.receivingChainKey, new Uint8Array([1]), 2);
3645
+ this.state.receivingChainKey = r;
3646
+ const o = Rn(n, this.state.receivingChainMessageNumber);
3647
+ this.state.skippedMessageKeys[o] = i, this.state.receivingChainMessageNumber++;
3648
+ }
3596
3649
  }
3597
- nostrSubscribeNext() {
3598
- const t = this.getNostrSenderKeypair(ae.Them, ce.Next).publicKey, n = this.state.nextReceivingChainKey;
3599
- this.nostrNextUnsubscribe = this.nostrSubscribe({ authors: [t], kinds: [We] }, (r) => {
3600
- var o;
3601
- const i = JSON.parse(fe.decrypt(r.content, n));
3602
- i.nextPublicKey !== this.state.theirCurrentNostrPublicKey && (this.rotateOurCurrentNostrKey(), this.updateTheirCurrentNostrPublicKey(i.nextPublicKey), (o = this.nostrUnsubscribe) == null || o.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrSubscribeNext()), this.internalSubscriptions.forEach((s) => s({ id: r.id, data: i.data, pubkey: i.nextPublicKey, time: i.time }));
3603
- });
3650
+ trySkippedMessageKeys(t, n, r) {
3651
+ const i = Rn(r, t.number);
3652
+ if (i in this.state.skippedMessageKeys) {
3653
+ const o = this.state.skippedMessageKeys[i];
3654
+ return delete this.state.skippedMessageKeys[i], V.decrypt(n, o);
3655
+ }
3656
+ return null;
3604
3657
  }
3605
- subscribeToNostrEvents() {
3606
- if (this.nostrUnsubscribe)
3607
- return;
3608
- const t = this.getNostrSenderKeypair(ae.Them, ce.Current).publicKey, n = this.state.receivingChainKey;
3609
- this.nostrUnsubscribe = this.nostrSubscribe({ authors: [t], kinds: [We] }, (r) => {
3610
- const i = JSON.parse(fe.decrypt(r.content, n));
3611
- i.nextPublicKey !== this.state.theirCurrentNostrPublicKey && this.updateTheirCurrentNostrPublicKey(i.nextPublicKey), this.internalSubscriptions.forEach((o) => o({ id: r.id, data: i.data, pubkey: i.nextPublicKey, time: i.time }));
3612
- }), this.nostrSubscribeNext();
3658
+ decryptHeader(t) {
3659
+ const n = t.tags[0][1];
3660
+ if (this.state.ourCurrentNostrKey) {
3661
+ const i = V.getConversationKey(this.state.ourCurrentNostrKey.privateKey, t.pubkey);
3662
+ try {
3663
+ return [JSON.parse(V.decrypt(n, i)), !1];
3664
+ } catch {
3665
+ }
3666
+ }
3667
+ const r = V.getConversationKey(this.state.ourNextNostrKey.privateKey, t.pubkey);
3668
+ try {
3669
+ return [JSON.parse(V.decrypt(n, r)), !0];
3670
+ } catch {
3671
+ }
3672
+ throw new Error("Failed to decrypt header with both current and next secrets");
3613
3673
  }
3614
- onMessage(t) {
3615
- const n = this.currentInternalSubscriptionId++;
3616
- return this.internalSubscriptions.set(n, t), this.subscribeToNostrEvents(), () => this.internalSubscriptions.delete(n);
3674
+ handleNostrEvent(t) {
3675
+ var o;
3676
+ const [n, r] = this.decryptHeader(t);
3677
+ this.state.theirNostrPublicKey !== n.nextPublicKey && (this.state.theirNostrPublicKey = n.nextPublicKey, (o = this.nostrUnsubscribe) == null || o.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
3678
+ { authors: [this.state.theirNostrPublicKey], kinds: [Me] },
3679
+ (s) => this.handleNostrEvent(s)
3680
+ )), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey));
3681
+ const i = this.ratchetDecrypt(n, t.content, t.pubkey);
3682
+ this.internalSubscriptions.forEach((s) => s({ id: t.id, data: i, pubkey: n.nextPublicKey, time: n.time }));
3617
3683
  }
3618
- send(t) {
3619
- const n = {
3620
- number: this.state.sendingChainMessageNumber,
3621
- data: t,
3622
- nextPublicKey: this.state.ourNextNostrKey.publicKey,
3623
- time: Date.now()
3624
- };
3625
- this.state.sendingChainMessageNumber++;
3626
- const r = this.getNostrSenderKeypair(ae.Us, ce.Current).privateKey, i = fe.encrypt(JSON.stringify(n), this.state.sendingChainKey);
3627
- return se({
3628
- content: i,
3629
- kind: We,
3630
- tags: [],
3631
- created_at: Math.floor(Date.now() / 1e3)
3632
- }, r);
3684
+ subscribeToNostrEvents() {
3685
+ this.nostrNextUnsubscribe || (this.state.theirNostrPublicKey && (this.nostrUnsubscribe = this.nostrSubscribe(
3686
+ { authors: [this.state.theirNostrPublicKey], kinds: [Me] },
3687
+ (t) => this.handleNostrEvent(t)
3688
+ )), this.nostrNextUnsubscribe = this.nostrSubscribe(
3689
+ { authors: [this.state.theirNostrPublicKey], kinds: [Me] },
3690
+ (t) => this.handleNostrEvent(t)
3691
+ ));
3633
3692
  }
3634
3693
  }
3635
3694
  new TextDecoder("utf-8");
3636
3695
  new TextEncoder();
3637
- function tt(e, t) {
3638
- const n = Le.getSharedSecret(e, "02" + t).subarray(1, 33);
3639
- return rn(Ne, n, "nip44-v2");
3696
+ function et(e, t) {
3697
+ const n = Ue.getSharedSecret(e, "02" + t).subarray(1, 33);
3698
+ return nn(Ae, n, "nip44-v2");
3640
3699
  }
3641
- class rt {
3700
+ class nt {
3642
3701
  constructor(t, n, r, i, o, s, c = []) {
3643
3702
  this.inviterSessionPublicKey = t, this.linkSecret = n, this.inviter = r, this.inviterSessionPrivateKey = i, this.label = o, this.maxUses = s, this.usedBy = c;
3644
3703
  }
3645
3704
  static createNew(t, n, r) {
3646
- const i = He(), o = Ee(i), s = ut.encode(He()).slice(8, 40);
3647
- return new rt(
3705
+ const i = Oe(), o = Ce(i), s = ct.encode(Oe()).slice(8, 40);
3706
+ return new nt(
3648
3707
  o,
3649
3708
  s,
3650
3709
  t,
@@ -3664,12 +3723,12 @@ class rt {
3664
3723
  throw new Error("Decoded inviter is not a string");
3665
3724
  if (typeof c.data != "string")
3666
3725
  throw new Error("Decoded session key is not a string");
3667
- const a = s.data, u = c.data;
3668
- return new rt(u, o, a);
3726
+ const a = s.data, l = c.data;
3727
+ return new nt(l, o, a);
3669
3728
  }
3670
3729
  static deserialize(t) {
3671
3730
  const n = JSON.parse(t);
3672
- return new rt(
3731
+ return new nt(
3673
3732
  n.inviterSessionPublicKey,
3674
3733
  n.linkSecret,
3675
3734
  n.inviter,
@@ -3710,36 +3769,36 @@ class rt {
3710
3769
  * so the inviter can create the channel on their side.
3711
3770
  */
3712
3771
  async acceptInvite(t, n, r) {
3713
- const i = He(), o = Ee(i), s = this.inviter || this.inviterSessionPublicKey, c = lt.init(t, this.inviterSessionPublicKey, i), a = He(), u = Ee(a), f = typeof r == "function" ? r : (w, y) => Promise.resolve(fe.encrypt(w, tt(r, y))), l = {
3772
+ const i = Oe(), o = Ce(i), s = this.inviter || this.inviterSessionPublicKey, c = lt.init(t, this.inviterSessionPublicKey, i, new Uint8Array(), void 0, !0), a = Oe(), l = Ce(a), f = typeof r == "function" ? r : (g, w) => Promise.resolve(V.encrypt(g, et(r, w))), u = {
3714
3773
  pubkey: n,
3715
3774
  tags: [["secret", this.linkSecret]],
3716
3775
  content: await f(o, s),
3717
3776
  created_at: Math.floor(Date.now() / 1e3)
3718
3777
  }, d = {
3719
- kind: We,
3720
- pubkey: u,
3721
- content: fe.encrypt(JSON.stringify(l), tt(a, this.inviterSessionPublicKey)),
3778
+ kind: Me,
3779
+ pubkey: l,
3780
+ content: V.encrypt(JSON.stringify(u), et(a, this.inviterSessionPublicKey)),
3722
3781
  created_at: Math.floor(Date.now() / 1e3),
3723
3782
  tags: [["p", this.inviterSessionPublicKey]]
3724
3783
  };
3725
- return { channel: c, event: se(d, a) };
3784
+ return { channel: c, event: ae(d, a) };
3726
3785
  }
3727
3786
  listen(t, n, r) {
3728
3787
  if (!this.inviterSessionPrivateKey)
3729
3788
  throw new Error("Inviter session key is not available");
3730
3789
  const i = {
3731
- kinds: [We],
3790
+ kinds: [Me],
3732
3791
  "#p": [this.inviterSessionPublicKey]
3733
3792
  };
3734
3793
  return n(i, async (o) => {
3735
3794
  try {
3736
- const s = await fe.decrypt(o.content, tt(this.inviterSessionPrivateKey, o.pubkey)), c = JSON.parse(s);
3737
- if (!c.tags || !c.tags.some(([l, d]) => l === "secret" && d === this.linkSecret)) {
3795
+ const s = await V.decrypt(o.content, et(this.inviterSessionPrivateKey, o.pubkey)), c = JSON.parse(s);
3796
+ if (!c.tags || !c.tags.some(([d, g]) => d === "secret" && g === this.linkSecret)) {
3738
3797
  console.error("Invalid secret from event", o);
3739
3798
  return;
3740
3799
  }
3741
- const u = await (typeof t == "function" ? t : (l, d) => Promise.resolve(fe.decrypt(l, tt(t, d))))(c.content, c.pubkey), f = lt.init(n, u, this.inviterSessionPrivateKey);
3742
- r(f, c.pubkey);
3800
+ const l = await (typeof t == "function" ? t : (d, g) => Promise.resolve(V.decrypt(d, et(t, g))))(c.content, c.pubkey), f = o.id, u = lt.init(n, l, this.inviterSessionPrivateKey, new Uint8Array(), f, !1);
3801
+ r(u, c.pubkey);
3743
3802
  } catch (s) {
3744
3803
  console.error("Error processing invite message:", s);
3745
3804
  }
@@ -3748,13 +3807,13 @@ class rt {
3748
3807
  }
3749
3808
  export {
3750
3809
  lt as Channel,
3751
- We as EVENT_KIND,
3752
- rt as InviteLink,
3753
- ce as KeyType,
3810
+ Me as EVENT_KIND,
3811
+ nt as InviteLink,
3754
3812
  Tc as MAX_SKIP,
3755
- ae as Sender,
3756
- Pc as createMessageStream,
3757
- Rc as deserializeChannelState,
3758
- Cc as kdf,
3759
- $c as serializeChannelState
3813
+ Nc as Sender,
3814
+ Oc as createMessageStream,
3815
+ Pc as deserializeChannelState,
3816
+ Re as kdf,
3817
+ Rc as serializeChannelState,
3818
+ Rn as skippedMessageIndexKey
3760
3819
  };