nostr-double-ratchet 0.0.20 → 0.0.22
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.
- package/dist/Invite.d.ts.map +1 -1
- package/dist/Session.d.ts.map +1 -1
- package/dist/nostr-double-ratchet.es.js +767 -744
- package/dist/nostr-double-ratchet.umd.js +1 -1
- package/dist/types.d.ts +10 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Invite.ts +13 -14
- package/src/Session.ts +40 -46
- package/src/types.ts +9 -5
- package/src/utils.ts +64 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var bi = Object.defineProperty;
|
|
2
2
|
var vi = (e, t, n) => t in e ? bi(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
3
|
var te = (e, t, n) => vi(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
-
function
|
|
4
|
+
function Sn(e) {
|
|
5
5
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
6
6
|
throw new Error(`Wrong positive integer: ${e}`);
|
|
7
7
|
}
|
|
@@ -11,10 +11,10 @@ function zn(e, ...t) {
|
|
|
11
11
|
if (t.length > 0 && !t.includes(e.length))
|
|
12
12
|
throw new Error(`Expected Uint8Array of length ${t}, not of length=${e.length}`);
|
|
13
13
|
}
|
|
14
|
-
function
|
|
14
|
+
function mi(e) {
|
|
15
15
|
if (typeof e != "function" || typeof e.create != "function")
|
|
16
16
|
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
17
|
-
|
|
17
|
+
Sn(e.outputLen), Sn(e.blockLen);
|
|
18
18
|
}
|
|
19
19
|
function et(e, t = !0) {
|
|
20
20
|
if (e.destroyed)
|
|
@@ -22,7 +22,7 @@ function et(e, t = !0) {
|
|
|
22
22
|
if (t && e.finished)
|
|
23
23
|
throw new Error("Hash#digest() has already been called");
|
|
24
24
|
}
|
|
25
|
-
function
|
|
25
|
+
function Ei(e, t) {
|
|
26
26
|
zn(e);
|
|
27
27
|
const n = t.outputLen;
|
|
28
28
|
if (e.length < n)
|
|
@@ -30,16 +30,16 @@ function mi(e, t) {
|
|
|
30
30
|
}
|
|
31
31
|
const xt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
32
32
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
33
|
-
const Vn = (e) => e instanceof Uint8Array,
|
|
33
|
+
const Vn = (e) => e instanceof Uint8Array, Kt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), re = (e, t) => e << 32 - t | e >>> t, xi = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
34
34
|
if (!xi)
|
|
35
35
|
throw new Error("Non little-endian hardware is not supported");
|
|
36
|
-
function
|
|
36
|
+
function Ki(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
|
|
42
|
-
if (typeof e == "string" && (e =
|
|
41
|
+
function Wt(e) {
|
|
42
|
+
if (typeof e == "string" && (e = Ki(e)), !Vn(e))
|
|
43
43
|
throw new Error(`expected Uint8Array, got ${typeof e}`);
|
|
44
44
|
return e;
|
|
45
45
|
}
|
|
@@ -58,8 +58,8 @@ let Wn = class {
|
|
|
58
58
|
return this._cloneInto();
|
|
59
59
|
}
|
|
60
60
|
};
|
|
61
|
-
function
|
|
62
|
-
const t = (r) => e().update(
|
|
61
|
+
function Si(e) {
|
|
62
|
+
const t = (r) => e().update(Wt(r)).digest(), n = e();
|
|
63
63
|
return t.outputLen = n.outputLen, t.blockLen = n.blockLen, t.create = () => e(), t;
|
|
64
64
|
}
|
|
65
65
|
function Zn(e = 32) {
|
|
@@ -67,7 +67,7 @@ function Zn(e = 32) {
|
|
|
67
67
|
return xt.getRandomValues(new Uint8Array(e));
|
|
68
68
|
throw new Error("crypto.getRandomValues must be defined");
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function Ai(e, t, n, r) {
|
|
71
71
|
if (typeof e.setBigUint64 == "function")
|
|
72
72
|
return e.setBigUint64(t, n, r);
|
|
73
73
|
const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
|
|
@@ -75,17 +75,17 @@ function Ki(e, t, n, r) {
|
|
|
75
75
|
}
|
|
76
76
|
let Ci = class extends Wn {
|
|
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 =
|
|
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
81
|
et(this);
|
|
82
82
|
const { view: n, buffer: r, blockLen: i } = this;
|
|
83
|
-
t =
|
|
83
|
+
t = Wt(t);
|
|
84
84
|
const s = t.length;
|
|
85
85
|
for (let o = 0; o < s; ) {
|
|
86
86
|
const c = Math.min(i - this.pos, s - o);
|
|
87
87
|
if (c === i) {
|
|
88
|
-
const a =
|
|
88
|
+
const a = Kt(t);
|
|
89
89
|
for (; i <= s - o; o += i)
|
|
90
90
|
this.process(a, o);
|
|
91
91
|
continue;
|
|
@@ -95,14 +95,14 @@ let Ci = class extends Wn {
|
|
|
95
95
|
return this.length += t.length, this.roundClean(), this;
|
|
96
96
|
}
|
|
97
97
|
digestInto(t) {
|
|
98
|
-
et(this),
|
|
98
|
+
et(this), Ei(t, this), this.finished = !0;
|
|
99
99
|
const { buffer: n, view: r, blockLen: i, isLE: s } = this;
|
|
100
100
|
let { pos: o } = this;
|
|
101
101
|
n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > i - o && (this.process(r, 0), o = 0);
|
|
102
102
|
for (let u = o; u < i; u++)
|
|
103
103
|
n[u] = 0;
|
|
104
|
-
|
|
105
|
-
const c =
|
|
104
|
+
Ai(r, i - 8, BigInt(this.length * 8), s), this.process(r, 0);
|
|
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
108
|
const l = a / 4, f = this.get();
|
|
@@ -123,7 +123,7 @@ let Ci = class extends Wn {
|
|
|
123
123
|
return t.length = i, t.pos = c, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
|
|
124
124
|
}
|
|
125
125
|
};
|
|
126
|
-
const Bi = (e, t, n) => e & t ^ ~e & n,
|
|
126
|
+
const Bi = (e, t, n) => e & t ^ ~e & n, _i = (e, t, n) => e & t ^ e & n ^ t & n, Ii = /* @__PURE__ */ new Uint32Array([
|
|
127
127
|
1116352408,
|
|
128
128
|
1899447441,
|
|
129
129
|
3049323471,
|
|
@@ -198,7 +198,7 @@ const Bi = (e, t, n) => e & t ^ ~e & n, ki = (e, t, n) => e & t ^ e & n ^ t & n,
|
|
|
198
198
|
528734635,
|
|
199
199
|
1541459225
|
|
200
200
|
]), ve = /* @__PURE__ */ new Uint32Array(64);
|
|
201
|
-
let
|
|
201
|
+
let ki = class extends Ci {
|
|
202
202
|
constructor() {
|
|
203
203
|
super(64, 32, 8, !1), this.A = be[0] | 0, this.B = be[1] | 0, this.C = be[2] | 0, this.D = be[3] | 0, this.E = be[4] | 0, this.F = be[5] | 0, this.G = be[6] | 0, this.H = be[7] | 0;
|
|
204
204
|
}
|
|
@@ -214,12 +214,12 @@ let Ii = class extends Ci {
|
|
|
214
214
|
for (let u = 0; u < 16; u++, n += 4)
|
|
215
215
|
ve[u] = t.getUint32(n, !1);
|
|
216
216
|
for (let u = 16; u < 64; u++) {
|
|
217
|
-
const
|
|
217
|
+
const y = ve[u - 15], b = ve[u - 2], p = re(y, 7) ^ re(y, 18) ^ y >>> 3, h = re(b, 17) ^ re(b, 19) ^ b >>> 10;
|
|
218
218
|
ve[u] = h + ve[u - 7] + p + ve[u - 16] | 0;
|
|
219
219
|
}
|
|
220
220
|
let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
|
|
221
221
|
for (let u = 0; u < 64; u++) {
|
|
222
|
-
const
|
|
222
|
+
const y = re(c, 6) ^ re(c, 11) ^ re(c, 25), b = f + y + Bi(c, a, l) + Ii[u] + ve[u] | 0, h = (re(r, 2) ^ re(r, 13) ^ re(r, 22)) + _i(r, i, s) | 0;
|
|
223
223
|
f = l, l = a, a = c, c = o + b | 0, o = s, s = i, i = r, r = b + h | 0;
|
|
224
224
|
}
|
|
225
225
|
r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
|
|
@@ -231,10 +231,10 @@ let Ii = class extends Ci {
|
|
|
231
231
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
232
232
|
}
|
|
233
233
|
};
|
|
234
|
-
const
|
|
234
|
+
const Lt = /* @__PURE__ */ Si(() => new ki());
|
|
235
235
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
236
236
|
const Gn = BigInt(0), ot = BigInt(1), Ui = BigInt(2), at = (e) => e instanceof Uint8Array, Li = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
237
|
-
function
|
|
237
|
+
function qe(e) {
|
|
238
238
|
if (!at(e))
|
|
239
239
|
throw new Error("Uint8Array expected");
|
|
240
240
|
let t = "";
|
|
@@ -246,12 +246,12 @@ function Fn(e) {
|
|
|
246
246
|
const t = e.toString(16);
|
|
247
247
|
return t.length & 1 ? `0${t}` : t;
|
|
248
248
|
}
|
|
249
|
-
function
|
|
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}`);
|
|
253
253
|
}
|
|
254
|
-
function
|
|
254
|
+
function De(e) {
|
|
255
255
|
if (typeof e != "string")
|
|
256
256
|
throw new Error("hex string expected, got " + typeof e);
|
|
257
257
|
const t = e.length;
|
|
@@ -267,27 +267,27 @@ function je(e) {
|
|
|
267
267
|
return n;
|
|
268
268
|
}
|
|
269
269
|
function F(e) {
|
|
270
|
-
return
|
|
270
|
+
return Zt(qe(e));
|
|
271
271
|
}
|
|
272
|
-
function
|
|
272
|
+
function Gt(e) {
|
|
273
273
|
if (!at(e))
|
|
274
274
|
throw new Error("Uint8Array expected");
|
|
275
|
-
return
|
|
275
|
+
return Zt(qe(Uint8Array.from(e).reverse()));
|
|
276
276
|
}
|
|
277
277
|
function Ne(e, t) {
|
|
278
|
-
return
|
|
278
|
+
return De(e.toString(16).padStart(t * 2, "0"));
|
|
279
279
|
}
|
|
280
|
-
function
|
|
280
|
+
function Ft(e, t) {
|
|
281
281
|
return Ne(e, t).reverse();
|
|
282
282
|
}
|
|
283
283
|
function $i(e) {
|
|
284
|
-
return
|
|
284
|
+
return De(Fn(e));
|
|
285
285
|
}
|
|
286
|
-
function
|
|
286
|
+
function Z(e, t, n) {
|
|
287
287
|
let r;
|
|
288
288
|
if (typeof t == "string")
|
|
289
289
|
try {
|
|
290
|
-
r =
|
|
290
|
+
r = De(t);
|
|
291
291
|
} catch (s) {
|
|
292
292
|
throw new Error(`${e} must be valid hex string, got "${t}". Cause: ${s}`);
|
|
293
293
|
}
|
|
@@ -328,10 +328,10 @@ function Oi(e) {
|
|
|
328
328
|
;
|
|
329
329
|
return t;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function Pi(e, t) {
|
|
332
332
|
return e >> BigInt(t) & ot;
|
|
333
333
|
}
|
|
334
|
-
const
|
|
334
|
+
const Mi = (e, t, n) => e | (n ? ot : Gn) << BigInt(t), Jt = (e) => (Ui << BigInt(e - 1)) - ot, Nt = (e) => new Uint8Array(e), An = (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");
|
|
@@ -343,23 +343,23 @@ function Jn(e, t, n) {
|
|
|
343
343
|
const o = () => {
|
|
344
344
|
r.fill(1), i.fill(0), s = 0;
|
|
345
345
|
}, c = (...u) => n(i, r, ...u), a = (u = Nt()) => {
|
|
346
|
-
i = c(
|
|
346
|
+
i = c(An([0]), u), r = c(), u.length !== 0 && (i = c(An([1]), u), r = c());
|
|
347
347
|
}, l = () => {
|
|
348
348
|
if (s++ >= 1e3)
|
|
349
349
|
throw new Error("drbg: tried 1000 values");
|
|
350
350
|
let u = 0;
|
|
351
|
-
const
|
|
351
|
+
const y = [];
|
|
352
352
|
for (; u < t; ) {
|
|
353
353
|
r = c();
|
|
354
354
|
const b = r.slice();
|
|
355
|
-
|
|
355
|
+
y.push(b), u += r.length;
|
|
356
356
|
}
|
|
357
|
-
return Ie(...
|
|
357
|
+
return Ie(...y);
|
|
358
358
|
};
|
|
359
|
-
return (u,
|
|
359
|
+
return (u, y) => {
|
|
360
360
|
o(), a(u);
|
|
361
361
|
let b;
|
|
362
|
-
for (; !(b =
|
|
362
|
+
for (; !(b = y(l())); )
|
|
363
363
|
a();
|
|
364
364
|
return o(), b;
|
|
365
365
|
};
|
|
@@ -392,71 +392,71 @@ function Ye(e, t, n = {}) {
|
|
|
392
392
|
}
|
|
393
393
|
const qi = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
394
394
|
__proto__: null,
|
|
395
|
-
bitGet:
|
|
395
|
+
bitGet: Pi,
|
|
396
396
|
bitLen: Oi,
|
|
397
|
-
bitMask:
|
|
398
|
-
bitSet:
|
|
399
|
-
bytesToHex:
|
|
397
|
+
bitMask: Jt,
|
|
398
|
+
bitSet: Mi,
|
|
399
|
+
bytesToHex: qe,
|
|
400
400
|
bytesToNumberBE: F,
|
|
401
|
-
bytesToNumberLE:
|
|
401
|
+
bytesToNumberLE: Gt,
|
|
402
402
|
concatBytes: Ie,
|
|
403
403
|
createHmacDrbg: Jn,
|
|
404
|
-
ensureBytes:
|
|
404
|
+
ensureBytes: Z,
|
|
405
405
|
equalBytes: Ti,
|
|
406
|
-
hexToBytes:
|
|
407
|
-
hexToNumber:
|
|
406
|
+
hexToBytes: De,
|
|
407
|
+
hexToNumber: Zt,
|
|
408
408
|
numberToBytesBE: Ne,
|
|
409
|
-
numberToBytesLE:
|
|
409
|
+
numberToBytesLE: Ft,
|
|
410
410
|
numberToHexUnpadded: Fn,
|
|
411
411
|
numberToVarBytesBE: $i,
|
|
412
412
|
utf8ToBytes: Ri,
|
|
413
413
|
validateObject: Ye
|
|
414
414
|
}, Symbol.toStringTag, { value: "Module" }));
|
|
415
415
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
416
|
-
const
|
|
416
|
+
const V = BigInt(0), j = BigInt(1), Ce = BigInt(2), Di = BigInt(3), $t = BigInt(4), Cn = BigInt(5), Bn = BigInt(8);
|
|
417
417
|
BigInt(9);
|
|
418
418
|
BigInt(16);
|
|
419
|
-
function
|
|
419
|
+
function W(e, t) {
|
|
420
420
|
const n = e % t;
|
|
421
|
-
return n >=
|
|
421
|
+
return n >= V ? n : t + n;
|
|
422
422
|
}
|
|
423
423
|
function ji(e, t, n) {
|
|
424
|
-
if (n <=
|
|
424
|
+
if (n <= V || t < V)
|
|
425
425
|
throw new Error("Expected power/modulo > 0");
|
|
426
426
|
if (n === j)
|
|
427
|
-
return
|
|
427
|
+
return V;
|
|
428
428
|
let r = j;
|
|
429
|
-
for (; t >
|
|
429
|
+
for (; t > V; )
|
|
430
430
|
t & j && (r = r * e % n), e = e * e % n, t >>= j;
|
|
431
431
|
return r;
|
|
432
432
|
}
|
|
433
433
|
function J(e, t, n) {
|
|
434
434
|
let r = e;
|
|
435
|
-
for (; t-- >
|
|
435
|
+
for (; t-- > V; )
|
|
436
436
|
r *= r, r %= n;
|
|
437
437
|
return r;
|
|
438
438
|
}
|
|
439
|
-
function
|
|
440
|
-
if (e ===
|
|
439
|
+
function Tt(e, t) {
|
|
440
|
+
if (e === V || t <= V)
|
|
441
441
|
throw new Error(`invert: expected positive integers, got n=${e} mod=${t}`);
|
|
442
|
-
let n =
|
|
443
|
-
for (; n !==
|
|
442
|
+
let n = W(e, t), r = t, i = V, s = j;
|
|
443
|
+
for (; n !== V; ) {
|
|
444
444
|
const c = r / n, a = r % n, l = i - s * c;
|
|
445
445
|
r = n, n = a, i = s, s = l;
|
|
446
446
|
}
|
|
447
447
|
if (r !== j)
|
|
448
448
|
throw new Error("invert: does not exist");
|
|
449
|
-
return
|
|
449
|
+
return W(i, t);
|
|
450
450
|
}
|
|
451
451
|
function zi(e) {
|
|
452
452
|
const t = (e - j) / Ce;
|
|
453
453
|
let n, r, i;
|
|
454
|
-
for (n = e - j, r = 0; n % Ce ===
|
|
454
|
+
for (n = e - j, r = 0; n % Ce === V; n /= Ce, r++)
|
|
455
455
|
;
|
|
456
456
|
for (i = Ce; i < e && ji(i, t, e) !== e - j; i++)
|
|
457
457
|
;
|
|
458
458
|
if (r === 1) {
|
|
459
|
-
const o = (e + j) /
|
|
459
|
+
const o = (e + j) / $t;
|
|
460
460
|
return function(a, l) {
|
|
461
461
|
const f = a.pow(l, o);
|
|
462
462
|
if (!a.eql(a.sqr(f), l))
|
|
@@ -468,22 +468,22 @@ function zi(e) {
|
|
|
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 l = r, f = c.pow(c.mul(c.ONE, i), n), u = c.pow(a, s),
|
|
472
|
-
for (; !c.eql(
|
|
473
|
-
if (c.eql(
|
|
471
|
+
let l = r, f = c.pow(c.mul(c.ONE, i), n), u = c.pow(a, s), y = c.pow(a, n);
|
|
472
|
+
for (; !c.eql(y, c.ONE); ) {
|
|
473
|
+
if (c.eql(y, c.ZERO))
|
|
474
474
|
return c.ZERO;
|
|
475
475
|
let b = 1;
|
|
476
|
-
for (let h = c.sqr(
|
|
476
|
+
for (let h = c.sqr(y); b < l && !c.eql(h, c.ONE); b++)
|
|
477
477
|
h = c.sqr(h);
|
|
478
478
|
const p = c.pow(f, j << BigInt(l - b - 1));
|
|
479
|
-
f = c.sqr(p), u = c.mul(u, p),
|
|
479
|
+
f = c.sqr(p), u = c.mul(u, p), y = c.mul(y, f), l = b;
|
|
480
480
|
}
|
|
481
481
|
return u;
|
|
482
482
|
};
|
|
483
483
|
}
|
|
484
484
|
function Vi(e) {
|
|
485
|
-
if (e %
|
|
486
|
-
const t = (e + j) /
|
|
485
|
+
if (e % $t === Di) {
|
|
486
|
+
const t = (e + j) / $t;
|
|
487
487
|
return function(r, i) {
|
|
488
488
|
const s = r.pow(i, t);
|
|
489
489
|
if (!r.eql(r.sqr(s), i))
|
|
@@ -491,8 +491,8 @@ function Vi(e) {
|
|
|
491
491
|
return s;
|
|
492
492
|
};
|
|
493
493
|
}
|
|
494
|
-
if (e %
|
|
495
|
-
const t = (e -
|
|
494
|
+
if (e % Bn === Cn) {
|
|
495
|
+
const t = (e - Cn) / Bn;
|
|
496
496
|
return function(r, i) {
|
|
497
497
|
const s = r.mul(i, Ce), o = r.pow(s, t), c = r.mul(i, o), a = r.mul(r.mul(c, Ce), o), l = r.mul(c, r.sub(a, r.ONE));
|
|
498
498
|
if (!r.eql(r.sqr(l), i))
|
|
@@ -531,14 +531,14 @@ function Zi(e) {
|
|
|
531
531
|
return Ye(e, n);
|
|
532
532
|
}
|
|
533
533
|
function Gi(e, t, n) {
|
|
534
|
-
if (n <
|
|
534
|
+
if (n < V)
|
|
535
535
|
throw new Error("Expected power > 0");
|
|
536
|
-
if (n ===
|
|
536
|
+
if (n === V)
|
|
537
537
|
return e.ONE;
|
|
538
538
|
if (n === j)
|
|
539
539
|
return t;
|
|
540
540
|
let r = e.ONE, i = t;
|
|
541
|
-
for (; n >
|
|
541
|
+
for (; n > V; )
|
|
542
542
|
n & j && (r = e.mul(r, i)), i = e.sqr(i), n >>= j;
|
|
543
543
|
return r;
|
|
544
544
|
}
|
|
@@ -551,7 +551,7 @@ function Yn(e, t) {
|
|
|
551
551
|
return { nBitLength: n, nByteLength: r };
|
|
552
552
|
}
|
|
553
553
|
function Ji(e, t, n = !1, r = {}) {
|
|
554
|
-
if (e <=
|
|
554
|
+
if (e <= V)
|
|
555
555
|
throw new Error(`Expected Field ORDER > 0, got ${e}`);
|
|
556
556
|
const { nBitLength: i, nByteLength: s } = Yn(e, t);
|
|
557
557
|
if (s > 2048)
|
|
@@ -560,41 +560,41 @@ function Ji(e, t, n = !1, r = {}) {
|
|
|
560
560
|
ORDER: e,
|
|
561
561
|
BITS: i,
|
|
562
562
|
BYTES: s,
|
|
563
|
-
MASK:
|
|
564
|
-
ZERO:
|
|
563
|
+
MASK: Jt(i),
|
|
564
|
+
ZERO: V,
|
|
565
565
|
ONE: j,
|
|
566
|
-
create: (a) =>
|
|
566
|
+
create: (a) => W(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
|
-
return
|
|
570
|
+
return V <= a && a < e;
|
|
571
571
|
},
|
|
572
|
-
is0: (a) => a ===
|
|
572
|
+
is0: (a) => a === V,
|
|
573
573
|
isOdd: (a) => (a & j) === j,
|
|
574
|
-
neg: (a) =>
|
|
574
|
+
neg: (a) => W(-a, e),
|
|
575
575
|
eql: (a, l) => a === l,
|
|
576
|
-
sqr: (a) =>
|
|
577
|
-
add: (a, l) =>
|
|
578
|
-
sub: (a, l) =>
|
|
579
|
-
mul: (a, l) =>
|
|
576
|
+
sqr: (a) => W(a * a, e),
|
|
577
|
+
add: (a, l) => W(a + l, e),
|
|
578
|
+
sub: (a, l) => W(a - l, e),
|
|
579
|
+
mul: (a, l) => W(a * l, e),
|
|
580
580
|
pow: (a, l) => Gi(c, a, l),
|
|
581
|
-
div: (a, l) =>
|
|
581
|
+
div: (a, l) => W(a * Tt(l, e), e),
|
|
582
582
|
// Same as above, but doesn't normalize
|
|
583
583
|
sqrN: (a) => a * a,
|
|
584
584
|
addN: (a, l) => a + l,
|
|
585
585
|
subN: (a, l) => a - l,
|
|
586
586
|
mulN: (a, l) => a * l,
|
|
587
|
-
inv: (a) =>
|
|
587
|
+
inv: (a) => Tt(a, e),
|
|
588
588
|
sqrt: r.sqrt || ((a) => o(c, a)),
|
|
589
589
|
invertBatch: (a) => Fi(c, a),
|
|
590
590
|
// TODO: do we really need constant cmov?
|
|
591
591
|
// We don't have const-time bigints anyway, so probably will be not very useful
|
|
592
592
|
cmov: (a, l, f) => f ? l : a,
|
|
593
|
-
toBytes: (a) => n ?
|
|
593
|
+
toBytes: (a) => n ? Ft(a, s) : Ne(a, s),
|
|
594
594
|
fromBytes: (a) => {
|
|
595
595
|
if (a.length !== s)
|
|
596
596
|
throw new Error(`Fp.fromBytes: expected ${s}, got ${a.length}`);
|
|
597
|
-
return n ?
|
|
597
|
+
return n ? Gt(a) : F(a);
|
|
598
598
|
}
|
|
599
599
|
});
|
|
600
600
|
return Object.freeze(c);
|
|
@@ -613,11 +613,11 @@ function Yi(e, t, n = !1) {
|
|
|
613
613
|
const r = e.length, i = Xn(t), s = Qn(t);
|
|
614
614
|
if (r < 16 || r < s || r > 1024)
|
|
615
615
|
throw new Error(`expected ${s}-1024 bytes of input, got ${r}`);
|
|
616
|
-
const o = n ? F(e) :
|
|
617
|
-
return n ?
|
|
616
|
+
const o = n ? F(e) : Gt(e), c = W(o, t - j) + j;
|
|
617
|
+
return n ? Ft(c, i) : Ne(c, i);
|
|
618
618
|
}
|
|
619
619
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
620
|
-
const Xi = BigInt(0),
|
|
620
|
+
const Xi = BigInt(0), St = BigInt(1);
|
|
621
621
|
function Qi(e, t) {
|
|
622
622
|
const n = (i, s) => {
|
|
623
623
|
const o = s.negate();
|
|
@@ -632,7 +632,7 @@ function Qi(e, t) {
|
|
|
632
632
|
unsafeLadder(i, s) {
|
|
633
633
|
let o = e.ZERO, c = i;
|
|
634
634
|
for (; s > Xi; )
|
|
635
|
-
s &
|
|
635
|
+
s & St && (o = o.add(c)), c = c.double(), s >>= St;
|
|
636
636
|
return o;
|
|
637
637
|
},
|
|
638
638
|
/**
|
|
@@ -650,7 +650,7 @@ function Qi(e, t) {
|
|
|
650
650
|
let l = i, f = l;
|
|
651
651
|
for (let u = 0; u < o; u++) {
|
|
652
652
|
f = l, a.push(f);
|
|
653
|
-
for (let
|
|
653
|
+
for (let y = 1; y < c; y++)
|
|
654
654
|
f = f.add(l), a.push(f);
|
|
655
655
|
l = f.double();
|
|
656
656
|
}
|
|
@@ -666,13 +666,13 @@ function Qi(e, t) {
|
|
|
666
666
|
wNAF(i, s, o) {
|
|
667
667
|
const { windows: c, windowSize: a } = r(i);
|
|
668
668
|
let l = e.ZERO, f = e.BASE;
|
|
669
|
-
const u = BigInt(2 ** i - 1),
|
|
669
|
+
const u = BigInt(2 ** i - 1), y = 2 ** i, b = BigInt(i);
|
|
670
670
|
for (let p = 0; p < c; p++) {
|
|
671
671
|
const h = p * a;
|
|
672
672
|
let d = Number(o & u);
|
|
673
|
-
o >>= b, d > a && (d -=
|
|
674
|
-
const
|
|
675
|
-
d === 0 ? f = f.add(n(
|
|
673
|
+
o >>= b, d > a && (d -= y, o += St);
|
|
674
|
+
const g = h, E = h + Math.abs(d) - 1, S = p % 2 !== 0, k = d < 0;
|
|
675
|
+
d === 0 ? f = f.add(n(S, s[g])) : l = l.add(n(k, s[E]));
|
|
676
676
|
}
|
|
677
677
|
return { p: l, f };
|
|
678
678
|
},
|
|
@@ -722,7 +722,7 @@ function es(e) {
|
|
|
722
722
|
}
|
|
723
723
|
return Object.freeze({ ...t });
|
|
724
724
|
}
|
|
725
|
-
const { bytesToNumberBE: ts, hexToBytes: ns } = qi,
|
|
725
|
+
const { bytesToNumberBE: ts, hexToBytes: ns } = qi, Be = {
|
|
726
726
|
// asn.1 DER encoding utils
|
|
727
727
|
Err: class extends Error {
|
|
728
728
|
constructor(t = "") {
|
|
@@ -730,7 +730,7 @@ const { bytesToNumberBE: ts, hexToBytes: ns } = qi, ke = {
|
|
|
730
730
|
}
|
|
731
731
|
},
|
|
732
732
|
_parseInt(e) {
|
|
733
|
-
const { Err: t } =
|
|
733
|
+
const { Err: t } = Be;
|
|
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: ts, hexToBytes: ns } = qi, ke = {
|
|
|
743
743
|
return { d: ts(r), l: e.subarray(n + 2) };
|
|
744
744
|
},
|
|
745
745
|
toSig(e) {
|
|
746
|
-
const { Err: t } =
|
|
746
|
+
const { Err: t } = Be, n = typeof e == "string" ? ns(e) : e;
|
|
747
747
|
if (!(n instanceof Uint8Array))
|
|
748
748
|
throw new Error("ui8a expected");
|
|
749
749
|
let r = n.length;
|
|
@@ -751,7 +751,7 @@ const { bytesToNumberBE: ts, hexToBytes: ns } = qi, 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: s } =
|
|
754
|
+
const { d: i, l: s } = Be._parseInt(n.subarray(2)), { d: o, l: c } = Be._parseInt(s);
|
|
755
755
|
if (c.length)
|
|
756
756
|
throw new t("Invalid signature: left bytes after parsing");
|
|
757
757
|
return { r: i, s: o };
|
|
@@ -769,15 +769,15 @@ const _n = BigInt(3);
|
|
|
769
769
|
BigInt(4);
|
|
770
770
|
function rs(e) {
|
|
771
771
|
const t = es(e), { Fp: n } = t, r = t.toBytes || ((p, h, d) => {
|
|
772
|
-
const
|
|
773
|
-
return Ie(Uint8Array.from([4]), n.toBytes(
|
|
772
|
+
const g = h.toAffine();
|
|
773
|
+
return Ie(Uint8Array.from([4]), n.toBytes(g.x), n.toBytes(g.y));
|
|
774
774
|
}), i = t.fromBytes || ((p) => {
|
|
775
|
-
const h = p.subarray(1), d = n.fromBytes(h.subarray(0, n.BYTES)),
|
|
776
|
-
return { x: d, y };
|
|
775
|
+
const h = p.subarray(1), d = n.fromBytes(h.subarray(0, n.BYTES)), g = n.fromBytes(h.subarray(n.BYTES, 2 * n.BYTES));
|
|
776
|
+
return { x: d, y: g };
|
|
777
777
|
});
|
|
778
778
|
function s(p) {
|
|
779
|
-
const { a: h, b: d } = t,
|
|
780
|
-
return n.add(n.add(
|
|
779
|
+
const { a: h, b: d } = t, g = n.sqr(p), E = n.mul(g, p);
|
|
780
|
+
return n.add(n.add(E, n.mul(p, h)), d);
|
|
781
781
|
}
|
|
782
782
|
if (!n.eql(n.sqr(t.Gy), s(t.Gx)))
|
|
783
783
|
throw new Error("bad generator point: equation left != right");
|
|
@@ -789,19 +789,19 @@ function rs(e) {
|
|
|
789
789
|
throw new Error("Expected valid bigint: 0 < bigint < curve.n");
|
|
790
790
|
}
|
|
791
791
|
function a(p) {
|
|
792
|
-
const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey:
|
|
792
|
+
const { allowedPrivateKeyLengths: h, nByteLength: d, wrapPrivateKey: g, n: E } = t;
|
|
793
793
|
if (h && typeof p != "bigint") {
|
|
794
|
-
if (p instanceof Uint8Array && (p =
|
|
794
|
+
if (p instanceof Uint8Array && (p = qe(p)), typeof p != "string" || !h.includes(p.length))
|
|
795
795
|
throw new Error("Invalid key");
|
|
796
796
|
p = p.padStart(d * 2, "0");
|
|
797
797
|
}
|
|
798
|
-
let
|
|
798
|
+
let S;
|
|
799
799
|
try {
|
|
800
|
-
|
|
800
|
+
S = typeof p == "bigint" ? p : F(Z("private key", p, d));
|
|
801
801
|
} catch {
|
|
802
802
|
throw new Error(`private key must be ${d} bytes, hex or bigint, not ${typeof p}`);
|
|
803
803
|
}
|
|
804
|
-
return
|
|
804
|
+
return g && (S = W(S, E)), c(S), S;
|
|
805
805
|
}
|
|
806
806
|
const l = /* @__PURE__ */ new Map();
|
|
807
807
|
function f(p) {
|
|
@@ -809,24 +809,24 @@ function rs(e) {
|
|
|
809
809
|
throw new Error("ProjectivePoint expected");
|
|
810
810
|
}
|
|
811
811
|
class u {
|
|
812
|
-
constructor(h, d,
|
|
813
|
-
if (this.px = h, this.py = d, this.pz =
|
|
812
|
+
constructor(h, d, g) {
|
|
813
|
+
if (this.px = h, this.py = d, this.pz = g, h == null || !n.isValid(h))
|
|
814
814
|
throw new Error("x required");
|
|
815
815
|
if (d == null || !n.isValid(d))
|
|
816
816
|
throw new Error("y required");
|
|
817
|
-
if (
|
|
817
|
+
if (g == null || !n.isValid(g))
|
|
818
818
|
throw new Error("z required");
|
|
819
819
|
}
|
|
820
820
|
// Does not validate if the point is on-curve.
|
|
821
821
|
// Use fromHex instead, or call assertValidity() later.
|
|
822
822
|
static fromAffine(h) {
|
|
823
|
-
const { x: d, y } = h || {};
|
|
824
|
-
if (!h || !n.isValid(d) || !n.isValid(
|
|
823
|
+
const { x: d, y: g } = h || {};
|
|
824
|
+
if (!h || !n.isValid(d) || !n.isValid(g))
|
|
825
825
|
throw new Error("invalid affine point");
|
|
826
826
|
if (h instanceof u)
|
|
827
827
|
throw new Error("projective point not allowed");
|
|
828
|
-
const
|
|
829
|
-
return
|
|
828
|
+
const E = (S) => n.eql(S, n.ZERO);
|
|
829
|
+
return E(d) && E(g) ? u.ZERO : new u(d, g, n.ONE);
|
|
830
830
|
}
|
|
831
831
|
get x() {
|
|
832
832
|
return this.toAffine().x;
|
|
@@ -841,15 +841,15 @@ function rs(e) {
|
|
|
841
841
|
* Optimization: converts a list of projective points to a list of identical points with Z=1.
|
|
842
842
|
*/
|
|
843
843
|
static normalizeZ(h) {
|
|
844
|
-
const d = n.invertBatch(h.map((
|
|
845
|
-
return h.map((
|
|
844
|
+
const d = n.invertBatch(h.map((g) => g.pz));
|
|
845
|
+
return h.map((g, E) => g.toAffine(d[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 d = u.fromAffine(i(
|
|
852
|
+
const d = u.fromAffine(i(Z("pointHex", h)));
|
|
853
853
|
return d.assertValidity(), d;
|
|
854
854
|
}
|
|
855
855
|
// Multiplies generator point by privateKey.
|
|
@@ -870,8 +870,8 @@ function rs(e) {
|
|
|
870
870
|
const { x: h, y: d } = this.toAffine();
|
|
871
871
|
if (!n.isValid(h) || !n.isValid(d))
|
|
872
872
|
throw new Error("bad point: x or y not FE");
|
|
873
|
-
const
|
|
874
|
-
if (!n.eql(
|
|
873
|
+
const g = n.sqr(d), E = s(h);
|
|
874
|
+
if (!n.eql(g, E))
|
|
875
875
|
throw new Error("bad point: equation left != right");
|
|
876
876
|
if (!this.isTorsionFree())
|
|
877
877
|
throw new Error("bad point: not in prime-order subgroup");
|
|
@@ -887,8 +887,8 @@ function rs(e) {
|
|
|
887
887
|
*/
|
|
888
888
|
equals(h) {
|
|
889
889
|
f(h);
|
|
890
|
-
const { px: d, py:
|
|
891
|
-
return
|
|
890
|
+
const { px: d, py: g, pz: E } = this, { px: S, py: k, pz: B } = h, m = n.eql(n.mul(d, B), n.mul(S, E)), x = n.eql(n.mul(g, B), n.mul(k, E));
|
|
891
|
+
return m && x;
|
|
892
892
|
}
|
|
893
893
|
/**
|
|
894
894
|
* Flips point to one corresponding to (x, -y) in Affine coordinates.
|
|
@@ -901,9 +901,9 @@ function rs(e) {
|
|
|
901
901
|
// https://eprint.iacr.org/2015/1060, algorithm 3
|
|
902
902
|
// Cost: 8M + 3S + 3*a + 2*b3 + 15add.
|
|
903
903
|
double() {
|
|
904
|
-
const { a: h, b: d } = t,
|
|
905
|
-
let B = n.ZERO,
|
|
906
|
-
return
|
|
904
|
+
const { a: h, b: d } = t, g = n.mul(d, _n), { px: E, py: S, pz: k } = this;
|
|
905
|
+
let B = n.ZERO, m = n.ZERO, x = n.ZERO, K = n.mul(E, E), M = n.mul(S, S), I = n.mul(k, k), A = n.mul(E, S);
|
|
906
|
+
return A = n.add(A, A), x = n.mul(E, k), x = n.add(x, x), B = n.mul(h, x), m = n.mul(g, I), m = n.add(B, m), B = n.sub(M, m), m = n.add(M, m), m = n.mul(B, m), B = n.mul(A, B), x = n.mul(g, x), I = n.mul(h, I), A = n.sub(K, I), A = n.mul(h, A), A = n.add(A, x), x = n.add(K, K), K = n.add(x, K), K = n.add(K, I), K = n.mul(K, A), m = n.add(m, K), I = n.mul(S, k), I = n.add(I, I), K = n.mul(I, A), B = n.sub(B, K), x = n.mul(I, M), x = n.add(x, x), x = n.add(x, x), new u(B, m, x);
|
|
907
907
|
}
|
|
908
908
|
// Renes-Costello-Batina exception-free addition formula.
|
|
909
909
|
// There is 30% faster Jacobian formula, but it is not complete.
|
|
@@ -911,13 +911,13 @@ function rs(e) {
|
|
|
911
911
|
// Cost: 12M + 0S + 3*a + 3*b3 + 23add.
|
|
912
912
|
add(h) {
|
|
913
913
|
f(h);
|
|
914
|
-
const { px: d, py:
|
|
915
|
-
let
|
|
916
|
-
const
|
|
917
|
-
let
|
|
918
|
-
H = n.mul(H, w), w = n.add(
|
|
919
|
-
let v = n.add(
|
|
920
|
-
return w = n.mul(w, v), v = n.add(
|
|
914
|
+
const { px: d, py: g, pz: E } = this, { px: S, py: k, pz: B } = h;
|
|
915
|
+
let m = n.ZERO, x = n.ZERO, K = n.ZERO;
|
|
916
|
+
const M = t.a, I = n.mul(t.b, _n);
|
|
917
|
+
let A = n.mul(d, S), T = n.mul(g, k), R = n.mul(E, B), H = n.add(d, g), w = n.add(S, k);
|
|
918
|
+
H = n.mul(H, w), w = n.add(A, T), H = n.sub(H, w), w = n.add(d, E);
|
|
919
|
+
let v = n.add(S, B);
|
|
920
|
+
return w = n.mul(w, v), v = n.add(A, R), w = n.sub(w, v), v = n.add(g, E), m = n.add(k, B), v = n.mul(v, m), m = n.add(T, R), v = n.sub(v, m), K = n.mul(M, w), m = n.mul(I, R), K = n.add(m, K), m = n.sub(T, K), K = n.add(T, K), x = n.mul(m, K), T = n.add(A, A), T = n.add(T, A), R = n.mul(M, R), w = n.mul(I, w), T = n.add(T, R), R = n.sub(A, R), R = n.mul(M, R), w = n.add(w, R), A = n.mul(T, w), x = n.add(x, A), A = n.mul(v, w), m = n.mul(H, m), m = n.sub(m, A), A = n.mul(H, T), K = n.mul(v, K), K = n.add(K, A), new u(m, x, K);
|
|
921
921
|
}
|
|
922
922
|
subtract(h) {
|
|
923
923
|
return this.add(h.negate());
|
|
@@ -927,8 +927,8 @@ function rs(e) {
|
|
|
927
927
|
}
|
|
928
928
|
wNAF(h) {
|
|
929
929
|
return b.wNAFCached(this, l, h, (d) => {
|
|
930
|
-
const
|
|
931
|
-
return d.map((
|
|
930
|
+
const g = n.invertBatch(d.map((E) => E.pz));
|
|
931
|
+
return d.map((E, S) => E.toAffine(g[S])).map(u.fromAffine);
|
|
932
932
|
});
|
|
933
933
|
}
|
|
934
934
|
/**
|
|
@@ -942,13 +942,13 @@ function rs(e) {
|
|
|
942
942
|
return d;
|
|
943
943
|
if (c(h), h === Y)
|
|
944
944
|
return this;
|
|
945
|
-
const { endo:
|
|
946
|
-
if (!
|
|
945
|
+
const { endo: g } = t;
|
|
946
|
+
if (!g)
|
|
947
947
|
return b.unsafeLadder(this, h);
|
|
948
|
-
let { k1neg:
|
|
949
|
-
for (;
|
|
950
|
-
|
|
951
|
-
return
|
|
948
|
+
let { k1neg: E, k1: S, k2neg: k, k2: B } = g.splitScalar(h), m = d, x = d, K = this;
|
|
949
|
+
for (; S > ae || B > ae; )
|
|
950
|
+
S & Y && (m = m.add(K)), B & Y && (x = x.add(K)), K = K.double(), S >>= Y, B >>= Y;
|
|
951
|
+
return E && (m = m.negate()), k && (x = x.negate()), x = new u(n.mul(x.px, g.beta), x.py, x.pz), m.add(x);
|
|
952
952
|
}
|
|
953
953
|
/**
|
|
954
954
|
* Constant time multiplication.
|
|
@@ -961,17 +961,17 @@ function rs(e) {
|
|
|
961
961
|
*/
|
|
962
962
|
multiply(h) {
|
|
963
963
|
c(h);
|
|
964
|
-
let d = h,
|
|
965
|
-
const { endo:
|
|
966
|
-
if (
|
|
967
|
-
const { k1neg:
|
|
968
|
-
let { p:
|
|
969
|
-
|
|
964
|
+
let d = h, g, E;
|
|
965
|
+
const { endo: S } = t;
|
|
966
|
+
if (S) {
|
|
967
|
+
const { k1neg: k, k1: B, k2neg: m, k2: x } = S.splitScalar(d);
|
|
968
|
+
let { p: K, f: M } = this.wNAF(B), { p: I, f: A } = this.wNAF(x);
|
|
969
|
+
K = b.constTimeNegate(k, K), I = b.constTimeNegate(m, I), I = new u(n.mul(I.px, S.beta), I.py, I.pz), g = K.add(I), E = M.add(A);
|
|
970
970
|
} else {
|
|
971
|
-
const { p:
|
|
972
|
-
|
|
971
|
+
const { p: k, f: B } = this.wNAF(d);
|
|
972
|
+
g = k, E = B;
|
|
973
973
|
}
|
|
974
|
-
return u.normalizeZ([
|
|
974
|
+
return u.normalizeZ([g, E])[0];
|
|
975
975
|
}
|
|
976
976
|
/**
|
|
977
977
|
* Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
|
|
@@ -979,22 +979,22 @@ function rs(e) {
|
|
|
979
979
|
* The trick could be useful if both P and Q are not G (not in our case).
|
|
980
980
|
* @returns non-zero affine point
|
|
981
981
|
*/
|
|
982
|
-
multiplyAndAddUnsafe(h, d,
|
|
983
|
-
const
|
|
984
|
-
return
|
|
982
|
+
multiplyAndAddUnsafe(h, d, g) {
|
|
983
|
+
const E = u.BASE, S = (B, m) => m === ae || m === Y || !B.equals(E) ? B.multiplyUnsafe(m) : B.multiply(m), k = S(this, d).add(S(h, g));
|
|
984
|
+
return k.is0() ? void 0 : k;
|
|
985
985
|
}
|
|
986
986
|
// Converts Projective point to affine (x, y) coordinates.
|
|
987
987
|
// Can accept precomputed Z^-1 - for example, from invertBatch.
|
|
988
988
|
// (x, y, z) ∋ (x=x/z, y=y/z)
|
|
989
989
|
toAffine(h) {
|
|
990
|
-
const { px: d, py:
|
|
991
|
-
h == null && (h =
|
|
992
|
-
const
|
|
993
|
-
if (
|
|
990
|
+
const { px: d, py: g, pz: E } = this, S = this.is0();
|
|
991
|
+
h == null && (h = S ? n.ONE : n.inv(E));
|
|
992
|
+
const k = n.mul(d, h), B = n.mul(g, h), m = n.mul(E, h);
|
|
993
|
+
if (S)
|
|
994
994
|
return { x: n.ZERO, y: n.ZERO };
|
|
995
|
-
if (!n.eql(
|
|
995
|
+
if (!n.eql(m, n.ONE))
|
|
996
996
|
throw new Error("invZ was invalid");
|
|
997
|
-
return { x:
|
|
997
|
+
return { x: k, y: B };
|
|
998
998
|
}
|
|
999
999
|
isTorsionFree() {
|
|
1000
1000
|
const { h, isTorsionFree: d } = t;
|
|
@@ -1012,11 +1012,11 @@ function rs(e) {
|
|
|
1012
1012
|
return this.assertValidity(), r(u, this, h);
|
|
1013
1013
|
}
|
|
1014
1014
|
toHex(h = !0) {
|
|
1015
|
-
return
|
|
1015
|
+
return qe(this.toRawBytes(h));
|
|
1016
1016
|
}
|
|
1017
1017
|
}
|
|
1018
1018
|
u.BASE = new u(t.Gx, t.Gy, n.ONE), u.ZERO = new u(n.ZERO, n.ONE, n.ZERO);
|
|
1019
|
-
const
|
|
1019
|
+
const y = t.nBitLength, b = Qi(u, t.endo ? Math.ceil(y / 2) : y);
|
|
1020
1020
|
return {
|
|
1021
1021
|
CURVE: t,
|
|
1022
1022
|
ProjectivePoint: u,
|
|
@@ -1043,21 +1043,21 @@ function ss(e) {
|
|
|
1043
1043
|
return ae < w && w < n.ORDER;
|
|
1044
1044
|
}
|
|
1045
1045
|
function c(w) {
|
|
1046
|
-
return
|
|
1046
|
+
return W(w, r);
|
|
1047
1047
|
}
|
|
1048
1048
|
function a(w) {
|
|
1049
|
-
return
|
|
1049
|
+
return Tt(w, r);
|
|
1050
1050
|
}
|
|
1051
|
-
const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder:
|
|
1051
|
+
const { ProjectivePoint: l, normPrivateKeyToScalar: f, weierstrassEquation: u, isWithinCurveOrder: y } = rs({
|
|
1052
1052
|
...t,
|
|
1053
1053
|
toBytes(w, v, N) {
|
|
1054
|
-
const
|
|
1055
|
-
return N ? U(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : U(Uint8Array.from([4]), C, n.toBytes(
|
|
1054
|
+
const _ = v.toAffine(), C = n.toBytes(_.x), U = Ie;
|
|
1055
|
+
return N ? U(Uint8Array.from([v.hasEvenY() ? 2 : 3]), C) : U(Uint8Array.from([4]), C, n.toBytes(_.y));
|
|
1056
1056
|
},
|
|
1057
1057
|
fromBytes(w) {
|
|
1058
|
-
const v = w.length, N = w[0],
|
|
1058
|
+
const v = w.length, N = w[0], _ = w.subarray(1);
|
|
1059
1059
|
if (v === i && (N === 2 || N === 3)) {
|
|
1060
|
-
const C = F(
|
|
1060
|
+
const C = F(_);
|
|
1061
1061
|
if (!o(C))
|
|
1062
1062
|
throw new Error("Point is not on curve");
|
|
1063
1063
|
const U = u(C);
|
|
@@ -1065,12 +1065,12 @@ function ss(e) {
|
|
|
1065
1065
|
const $ = (O & Y) === Y;
|
|
1066
1066
|
return (N & 1) === 1 !== $ && (O = n.neg(O)), { x: C, y: O };
|
|
1067
1067
|
} else if (v === s && N === 4) {
|
|
1068
|
-
const C = n.fromBytes(
|
|
1068
|
+
const C = n.fromBytes(_.subarray(0, n.BYTES)), U = n.fromBytes(_.subarray(n.BYTES, 2 * n.BYTES));
|
|
1069
1069
|
return { x: C, y: U };
|
|
1070
1070
|
} else
|
|
1071
1071
|
throw new Error(`Point of length ${v} was invalid. Expected ${i} compressed bytes or ${s} uncompressed bytes`);
|
|
1072
1072
|
}
|
|
1073
|
-
}), b = (w) =>
|
|
1073
|
+
}), b = (w) => qe(Ne(w, t.nByteLength));
|
|
1074
1074
|
function p(w) {
|
|
1075
1075
|
const v = r >> Y;
|
|
1076
1076
|
return w > v;
|
|
@@ -1079,38 +1079,38 @@ function ss(e) {
|
|
|
1079
1079
|
return p(w) ? c(-w) : w;
|
|
1080
1080
|
}
|
|
1081
1081
|
const d = (w, v, N) => F(w.slice(v, N));
|
|
1082
|
-
class
|
|
1083
|
-
constructor(v, N,
|
|
1084
|
-
this.r = v, this.s = N, this.recovery =
|
|
1082
|
+
class g {
|
|
1083
|
+
constructor(v, N, _) {
|
|
1084
|
+
this.r = v, this.s = N, this.recovery = _, this.assertValidity();
|
|
1085
1085
|
}
|
|
1086
1086
|
// pair (bytes of r, bytes of s)
|
|
1087
1087
|
static fromCompact(v) {
|
|
1088
1088
|
const N = t.nByteLength;
|
|
1089
|
-
return v =
|
|
1089
|
+
return v = Z("compactSignature", v, N * 2), new g(d(v, 0, N), d(v, N, 2 * N));
|
|
1090
1090
|
}
|
|
1091
1091
|
// DER encoded ECDSA signature
|
|
1092
1092
|
// https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
|
|
1093
1093
|
static fromDER(v) {
|
|
1094
|
-
const { r: N, s:
|
|
1095
|
-
return new
|
|
1094
|
+
const { r: N, s: _ } = Be.toSig(Z("DER", v));
|
|
1095
|
+
return new g(N, _);
|
|
1096
1096
|
}
|
|
1097
1097
|
assertValidity() {
|
|
1098
|
-
if (!
|
|
1098
|
+
if (!y(this.r))
|
|
1099
1099
|
throw new Error("r must be 0 < r < CURVE.n");
|
|
1100
|
-
if (!
|
|
1100
|
+
if (!y(this.s))
|
|
1101
1101
|
throw new Error("s must be 0 < s < CURVE.n");
|
|
1102
1102
|
}
|
|
1103
1103
|
addRecoveryBit(v) {
|
|
1104
|
-
return new
|
|
1104
|
+
return new g(this.r, this.s, v);
|
|
1105
1105
|
}
|
|
1106
1106
|
recoverPublicKey(v) {
|
|
1107
|
-
const { r: N, s:
|
|
1107
|
+
const { r: N, s: _, recovery: C } = this, U = x(Z("msgHash", v));
|
|
1108
1108
|
if (C == null || ![0, 1, 2, 3].includes(C))
|
|
1109
1109
|
throw new Error("recovery id invalid");
|
|
1110
1110
|
const O = C === 2 || C === 3 ? N + t.n : N;
|
|
1111
1111
|
if (O >= n.ORDER)
|
|
1112
1112
|
throw new Error("recovery id 2 or 3 invalid");
|
|
1113
|
-
const $ = C & 1 ? "03" : "02", Q = l.fromHex($ + b(O)), ge = a(O),
|
|
1113
|
+
const $ = C & 1 ? "03" : "02", Q = l.fromHex($ + b(O)), ge = a(O), Ue = c(-U * ge), Ve = c(_ * ge), we = l.BASE.multiplyAndAddUnsafe(Q, Ue, Ve);
|
|
1114
1114
|
if (!we)
|
|
1115
1115
|
throw new Error("point at infinify");
|
|
1116
1116
|
return we.assertValidity(), we;
|
|
@@ -1120,24 +1120,24 @@ function ss(e) {
|
|
|
1120
1120
|
return p(this.s);
|
|
1121
1121
|
}
|
|
1122
1122
|
normalizeS() {
|
|
1123
|
-
return this.hasHighS() ? new
|
|
1123
|
+
return this.hasHighS() ? new g(this.r, c(-this.s), this.recovery) : this;
|
|
1124
1124
|
}
|
|
1125
1125
|
// DER-encoded
|
|
1126
1126
|
toDERRawBytes() {
|
|
1127
|
-
return
|
|
1127
|
+
return De(this.toDERHex());
|
|
1128
1128
|
}
|
|
1129
1129
|
toDERHex() {
|
|
1130
|
-
return
|
|
1130
|
+
return Be.hexFromSig({ r: this.r, s: this.s });
|
|
1131
1131
|
}
|
|
1132
1132
|
// padded bytes of r, then padded bytes of s
|
|
1133
1133
|
toCompactRawBytes() {
|
|
1134
|
-
return
|
|
1134
|
+
return De(this.toCompactHex());
|
|
1135
1135
|
}
|
|
1136
1136
|
toCompactHex() {
|
|
1137
1137
|
return b(this.r) + b(this.s);
|
|
1138
1138
|
}
|
|
1139
1139
|
}
|
|
1140
|
-
const
|
|
1140
|
+
const E = {
|
|
1141
1141
|
isValidPrivateKey(w) {
|
|
1142
1142
|
try {
|
|
1143
1143
|
return f(w), !0;
|
|
@@ -1166,85 +1166,85 @@ function ss(e) {
|
|
|
1166
1166
|
return v._setWindowSize(w), v.multiply(BigInt(3)), v;
|
|
1167
1167
|
}
|
|
1168
1168
|
};
|
|
1169
|
-
function
|
|
1169
|
+
function S(w, v = !0) {
|
|
1170
1170
|
return l.fromPrivateKey(w).toRawBytes(v);
|
|
1171
1171
|
}
|
|
1172
|
-
function
|
|
1173
|
-
const v = w instanceof Uint8Array, N = typeof w == "string",
|
|
1174
|
-
return v ?
|
|
1172
|
+
function k(w) {
|
|
1173
|
+
const v = w instanceof Uint8Array, N = typeof w == "string", _ = (v || N) && w.length;
|
|
1174
|
+
return v ? _ === i || _ === s : N ? _ === 2 * i || _ === 2 * s : w instanceof l;
|
|
1175
1175
|
}
|
|
1176
1176
|
function B(w, v, N = !0) {
|
|
1177
|
-
if (
|
|
1177
|
+
if (k(w))
|
|
1178
1178
|
throw new Error("first arg must be private key");
|
|
1179
|
-
if (!
|
|
1179
|
+
if (!k(v))
|
|
1180
1180
|
throw new Error("second arg must be public key");
|
|
1181
1181
|
return l.fromHex(v).multiply(f(w)).toRawBytes(N);
|
|
1182
1182
|
}
|
|
1183
|
-
const
|
|
1183
|
+
const m = t.bits2int || function(w) {
|
|
1184
1184
|
const v = F(w), N = w.length * 8 - t.nBitLength;
|
|
1185
1185
|
return N > 0 ? v >> BigInt(N) : v;
|
|
1186
1186
|
}, x = t.bits2int_modN || function(w) {
|
|
1187
|
-
return c(
|
|
1188
|
-
},
|
|
1189
|
-
function
|
|
1187
|
+
return c(m(w));
|
|
1188
|
+
}, K = Jt(t.nBitLength);
|
|
1189
|
+
function M(w) {
|
|
1190
1190
|
if (typeof w != "bigint")
|
|
1191
1191
|
throw new Error("bigint expected");
|
|
1192
|
-
if (!(ae <= w && w <
|
|
1192
|
+
if (!(ae <= w && w < K))
|
|
1193
1193
|
throw new Error(`bigint expected < 2^${t.nBitLength}`);
|
|
1194
1194
|
return Ne(w, t.nByteLength);
|
|
1195
1195
|
}
|
|
1196
|
-
function
|
|
1197
|
-
if (["recovered", "canonical"].some((
|
|
1196
|
+
function I(w, v, N = A) {
|
|
1197
|
+
if (["recovered", "canonical"].some((Ae) => Ae in N))
|
|
1198
1198
|
throw new Error("sign() legacy options not supported");
|
|
1199
|
-
const { hash:
|
|
1199
|
+
const { hash: _, randomBytes: C } = t;
|
|
1200
1200
|
let { lowS: U, prehash: O, extraEntropy: $ } = N;
|
|
1201
|
-
U == null && (U = !0), w =
|
|
1202
|
-
const Q = x(w), ge = f(v),
|
|
1201
|
+
U == null && (U = !0), w = Z("msgHash", w), O && (w = Z("prehashed msgHash", _(w)));
|
|
1202
|
+
const Q = x(w), ge = f(v), Ue = [M(ge), M(Q)];
|
|
1203
1203
|
if ($ != null) {
|
|
1204
|
-
const
|
|
1205
|
-
|
|
1204
|
+
const Ae = $ === !0 ? C(n.BYTES) : $;
|
|
1205
|
+
Ue.push(Z("extraEntropy", Ae));
|
|
1206
1206
|
}
|
|
1207
|
-
const
|
|
1208
|
-
function
|
|
1209
|
-
const
|
|
1210
|
-
if (!
|
|
1207
|
+
const Ve = Ie(...Ue), we = Q;
|
|
1208
|
+
function Et(Ae) {
|
|
1209
|
+
const Le = m(Ae);
|
|
1210
|
+
if (!y(Le))
|
|
1211
1211
|
return;
|
|
1212
|
-
const
|
|
1212
|
+
const xn = a(Le), $e = l.BASE.multiply(Le).toAffine(), ee = c($e.x);
|
|
1213
1213
|
if (ee === ae)
|
|
1214
1214
|
return;
|
|
1215
|
-
const
|
|
1216
|
-
if (
|
|
1215
|
+
const Te = c(xn * c(we + ee * ge));
|
|
1216
|
+
if (Te === ae)
|
|
1217
1217
|
return;
|
|
1218
|
-
let
|
|
1219
|
-
return U && p(
|
|
1218
|
+
let Kn = ($e.x === ee ? 0 : 2) | Number($e.y & Y), Nn = Te;
|
|
1219
|
+
return U && p(Te) && (Nn = h(Te), Kn ^= 1), new g(ee, Nn, Kn);
|
|
1220
1220
|
}
|
|
1221
|
-
return { seed:
|
|
1221
|
+
return { seed: Ve, k2sig: Et };
|
|
1222
1222
|
}
|
|
1223
|
-
const
|
|
1224
|
-
function R(w, v, N =
|
|
1225
|
-
const { seed:
|
|
1226
|
-
return Jn(U.hash.outputLen, U.nByteLength, U.hmac)(
|
|
1223
|
+
const A = { lowS: t.lowS, prehash: !1 }, T = { lowS: t.lowS, prehash: !1 };
|
|
1224
|
+
function R(w, v, N = A) {
|
|
1225
|
+
const { seed: _, k2sig: C } = I(w, v, N), U = t;
|
|
1226
|
+
return Jn(U.hash.outputLen, U.nByteLength, U.hmac)(_, C);
|
|
1227
1227
|
}
|
|
1228
1228
|
l.BASE._setWindowSize(8);
|
|
1229
|
-
function H(w, v, N,
|
|
1230
|
-
var
|
|
1229
|
+
function H(w, v, N, _ = T) {
|
|
1230
|
+
var $e;
|
|
1231
1231
|
const C = w;
|
|
1232
|
-
if (v =
|
|
1232
|
+
if (v = Z("msgHash", v), N = Z("publicKey", N), "strict" in _)
|
|
1233
1233
|
throw new Error("options.strict was renamed to lowS");
|
|
1234
|
-
const { lowS: U, prehash: O } =
|
|
1234
|
+
const { lowS: U, prehash: O } = _;
|
|
1235
1235
|
let $, Q;
|
|
1236
1236
|
try {
|
|
1237
1237
|
if (typeof C == "string" || C instanceof Uint8Array)
|
|
1238
1238
|
try {
|
|
1239
|
-
$ =
|
|
1239
|
+
$ = g.fromDER(C);
|
|
1240
1240
|
} catch (ee) {
|
|
1241
|
-
if (!(ee instanceof
|
|
1241
|
+
if (!(ee instanceof Be.Err))
|
|
1242
1242
|
throw ee;
|
|
1243
|
-
$ =
|
|
1243
|
+
$ = g.fromCompact(C);
|
|
1244
1244
|
}
|
|
1245
1245
|
else if (typeof C == "object" && typeof C.r == "bigint" && typeof C.s == "bigint") {
|
|
1246
|
-
const { r: ee, s:
|
|
1247
|
-
$ = new
|
|
1246
|
+
const { r: ee, s: Te } = C;
|
|
1247
|
+
$ = new g(ee, Te);
|
|
1248
1248
|
} else
|
|
1249
1249
|
throw new Error("PARSE");
|
|
1250
1250
|
Q = l.fromHex(N);
|
|
@@ -1256,24 +1256,24 @@ function ss(e) {
|
|
|
1256
1256
|
if (U && $.hasHighS())
|
|
1257
1257
|
return !1;
|
|
1258
1258
|
O && (v = t.hash(v));
|
|
1259
|
-
const { r: ge, s:
|
|
1260
|
-
return
|
|
1259
|
+
const { r: ge, s: Ue } = $, Ve = x(v), we = a(Ue), Et = c(Ve * we), Ae = c(ge * we), Le = ($e = l.BASE.multiplyAndAddUnsafe(Q, Et, Ae)) == null ? void 0 : $e.toAffine();
|
|
1260
|
+
return Le ? c(Le.x) === ge : !1;
|
|
1261
1261
|
}
|
|
1262
1262
|
return {
|
|
1263
1263
|
CURVE: t,
|
|
1264
|
-
getPublicKey:
|
|
1264
|
+
getPublicKey: S,
|
|
1265
1265
|
getSharedSecret: B,
|
|
1266
1266
|
sign: R,
|
|
1267
1267
|
verify: H,
|
|
1268
1268
|
ProjectivePoint: l,
|
|
1269
|
-
Signature:
|
|
1270
|
-
utils:
|
|
1269
|
+
Signature: g,
|
|
1270
|
+
utils: E
|
|
1271
1271
|
};
|
|
1272
1272
|
}
|
|
1273
1273
|
let tr = class extends Wn {
|
|
1274
1274
|
constructor(t, n) {
|
|
1275
|
-
super(), this.finished = !1, this.destroyed = !1,
|
|
1276
|
-
const r =
|
|
1275
|
+
super(), this.finished = !1, this.destroyed = !1, mi(t);
|
|
1276
|
+
const r = Wt(n);
|
|
1277
1277
|
if (this.iHash = t.create(), typeof this.iHash.update != "function")
|
|
1278
1278
|
throw new Error("Expected instance of class which extends utils.Hash");
|
|
1279
1279
|
this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
|
|
@@ -1322,15 +1322,15 @@ function as(e, t) {
|
|
|
1322
1322
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1323
1323
|
const ct = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"), tt = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"), rr = BigInt(1), nt = BigInt(2), In = (e, t) => (e + t / nt) / t;
|
|
1324
1324
|
function ir(e) {
|
|
1325
|
-
const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = J(f, n, t) * f % t,
|
|
1326
|
-
if (!
|
|
1325
|
+
const t = ct, n = BigInt(3), r = BigInt(6), i = BigInt(11), s = BigInt(22), o = BigInt(23), c = BigInt(44), a = BigInt(88), l = e * e * e % t, f = l * l * e % t, u = J(f, n, t) * f % t, y = J(u, n, t) * f % t, b = J(y, nt, t) * l % t, p = J(b, i, t) * b % t, h = J(p, s, t) * p % t, d = J(h, c, t) * h % t, g = J(d, a, t) * d % t, E = J(g, c, t) * h % t, S = J(E, n, t) * f % t, k = J(S, o, t) * p % t, B = J(k, r, t) * l % t, m = J(B, nt, t);
|
|
1326
|
+
if (!Rt.eql(Rt.sqr(m), e))
|
|
1327
1327
|
throw new Error("Cannot find square root");
|
|
1328
|
-
return
|
|
1328
|
+
return m;
|
|
1329
1329
|
}
|
|
1330
|
-
const
|
|
1330
|
+
const Rt = Ji(ct, void 0, void 0, { sqrt: ir }), ke = as({
|
|
1331
1331
|
a: BigInt(0),
|
|
1332
1332
|
b: BigInt(7),
|
|
1333
|
-
Fp:
|
|
1333
|
+
Fp: Rt,
|
|
1334
1334
|
n: tt,
|
|
1335
1335
|
// Base point (x, y) aka generator point
|
|
1336
1336
|
Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
|
|
@@ -1347,34 +1347,34 @@ const Ot = Ji(ct, void 0, void 0, { sqrt: ir }), Ue = as({
|
|
|
1347
1347
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
|
1348
1348
|
splitScalar: (e) => {
|
|
1349
1349
|
const t = tt, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), r = -rr * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), i = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), s = n, o = BigInt("0x100000000000000000000000000000000"), c = In(s * e, t), a = In(-r * e, t);
|
|
1350
|
-
let l =
|
|
1351
|
-
const u = l > o,
|
|
1352
|
-
if (u && (l = t - l),
|
|
1350
|
+
let l = W(e - c * n - a * i, t), f = W(-c * r - a * s, t);
|
|
1351
|
+
const u = l > o, y = f > o;
|
|
1352
|
+
if (u && (l = t - l), y && (f = t - f), l > o || f > o)
|
|
1353
1353
|
throw new Error("splitScalar: Endomorphism failed, k=" + e);
|
|
1354
|
-
return { k1neg: u, k1: l, k2neg:
|
|
1354
|
+
return { k1neg: u, k1: l, k2neg: y, k2: f };
|
|
1355
1355
|
}
|
|
1356
1356
|
}
|
|
1357
|
-
},
|
|
1357
|
+
}, Lt), ut = BigInt(0), sr = (e) => typeof e == "bigint" && ut < e && e < ct, cs = (e) => typeof e == "bigint" && ut < e && e < tt, kn = {};
|
|
1358
1358
|
function rt(e, ...t) {
|
|
1359
|
-
let n =
|
|
1359
|
+
let n = kn[e];
|
|
1360
1360
|
if (n === void 0) {
|
|
1361
|
-
const r =
|
|
1362
|
-
n = Ie(r, r),
|
|
1361
|
+
const r = Lt(Uint8Array.from(e, (i) => i.charCodeAt(0)));
|
|
1362
|
+
n = Ie(r, r), kn[e] = n;
|
|
1363
1363
|
}
|
|
1364
|
-
return
|
|
1364
|
+
return Lt(Ie(n, ...t));
|
|
1365
1365
|
}
|
|
1366
|
-
const
|
|
1366
|
+
const Yt = (e) => e.toRawBytes(!0).slice(1), Ot = (e) => Ne(e, 32), At = (e) => W(e, ct), Fe = (e) => W(e, tt), Xt = ke.ProjectivePoint, us = (e, t, n) => Xt.BASE.multiplyAndAddUnsafe(e, t, n);
|
|
1367
1367
|
function Pt(e) {
|
|
1368
|
-
let t =
|
|
1369
|
-
return { scalar: n.hasEvenY() ? t : Fe(-t), bytes:
|
|
1368
|
+
let t = ke.utils.normPrivateKeyToScalar(e), n = Xt.fromPrivateKey(t);
|
|
1369
|
+
return { scalar: n.hasEvenY() ? t : Fe(-t), bytes: Yt(n) };
|
|
1370
1370
|
}
|
|
1371
1371
|
function or(e) {
|
|
1372
1372
|
if (!sr(e))
|
|
1373
1373
|
throw new Error("bad x: need 0 < x < p");
|
|
1374
|
-
const t =
|
|
1374
|
+
const t = At(e * e), n = At(t * e + BigInt(7));
|
|
1375
1375
|
let r = ir(n);
|
|
1376
|
-
r % nt !== ut && (r =
|
|
1377
|
-
const i = new
|
|
1376
|
+
r % nt !== ut && (r = At(-r));
|
|
1377
|
+
const i = new Xt(e, r, rr);
|
|
1378
1378
|
return i.assertValidity(), i;
|
|
1379
1379
|
}
|
|
1380
1380
|
function ar(...e) {
|
|
@@ -1384,16 +1384,16 @@ function ls(e) {
|
|
|
1384
1384
|
return Pt(e).bytes;
|
|
1385
1385
|
}
|
|
1386
1386
|
function fs(e, t, n = Zn(32)) {
|
|
1387
|
-
const r =
|
|
1387
|
+
const r = Z("message", e), { bytes: i, scalar: s } = Pt(t), o = Z("auxRand", n, 32), c = Ot(s ^ F(rt("BIP0340/aux", o))), a = rt("BIP0340/nonce", c, i, r), l = Fe(F(a));
|
|
1388
1388
|
if (l === ut)
|
|
1389
1389
|
throw new Error("sign failed: k is zero");
|
|
1390
|
-
const { bytes: f, scalar: u } = Pt(l),
|
|
1391
|
-
if (b.set(f, 0), b.set(
|
|
1390
|
+
const { bytes: f, scalar: u } = Pt(l), y = ar(f, i, r), b = new Uint8Array(64);
|
|
1391
|
+
if (b.set(f, 0), b.set(Ot(Fe(u + y * s)), 32), !cr(b, r, i))
|
|
1392
1392
|
throw new Error("sign: Invalid signature produced");
|
|
1393
1393
|
return b;
|
|
1394
1394
|
}
|
|
1395
1395
|
function cr(e, t, n) {
|
|
1396
|
-
const r =
|
|
1396
|
+
const r = Z("signature", e, 64), i = Z("message", t), s = Z("publicKey", n, 32);
|
|
1397
1397
|
try {
|
|
1398
1398
|
const o = or(F(s)), c = F(r.subarray(0, 32));
|
|
1399
1399
|
if (!sr(c))
|
|
@@ -1401,40 +1401,40 @@ function cr(e, t, n) {
|
|
|
1401
1401
|
const a = F(r.subarray(32, 64));
|
|
1402
1402
|
if (!cs(a))
|
|
1403
1403
|
return !1;
|
|
1404
|
-
const l = ar(
|
|
1404
|
+
const l = ar(Ot(c), Yt(o), i), f = us(o, a, Fe(-l));
|
|
1405
1405
|
return !(!f || !f.hasEvenY() || f.toAffine().x !== c);
|
|
1406
1406
|
} catch {
|
|
1407
1407
|
return !1;
|
|
1408
1408
|
}
|
|
1409
1409
|
}
|
|
1410
|
-
const
|
|
1410
|
+
const We = {
|
|
1411
1411
|
getPublicKey: ls,
|
|
1412
1412
|
sign: fs,
|
|
1413
1413
|
verify: cr,
|
|
1414
1414
|
utils: {
|
|
1415
|
-
randomPrivateKey:
|
|
1415
|
+
randomPrivateKey: ke.utils.randomPrivateKey,
|
|
1416
1416
|
lift_x: or,
|
|
1417
|
-
pointToBytes:
|
|
1417
|
+
pointToBytes: Yt,
|
|
1418
1418
|
numberToBytesBE: Ne,
|
|
1419
1419
|
bytesToNumberBE: F,
|
|
1420
1420
|
taggedHash: rt,
|
|
1421
|
-
mod:
|
|
1421
|
+
mod: W
|
|
1422
1422
|
}
|
|
1423
1423
|
}, Ct = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
|
|
1424
1424
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1425
|
-
const
|
|
1425
|
+
const Qt = (e) => e instanceof Uint8Array, Bt = (e) => new DataView(e.buffer, e.byteOffset, e.byteLength), ie = (e, t) => e << 32 - t | e >>> t, hs = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
1426
1426
|
if (!hs)
|
|
1427
1427
|
throw new Error("Non little-endian hardware is not supported");
|
|
1428
1428
|
const ds = Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
1429
|
-
function
|
|
1430
|
-
if (!
|
|
1429
|
+
function P(e) {
|
|
1430
|
+
if (!Qt(e))
|
|
1431
1431
|
throw new Error("Uint8Array expected");
|
|
1432
1432
|
let t = "";
|
|
1433
1433
|
for (let n = 0; n < e.length; n++)
|
|
1434
1434
|
t += ds[e[n]];
|
|
1435
1435
|
return t;
|
|
1436
1436
|
}
|
|
1437
|
-
function
|
|
1437
|
+
function z(e) {
|
|
1438
1438
|
if (typeof e != "string")
|
|
1439
1439
|
throw new Error("hex string expected, got " + typeof e);
|
|
1440
1440
|
const t = e.length;
|
|
@@ -1449,13 +1449,13 @@ function G(e) {
|
|
|
1449
1449
|
}
|
|
1450
1450
|
return n;
|
|
1451
1451
|
}
|
|
1452
|
-
function
|
|
1452
|
+
function ys(e) {
|
|
1453
1453
|
if (typeof e != "string")
|
|
1454
1454
|
throw new Error(`utf8ToBytes expected string, got ${typeof e}`);
|
|
1455
1455
|
return new Uint8Array(new TextEncoder().encode(e));
|
|
1456
1456
|
}
|
|
1457
1457
|
function Je(e) {
|
|
1458
|
-
if (typeof e == "string" && (e =
|
|
1458
|
+
if (typeof e == "string" && (e = ys(e)), !Qt(e))
|
|
1459
1459
|
throw new Error(`expected Uint8Array, got ${typeof e}`);
|
|
1460
1460
|
return e;
|
|
1461
1461
|
}
|
|
@@ -1463,7 +1463,7 @@ function lt(...e) {
|
|
|
1463
1463
|
const t = new Uint8Array(e.reduce((r, i) => r + i.length, 0));
|
|
1464
1464
|
let n = 0;
|
|
1465
1465
|
return e.forEach((r) => {
|
|
1466
|
-
if (!
|
|
1466
|
+
if (!Qt(r))
|
|
1467
1467
|
throw new Error("Uint8Array expected");
|
|
1468
1468
|
t.set(r, n), n += r.length;
|
|
1469
1469
|
}), t;
|
|
@@ -1483,11 +1483,11 @@ function fr(e = 32) {
|
|
|
1483
1483
|
return Ct.getRandomValues(new Uint8Array(e));
|
|
1484
1484
|
throw new Error("crypto.getRandomValues must be defined");
|
|
1485
1485
|
}
|
|
1486
|
-
function
|
|
1486
|
+
function Mt(e) {
|
|
1487
1487
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
1488
1488
|
throw new Error(`Wrong positive integer: ${e}`);
|
|
1489
1489
|
}
|
|
1490
|
-
function
|
|
1490
|
+
function ps(e) {
|
|
1491
1491
|
if (typeof e != "boolean")
|
|
1492
1492
|
throw new Error(`Expected boolean, not ${e}`);
|
|
1493
1493
|
}
|
|
@@ -1500,7 +1500,7 @@ function hr(e, ...t) {
|
|
|
1500
1500
|
function gs(e) {
|
|
1501
1501
|
if (typeof e != "function" || typeof e.create != "function")
|
|
1502
1502
|
throw new Error("Hash should be wrapped by utils.wrapConstructor");
|
|
1503
|
-
|
|
1503
|
+
Mt(e.outputLen), Mt(e.blockLen);
|
|
1504
1504
|
}
|
|
1505
1505
|
function ws(e, t = !0) {
|
|
1506
1506
|
if (e.destroyed)
|
|
@@ -1515,8 +1515,8 @@ function bs(e, t) {
|
|
|
1515
1515
|
throw new Error(`digestInto() expects output buffer of length at least ${n}`);
|
|
1516
1516
|
}
|
|
1517
1517
|
const se = {
|
|
1518
|
-
number:
|
|
1519
|
-
bool:
|
|
1518
|
+
number: Mt,
|
|
1519
|
+
bool: ps,
|
|
1520
1520
|
bytes: hr,
|
|
1521
1521
|
hash: gs,
|
|
1522
1522
|
exists: ws,
|
|
@@ -1528,7 +1528,7 @@ function vs(e, t, n, r) {
|
|
|
1528
1528
|
const i = BigInt(32), s = BigInt(4294967295), o = Number(n >> i & s), c = Number(n & s), a = r ? 4 : 0, l = r ? 0 : 4;
|
|
1529
1529
|
e.setUint32(t + a, o, r), e.setUint32(t + l, c, r);
|
|
1530
1530
|
}
|
|
1531
|
-
class
|
|
1531
|
+
class ms extends ur {
|
|
1532
1532
|
constructor(t, n, r, i) {
|
|
1533
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 = Bt(this.buffer);
|
|
1534
1534
|
}
|
|
@@ -1578,7 +1578,7 @@ class Es extends ur {
|
|
|
1578
1578
|
return t.length = i, t.pos = c, t.finished = s, t.destroyed = o, i % n && t.buffer.set(r), t;
|
|
1579
1579
|
}
|
|
1580
1580
|
}
|
|
1581
|
-
const
|
|
1581
|
+
const Es = (e, t, n) => e & t ^ ~e & n, xs = (e, t, n) => e & t ^ e & n ^ t & n, Ks = new Uint32Array([
|
|
1582
1582
|
1116352408,
|
|
1583
1583
|
1899447441,
|
|
1584
1584
|
3049323471,
|
|
@@ -1643,7 +1643,7 @@ const ms = (e, t, n) => e & t ^ ~e & n, xs = (e, t, n) => e & t ^ e & n ^ t & n,
|
|
|
1643
1643
|
2756734187,
|
|
1644
1644
|
3204031479,
|
|
1645
1645
|
3329325298
|
|
1646
|
-
]),
|
|
1646
|
+
]), me = new Uint32Array([
|
|
1647
1647
|
1779033703,
|
|
1648
1648
|
3144134277,
|
|
1649
1649
|
1013904242,
|
|
@@ -1652,10 +1652,10 @@ const ms = (e, t, n) => e & t ^ ~e & n, xs = (e, t, n) => e & t ^ e & n ^ t & n,
|
|
|
1652
1652
|
2600822924,
|
|
1653
1653
|
528734635,
|
|
1654
1654
|
1541459225
|
|
1655
|
-
]),
|
|
1656
|
-
class dr extends
|
|
1655
|
+
]), Ee = new Uint32Array(64);
|
|
1656
|
+
class dr extends ms {
|
|
1657
1657
|
constructor() {
|
|
1658
|
-
super(64, 32, 8, !1), this.A =
|
|
1658
|
+
super(64, 32, 8, !1), this.A = me[0] | 0, this.B = me[1] | 0, this.C = me[2] | 0, this.D = me[3] | 0, this.E = me[4] | 0, this.F = me[5] | 0, this.G = me[6] | 0, this.H = me[7] | 0;
|
|
1659
1659
|
}
|
|
1660
1660
|
get() {
|
|
1661
1661
|
const { A: t, B: n, C: r, D: i, E: s, F: o, G: c, H: a } = this;
|
|
@@ -1667,20 +1667,20 @@ class dr extends Es {
|
|
|
1667
1667
|
}
|
|
1668
1668
|
process(t, n) {
|
|
1669
1669
|
for (let u = 0; u < 16; u++, n += 4)
|
|
1670
|
-
|
|
1670
|
+
Ee[u] = t.getUint32(n, !1);
|
|
1671
1671
|
for (let u = 16; u < 64; u++) {
|
|
1672
|
-
const
|
|
1673
|
-
|
|
1672
|
+
const y = Ee[u - 15], b = Ee[u - 2], p = ie(y, 7) ^ ie(y, 18) ^ y >>> 3, h = ie(b, 17) ^ ie(b, 19) ^ b >>> 10;
|
|
1673
|
+
Ee[u] = h + Ee[u - 7] + p + Ee[u - 16] | 0;
|
|
1674
1674
|
}
|
|
1675
1675
|
let { A: r, B: i, C: s, D: o, E: c, F: a, G: l, H: f } = this;
|
|
1676
1676
|
for (let u = 0; u < 64; u++) {
|
|
1677
|
-
const
|
|
1677
|
+
const y = ie(c, 6) ^ ie(c, 11) ^ ie(c, 25), b = f + y + Es(c, a, l) + Ks[u] + Ee[u] | 0, h = (ie(r, 2) ^ ie(r, 13) ^ ie(r, 22)) + xs(r, i, s) | 0;
|
|
1678
1678
|
f = l, l = a, a = c, c = o + b | 0, o = s, s = i, i = r, r = b + h | 0;
|
|
1679
1679
|
}
|
|
1680
1680
|
r = r + this.A | 0, i = i + this.B | 0, s = s + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, a = a + this.F | 0, l = l + this.G | 0, f = f + this.H | 0, this.set(r, i, s, o, c, a, l, f);
|
|
1681
1681
|
}
|
|
1682
1682
|
roundClean() {
|
|
1683
|
-
|
|
1683
|
+
Ee.fill(0);
|
|
1684
1684
|
}
|
|
1685
1685
|
destroy() {
|
|
1686
1686
|
this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
|
|
@@ -1694,7 +1694,7 @@ class Ns extends dr {
|
|
|
1694
1694
|
const fe = lr(() => new dr());
|
|
1695
1695
|
lr(() => new Ns());
|
|
1696
1696
|
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
1697
|
-
function
|
|
1697
|
+
function ze(e) {
|
|
1698
1698
|
if (!Number.isSafeInteger(e))
|
|
1699
1699
|
throw new Error(`Wrong integer: ${e}`);
|
|
1700
1700
|
}
|
|
@@ -1702,13 +1702,13 @@ function de(...e) {
|
|
|
1702
1702
|
const t = (i, s) => (o) => i(s(o)), n = Array.from(e).reverse().reduce((i, s) => i ? t(i, s.encode) : s.encode, void 0), r = e.reduce((i, s) => i ? t(i, s.decode) : s.decode, void 0);
|
|
1703
1703
|
return { encode: n, decode: r };
|
|
1704
1704
|
}
|
|
1705
|
-
function
|
|
1705
|
+
function ye(e) {
|
|
1706
1706
|
return {
|
|
1707
1707
|
encode: (t) => {
|
|
1708
1708
|
if (!Array.isArray(t) || t.length && typeof t[0] != "number")
|
|
1709
1709
|
throw new Error("alphabet.encode input should be an array of numbers");
|
|
1710
1710
|
return t.map((n) => {
|
|
1711
|
-
if (
|
|
1711
|
+
if (ze(n), n < 0 || n >= e.length)
|
|
1712
1712
|
throw new Error(`Digit index outside alphabet: ${n} (alphabet: ${e.length})`);
|
|
1713
1713
|
return e[n];
|
|
1714
1714
|
});
|
|
@@ -1727,7 +1727,7 @@ function pe(e) {
|
|
|
1727
1727
|
}
|
|
1728
1728
|
};
|
|
1729
1729
|
}
|
|
1730
|
-
function
|
|
1730
|
+
function pe(e = "") {
|
|
1731
1731
|
if (typeof e != "string")
|
|
1732
1732
|
throw new Error("join separator should be string");
|
|
1733
1733
|
return {
|
|
@@ -1747,7 +1747,7 @@ function ye(e = "") {
|
|
|
1747
1747
|
};
|
|
1748
1748
|
}
|
|
1749
1749
|
function ft(e, t = "=") {
|
|
1750
|
-
if (
|
|
1750
|
+
if (ze(e), typeof t != "string")
|
|
1751
1751
|
throw new Error("padding chr should be string");
|
|
1752
1752
|
return {
|
|
1753
1753
|
encode(n) {
|
|
@@ -1776,12 +1776,12 @@ function ft(e, t = "=") {
|
|
|
1776
1776
|
}
|
|
1777
1777
|
};
|
|
1778
1778
|
}
|
|
1779
|
-
function
|
|
1779
|
+
function yr(e) {
|
|
1780
1780
|
if (typeof e != "function")
|
|
1781
1781
|
throw new Error("normalize fn should be function");
|
|
1782
1782
|
return { encode: (t) => t, decode: (t) => e(t) };
|
|
1783
1783
|
}
|
|
1784
|
-
function
|
|
1784
|
+
function Un(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)
|
|
@@ -1793,7 +1793,7 @@ function Ln(e, t, n) {
|
|
|
1793
1793
|
let r = 0;
|
|
1794
1794
|
const i = [], s = Array.from(e);
|
|
1795
1795
|
for (s.forEach((o) => {
|
|
1796
|
-
if (
|
|
1796
|
+
if (ze(o), o < 0 || o >= t)
|
|
1797
1797
|
throw new Error(`Wrong integer: ${o}`);
|
|
1798
1798
|
}); ; ) {
|
|
1799
1799
|
let o = 0, c = !0;
|
|
@@ -1814,8 +1814,8 @@ function Ln(e, t, n) {
|
|
|
1814
1814
|
i.push(0);
|
|
1815
1815
|
return i.reverse();
|
|
1816
1816
|
}
|
|
1817
|
-
const
|
|
1818
|
-
function
|
|
1817
|
+
const pr = (e, t) => t ? pr(t, e % t) : e, it = (e, t) => e + (t - pr(e, t));
|
|
1818
|
+
function Ht(e, t, n, r) {
|
|
1819
1819
|
if (!Array.isArray(e))
|
|
1820
1820
|
throw new Error("convertRadix2: data should be array");
|
|
1821
1821
|
if (t <= 0 || t > 32)
|
|
@@ -1827,7 +1827,7 @@ function qt(e, t, n, r) {
|
|
|
1827
1827
|
let i = 0, s = 0;
|
|
1828
1828
|
const o = 2 ** n - 1, c = [];
|
|
1829
1829
|
for (const a of e) {
|
|
1830
|
-
if (
|
|
1830
|
+
if (ze(a), a >= 2 ** t)
|
|
1831
1831
|
throw new Error(`convertRadix2: invalid data word=${a} from=${t}`);
|
|
1832
1832
|
if (i = i << t | a, s + t > 32)
|
|
1833
1833
|
throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);
|
|
@@ -1841,22 +1841,22 @@ function qt(e, t, n, r) {
|
|
|
1841
1841
|
throw new Error(`Non-zero padding: ${i}`);
|
|
1842
1842
|
return r && s > 0 && c.push(i >>> 0), c;
|
|
1843
1843
|
}
|
|
1844
|
-
function
|
|
1845
|
-
return
|
|
1844
|
+
function Ss(e) {
|
|
1845
|
+
return ze(e), {
|
|
1846
1846
|
encode: (t) => {
|
|
1847
1847
|
if (!(t instanceof Uint8Array))
|
|
1848
1848
|
throw new Error("radix.encode input should be Uint8Array");
|
|
1849
|
-
return
|
|
1849
|
+
return Un(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(
|
|
1854
|
+
return Uint8Array.from(Un(t, e, 2 ** 8));
|
|
1855
1855
|
}
|
|
1856
1856
|
};
|
|
1857
1857
|
}
|
|
1858
|
-
function
|
|
1859
|
-
if (
|
|
1858
|
+
function Se(e, t = !1) {
|
|
1859
|
+
if (ze(e), e <= 0 || e > 32)
|
|
1860
1860
|
throw new Error("radix2: bits should be in (0..32]");
|
|
1861
1861
|
if (it(8, e) > 32 || it(e, 8) > 32)
|
|
1862
1862
|
throw new Error("radix2: carry overflow");
|
|
@@ -1864,16 +1864,16 @@ function Ae(e, t = !1) {
|
|
|
1864
1864
|
encode: (n) => {
|
|
1865
1865
|
if (!(n instanceof Uint8Array))
|
|
1866
1866
|
throw new Error("radix2.encode input should be Uint8Array");
|
|
1867
|
-
return
|
|
1867
|
+
return Ht(Array.from(n), 8, e, !t);
|
|
1868
1868
|
},
|
|
1869
1869
|
decode: (n) => {
|
|
1870
1870
|
if (!Array.isArray(n) || n.length && typeof n[0] != "number")
|
|
1871
1871
|
throw new Error("radix2.decode input should be array of strings");
|
|
1872
|
-
return Uint8Array.from(
|
|
1872
|
+
return Uint8Array.from(Ht(n, e, 8, t));
|
|
1873
1873
|
}
|
|
1874
1874
|
};
|
|
1875
1875
|
}
|
|
1876
|
-
function
|
|
1876
|
+
function Ln(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 $n(e) {
|
|
|
1883
1883
|
}
|
|
1884
1884
|
};
|
|
1885
1885
|
}
|
|
1886
|
-
const
|
|
1887
|
-
de(
|
|
1888
|
-
de(
|
|
1889
|
-
const he = de(
|
|
1890
|
-
|
|
1891
|
-
|
|
1892
|
-
const
|
|
1886
|
+
const As = de(Se(4), ye("0123456789ABCDEF"), pe("")), Cs = de(Se(5), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"), ft(5), pe(""));
|
|
1887
|
+
de(Se(5), ye("0123456789ABCDEFGHIJKLMNOPQRSTUV"), ft(5), pe(""));
|
|
1888
|
+
de(Se(5), ye("0123456789ABCDEFGHJKMNPQRSTVWXYZ"), pe(""), yr((e) => e.toUpperCase().replace(/O/g, "0").replace(/[IL]/g, "1")));
|
|
1889
|
+
const he = de(Se(6), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"), ft(6), pe("")), Bs = de(Se(6), ye("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"), ft(6), pe("")), en = (e) => de(Ss(58), ye(e), pe("")), qt = en("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz");
|
|
1890
|
+
en("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ");
|
|
1891
|
+
en("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");
|
|
1892
|
+
const $n = [0, 2, 3, 5, 6, 7, 9, 10, 11], _s = {
|
|
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 +=
|
|
1897
|
+
t += qt.encode(r).padStart($n[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 =
|
|
1904
|
+
const r = e.slice(n, n + 11), i = $n.indexOf(r.length), s = qt.decode(r);
|
|
1905
1905
|
for (let o = 0; o < s.length - i; o++)
|
|
1906
1906
|
if (s[o] !== 0)
|
|
1907
1907
|
throw new Error("base58xmr: wrong padding");
|
|
@@ -1909,96 +1909,96 @@ const Tn = [0, 2, 3, 5, 6, 7, 9, 10, 11], ks = {
|
|
|
1909
1909
|
}
|
|
1910
1910
|
return Uint8Array.from(t);
|
|
1911
1911
|
}
|
|
1912
|
-
},
|
|
1913
|
-
function
|
|
1912
|
+
}, Dt = de(ye("qpzry9x8gf2tvdw0s3jn54khce6mua7l"), pe("")), Tn = [996825010, 642813549, 513874426, 1027748829, 705979059];
|
|
1913
|
+
function Ze(e) {
|
|
1914
1914
|
const t = e >> 25;
|
|
1915
1915
|
let n = (e & 33554431) << 5;
|
|
1916
|
-
for (let r = 0; r <
|
|
1917
|
-
(t >> r & 1) === 1 && (n ^=
|
|
1916
|
+
for (let r = 0; r < Tn.length; r++)
|
|
1917
|
+
(t >> r & 1) === 1 && (n ^= Tn[r]);
|
|
1918
1918
|
return n;
|
|
1919
1919
|
}
|
|
1920
|
-
function
|
|
1920
|
+
function Rn(e, t, n = 1) {
|
|
1921
1921
|
const r = e.length;
|
|
1922
1922
|
let i = 1;
|
|
1923
1923
|
for (let s = 0; s < r; s++) {
|
|
1924
1924
|
const o = e.charCodeAt(s);
|
|
1925
1925
|
if (o < 33 || o > 126)
|
|
1926
1926
|
throw new Error(`Invalid prefix (${e})`);
|
|
1927
|
-
i =
|
|
1927
|
+
i = Ze(i) ^ o >> 5;
|
|
1928
1928
|
}
|
|
1929
|
-
i =
|
|
1929
|
+
i = Ze(i);
|
|
1930
1930
|
for (let s = 0; s < r; s++)
|
|
1931
|
-
i =
|
|
1931
|
+
i = Ze(i) ^ e.charCodeAt(s) & 31;
|
|
1932
1932
|
for (let s of t)
|
|
1933
|
-
i =
|
|
1933
|
+
i = Ze(i) ^ s;
|
|
1934
1934
|
for (let s = 0; s < 6; s++)
|
|
1935
|
-
i =
|
|
1936
|
-
return i ^= n,
|
|
1935
|
+
i = Ze(i);
|
|
1936
|
+
return i ^= n, Dt.encode(Ht([i % 2 ** 30], 30, 5, !1));
|
|
1937
1937
|
}
|
|
1938
1938
|
function gr(e) {
|
|
1939
|
-
const t = e === "bech32" ? 1 : 734539939, n =
|
|
1940
|
-
function o(f, u,
|
|
1939
|
+
const t = e === "bech32" ? 1 : 734539939, n = Se(5), r = n.decode, i = n.encode, s = Ln(r);
|
|
1940
|
+
function o(f, u, y = 90) {
|
|
1941
1941
|
if (typeof f != "string")
|
|
1942
1942
|
throw new Error(`bech32.encode prefix should be string, not ${typeof f}`);
|
|
1943
1943
|
if (!Array.isArray(u) || u.length && typeof u[0] != "number")
|
|
1944
1944
|
throw new Error(`bech32.encode words should be array of numbers, not ${typeof u}`);
|
|
1945
1945
|
const b = f.length + 7 + u.length;
|
|
1946
|
-
if (
|
|
1947
|
-
throw new TypeError(`Length ${b} exceeds limit ${
|
|
1948
|
-
return f = f.toLowerCase(), `${f}1${
|
|
1946
|
+
if (y !== !1 && b > y)
|
|
1947
|
+
throw new TypeError(`Length ${b} exceeds limit ${y}`);
|
|
1948
|
+
return f = f.toLowerCase(), `${f}1${Dt.encode(u)}${Rn(f, u, t)}`;
|
|
1949
1949
|
}
|
|
1950
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
1953
|
if (f.length < 8 || u !== !1 && f.length > u)
|
|
1954
1954
|
throw new TypeError(`Wrong string length: ${f.length} (${f}). Expected (8..${u})`);
|
|
1955
|
-
const
|
|
1956
|
-
if (f !==
|
|
1955
|
+
const y = f.toLowerCase();
|
|
1956
|
+
if (f !== y && f !== f.toUpperCase())
|
|
1957
1957
|
throw new Error("String must be lowercase or uppercase");
|
|
1958
|
-
f =
|
|
1958
|
+
f = y;
|
|
1959
1959
|
const b = f.lastIndexOf("1");
|
|
1960
1960
|
if (b === 0 || b === -1)
|
|
1961
1961
|
throw new Error('Letter "1" must be present between prefix and data only');
|
|
1962
1962
|
const p = f.slice(0, b), h = f.slice(b + 1);
|
|
1963
1963
|
if (h.length < 6)
|
|
1964
1964
|
throw new Error("Data must be at least 6 characters long");
|
|
1965
|
-
const d =
|
|
1966
|
-
if (!h.endsWith(
|
|
1967
|
-
throw new Error(`Invalid checksum in ${f}: expected "${
|
|
1965
|
+
const d = Dt.decode(h).slice(0, -6), g = Rn(p, d, t);
|
|
1966
|
+
if (!h.endsWith(g))
|
|
1967
|
+
throw new Error(`Invalid checksum in ${f}: expected "${g}"`);
|
|
1968
1968
|
return { prefix: p, words: d };
|
|
1969
1969
|
}
|
|
1970
|
-
const a =
|
|
1970
|
+
const a = Ln(c);
|
|
1971
1971
|
function l(f) {
|
|
1972
|
-
const { prefix: u, words:
|
|
1973
|
-
return { prefix: u, words:
|
|
1972
|
+
const { prefix: u, words: y } = c(f, !1);
|
|
1973
|
+
return { prefix: u, words: y, bytes: r(y) };
|
|
1974
1974
|
}
|
|
1975
1975
|
return { encode: o, decode: c, decodeToBytes: l, decodeUnsafe: a, fromWords: r, fromWordsUnsafe: s, toWords: i };
|
|
1976
1976
|
}
|
|
1977
|
-
const
|
|
1977
|
+
const je = gr("bech32");
|
|
1978
1978
|
gr("bech32m");
|
|
1979
|
-
const
|
|
1979
|
+
const Is = {
|
|
1980
1980
|
encode: (e) => new TextDecoder().decode(e),
|
|
1981
1981
|
decode: (e) => new TextEncoder().encode(e)
|
|
1982
|
-
},
|
|
1982
|
+
}, ks = de(Se(4), ye("0123456789abcdef"), pe(""), yr((e) => {
|
|
1983
1983
|
if (typeof e != "string" || e.length % 2)
|
|
1984
1984
|
throw new TypeError(`hex.decode: expected string, got ${typeof e} with length ${e.length}`);
|
|
1985
1985
|
return e.toLowerCase();
|
|
1986
1986
|
})), Us = {
|
|
1987
|
-
utf8:
|
|
1988
|
-
hex:
|
|
1989
|
-
base16:
|
|
1987
|
+
utf8: Is,
|
|
1988
|
+
hex: ks,
|
|
1989
|
+
base16: As,
|
|
1990
1990
|
base32: Cs,
|
|
1991
1991
|
base64: he,
|
|
1992
1992
|
base64url: Bs,
|
|
1993
|
-
base58:
|
|
1994
|
-
base58xmr:
|
|
1993
|
+
base58: qt,
|
|
1994
|
+
base58xmr: _s
|
|
1995
1995
|
};
|
|
1996
1996
|
`${Object.keys(Us).join(", ")}`;
|
|
1997
|
-
function
|
|
1997
|
+
function _t(e) {
|
|
1998
1998
|
if (!Number.isSafeInteger(e) || e < 0)
|
|
1999
1999
|
throw new Error(`positive integer expected, not ${e}`);
|
|
2000
2000
|
}
|
|
2001
|
-
function
|
|
2001
|
+
function On(e) {
|
|
2002
2002
|
if (typeof e != "boolean")
|
|
2003
2003
|
throw new Error(`boolean expected, not ${e}`);
|
|
2004
2004
|
}
|
|
@@ -2012,7 +2012,7 @@ function ce(e, ...t) {
|
|
|
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
|
|
2015
|
+
const G = (e) => new Uint32Array(e.buffer, e.byteOffset, Math.floor(e.byteLength / 4)), $s = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
|
2016
2016
|
if (!$s)
|
|
2017
2017
|
throw new Error("Non little-endian hardware is not supported");
|
|
2018
2018
|
function Ts(e, t) {
|
|
@@ -2028,19 +2028,19 @@ function Rs(e, t) {
|
|
|
2028
2028
|
n |= e[r] ^ t[r];
|
|
2029
2029
|
return n === 0;
|
|
2030
2030
|
}
|
|
2031
|
-
const Os = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t),
|
|
2032
|
-
function
|
|
2033
|
-
return e << 1 ^
|
|
2031
|
+
const Os = /* @__NO_SIDE_EFFECTS__ */ (e, t) => (Object.assign(t, e), t), Ke = 16, Ps = 283;
|
|
2032
|
+
function tn(e) {
|
|
2033
|
+
return e << 1 ^ Ps & -(e >> 7);
|
|
2034
2034
|
}
|
|
2035
|
-
function
|
|
2035
|
+
function Me(e, t) {
|
|
2036
2036
|
let n = 0;
|
|
2037
2037
|
for (; t > 0; t >>= 1)
|
|
2038
|
-
n ^= e & -(t & 1), e =
|
|
2038
|
+
n ^= e & -(t & 1), e = tn(e);
|
|
2039
2039
|
return n;
|
|
2040
2040
|
}
|
|
2041
|
-
const
|
|
2041
|
+
const jt = /* @__PURE__ */ (() => {
|
|
2042
2042
|
let e = new Uint8Array(256);
|
|
2043
|
-
for (let n = 0, r = 1; n < 256; n++, r ^=
|
|
2043
|
+
for (let n = 0, r = 1; n < 256; n++, r ^= tn(r))
|
|
2044
2044
|
e[n] = r;
|
|
2045
2045
|
const t = new Uint8Array(256);
|
|
2046
2046
|
t[0] = 99;
|
|
@@ -2049,11 +2049,11 @@ const zt = /* @__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
|
-
})(),
|
|
2052
|
+
})(), Ms = /* @__PURE__ */ jt.map((e, t) => jt.indexOf(t)), Hs = (e) => e << 24 | e >>> 8, It = (e) => e << 8 | e >>> 24;
|
|
2053
2053
|
function wr(e, t) {
|
|
2054
2054
|
if (e.length !== 256)
|
|
2055
2055
|
throw new Error("Wrong sbox length");
|
|
2056
|
-
const n = new Uint32Array(256).map((l, f) => t(e[f])), r = n.map(
|
|
2056
|
+
const n = new Uint32Array(256).map((l, f) => t(e[f])), r = n.map(It), i = r.map(It), s = i.map(It), o = new Uint32Array(256 * 256), c = new Uint32Array(256 * 256), a = new Uint16Array(256 * 256);
|
|
2057
2057
|
for (let l = 0; l < 256; l++)
|
|
2058
2058
|
for (let f = 0; f < 256; f++) {
|
|
2059
2059
|
const u = l * 256 + f;
|
|
@@ -2061,9 +2061,9 @@ function wr(e, t) {
|
|
|
2061
2061
|
}
|
|
2062
2062
|
return { sbox: e, sbox2: a, T0: n, T1: r, T2: i, T3: s, T01: o, T23: c };
|
|
2063
2063
|
}
|
|
2064
|
-
const
|
|
2064
|
+
const nn = /* @__PURE__ */ wr(jt, (e) => Me(e, 3) << 24 | e << 16 | e << 8 | Me(e, 2)), br = /* @__PURE__ */ wr(Ms, (e) => Me(e, 11) << 24 | Me(e, 13) << 16 | Me(e, 9) << 8 | Me(e, 14)), qs = /* @__PURE__ */ (() => {
|
|
2065
2065
|
const e = new Uint8Array(16);
|
|
2066
|
-
for (let t = 0, n = 1; t < 16; t++, n =
|
|
2066
|
+
for (let t = 0, n = 1; t < 16; t++, n = tn(n))
|
|
2067
2067
|
e[t] = n;
|
|
2068
2068
|
return e;
|
|
2069
2069
|
})();
|
|
@@ -2072,7 +2072,7 @@ function vr(e) {
|
|
|
2072
2072
|
const t = e.length;
|
|
2073
2073
|
if (![16, 24, 32].includes(t))
|
|
2074
2074
|
throw new Error(`aes: wrong key size: should be 16, 24 or 32, got: ${t}`);
|
|
2075
|
-
const { sbox2: n } =
|
|
2075
|
+
const { sbox2: n } = nn, r = G(e), i = r.length, s = (c) => oe(n, c, c, c, c), o = new Uint32Array(t + 28);
|
|
2076
2076
|
o.set(r);
|
|
2077
2077
|
for (let c = i; c < o.length; c++) {
|
|
2078
2078
|
let a = o[c - 1];
|
|
@@ -2081,7 +2081,7 @@ function vr(e) {
|
|
|
2081
2081
|
return o;
|
|
2082
2082
|
}
|
|
2083
2083
|
function Ds(e) {
|
|
2084
|
-
const t = vr(e), n = t.slice(), r = t.length, { sbox2: i } =
|
|
2084
|
+
const t = vr(e), n = t.slice(), r = t.length, { sbox2: i } = nn, { T0: s, T1: o, T2: c, T3: a } = br;
|
|
2085
2085
|
for (let l = 0; l < r; l += 4)
|
|
2086
2086
|
for (let f = 0; f < 4; f++)
|
|
2087
2087
|
n[l + f] = t[r - l - 4 + f];
|
|
@@ -2099,16 +2099,16 @@ function oe(e, t, n, r, i) {
|
|
|
2099
2099
|
return e[t & 255 | n & 65280] | e[r >>> 16 & 255 | i >>> 16 & 65280] << 16;
|
|
2100
2100
|
}
|
|
2101
2101
|
function Pn(e, t, n, r, i) {
|
|
2102
|
-
const { sbox2: s, T01: o, T23: c } =
|
|
2102
|
+
const { sbox2: s, T01: o, T23: c } = nn;
|
|
2103
2103
|
let a = 0;
|
|
2104
2104
|
t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
|
|
2105
2105
|
const l = e.length / 4 - 2;
|
|
2106
2106
|
for (let p = 0; p < l; p++) {
|
|
2107
|
-
const h = e[a++] ^ xe(o, c, t, n, r, i), d = e[a++] ^ xe(o, c, n, r, i, t),
|
|
2108
|
-
t = h, n = d, r =
|
|
2107
|
+
const h = e[a++] ^ xe(o, c, t, n, r, i), d = e[a++] ^ xe(o, c, n, r, i, t), g = e[a++] ^ xe(o, c, r, i, t, n), E = e[a++] ^ xe(o, c, i, t, n, r);
|
|
2108
|
+
t = h, n = d, r = g, i = E;
|
|
2109
2109
|
}
|
|
2110
|
-
const f = e[a++] ^ oe(s, t, n, r, i), u = e[a++] ^ oe(s, n, r, i, t),
|
|
2111
|
-
return { s0: f, s1: u, s2:
|
|
2110
|
+
const f = e[a++] ^ oe(s, t, n, r, i), u = e[a++] ^ oe(s, n, r, i, t), y = e[a++] ^ oe(s, r, i, t, n), b = e[a++] ^ oe(s, i, t, n, r);
|
|
2111
|
+
return { s0: f, s1: u, s2: y, s3: b };
|
|
2112
2112
|
}
|
|
2113
2113
|
function js(e, t, n, r, i) {
|
|
2114
2114
|
const { sbox2: s, T01: o, T23: c } = br;
|
|
@@ -2116,13 +2116,13 @@ function js(e, t, n, r, i) {
|
|
|
2116
2116
|
t ^= e[a++], n ^= e[a++], r ^= e[a++], i ^= e[a++];
|
|
2117
2117
|
const l = e.length / 4 - 2;
|
|
2118
2118
|
for (let p = 0; p < l; p++) {
|
|
2119
|
-
const h = e[a++] ^ xe(o, c, t, i, r, n), d = e[a++] ^ xe(o, c, n, t, i, r),
|
|
2120
|
-
t = h, n = d, r =
|
|
2119
|
+
const h = e[a++] ^ xe(o, c, t, i, r, n), d = e[a++] ^ xe(o, c, n, t, i, r), g = e[a++] ^ xe(o, c, r, n, t, i), E = e[a++] ^ xe(o, c, i, r, n, t);
|
|
2120
|
+
t = h, n = d, r = g, i = E;
|
|
2121
2121
|
}
|
|
2122
|
-
const f = e[a++] ^ oe(s, t, i, r, n), u = e[a++] ^ oe(s, n, t, i, r),
|
|
2123
|
-
return { s0: f, s1: u, s2:
|
|
2122
|
+
const f = e[a++] ^ oe(s, t, i, r, n), u = e[a++] ^ oe(s, n, t, i, r), y = e[a++] ^ oe(s, r, n, t, i), b = e[a++] ^ oe(s, i, r, n, t);
|
|
2123
|
+
return { s0: f, s1: u, s2: y, s3: b };
|
|
2124
2124
|
}
|
|
2125
|
-
function
|
|
2125
|
+
function mr(e, t) {
|
|
2126
2126
|
if (!t)
|
|
2127
2127
|
return new Uint8Array(e);
|
|
2128
2128
|
if (ce(t), t.length < e)
|
|
@@ -2130,20 +2130,20 @@ function Er(e, t) {
|
|
|
2130
2130
|
return t;
|
|
2131
2131
|
}
|
|
2132
2132
|
function zs(e) {
|
|
2133
|
-
if (ce(e), e.length %
|
|
2134
|
-
throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${
|
|
2133
|
+
if (ce(e), e.length % Ke !== 0)
|
|
2134
|
+
throw new Error(`aes/(cbc-ecb).decrypt ciphertext should consist of blocks with size ${Ke}`);
|
|
2135
2135
|
}
|
|
2136
2136
|
function Vs(e, t, n) {
|
|
2137
2137
|
let r = e.length;
|
|
2138
|
-
const i = r %
|
|
2138
|
+
const i = r % Ke;
|
|
2139
2139
|
if (!t && i !== 0)
|
|
2140
2140
|
throw new Error("aec/(cbc-ecb): unpadded plaintext with disabled padding");
|
|
2141
|
-
const s =
|
|
2141
|
+
const s = G(e);
|
|
2142
2142
|
if (t) {
|
|
2143
|
-
let a =
|
|
2144
|
-
a || (a =
|
|
2143
|
+
let a = Ke - i;
|
|
2144
|
+
a || (a = Ke), r = r + a;
|
|
2145
2145
|
}
|
|
2146
|
-
const o =
|
|
2146
|
+
const o = mr(r, n), c = G(o);
|
|
2147
2147
|
return { b: s, o: c, out: o };
|
|
2148
2148
|
}
|
|
2149
2149
|
function Ws(e, t) {
|
|
@@ -2162,52 +2162,52 @@ function Ws(e, t) {
|
|
|
2162
2162
|
return i;
|
|
2163
2163
|
}
|
|
2164
2164
|
function Zs(e) {
|
|
2165
|
-
const t = new Uint8Array(16), n =
|
|
2165
|
+
const t = new Uint8Array(16), n = G(t);
|
|
2166
2166
|
t.set(e);
|
|
2167
|
-
const r =
|
|
2168
|
-
for (let i =
|
|
2167
|
+
const r = Ke - e.length;
|
|
2168
|
+
for (let i = Ke - r; i < Ke; i++)
|
|
2169
2169
|
t[i] = r;
|
|
2170
2170
|
return n;
|
|
2171
2171
|
}
|
|
2172
|
-
const
|
|
2172
|
+
const Er = /* @__PURE__ */ Os({ blockSize: 16, nonceLength: 16 }, function(t, n, r = {}) {
|
|
2173
2173
|
ce(t), ce(n, 16);
|
|
2174
2174
|
const i = !r.disablePadding;
|
|
2175
2175
|
return {
|
|
2176
2176
|
encrypt: (s, o) => {
|
|
2177
|
-
const c = vr(t), { b: a, o: l, out: f } = Vs(s, i, o), u =
|
|
2178
|
-
let
|
|
2177
|
+
const c = vr(t), { b: a, o: l, out: f } = Vs(s, i, o), u = G(n);
|
|
2178
|
+
let y = u[0], b = u[1], p = u[2], h = u[3], d = 0;
|
|
2179
2179
|
for (; d + 4 <= a.length; )
|
|
2180
|
-
|
|
2180
|
+
y ^= a[d + 0], b ^= a[d + 1], p ^= a[d + 2], h ^= a[d + 3], { s0: y, s1: b, s2: p, s3: h } = Pn(c, y, b, p, h), l[d++] = y, l[d++] = b, l[d++] = p, l[d++] = h;
|
|
2181
2181
|
if (i) {
|
|
2182
|
-
const
|
|
2183
|
-
|
|
2182
|
+
const g = Zs(s.subarray(d * 4));
|
|
2183
|
+
y ^= g[0], b ^= g[1], p ^= g[2], h ^= g[3], { s0: y, s1: b, s2: p, s3: h } = Pn(c, y, b, p, h), l[d++] = y, l[d++] = b, l[d++] = p, l[d++] = h;
|
|
2184
2184
|
}
|
|
2185
2185
|
return c.fill(0), f;
|
|
2186
2186
|
},
|
|
2187
2187
|
decrypt: (s, o) => {
|
|
2188
2188
|
zs(s);
|
|
2189
|
-
const c = Ds(t), a =
|
|
2190
|
-
let
|
|
2189
|
+
const c = Ds(t), a = G(n), l = mr(s.length, o), f = G(s), u = G(l);
|
|
2190
|
+
let y = a[0], b = a[1], p = a[2], h = a[3];
|
|
2191
2191
|
for (let d = 0; d + 4 <= f.length; ) {
|
|
2192
|
-
const
|
|
2193
|
-
|
|
2194
|
-
const { s0: B, s1:
|
|
2195
|
-
u[d++] = B ^
|
|
2192
|
+
const g = y, E = b, S = p, k = h;
|
|
2193
|
+
y = f[d + 0], b = f[d + 1], p = f[d + 2], h = f[d + 3];
|
|
2194
|
+
const { s0: B, s1: m, s2: x, s3: K } = js(c, y, b, p, h);
|
|
2195
|
+
u[d++] = B ^ g, u[d++] = m ^ E, u[d++] = x ^ S, u[d++] = K ^ k;
|
|
2196
2196
|
}
|
|
2197
2197
|
return c.fill(0), Ws(l, i);
|
|
2198
2198
|
}
|
|
2199
2199
|
};
|
|
2200
|
-
}), xr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Gs = xr("expand 16-byte k"), Fs = xr("expand 32-byte k"), Js =
|
|
2201
|
-
|
|
2200
|
+
}), xr = (e) => Uint8Array.from(e.split("").map((t) => t.charCodeAt(0))), Gs = xr("expand 16-byte k"), Fs = xr("expand 32-byte k"), Js = G(Gs), Kr = G(Fs);
|
|
2201
|
+
Kr.slice();
|
|
2202
2202
|
function L(e, t) {
|
|
2203
2203
|
return e << t | e >>> 32 - t;
|
|
2204
2204
|
}
|
|
2205
|
-
function
|
|
2205
|
+
function zt(e) {
|
|
2206
2206
|
return e.byteOffset % 4 === 0;
|
|
2207
2207
|
}
|
|
2208
|
-
const Xe = 64, Ys = 16, Nr = 2 ** 32 - 1,
|
|
2208
|
+
const Xe = 64, Ys = 16, Nr = 2 ** 32 - 1, Mn = new Uint32Array();
|
|
2209
2209
|
function Xs(e, t, n, r, i, s, o, c) {
|
|
2210
|
-
const a = i.length, l = new Uint8Array(Xe), f =
|
|
2210
|
+
const a = i.length, l = new Uint8Array(Xe), f = G(l), u = zt(i) && zt(s), y = u ? G(i) : Mn, b = u ? G(s) : Mn;
|
|
2211
2211
|
for (let p = 0; p < a; o++) {
|
|
2212
2212
|
if (e(t, n, r, f, o, c), o >= Nr)
|
|
2213
2213
|
throw new Error("arx: counter overflow");
|
|
@@ -2216,13 +2216,13 @@ function Xs(e, t, n, r, i, s, o, c) {
|
|
|
2216
2216
|
const d = p / 4;
|
|
2217
2217
|
if (p % 4 !== 0)
|
|
2218
2218
|
throw new Error("arx: invalid block position");
|
|
2219
|
-
for (let
|
|
2220
|
-
|
|
2219
|
+
for (let g = 0, E; g < Ys; g++)
|
|
2220
|
+
E = d + g, b[E] = y[E] ^ f[g];
|
|
2221
2221
|
p += Xe;
|
|
2222
2222
|
continue;
|
|
2223
2223
|
}
|
|
2224
|
-
for (let d = 0,
|
|
2225
|
-
|
|
2224
|
+
for (let d = 0, g; d < h; d++)
|
|
2225
|
+
g = p + d, s[g] = i[g] ^ l[d];
|
|
2226
2226
|
p += h;
|
|
2227
2227
|
}
|
|
2228
2228
|
}
|
|
@@ -2230,54 +2230,54 @@ function Qs(e, t) {
|
|
|
2230
2230
|
const { allowShortKeys: n, extendNonceFn: r, counterLength: i, counterRight: s, rounds: o } = Ts({ allowShortKeys: !1, counterLength: 8, counterRight: !1, rounds: 20 }, t);
|
|
2231
2231
|
if (typeof e != "function")
|
|
2232
2232
|
throw new Error("core must be a function");
|
|
2233
|
-
return
|
|
2233
|
+
return _t(i), _t(o), On(s), On(n), (c, a, l, f, u = 0) => {
|
|
2234
2234
|
ce(c), ce(a), ce(l);
|
|
2235
|
-
const
|
|
2236
|
-
if (f || (f = new Uint8Array(
|
|
2235
|
+
const y = l.length;
|
|
2236
|
+
if (f || (f = new Uint8Array(y)), ce(f), _t(u), u < 0 || u >= Nr)
|
|
2237
2237
|
throw new Error("arx: counter overflow");
|
|
2238
|
-
if (f.length <
|
|
2239
|
-
throw new Error(`arx: output (${f.length}) is shorter than data (${
|
|
2238
|
+
if (f.length < y)
|
|
2239
|
+
throw new Error(`arx: output (${f.length}) is shorter than data (${y})`);
|
|
2240
2240
|
const b = [];
|
|
2241
2241
|
let p = c.length, h, d;
|
|
2242
2242
|
if (p === 32)
|
|
2243
|
-
h = c.slice(), b.push(h), d =
|
|
2243
|
+
h = c.slice(), b.push(h), d = Kr;
|
|
2244
2244
|
else if (p === 16 && n)
|
|
2245
2245
|
h = new Uint8Array(32), h.set(c), h.set(c, 16), d = Js, b.push(h);
|
|
2246
2246
|
else
|
|
2247
2247
|
throw new Error(`arx: invalid 32-byte key, got length=${p}`);
|
|
2248
|
-
|
|
2249
|
-
const
|
|
2248
|
+
zt(a) || (a = a.slice(), b.push(a));
|
|
2249
|
+
const g = G(h);
|
|
2250
2250
|
if (r) {
|
|
2251
2251
|
if (a.length !== 24)
|
|
2252
2252
|
throw new Error("arx: extended nonce must be 24 bytes");
|
|
2253
|
-
r(d,
|
|
2253
|
+
r(d, g, G(a.subarray(0, 16)), g), a = a.subarray(16);
|
|
2254
2254
|
}
|
|
2255
|
-
const
|
|
2256
|
-
if (
|
|
2257
|
-
throw new Error(`arx: nonce must be ${
|
|
2258
|
-
if (
|
|
2259
|
-
const
|
|
2260
|
-
|
|
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
|
+
const k = new Uint8Array(12);
|
|
2260
|
+
k.set(a, s ? 0 : 12 - a.length), a = k, b.push(a);
|
|
2261
2261
|
}
|
|
2262
|
-
const
|
|
2263
|
-
for (Xs(e, d,
|
|
2262
|
+
const S = G(a);
|
|
2263
|
+
for (Xs(e, d, g, S, l, f, u, o); b.length > 0; )
|
|
2264
2264
|
b.pop().fill(0);
|
|
2265
2265
|
return f;
|
|
2266
2266
|
};
|
|
2267
2267
|
}
|
|
2268
2268
|
function eo(e, t, n, r, i, s = 20) {
|
|
2269
|
-
let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1],
|
|
2269
|
+
let o = e[0], c = e[1], a = e[2], l = e[3], f = t[0], u = t[1], y = t[2], b = t[3], p = t[4], h = t[5], d = t[6], g = t[7], E = i, S = n[0], k = n[1], B = n[2], m = o, x = c, K = a, M = l, I = f, A = u, T = y, R = b, H = p, w = h, v = d, N = g, _ = E, C = S, U = k, O = B;
|
|
2270
2270
|
for (let Q = 0; Q < s; Q += 2)
|
|
2271
|
-
|
|
2271
|
+
m = m + I | 0, _ = L(_ ^ m, 16), H = H + _ | 0, I = L(I ^ H, 12), m = m + I | 0, _ = L(_ ^ m, 8), H = H + _ | 0, I = L(I ^ H, 7), x = x + A | 0, C = L(C ^ x, 16), w = w + C | 0, A = L(A ^ w, 12), x = x + A | 0, C = L(C ^ x, 8), w = w + C | 0, A = L(A ^ w, 7), K = K + T | 0, U = L(U ^ K, 16), v = v + U | 0, T = L(T ^ v, 12), K = K + T | 0, U = L(U ^ K, 8), v = v + U | 0, T = L(T ^ v, 7), M = M + R | 0, O = L(O ^ M, 16), N = N + O | 0, R = L(R ^ N, 12), M = M + R | 0, O = L(O ^ M, 8), N = N + O | 0, R = L(R ^ N, 7), m = m + A | 0, O = L(O ^ m, 16), v = v + O | 0, A = L(A ^ v, 12), m = m + A | 0, O = L(O ^ m, 8), v = v + O | 0, A = L(A ^ v, 7), x = x + T | 0, _ = L(_ ^ x, 16), N = N + _ | 0, T = L(T ^ N, 12), x = x + T | 0, _ = L(_ ^ x, 8), N = N + _ | 0, T = L(T ^ N, 7), K = K + R | 0, C = L(C ^ K, 16), H = H + C | 0, R = L(R ^ H, 12), K = K + R | 0, C = L(C ^ K, 8), H = H + C | 0, R = L(R ^ H, 7), M = M + I | 0, U = L(U ^ M, 16), w = w + U | 0, I = L(I ^ w, 12), M = M + I | 0, U = L(U ^ M, 8), w = w + U | 0, I = L(I ^ w, 7);
|
|
2272
2272
|
let $ = 0;
|
|
2273
|
-
r[$++] = o +
|
|
2273
|
+
r[$++] = o + m | 0, r[$++] = c + x | 0, r[$++] = a + K | 0, r[$++] = l + M | 0, r[$++] = f + I | 0, r[$++] = u + A | 0, r[$++] = y + T | 0, r[$++] = b + R | 0, r[$++] = p + H | 0, r[$++] = h + w | 0, r[$++] = d + v | 0, r[$++] = g + N | 0, r[$++] = E + _ | 0, r[$++] = S + C | 0, r[$++] = k + U | 0, r[$++] = B + O | 0;
|
|
2274
2274
|
}
|
|
2275
|
-
const
|
|
2275
|
+
const Sr = /* @__PURE__ */ Qs(eo, {
|
|
2276
2276
|
counterRight: !1,
|
|
2277
2277
|
counterLength: 4,
|
|
2278
2278
|
allowShortKeys: !1
|
|
2279
2279
|
});
|
|
2280
|
-
class
|
|
2280
|
+
class Ar extends ur {
|
|
2281
2281
|
constructor(t, n) {
|
|
2282
2282
|
super(), this.finished = !1, this.destroyed = !1, se.hash(t);
|
|
2283
2283
|
const r = Je(n);
|
|
@@ -2312,26 +2312,26 @@ class Kr extends ur {
|
|
|
2312
2312
|
this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
|
|
2313
2313
|
}
|
|
2314
2314
|
}
|
|
2315
|
-
const ht = (e, t, n) => new
|
|
2316
|
-
ht.create = (e, t) => new
|
|
2317
|
-
function
|
|
2315
|
+
const ht = (e, t, n) => new Ar(e, t).update(n).digest();
|
|
2316
|
+
ht.create = (e, t) => new Ar(e, t);
|
|
2317
|
+
function rn(e, t, n) {
|
|
2318
2318
|
return se.hash(e), n === void 0 && (n = new Uint8Array(e.outputLen)), ht(e, Je(n), Je(t));
|
|
2319
2319
|
}
|
|
2320
|
-
const
|
|
2320
|
+
const kt = new Uint8Array([0]), Hn = new Uint8Array();
|
|
2321
2321
|
function Cr(e, t, n, r = 32) {
|
|
2322
2322
|
if (se.hash(e), se.number(r), r > 255 * e.outputLen)
|
|
2323
2323
|
throw new Error("Length should be <= 255*HashLen");
|
|
2324
2324
|
const i = Math.ceil(r / e.outputLen);
|
|
2325
|
-
n === void 0 && (n =
|
|
2325
|
+
n === void 0 && (n = Hn);
|
|
2326
2326
|
const s = new Uint8Array(i * e.outputLen), o = ht.create(e, t), c = o._cloneInto(), a = new Uint8Array(o.outputLen);
|
|
2327
2327
|
for (let l = 0; l < i; l++)
|
|
2328
|
-
|
|
2329
|
-
return o.destroy(), c.destroy(), a.fill(0),
|
|
2328
|
+
kt[0] = l + 1, c.update(l === 0 ? Hn : a).update(n).update(kt).digestInto(a), s.set(a, e.outputLen * l), o._cloneInto(c);
|
|
2329
|
+
return o.destroy(), c.destroy(), a.fill(0), kt.fill(0), s.slice(0, r);
|
|
2330
2330
|
}
|
|
2331
2331
|
var to = Object.defineProperty, D = (e, t) => {
|
|
2332
2332
|
for (var n in t)
|
|
2333
2333
|
to(e, n, { get: t[n], enumerable: !0 });
|
|
2334
|
-
},
|
|
2334
|
+
}, Re = Symbol("verified"), no = (e) => e instanceof Object;
|
|
2335
2335
|
function dt(e) {
|
|
2336
2336
|
if (!no(e) || typeof e.kind != "number" || typeof e.content != "string" || typeof e.created_at != "number" || typeof e.pubkey != "string" || !e.pubkey.match(/^[a-f0-9]{64}$/) || !Array.isArray(e.tags))
|
|
2337
2337
|
return !1;
|
|
@@ -2349,7 +2349,7 @@ var ro = {};
|
|
|
2349
2349
|
D(ro, {
|
|
2350
2350
|
Queue: () => ao,
|
|
2351
2351
|
QueueNode: () => Br,
|
|
2352
|
-
binarySearch: () =>
|
|
2352
|
+
binarySearch: () => sn,
|
|
2353
2353
|
insertEventIntoAscendingList: () => oo,
|
|
2354
2354
|
insertEventIntoDescendingList: () => so,
|
|
2355
2355
|
normalizeURL: () => io,
|
|
@@ -2363,14 +2363,14 @@ function io(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 so(e, t) {
|
|
2366
|
-
const [n, r] =
|
|
2366
|
+
const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : i.created_at - t.created_at);
|
|
2367
2367
|
return r || e.splice(n, 0, t), e;
|
|
2368
2368
|
}
|
|
2369
2369
|
function oo(e, t) {
|
|
2370
|
-
const [n, r] =
|
|
2370
|
+
const [n, r] = sn(e, (i) => t.id === i.id ? 0 : t.created_at === i.created_at ? -1 : t.created_at - i.created_at);
|
|
2371
2371
|
return r || e.splice(n, 0, t), e;
|
|
2372
2372
|
}
|
|
2373
|
-
function
|
|
2373
|
+
function sn(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), s = t(e[i]);
|
|
@@ -2409,26 +2409,26 @@ var Br = class {
|
|
|
2409
2409
|
}
|
|
2410
2410
|
}, co = class {
|
|
2411
2411
|
generateSecretKey() {
|
|
2412
|
-
return
|
|
2412
|
+
return We.utils.randomPrivateKey();
|
|
2413
2413
|
}
|
|
2414
2414
|
getPublicKey(e) {
|
|
2415
|
-
return
|
|
2415
|
+
return P(We.getPublicKey(e));
|
|
2416
2416
|
}
|
|
2417
2417
|
finalizeEvent(e, t) {
|
|
2418
2418
|
const n = e;
|
|
2419
|
-
return n.pubkey =
|
|
2419
|
+
return n.pubkey = P(We.getPublicKey(t)), n.id = He(n), n.sig = P(We.sign(He(n), t)), n[Re] = !0, n;
|
|
2420
2420
|
}
|
|
2421
2421
|
verifyEvent(e) {
|
|
2422
|
-
if (typeof e[
|
|
2423
|
-
return e[
|
|
2424
|
-
const t =
|
|
2422
|
+
if (typeof e[Re] == "boolean")
|
|
2423
|
+
return e[Re];
|
|
2424
|
+
const t = He(e);
|
|
2425
2425
|
if (t !== e.id)
|
|
2426
|
-
return e[
|
|
2426
|
+
return e[Re] = !1, !1;
|
|
2427
2427
|
try {
|
|
2428
|
-
const n =
|
|
2429
|
-
return e[
|
|
2428
|
+
const n = We.verify(e.sig, t, e.pubkey);
|
|
2429
|
+
return e[Re] = n, n;
|
|
2430
2430
|
} catch {
|
|
2431
|
-
return e[
|
|
2431
|
+
return e[Re] = !1, !1;
|
|
2432
2432
|
}
|
|
2433
2433
|
}
|
|
2434
2434
|
};
|
|
@@ -2437,30 +2437,30 @@ function uo(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
|
|
2440
|
+
function He(e) {
|
|
2441
2441
|
let t = fe(ne.encode(uo(e)));
|
|
2442
|
-
return
|
|
2442
|
+
return P(t);
|
|
2443
2443
|
}
|
|
2444
|
-
var
|
|
2444
|
+
var yt = new co(), _e = yt.generateSecretKey, le = yt.getPublicKey, X = yt.finalizeEvent, pt = yt.verifyEvent, lo = {};
|
|
2445
2445
|
D(lo, {
|
|
2446
2446
|
Application: () => da,
|
|
2447
|
-
BadgeAward: () =>
|
|
2447
|
+
BadgeAward: () => mo,
|
|
2448
2448
|
BadgeDefinition: () => oa,
|
|
2449
2449
|
BlockedRelaysList: () => zo,
|
|
2450
2450
|
BookmarkList: () => qo,
|
|
2451
2451
|
Bookmarksets: () => ra,
|
|
2452
|
-
Calendar: () =>
|
|
2453
|
-
CalendarEventRSVP: () =>
|
|
2452
|
+
Calendar: () => ma,
|
|
2453
|
+
CalendarEventRSVP: () => Ea,
|
|
2454
2454
|
ChannelCreation: () => $r,
|
|
2455
2455
|
ChannelHideMessage: () => Or,
|
|
2456
2456
|
ChannelMessage: () => Rr,
|
|
2457
2457
|
ChannelMetadata: () => Tr,
|
|
2458
|
-
ChannelMuteUser: () =>
|
|
2458
|
+
ChannelMuteUser: () => Pr,
|
|
2459
2459
|
ClassifiedListing: () => ga,
|
|
2460
2460
|
ClientAuth: () => Hr,
|
|
2461
2461
|
CommunitiesList: () => Do,
|
|
2462
2462
|
CommunityDefinition: () => Na,
|
|
2463
|
-
CommunityPostApproval: () =>
|
|
2463
|
+
CommunityPostApproval: () => Io,
|
|
2464
2464
|
Contacts: () => wo,
|
|
2465
2465
|
CreateOrUpdateProduct: () => ua,
|
|
2466
2466
|
CreateOrUpdateStall: () => ca,
|
|
@@ -2477,85 +2477,85 @@ D(lo, {
|
|
|
2477
2477
|
Followsets: () => ea,
|
|
2478
2478
|
GenericRepost: () => xo,
|
|
2479
2479
|
Genericlists: () => ta,
|
|
2480
|
-
GiftWrap: () =>
|
|
2481
|
-
HTTPAuth: () =>
|
|
2482
|
-
Handlerinformation: () =>
|
|
2480
|
+
GiftWrap: () => Mr,
|
|
2481
|
+
HTTPAuth: () => cn,
|
|
2482
|
+
Handlerinformation: () => Ka,
|
|
2483
2483
|
Handlerrecommendation: () => xa,
|
|
2484
2484
|
Highlights: () => Oo,
|
|
2485
2485
|
InterestsList: () => Wo,
|
|
2486
2486
|
Interestsets: () => aa,
|
|
2487
2487
|
JobFeedback: () => Lo,
|
|
2488
|
-
JobRequest: () =>
|
|
2488
|
+
JobRequest: () => ko,
|
|
2489
2489
|
JobResult: () => Uo,
|
|
2490
|
-
Label: () =>
|
|
2490
|
+
Label: () => _o,
|
|
2491
2491
|
LightningPubRPC: () => Yo,
|
|
2492
|
-
LiveChatMessage: () =>
|
|
2493
|
-
LiveEvent: () =>
|
|
2492
|
+
LiveChatMessage: () => So,
|
|
2493
|
+
LiveEvent: () => ya,
|
|
2494
2494
|
LongFormArticle: () => la,
|
|
2495
|
-
Metadata: () =>
|
|
2496
|
-
Mutelist: () =>
|
|
2495
|
+
Metadata: () => yo,
|
|
2496
|
+
Mutelist: () => Po,
|
|
2497
2497
|
NWCWalletInfo: () => Jo,
|
|
2498
2498
|
NWCWalletRequest: () => qr,
|
|
2499
2499
|
NWCWalletResponse: () => Xo,
|
|
2500
2500
|
NostrConnect: () => Qo,
|
|
2501
|
-
OpenTimestamps: () =>
|
|
2502
|
-
Pinlist: () =>
|
|
2503
|
-
PrivateDirectMessage: () =>
|
|
2504
|
-
ProblemTracker: () =>
|
|
2501
|
+
OpenTimestamps: () => Ko,
|
|
2502
|
+
Pinlist: () => Mo,
|
|
2503
|
+
PrivateDirectMessage: () => Eo,
|
|
2504
|
+
ProblemTracker: () => Ao,
|
|
2505
2505
|
ProfileBadges: () => sa,
|
|
2506
2506
|
PublicChatsList: () => jo,
|
|
2507
|
-
Reaction: () =>
|
|
2507
|
+
Reaction: () => an,
|
|
2508
2508
|
RecommendRelay: () => go,
|
|
2509
2509
|
RelayList: () => Ho,
|
|
2510
2510
|
Relaysets: () => na,
|
|
2511
2511
|
Report: () => Co,
|
|
2512
2512
|
Reporting: () => Bo,
|
|
2513
|
-
Repost: () =>
|
|
2513
|
+
Repost: () => on,
|
|
2514
2514
|
Seal: () => Lr,
|
|
2515
2515
|
SearchRelaysList: () => Vo,
|
|
2516
|
-
ShortTextNote: () =>
|
|
2516
|
+
ShortTextNote: () => po,
|
|
2517
2517
|
Time: () => va,
|
|
2518
2518
|
UserEmojiList: () => Zo,
|
|
2519
|
-
UserStatuses: () =>
|
|
2519
|
+
UserStatuses: () => pa,
|
|
2520
2520
|
Zap: () => Ro,
|
|
2521
2521
|
ZapGoal: () => $o,
|
|
2522
2522
|
ZapRequest: () => To,
|
|
2523
2523
|
classifyKind: () => fo,
|
|
2524
|
-
isEphemeralKind: () =>
|
|
2524
|
+
isEphemeralKind: () => kr,
|
|
2525
2525
|
isKind: () => ho,
|
|
2526
2526
|
isParameterizedReplaceableKind: () => Ur,
|
|
2527
|
-
isRegularKind: () =>
|
|
2528
|
-
isReplaceableKind: () =>
|
|
2527
|
+
isRegularKind: () => _r,
|
|
2528
|
+
isReplaceableKind: () => Ir
|
|
2529
2529
|
});
|
|
2530
|
-
function
|
|
2530
|
+
function _r(e) {
|
|
2531
2531
|
return 1e3 <= e && e < 1e4 || [1, 2, 4, 5, 6, 7, 8, 16, 40, 41, 42, 43, 44].includes(e);
|
|
2532
2532
|
}
|
|
2533
|
-
function
|
|
2533
|
+
function Ir(e) {
|
|
2534
2534
|
return [0, 3].includes(e) || 1e4 <= e && e < 2e4;
|
|
2535
2535
|
}
|
|
2536
|
-
function
|
|
2536
|
+
function kr(e) {
|
|
2537
2537
|
return 2e4 <= e && e < 3e4;
|
|
2538
2538
|
}
|
|
2539
2539
|
function Ur(e) {
|
|
2540
2540
|
return 3e4 <= e && e < 4e4;
|
|
2541
2541
|
}
|
|
2542
2542
|
function fo(e) {
|
|
2543
|
-
return
|
|
2543
|
+
return _r(e) ? "regular" : Ir(e) ? "replaceable" : kr(e) ? "ephemeral" : Ur(e) ? "parameterized" : "unknown";
|
|
2544
2544
|
}
|
|
2545
2545
|
function ho(e, t) {
|
|
2546
2546
|
const n = t instanceof Array ? t : [t];
|
|
2547
2547
|
return dt(e) && n.includes(e.kind) || !1;
|
|
2548
2548
|
}
|
|
2549
|
-
var
|
|
2550
|
-
D(
|
|
2551
|
-
getHex64: () =>
|
|
2549
|
+
var yo = 0, po = 1, go = 2, wo = 3, bo = 4, vo = 5, on = 6, an = 7, mo = 8, Lr = 13, Eo = 14, xo = 16, $r = 40, Tr = 41, Rr = 42, Or = 43, Pr = 44, Ko = 1040, Mr = 1059, No = 1063, So = 1311, Ao = 1971, Co = 1984, Bo = 1984, _o = 1985, Io = 4550, ko = 5999, Uo = 6999, Lo = 7e3, $o = 9041, To = 9734, Ro = 9735, Oo = 9802, Po = 1e4, Mo = 10001, Ho = 10002, qo = 10003, Do = 10004, jo = 10005, zo = 10006, Vo = 10007, Wo = 10015, Zo = 10030, Go = 10050, Fo = 10096, Jo = 13194, Yo = 21e3, Hr = 22242, qr = 23194, Xo = 23195, Qo = 24133, cn = 27235, ea = 3e4, ta = 30001, na = 30002, ra = 30003, ia = 30004, sa = 30008, oa = 30009, aa = 30015, ca = 30017, ua = 30018, la = 30023, fa = 30024, ha = 30030, da = 30078, ya = 30311, pa = 30315, ga = 30402, wa = 30403, ba = 31922, va = 31923, ma = 31924, Ea = 31925, xa = 31989, Ka = 31990, Na = 34550, Sa = {};
|
|
2550
|
+
D(Sa, {
|
|
2551
|
+
getHex64: () => un,
|
|
2552
2552
|
getInt: () => Dr,
|
|
2553
|
-
getSubscriptionId: () =>
|
|
2553
|
+
getSubscriptionId: () => Aa,
|
|
2554
2554
|
matchEventId: () => Ca,
|
|
2555
|
-
matchEventKind: () =>
|
|
2555
|
+
matchEventKind: () => _a,
|
|
2556
2556
|
matchEventPubkey: () => Ba
|
|
2557
2557
|
});
|
|
2558
|
-
function
|
|
2558
|
+
function un(e, t) {
|
|
2559
2559
|
let n = t.length + 3, r = e.indexOf(`"${t}":`) + n, i = e.slice(r).indexOf('"') + r + 1;
|
|
2560
2560
|
return e.slice(i, i + 64);
|
|
2561
2561
|
}
|
|
@@ -2563,7 +2563,7 @@ function Dr(e, t) {
|
|
|
2563
2563
|
let n = t.length, r = e.indexOf(`"${t}":`) + n + 3, i = e.slice(r), s = Math.min(i.indexOf(","), i.indexOf("}"));
|
|
2564
2564
|
return parseInt(i.slice(0, s), 10);
|
|
2565
2565
|
}
|
|
2566
|
-
function
|
|
2566
|
+
function Aa(e) {
|
|
2567
2567
|
let t = e.slice(0, 22).indexOf('"EVENT"');
|
|
2568
2568
|
if (t === -1)
|
|
2569
2569
|
return null;
|
|
@@ -2577,19 +2577,19 @@ function Ka(e) {
|
|
|
2577
2577
|
return e.slice(r + 1, s);
|
|
2578
2578
|
}
|
|
2579
2579
|
function Ca(e, t) {
|
|
2580
|
-
return t ===
|
|
2580
|
+
return t === un(e, "id");
|
|
2581
2581
|
}
|
|
2582
2582
|
function Ba(e, t) {
|
|
2583
|
-
return t ===
|
|
2583
|
+
return t === un(e, "pubkey");
|
|
2584
2584
|
}
|
|
2585
|
-
function
|
|
2585
|
+
function _a(e, t) {
|
|
2586
2586
|
return t === Dr(e, "kind");
|
|
2587
2587
|
}
|
|
2588
|
-
var
|
|
2589
|
-
D(
|
|
2590
|
-
makeAuthEvent: () =>
|
|
2588
|
+
var Ia = {};
|
|
2589
|
+
D(Ia, {
|
|
2590
|
+
makeAuthEvent: () => ka
|
|
2591
2591
|
});
|
|
2592
|
-
function
|
|
2592
|
+
function ka(e, t) {
|
|
2593
2593
|
return {
|
|
2594
2594
|
kind: Hr,
|
|
2595
2595
|
created_at: Math.floor(Date.now() / 1e3),
|
|
@@ -2613,15 +2613,15 @@ try {
|
|
|
2613
2613
|
var $a = {};
|
|
2614
2614
|
D($a, {
|
|
2615
2615
|
BECH32_REGEX: () => jr,
|
|
2616
|
-
Bech32MaxSize: () =>
|
|
2616
|
+
Bech32MaxSize: () => ln,
|
|
2617
2617
|
NostrTypeGuard: () => Ta,
|
|
2618
2618
|
decode: () => gt,
|
|
2619
2619
|
encodeBytes: () => bt,
|
|
2620
2620
|
naddrEncode: () => Da,
|
|
2621
2621
|
neventEncode: () => qa,
|
|
2622
|
-
noteEncode: () =>
|
|
2622
|
+
noteEncode: () => Ma,
|
|
2623
2623
|
nprofileEncode: () => Ha,
|
|
2624
|
-
npubEncode: () =>
|
|
2624
|
+
npubEncode: () => Pa,
|
|
2625
2625
|
nsecEncode: () => Oa
|
|
2626
2626
|
});
|
|
2627
2627
|
var Ta = {
|
|
@@ -2632,14 +2632,14 @@ var Ta = {
|
|
|
2632
2632
|
isNPub: (e) => /^npub1[a-z\d]{58}$/.test(e || ""),
|
|
2633
2633
|
isNote: (e) => /^note1[a-z\d]+$/.test(e || ""),
|
|
2634
2634
|
isNcryptsec: (e) => /^ncryptsec1[a-z\d]+$/.test(e || "")
|
|
2635
|
-
},
|
|
2635
|
+
}, ln = 5e3, jr = /[\x21-\x7E]{1,83}1[023456789acdefghjklmnpqrstuvwxyz]{6,}/;
|
|
2636
2636
|
function Ra(e) {
|
|
2637
2637
|
const t = new Uint8Array(4);
|
|
2638
2638
|
return t[0] = e >> 24 & 255, t[1] = e >> 16 & 255, t[2] = e >> 8 & 255, t[3] = e & 255, t;
|
|
2639
2639
|
}
|
|
2640
2640
|
function gt(e) {
|
|
2641
2641
|
var i, s, o, c, a, l, f;
|
|
2642
|
-
let { prefix: t, words: n } =
|
|
2642
|
+
let { prefix: t, words: n } = je.decode(e, ln), r = new Uint8Array(je.fromWords(n));
|
|
2643
2643
|
switch (t) {
|
|
2644
2644
|
case "nprofile": {
|
|
2645
2645
|
let u = Ut(r);
|
|
@@ -2650,8 +2650,8 @@ function gt(e) {
|
|
|
2650
2650
|
return {
|
|
2651
2651
|
type: "nprofile",
|
|
2652
2652
|
data: {
|
|
2653
|
-
pubkey:
|
|
2654
|
-
relays: u[1] ? u[1].map((
|
|
2653
|
+
pubkey: P(u[0][0]),
|
|
2654
|
+
relays: u[1] ? u[1].map((y) => ue.decode(y)) : []
|
|
2655
2655
|
}
|
|
2656
2656
|
};
|
|
2657
2657
|
}
|
|
@@ -2668,10 +2668,10 @@ function gt(e) {
|
|
|
2668
2668
|
return {
|
|
2669
2669
|
type: "nevent",
|
|
2670
2670
|
data: {
|
|
2671
|
-
id:
|
|
2672
|
-
relays: u[1] ? u[1].map((
|
|
2673
|
-
author: (o = u[2]) != null && o[0] ?
|
|
2674
|
-
kind: (c = u[3]) != null && c[0] ? parseInt(
|
|
2671
|
+
id: P(u[0][0]),
|
|
2672
|
+
relays: u[1] ? u[1].map((y) => ue.decode(y)) : [],
|
|
2673
|
+
author: (o = u[2]) != null && o[0] ? P(u[2][0]) : void 0,
|
|
2674
|
+
kind: (c = u[3]) != null && c[0] ? parseInt(P(u[3][0]), 16) : void 0
|
|
2675
2675
|
}
|
|
2676
2676
|
};
|
|
2677
2677
|
}
|
|
@@ -2691,9 +2691,9 @@ function gt(e) {
|
|
|
2691
2691
|
type: "naddr",
|
|
2692
2692
|
data: {
|
|
2693
2693
|
identifier: ue.decode(u[0][0]),
|
|
2694
|
-
pubkey:
|
|
2695
|
-
kind: parseInt(
|
|
2696
|
-
relays: u[1] ? u[1].map((
|
|
2694
|
+
pubkey: P(u[2][0]),
|
|
2695
|
+
kind: parseInt(P(u[3][0]), 16),
|
|
2696
|
+
relays: u[1] ? u[1].map((y) => ue.decode(y)) : []
|
|
2697
2697
|
}
|
|
2698
2698
|
};
|
|
2699
2699
|
}
|
|
@@ -2701,7 +2701,7 @@ function gt(e) {
|
|
|
2701
2701
|
return { type: t, data: r };
|
|
2702
2702
|
case "npub":
|
|
2703
2703
|
case "note":
|
|
2704
|
-
return { type: t, data:
|
|
2704
|
+
return { type: t, data: P(r) };
|
|
2705
2705
|
default:
|
|
2706
2706
|
throw new Error(`unknown prefix ${t}`);
|
|
2707
2707
|
}
|
|
@@ -2719,22 +2719,22 @@ function Ut(e) {
|
|
|
2719
2719
|
function Oa(e) {
|
|
2720
2720
|
return bt("nsec", e);
|
|
2721
2721
|
}
|
|
2722
|
-
function Ma(e) {
|
|
2723
|
-
return bt("npub", G(e));
|
|
2724
|
-
}
|
|
2725
2722
|
function Pa(e) {
|
|
2726
|
-
return bt("
|
|
2723
|
+
return bt("npub", z(e));
|
|
2724
|
+
}
|
|
2725
|
+
function Ma(e) {
|
|
2726
|
+
return bt("note", z(e));
|
|
2727
2727
|
}
|
|
2728
2728
|
function wt(e, t) {
|
|
2729
|
-
let n =
|
|
2730
|
-
return
|
|
2729
|
+
let n = je.toWords(t);
|
|
2730
|
+
return je.encode(e, n, ln);
|
|
2731
2731
|
}
|
|
2732
2732
|
function bt(e, t) {
|
|
2733
2733
|
return wt(e, t);
|
|
2734
2734
|
}
|
|
2735
2735
|
function Ha(e) {
|
|
2736
|
-
let t =
|
|
2737
|
-
0: [
|
|
2736
|
+
let t = fn({
|
|
2737
|
+
0: [z(e.pubkey)],
|
|
2738
2738
|
1: (e.relays || []).map((n) => ne.encode(n))
|
|
2739
2739
|
});
|
|
2740
2740
|
return wt("nprofile", t);
|
|
@@ -2742,10 +2742,10 @@ function Ha(e) {
|
|
|
2742
2742
|
function qa(e) {
|
|
2743
2743
|
let t;
|
|
2744
2744
|
e.kind !== void 0 && (t = Ra(e.kind));
|
|
2745
|
-
let n =
|
|
2746
|
-
0: [
|
|
2745
|
+
let n = fn({
|
|
2746
|
+
0: [z(e.id)],
|
|
2747
2747
|
1: (e.relays || []).map((r) => ne.encode(r)),
|
|
2748
|
-
2: e.author ? [
|
|
2748
|
+
2: e.author ? [z(e.author)] : [],
|
|
2749
2749
|
3: t ? [new Uint8Array(t)] : []
|
|
2750
2750
|
});
|
|
2751
2751
|
return wt("nevent", n);
|
|
@@ -2753,15 +2753,15 @@ function qa(e) {
|
|
|
2753
2753
|
function Da(e) {
|
|
2754
2754
|
let t = new ArrayBuffer(4);
|
|
2755
2755
|
new DataView(t).setUint32(0, e.kind, !1);
|
|
2756
|
-
let n =
|
|
2756
|
+
let n = fn({
|
|
2757
2757
|
0: [ne.encode(e.identifier)],
|
|
2758
2758
|
1: (e.relays || []).map((r) => ne.encode(r)),
|
|
2759
|
-
2: [
|
|
2759
|
+
2: [z(e.pubkey)],
|
|
2760
2760
|
3: [new Uint8Array(t)]
|
|
2761
2761
|
});
|
|
2762
2762
|
return wt("naddr", n);
|
|
2763
2763
|
}
|
|
2764
|
-
function
|
|
2764
|
+
function fn(e) {
|
|
2765
2765
|
let t = [];
|
|
2766
2766
|
return Object.entries(e).reverse().forEach(([n, r]) => {
|
|
2767
2767
|
r.forEach((i) => {
|
|
@@ -2776,13 +2776,13 @@ D(ja, {
|
|
|
2776
2776
|
encrypt: () => zr
|
|
2777
2777
|
});
|
|
2778
2778
|
async function zr(e, t, n) {
|
|
2779
|
-
const r = e instanceof Uint8Array ?
|
|
2780
|
-
let o = Uint8Array.from(fr(16)), c = ne.encode(n), a =
|
|
2779
|
+
const r = e instanceof Uint8Array ? P(e) : e, i = ke.getSharedSecret(r, "02" + t), s = Vr(i);
|
|
2780
|
+
let o = Uint8Array.from(fr(16)), c = ne.encode(n), a = Er(s, o).encrypt(c), l = he.encode(new Uint8Array(a)), f = he.encode(new Uint8Array(o.buffer));
|
|
2781
2781
|
return `${l}?iv=${f}`;
|
|
2782
2782
|
}
|
|
2783
2783
|
async function za(e, t, n) {
|
|
2784
|
-
const r = e instanceof Uint8Array ?
|
|
2785
|
-
let [i, s] = n.split("?iv="), o =
|
|
2784
|
+
const r = e instanceof Uint8Array ? P(e) : e;
|
|
2785
|
+
let [i, s] = n.split("?iv="), o = ke.getSharedSecret(r, "02" + t), c = Vr(o), a = he.decode(s), l = he.decode(i), f = Er(c, a).decrypt(l);
|
|
2786
2786
|
return ue.decode(f);
|
|
2787
2787
|
}
|
|
2788
2788
|
function Vr(e) {
|
|
@@ -2790,14 +2790,14 @@ function Vr(e) {
|
|
|
2790
2790
|
}
|
|
2791
2791
|
var Va = {};
|
|
2792
2792
|
D(Va, {
|
|
2793
|
-
NIP05_REGEX: () =>
|
|
2793
|
+
NIP05_REGEX: () => hn,
|
|
2794
2794
|
isNip05: () => Wa,
|
|
2795
2795
|
isValid: () => Fa,
|
|
2796
2796
|
queryProfile: () => Wr,
|
|
2797
2797
|
searchDomain: () => Ga,
|
|
2798
2798
|
useFetchImplementation: () => Za
|
|
2799
2799
|
});
|
|
2800
|
-
var
|
|
2800
|
+
var hn = /^(?:([\w.+-]+)@)?([\w_-]+(\.[\w_-]+)+)$/, Wa = (e) => hn.test(e || ""), vt;
|
|
2801
2801
|
try {
|
|
2802
2802
|
vt = fetch;
|
|
2803
2803
|
} catch {
|
|
@@ -2817,7 +2817,7 @@ async function Ga(e, t = "") {
|
|
|
2817
2817
|
}
|
|
2818
2818
|
async function Wr(e) {
|
|
2819
2819
|
var i;
|
|
2820
|
-
const t = e.match(
|
|
2820
|
+
const t = e.match(hn);
|
|
2821
2821
|
if (!t)
|
|
2822
2822
|
return null;
|
|
2823
2823
|
const [, n = "_", r] = t;
|
|
@@ -2954,7 +2954,7 @@ function nc(e, t) {
|
|
|
2954
2954
|
return r;
|
|
2955
2955
|
}
|
|
2956
2956
|
function Fr(e) {
|
|
2957
|
-
return
|
|
2957
|
+
return P(
|
|
2958
2958
|
fe(ne.encode(JSON.stringify([0, e.pubkey, e.created_at, e.kind, e.tags, e.content])))
|
|
2959
2959
|
);
|
|
2960
2960
|
}
|
|
@@ -2967,7 +2967,7 @@ D(rc, {
|
|
|
2967
2967
|
function ic(e, t, n, r) {
|
|
2968
2968
|
return X(
|
|
2969
2969
|
{
|
|
2970
|
-
kind:
|
|
2970
|
+
kind: on,
|
|
2971
2971
|
tags: [...e.tags ?? [], ["e", t.id, n], ["p", t.pubkey]],
|
|
2972
2972
|
content: e.content === "" ? "" : JSON.stringify(t),
|
|
2973
2973
|
created_at: e.created_at
|
|
@@ -2976,7 +2976,7 @@ function ic(e, t, n, r) {
|
|
|
2976
2976
|
);
|
|
2977
2977
|
}
|
|
2978
2978
|
function Jr(e) {
|
|
2979
|
-
if (e.kind !==
|
|
2979
|
+
if (e.kind !== on)
|
|
2980
2980
|
return;
|
|
2981
2981
|
let t, n;
|
|
2982
2982
|
for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
|
|
@@ -3000,21 +3000,21 @@ function sc(e, { skipVerification: t } = {}) {
|
|
|
3000
3000
|
} catch {
|
|
3001
3001
|
return;
|
|
3002
3002
|
}
|
|
3003
|
-
if (r.id === n.id && !(!t && !
|
|
3003
|
+
if (r.id === n.id && !(!t && !pt(r)))
|
|
3004
3004
|
return r;
|
|
3005
3005
|
}
|
|
3006
3006
|
var oc = {};
|
|
3007
3007
|
D(oc, {
|
|
3008
|
-
NOSTR_URI_REGEX: () =>
|
|
3008
|
+
NOSTR_URI_REGEX: () => mt,
|
|
3009
3009
|
parse: () => cc,
|
|
3010
3010
|
test: () => ac
|
|
3011
3011
|
});
|
|
3012
|
-
var
|
|
3012
|
+
var mt = new RegExp(`nostr:(${jr.source})`);
|
|
3013
3013
|
function ac(e) {
|
|
3014
|
-
return typeof e == "string" && new RegExp(`^${
|
|
3014
|
+
return typeof e == "string" && new RegExp(`^${mt.source}$`).test(e);
|
|
3015
3015
|
}
|
|
3016
3016
|
function cc(e) {
|
|
3017
|
-
const t = e.match(new RegExp(`^${
|
|
3017
|
+
const t = e.match(new RegExp(`^${mt.source}$`));
|
|
3018
3018
|
if (!t)
|
|
3019
3019
|
throw new Error(`Invalid Nostr URI: ${e}`);
|
|
3020
3020
|
return {
|
|
@@ -3033,7 +3033,7 @@ function lc(e, t, n) {
|
|
|
3033
3033
|
return X(
|
|
3034
3034
|
{
|
|
3035
3035
|
...e,
|
|
3036
|
-
kind:
|
|
3036
|
+
kind: an,
|
|
3037
3037
|
tags: [...e.tags ?? [], ...r, ["e", t.id], ["p", t.pubkey]],
|
|
3038
3038
|
content: e.content ?? "+"
|
|
3039
3039
|
},
|
|
@@ -3041,7 +3041,7 @@ function lc(e, t, n) {
|
|
|
3041
3041
|
);
|
|
3042
3042
|
}
|
|
3043
3043
|
function fc(e) {
|
|
3044
|
-
if (e.kind !==
|
|
3044
|
+
if (e.kind !== an)
|
|
3045
3045
|
return;
|
|
3046
3046
|
let t, n;
|
|
3047
3047
|
for (let r = e.tags.length - 1; r >= 0 && (t === void 0 || n === void 0); r--) {
|
|
@@ -3058,12 +3058,12 @@ function fc(e) {
|
|
|
3058
3058
|
var hc = {};
|
|
3059
3059
|
D(hc, {
|
|
3060
3060
|
matchAll: () => dc,
|
|
3061
|
-
regex: () =>
|
|
3062
|
-
replaceAll: () =>
|
|
3061
|
+
regex: () => dn,
|
|
3062
|
+
replaceAll: () => yc
|
|
3063
3063
|
});
|
|
3064
|
-
var
|
|
3064
|
+
var dn = () => new RegExp(`\\b${mt.source}\\b`, "g");
|
|
3065
3065
|
function* dc(e) {
|
|
3066
|
-
const t = e.matchAll(
|
|
3066
|
+
const t = e.matchAll(dn());
|
|
3067
3067
|
for (const n of t)
|
|
3068
3068
|
try {
|
|
3069
3069
|
const [r, i] = n;
|
|
@@ -3077,20 +3077,20 @@ function* dc(e) {
|
|
|
3077
3077
|
} catch {
|
|
3078
3078
|
}
|
|
3079
3079
|
}
|
|
3080
|
-
function
|
|
3081
|
-
return e.replaceAll(
|
|
3080
|
+
function yc(e, t) {
|
|
3081
|
+
return e.replaceAll(dn(), (n, r) => t({
|
|
3082
3082
|
uri: n,
|
|
3083
3083
|
value: r,
|
|
3084
3084
|
decoded: gt(r)
|
|
3085
3085
|
}));
|
|
3086
3086
|
}
|
|
3087
|
-
var
|
|
3088
|
-
D(
|
|
3087
|
+
var pc = {};
|
|
3088
|
+
D(pc, {
|
|
3089
3089
|
channelCreateEvent: () => gc,
|
|
3090
3090
|
channelHideMessageEvent: () => vc,
|
|
3091
3091
|
channelMessageEvent: () => bc,
|
|
3092
3092
|
channelMetadataEvent: () => wc,
|
|
3093
|
-
channelMuteUserEvent: () =>
|
|
3093
|
+
channelMuteUserEvent: () => mc
|
|
3094
3094
|
});
|
|
3095
3095
|
var gc = (e, t) => {
|
|
3096
3096
|
let n;
|
|
@@ -3154,7 +3154,7 @@ var gc = (e, t) => {
|
|
|
3154
3154
|
},
|
|
3155
3155
|
t
|
|
3156
3156
|
);
|
|
3157
|
-
},
|
|
3157
|
+
}, mc = (e, t) => {
|
|
3158
3158
|
let n;
|
|
3159
3159
|
if (typeof e.content == "object")
|
|
3160
3160
|
n = JSON.stringify(e.content);
|
|
@@ -3164,19 +3164,19 @@ var gc = (e, t) => {
|
|
|
3164
3164
|
return;
|
|
3165
3165
|
return X(
|
|
3166
3166
|
{
|
|
3167
|
-
kind:
|
|
3167
|
+
kind: Pr,
|
|
3168
3168
|
tags: [["p", e.pubkey_to_mute], ...e.tags ?? []],
|
|
3169
3169
|
content: n,
|
|
3170
3170
|
created_at: e.created_at
|
|
3171
3171
|
},
|
|
3172
3172
|
t
|
|
3173
3173
|
);
|
|
3174
|
-
},
|
|
3175
|
-
D(
|
|
3174
|
+
}, Ec = {};
|
|
3175
|
+
D(Ec, {
|
|
3176
3176
|
EMOJI_SHORTCODE_REGEX: () => Yr,
|
|
3177
3177
|
matchAll: () => xc,
|
|
3178
3178
|
regex: () => yn,
|
|
3179
|
-
replaceAll: () =>
|
|
3179
|
+
replaceAll: () => Kc
|
|
3180
3180
|
});
|
|
3181
3181
|
var Yr = /:(\w+):/, yn = () => new RegExp(`\\B${Yr.source}\\B`, "g");
|
|
3182
3182
|
function* xc(e) {
|
|
@@ -3193,7 +3193,7 @@ function* xc(e) {
|
|
|
3193
3193
|
} catch {
|
|
3194
3194
|
}
|
|
3195
3195
|
}
|
|
3196
|
-
function
|
|
3196
|
+
function Kc(e, t) {
|
|
3197
3197
|
return e.replaceAll(yn(), (n, r) => t({
|
|
3198
3198
|
shortcode: n,
|
|
3199
3199
|
name: r
|
|
@@ -3201,35 +3201,35 @@ function Sc(e, t) {
|
|
|
3201
3201
|
}
|
|
3202
3202
|
var Nc = {};
|
|
3203
3203
|
D(Nc, {
|
|
3204
|
-
useFetchImplementation: () =>
|
|
3205
|
-
validateGithub: () =>
|
|
3204
|
+
useFetchImplementation: () => Sc,
|
|
3205
|
+
validateGithub: () => Ac
|
|
3206
3206
|
});
|
|
3207
|
-
var
|
|
3207
|
+
var pn;
|
|
3208
3208
|
try {
|
|
3209
|
-
|
|
3209
|
+
pn = fetch;
|
|
3210
3210
|
} catch {
|
|
3211
3211
|
}
|
|
3212
|
-
function
|
|
3213
|
-
|
|
3212
|
+
function Sc(e) {
|
|
3213
|
+
pn = e;
|
|
3214
3214
|
}
|
|
3215
|
-
async function
|
|
3215
|
+
async function Ac(e, t, n) {
|
|
3216
3216
|
try {
|
|
3217
|
-
return await (await
|
|
3217
|
+
return await (await pn(`https://gist.github.com/${t}/${n}/raw`)).text() === `Verifying that I control the following Nostr public key: ${e}`;
|
|
3218
3218
|
} catch {
|
|
3219
3219
|
return !1;
|
|
3220
3220
|
}
|
|
3221
3221
|
}
|
|
3222
3222
|
var q = {};
|
|
3223
3223
|
D(q, {
|
|
3224
|
-
decrypt: () =>
|
|
3225
|
-
encrypt: () =>
|
|
3226
|
-
getConversationKey: () =>
|
|
3227
|
-
v2: () =>
|
|
3224
|
+
decrypt: () => vn,
|
|
3225
|
+
encrypt: () => bn,
|
|
3226
|
+
getConversationKey: () => gn,
|
|
3227
|
+
v2: () => kc
|
|
3228
3228
|
});
|
|
3229
3229
|
var Xr = 1, Qr = 65535;
|
|
3230
|
-
function
|
|
3231
|
-
const n =
|
|
3232
|
-
return
|
|
3230
|
+
function gn(e, t) {
|
|
3231
|
+
const n = ke.getSharedSecret(e, "02" + t).subarray(1, 33);
|
|
3232
|
+
return rn(fe, n, "nip44-v2");
|
|
3233
3233
|
}
|
|
3234
3234
|
function ei(e, t) {
|
|
3235
3235
|
const n = Cr(fe, e, t, 76);
|
|
@@ -3239,7 +3239,7 @@ function ei(e, t) {
|
|
|
3239
3239
|
hmac_key: n.subarray(44, 76)
|
|
3240
3240
|
};
|
|
3241
3241
|
}
|
|
3242
|
-
function
|
|
3242
|
+
function wn(e) {
|
|
3243
3243
|
if (!Number.isSafeInteger(e) || e < 1)
|
|
3244
3244
|
throw new Error("expected positive integer");
|
|
3245
3245
|
if (e <= 32)
|
|
@@ -3254,12 +3254,12 @@ function Cc(e) {
|
|
|
3254
3254
|
return new DataView(t.buffer).setUint16(0, e, !1), t;
|
|
3255
3255
|
}
|
|
3256
3256
|
function Bc(e) {
|
|
3257
|
-
const t = ne.encode(e), n = t.length, r = Cc(n), i = new Uint8Array(
|
|
3257
|
+
const t = ne.encode(e), n = t.length, r = Cc(n), i = new Uint8Array(wn(n) - n);
|
|
3258
3258
|
return lt(r, t, i);
|
|
3259
3259
|
}
|
|
3260
|
-
function
|
|
3260
|
+
function _c(e) {
|
|
3261
3261
|
const t = new DataView(e.buffer).getUint16(0), n = e.subarray(2, 2 + t);
|
|
3262
|
-
if (t < Xr || t > Qr || n.length !== t || e.length !== 2 +
|
|
3262
|
+
if (t < Xr || t > Qr || n.length !== t || e.length !== 2 + wn(t))
|
|
3263
3263
|
throw new Error("invalid padding");
|
|
3264
3264
|
return ue.decode(n);
|
|
3265
3265
|
}
|
|
@@ -3269,7 +3269,7 @@ function ti(e, t, n) {
|
|
|
3269
3269
|
const r = lt(n, t);
|
|
3270
3270
|
return ht(fe, e, r);
|
|
3271
3271
|
}
|
|
3272
|
-
function
|
|
3272
|
+
function Ic(e) {
|
|
3273
3273
|
if (typeof e != "string")
|
|
3274
3274
|
throw new Error("payload must be a valid string");
|
|
3275
3275
|
const t = e.length;
|
|
@@ -3295,24 +3295,24 @@ function _c(e) {
|
|
|
3295
3295
|
mac: n.subarray(-32)
|
|
3296
3296
|
};
|
|
3297
3297
|
}
|
|
3298
|
-
function
|
|
3299
|
-
const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ei(t, n), o = Bc(e), c =
|
|
3298
|
+
function bn(e, t, n = fr(32)) {
|
|
3299
|
+
const { chacha_key: r, chacha_nonce: i, hmac_key: s } = ei(t, n), o = Bc(e), c = Sr(r, i, o), a = ti(s, c, n);
|
|
3300
3300
|
return he.encode(lt(new Uint8Array([2]), n, c, a));
|
|
3301
3301
|
}
|
|
3302
|
-
function
|
|
3303
|
-
const { nonce: n, ciphertext: r, mac: i } =
|
|
3302
|
+
function vn(e, t) {
|
|
3303
|
+
const { nonce: n, ciphertext: r, mac: i } = Ic(e), { chacha_key: s, chacha_nonce: o, hmac_key: c } = ei(t, n), a = ti(c, r, n);
|
|
3304
3304
|
if (!Rs(a, i))
|
|
3305
3305
|
throw new Error("invalid MAC");
|
|
3306
|
-
const l =
|
|
3307
|
-
return
|
|
3306
|
+
const l = Sr(s, o, r);
|
|
3307
|
+
return _c(l);
|
|
3308
3308
|
}
|
|
3309
|
-
var
|
|
3309
|
+
var kc = {
|
|
3310
3310
|
utils: {
|
|
3311
|
-
getConversationKey:
|
|
3312
|
-
calcPaddedLen:
|
|
3311
|
+
getConversationKey: gn,
|
|
3312
|
+
calcPaddedLen: wn
|
|
3313
3313
|
},
|
|
3314
|
-
encrypt:
|
|
3315
|
-
decrypt:
|
|
3314
|
+
encrypt: bn,
|
|
3315
|
+
decrypt: vn
|
|
3316
3316
|
}, Uc = {};
|
|
3317
3317
|
D(Uc, {
|
|
3318
3318
|
makeNwcRequestEvent: () => $c,
|
|
@@ -3342,9 +3342,9 @@ var Tc = {};
|
|
|
3342
3342
|
D(Tc, {
|
|
3343
3343
|
getZapEndpoint: () => Oc,
|
|
3344
3344
|
makeZapReceipt: () => Hc,
|
|
3345
|
-
makeZapRequest: () =>
|
|
3345
|
+
makeZapRequest: () => Pc,
|
|
3346
3346
|
useFetchImplementation: () => Rc,
|
|
3347
|
-
validateZapRequest: () =>
|
|
3347
|
+
validateZapRequest: () => Mc
|
|
3348
3348
|
});
|
|
3349
3349
|
var mn;
|
|
3350
3350
|
try {
|
|
@@ -3358,7 +3358,7 @@ async function Oc(e) {
|
|
|
3358
3358
|
try {
|
|
3359
3359
|
let t = "", { lud06: n, lud16: r } = JSON.parse(e.content);
|
|
3360
3360
|
if (n) {
|
|
3361
|
-
let { words: o } =
|
|
3361
|
+
let { words: o } = je.decode(n, 1e3), c = je.fromWords(o);
|
|
3362
3362
|
t = ue.decode(c);
|
|
3363
3363
|
} else if (r) {
|
|
3364
3364
|
let [o, c] = r.split("@");
|
|
@@ -3372,7 +3372,7 @@ async function Oc(e) {
|
|
|
3372
3372
|
}
|
|
3373
3373
|
return null;
|
|
3374
3374
|
}
|
|
3375
|
-
function
|
|
3375
|
+
function Pc({
|
|
3376
3376
|
profile: e,
|
|
3377
3377
|
event: t,
|
|
3378
3378
|
amount: n,
|
|
@@ -3395,7 +3395,7 @@ function Mc({
|
|
|
3395
3395
|
};
|
|
3396
3396
|
return t && s.tags.push(["e", t]), s;
|
|
3397
3397
|
}
|
|
3398
|
-
function
|
|
3398
|
+
function Mc(e) {
|
|
3399
3399
|
let t;
|
|
3400
3400
|
try {
|
|
3401
3401
|
t = JSON.parse(e);
|
|
@@ -3404,7 +3404,7 @@ function Pc(e) {
|
|
|
3404
3404
|
}
|
|
3405
3405
|
if (!dt(t))
|
|
3406
3406
|
return "Zap request is not a valid Nostr event.";
|
|
3407
|
-
if (!
|
|
3407
|
+
if (!pt(t))
|
|
3408
3408
|
return "Invalid signature on zap request.";
|
|
3409
3409
|
let n = t.tags.find(([s, o]) => s === "p" && o);
|
|
3410
3410
|
if (!n)
|
|
@@ -3435,10 +3435,10 @@ D(qc, {
|
|
|
3435
3435
|
createWrap: () => ci,
|
|
3436
3436
|
unwrapEvent: () => ui,
|
|
3437
3437
|
unwrapManyEvents: () => zc,
|
|
3438
|
-
wrapEvent: () =>
|
|
3438
|
+
wrapEvent: () => Vt,
|
|
3439
3439
|
wrapManyEvents: () => jc
|
|
3440
3440
|
});
|
|
3441
|
-
var Dc = 2 * 24 * 60 * 60, ni = () => Math.round(Date.now() / 1e3), ri = () => Math.round(ni() - Math.random() * Dc), ii = (e, t) =>
|
|
3441
|
+
var Dc = 2 * 24 * 60 * 60, ni = () => Math.round(Date.now() / 1e3), ri = () => Math.round(ni() - Math.random() * Dc), ii = (e, t) => gn(e, t), si = (e, t, n) => bn(JSON.stringify(e), ii(t, n)), qn = (e, t) => JSON.parse(vn(e.content, ii(t, e.pubkey)));
|
|
3442
3442
|
function oi(e, t) {
|
|
3443
3443
|
const n = {
|
|
3444
3444
|
created_at: ni(),
|
|
@@ -3447,7 +3447,7 @@ function oi(e, t) {
|
|
|
3447
3447
|
...e,
|
|
3448
3448
|
pubkey: le(t)
|
|
3449
3449
|
};
|
|
3450
|
-
return n.id =
|
|
3450
|
+
return n.id = He(n), n;
|
|
3451
3451
|
}
|
|
3452
3452
|
function ai(e, t, n) {
|
|
3453
3453
|
return X(
|
|
@@ -3464,7 +3464,7 @@ function ci(e, t) {
|
|
|
3464
3464
|
const n = _e();
|
|
3465
3465
|
return X(
|
|
3466
3466
|
{
|
|
3467
|
-
kind:
|
|
3467
|
+
kind: Mr,
|
|
3468
3468
|
content: si(e, n, t),
|
|
3469
3469
|
created_at: ri(),
|
|
3470
3470
|
tags: [["p", t]]
|
|
@@ -3472,21 +3472,21 @@ function ci(e, t) {
|
|
|
3472
3472
|
n
|
|
3473
3473
|
);
|
|
3474
3474
|
}
|
|
3475
|
-
function
|
|
3475
|
+
function Vt(e, t, n) {
|
|
3476
3476
|
const r = oi(e, t), i = ai(r, t, n);
|
|
3477
3477
|
return ci(i, n);
|
|
3478
3478
|
}
|
|
3479
3479
|
function jc(e, t, n) {
|
|
3480
3480
|
if (!n || n.length === 0)
|
|
3481
3481
|
throw new Error("At least one recipient is required.");
|
|
3482
|
-
const r = le(t), i = [
|
|
3482
|
+
const r = le(t), i = [Vt(e, t, r)];
|
|
3483
3483
|
return n.forEach((s) => {
|
|
3484
|
-
i.push(
|
|
3484
|
+
i.push(Vt(e, t, s));
|
|
3485
3485
|
}), i;
|
|
3486
3486
|
}
|
|
3487
3487
|
function ui(e, t) {
|
|
3488
|
-
const n =
|
|
3489
|
-
return
|
|
3488
|
+
const n = qn(e, t);
|
|
3489
|
+
return qn(n, t);
|
|
3490
3490
|
}
|
|
3491
3491
|
function zc(e, t) {
|
|
3492
3492
|
let n = [];
|
|
@@ -3497,20 +3497,20 @@ function zc(e, t) {
|
|
|
3497
3497
|
var Vc = {};
|
|
3498
3498
|
D(Vc, {
|
|
3499
3499
|
getToken: () => Wc,
|
|
3500
|
-
hashPayload: () =>
|
|
3500
|
+
hashPayload: () => En,
|
|
3501
3501
|
unpackEventFromToken: () => fi,
|
|
3502
3502
|
validateEvent: () => wi,
|
|
3503
3503
|
validateEventKind: () => di,
|
|
3504
|
-
validateEventMethodTag: () =>
|
|
3504
|
+
validateEventMethodTag: () => pi,
|
|
3505
3505
|
validateEventPayloadTag: () => gi,
|
|
3506
3506
|
validateEventTimestamp: () => hi,
|
|
3507
|
-
validateEventUrlTag: () =>
|
|
3507
|
+
validateEventUrlTag: () => yi,
|
|
3508
3508
|
validateToken: () => Zc
|
|
3509
3509
|
});
|
|
3510
3510
|
var li = "Nostr ";
|
|
3511
3511
|
async function Wc(e, t, n, r = !1, i) {
|
|
3512
3512
|
const s = {
|
|
3513
|
-
kind:
|
|
3513
|
+
kind: cn,
|
|
3514
3514
|
tags: [
|
|
3515
3515
|
["u", e],
|
|
3516
3516
|
["method", t]
|
|
@@ -3518,7 +3518,7 @@ async function Wc(e, t, n, r = !1, i) {
|
|
|
3518
3518
|
created_at: Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3),
|
|
3519
3519
|
content: ""
|
|
3520
3520
|
};
|
|
3521
|
-
i && s.tags.push(["payload",
|
|
3521
|
+
i && s.tags.push(["payload", En(i)]);
|
|
3522
3522
|
const o = await n(s);
|
|
3523
3523
|
return (r ? li : "") + he.encode(ne.encode(JSON.stringify(o)));
|
|
3524
3524
|
}
|
|
@@ -3543,109 +3543,142 @@ function hi(e) {
|
|
|
3543
3543
|
return e.created_at ? Math.round((/* @__PURE__ */ new Date()).getTime() / 1e3) - e.created_at < 60 : !1;
|
|
3544
3544
|
}
|
|
3545
3545
|
function di(e) {
|
|
3546
|
-
return e.kind ===
|
|
3546
|
+
return e.kind === cn;
|
|
3547
3547
|
}
|
|
3548
|
-
function
|
|
3548
|
+
function yi(e, t) {
|
|
3549
3549
|
const n = e.tags.find((r) => r[0] === "u");
|
|
3550
3550
|
return n ? n.length > 0 && n[1] === t : !1;
|
|
3551
3551
|
}
|
|
3552
|
-
function
|
|
3552
|
+
function pi(e, t) {
|
|
3553
3553
|
const n = e.tags.find((r) => r[0] === "method");
|
|
3554
3554
|
return n ? n.length > 0 && n[1].toLowerCase() === t.toLowerCase() : !1;
|
|
3555
3555
|
}
|
|
3556
|
-
function
|
|
3556
|
+
function En(e) {
|
|
3557
3557
|
const t = fe(ne.encode(JSON.stringify(e)));
|
|
3558
|
-
return
|
|
3558
|
+
return P(t);
|
|
3559
3559
|
}
|
|
3560
3560
|
function gi(e, t) {
|
|
3561
3561
|
const n = e.tags.find((i) => i[0] === "payload");
|
|
3562
3562
|
if (!n)
|
|
3563
3563
|
return !1;
|
|
3564
|
-
const r =
|
|
3564
|
+
const r = En(t);
|
|
3565
3565
|
return n.length > 0 && n[1] === r;
|
|
3566
3566
|
}
|
|
3567
3567
|
async function wi(e, t, n, r) {
|
|
3568
|
-
if (!
|
|
3568
|
+
if (!pt(e))
|
|
3569
3569
|
throw new Error("Invalid nostr event, signature invalid");
|
|
3570
3570
|
if (!di(e))
|
|
3571
3571
|
throw new Error("Invalid nostr event, kind invalid");
|
|
3572
3572
|
if (!hi(e))
|
|
3573
3573
|
throw new Error("Invalid nostr event, created_at timestamp invalid");
|
|
3574
|
-
if (!
|
|
3574
|
+
if (!yi(e, t))
|
|
3575
3575
|
throw new Error("Invalid nostr event, url tag invalid");
|
|
3576
|
-
if (!
|
|
3576
|
+
if (!pi(e, n))
|
|
3577
3577
|
throw new Error("Invalid nostr event, method tag invalid");
|
|
3578
3578
|
if (r && typeof r == "object" && Object.keys(r).length > 0 && !gi(e, r))
|
|
3579
3579
|
throw new Error("Invalid nostr event, payload tag does not match request body hash");
|
|
3580
3580
|
return !0;
|
|
3581
3581
|
}
|
|
3582
|
-
const
|
|
3583
|
-
function
|
|
3582
|
+
const Ge = 30078, Dn = 30078, jn = 1059, Gc = 14, au = 100, Fc = 1;
|
|
3583
|
+
function cu(e) {
|
|
3584
3584
|
return JSON.stringify({
|
|
3585
|
-
|
|
3585
|
+
version: Fc,
|
|
3586
|
+
rootKey: P(e.rootKey),
|
|
3586
3587
|
theirCurrentNostrPublicKey: e.theirCurrentNostrPublicKey,
|
|
3587
3588
|
theirNextNostrPublicKey: e.theirNextNostrPublicKey,
|
|
3588
3589
|
ourCurrentNostrKey: e.ourCurrentNostrKey ? {
|
|
3589
3590
|
publicKey: e.ourCurrentNostrKey.publicKey,
|
|
3590
|
-
privateKey:
|
|
3591
|
+
privateKey: P(e.ourCurrentNostrKey.privateKey)
|
|
3591
3592
|
} : void 0,
|
|
3592
3593
|
ourNextNostrKey: {
|
|
3593
3594
|
publicKey: e.ourNextNostrKey.publicKey,
|
|
3594
|
-
privateKey:
|
|
3595
|
+
privateKey: P(e.ourNextNostrKey.privateKey)
|
|
3595
3596
|
},
|
|
3596
|
-
receivingChainKey: e.receivingChainKey ?
|
|
3597
|
-
sendingChainKey: e.sendingChainKey ?
|
|
3597
|
+
receivingChainKey: e.receivingChainKey ? P(e.receivingChainKey) : void 0,
|
|
3598
|
+
sendingChainKey: e.sendingChainKey ? P(e.sendingChainKey) : void 0,
|
|
3598
3599
|
sendingChainMessageNumber: e.sendingChainMessageNumber,
|
|
3599
3600
|
receivingChainMessageNumber: e.receivingChainMessageNumber,
|
|
3600
3601
|
previousSendingChainMessageCount: e.previousSendingChainMessageCount,
|
|
3601
|
-
|
|
3602
|
-
Object.entries(e.
|
|
3603
|
-
t,
|
|
3604
|
-
M(n)
|
|
3605
|
-
])
|
|
3606
|
-
),
|
|
3607
|
-
skippedHeaderKeys: Object.fromEntries(
|
|
3608
|
-
Object.entries(e.skippedHeaderKeys).map(([t, n]) => [
|
|
3602
|
+
skippedKeys: Object.fromEntries(
|
|
3603
|
+
Object.entries(e.skippedKeys).map(([t, n]) => [
|
|
3609
3604
|
t,
|
|
3610
|
-
|
|
3605
|
+
{
|
|
3606
|
+
headerKeys: n.headerKeys.map((r) => P(r)),
|
|
3607
|
+
messageKeys: Object.fromEntries(
|
|
3608
|
+
Object.entries(n.messageKeys).map(([r, i]) => [
|
|
3609
|
+
r,
|
|
3610
|
+
P(i)
|
|
3611
|
+
])
|
|
3612
|
+
)
|
|
3613
|
+
}
|
|
3611
3614
|
])
|
|
3612
3615
|
)
|
|
3613
3616
|
});
|
|
3614
3617
|
}
|
|
3615
|
-
function
|
|
3618
|
+
function uu(e) {
|
|
3616
3619
|
const t = JSON.parse(e);
|
|
3620
|
+
if (!t.version) {
|
|
3621
|
+
const n = {};
|
|
3622
|
+
return t.skippedMessageKeys && Object.entries(t.skippedMessageKeys).forEach(([r, i]) => {
|
|
3623
|
+
var s;
|
|
3624
|
+
n[r] = {
|
|
3625
|
+
headerKeys: ((s = t.skippedHeaderKeys) == null ? void 0 : s[r]) || [],
|
|
3626
|
+
messageKeys: i
|
|
3627
|
+
};
|
|
3628
|
+
}), {
|
|
3629
|
+
rootKey: z(t.rootKey),
|
|
3630
|
+
theirCurrentNostrPublicKey: t.theirCurrentNostrPublicKey,
|
|
3631
|
+
theirNextNostrPublicKey: t.theirNextNostrPublicKey,
|
|
3632
|
+
ourCurrentNostrKey: t.ourCurrentNostrKey ? {
|
|
3633
|
+
publicKey: t.ourCurrentNostrKey.publicKey,
|
|
3634
|
+
privateKey: z(t.ourCurrentNostrKey.privateKey)
|
|
3635
|
+
} : void 0,
|
|
3636
|
+
ourNextNostrKey: {
|
|
3637
|
+
publicKey: t.ourNextNostrKey.publicKey,
|
|
3638
|
+
privateKey: z(t.ourNextNostrKey.privateKey)
|
|
3639
|
+
},
|
|
3640
|
+
receivingChainKey: t.receivingChainKey ? z(t.receivingChainKey) : void 0,
|
|
3641
|
+
sendingChainKey: t.sendingChainKey ? z(t.sendingChainKey) : void 0,
|
|
3642
|
+
sendingChainMessageNumber: t.sendingChainMessageNumber,
|
|
3643
|
+
receivingChainMessageNumber: t.receivingChainMessageNumber,
|
|
3644
|
+
previousSendingChainMessageCount: t.previousSendingChainMessageCount,
|
|
3645
|
+
skippedKeys: n
|
|
3646
|
+
};
|
|
3647
|
+
}
|
|
3617
3648
|
return {
|
|
3618
|
-
rootKey:
|
|
3649
|
+
rootKey: z(t.rootKey),
|
|
3619
3650
|
theirCurrentNostrPublicKey: t.theirCurrentNostrPublicKey,
|
|
3620
3651
|
theirNextNostrPublicKey: t.theirNextNostrPublicKey,
|
|
3621
3652
|
ourCurrentNostrKey: t.ourCurrentNostrKey ? {
|
|
3622
3653
|
publicKey: t.ourCurrentNostrKey.publicKey,
|
|
3623
|
-
privateKey:
|
|
3654
|
+
privateKey: z(t.ourCurrentNostrKey.privateKey)
|
|
3624
3655
|
} : void 0,
|
|
3625
3656
|
ourNextNostrKey: {
|
|
3626
3657
|
publicKey: t.ourNextNostrKey.publicKey,
|
|
3627
|
-
privateKey:
|
|
3658
|
+
privateKey: z(t.ourNextNostrKey.privateKey)
|
|
3628
3659
|
},
|
|
3629
|
-
receivingChainKey: t.receivingChainKey ?
|
|
3630
|
-
sendingChainKey: t.sendingChainKey ?
|
|
3660
|
+
receivingChainKey: t.receivingChainKey ? z(t.receivingChainKey) : void 0,
|
|
3661
|
+
sendingChainKey: t.sendingChainKey ? z(t.sendingChainKey) : void 0,
|
|
3631
3662
|
sendingChainMessageNumber: t.sendingChainMessageNumber,
|
|
3632
3663
|
receivingChainMessageNumber: t.receivingChainMessageNumber,
|
|
3633
3664
|
previousSendingChainMessageCount: t.previousSendingChainMessageCount,
|
|
3634
|
-
|
|
3635
|
-
Object.entries(t.
|
|
3636
|
-
n,
|
|
3637
|
-
G(r)
|
|
3638
|
-
])
|
|
3639
|
-
),
|
|
3640
|
-
skippedHeaderKeys: Object.fromEntries(
|
|
3641
|
-
Object.entries(t.skippedHeaderKeys || {}).map(([n, r]) => [
|
|
3665
|
+
skippedKeys: Object.fromEntries(
|
|
3666
|
+
Object.entries(t.skippedKeys || {}).map(([n, r]) => [
|
|
3642
3667
|
n,
|
|
3643
|
-
|
|
3668
|
+
{
|
|
3669
|
+
headerKeys: r.headerKeys.map((i) => z(i)),
|
|
3670
|
+
messageKeys: Object.fromEntries(
|
|
3671
|
+
Object.entries(r.messageKeys).map(([i, s]) => [
|
|
3672
|
+
i,
|
|
3673
|
+
z(s)
|
|
3674
|
+
])
|
|
3675
|
+
)
|
|
3676
|
+
}
|
|
3644
3677
|
])
|
|
3645
3678
|
)
|
|
3646
3679
|
};
|
|
3647
3680
|
}
|
|
3648
|
-
async function*
|
|
3681
|
+
async function* lu(e) {
|
|
3649
3682
|
const t = [];
|
|
3650
3683
|
let n = null;
|
|
3651
3684
|
const r = e.onEvent((i) => {
|
|
@@ -3660,21 +3693,21 @@ async function* ou(e) {
|
|
|
3660
3693
|
r();
|
|
3661
3694
|
}
|
|
3662
3695
|
}
|
|
3663
|
-
function
|
|
3664
|
-
const r =
|
|
3696
|
+
function Oe(e, t = new Uint8Array(32), n = 1) {
|
|
3697
|
+
const r = rn(fe, e, t), i = [];
|
|
3665
3698
|
for (let s = 1; s <= n; s++)
|
|
3666
3699
|
i.push(Cr(fe, r, new Uint8Array([s]), 32));
|
|
3667
3700
|
return i;
|
|
3668
3701
|
}
|
|
3669
|
-
function
|
|
3702
|
+
function fu(e, t) {
|
|
3670
3703
|
return `${e}:${t}`;
|
|
3671
3704
|
}
|
|
3672
|
-
function
|
|
3705
|
+
function hu(e) {
|
|
3673
3706
|
var n;
|
|
3674
3707
|
const t = (n = e.tags) == null ? void 0 : n.find((r) => r[0] === "ms");
|
|
3675
3708
|
return t ? parseInt(t[1]) : e.created_at * 1e3;
|
|
3676
3709
|
}
|
|
3677
|
-
const
|
|
3710
|
+
const Jc = 1e3, Yc = "0000000000000000000000000000000000000000000000000000000000000000";
|
|
3678
3711
|
class st {
|
|
3679
3712
|
// 1. CHANNEL PUBLIC INTERFACE
|
|
3680
3713
|
constructor(t, n) {
|
|
@@ -3696,10 +3729,10 @@ class st {
|
|
|
3696
3729
|
* @returns A new Session instance
|
|
3697
3730
|
*/
|
|
3698
3731
|
static init(t, n, r, i, s, o) {
|
|
3699
|
-
const c = _e(), [a, l] =
|
|
3732
|
+
const c = _e(), [a, l] = Oe(s, q.getConversationKey(c, n), 2);
|
|
3700
3733
|
let f, u;
|
|
3701
3734
|
i ? (f = { publicKey: le(r), privateKey: r }, u = { publicKey: le(c), privateKey: c }) : u = { publicKey: le(r), privateKey: r };
|
|
3702
|
-
const
|
|
3735
|
+
const y = {
|
|
3703
3736
|
rootKey: i ? a : s,
|
|
3704
3737
|
theirNextNostrPublicKey: n,
|
|
3705
3738
|
ourCurrentNostrKey: f,
|
|
@@ -3709,9 +3742,8 @@ class st {
|
|
|
3709
3742
|
sendingChainMessageNumber: 0,
|
|
3710
3743
|
receivingChainMessageNumber: 0,
|
|
3711
3744
|
previousSendingChainMessageCount: 0,
|
|
3712
|
-
|
|
3713
|
-
|
|
3714
|
-
}, b = new st(t, g);
|
|
3745
|
+
skippedKeys: {}
|
|
3746
|
+
}, b = new st(t, y);
|
|
3715
3747
|
return o && (b.name = o), b;
|
|
3716
3748
|
}
|
|
3717
3749
|
/**
|
|
@@ -3742,18 +3774,18 @@ class st {
|
|
|
3742
3774
|
const n = Date.now(), r = {
|
|
3743
3775
|
...t,
|
|
3744
3776
|
content: t.content || "",
|
|
3745
|
-
kind: t.kind ||
|
|
3777
|
+
kind: t.kind || Ge,
|
|
3746
3778
|
created_at: t.created_at || Math.floor(n / 1e3),
|
|
3747
3779
|
tags: t.tags || [],
|
|
3748
|
-
pubkey: t.pubkey ||
|
|
3780
|
+
pubkey: t.pubkey || Yc
|
|
3749
3781
|
};
|
|
3750
|
-
r.tags.some(([l]) => l === "ms") || r.tags.push(["ms", String(n)]), r.id =
|
|
3782
|
+
r.tags.some(([l]) => l === "ms") || r.tags.push(["ms", String(n)]), r.id = He(r);
|
|
3751
3783
|
const [i, s] = this.ratchetEncrypt(JSON.stringify(r)), o = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, this.state.theirNextNostrPublicKey), c = q.encrypt(JSON.stringify(i), o);
|
|
3752
3784
|
return { event: X({
|
|
3753
3785
|
content: s,
|
|
3754
|
-
kind:
|
|
3786
|
+
kind: Ge,
|
|
3755
3787
|
tags: [["header", c]],
|
|
3756
|
-
created_at: Math.floor(
|
|
3788
|
+
created_at: Math.floor(n / 1e3)
|
|
3757
3789
|
}, this.state.ourCurrentNostrKey.privateKey), innerEvent: r };
|
|
3758
3790
|
}
|
|
3759
3791
|
/**
|
|
@@ -3774,7 +3806,7 @@ class st {
|
|
|
3774
3806
|
}
|
|
3775
3807
|
// 2. RATCHET FUNCTIONS
|
|
3776
3808
|
ratchetEncrypt(t) {
|
|
3777
|
-
const [n, r] =
|
|
3809
|
+
const [n, r] = Oe(this.state.sendingChainKey, new Uint8Array([1]), 2);
|
|
3778
3810
|
return this.state.sendingChainKey = n, [{
|
|
3779
3811
|
number: this.state.sendingChainMessageNumber++,
|
|
3780
3812
|
nextPublicKey: this.state.ourNextNostrKey.publicKey,
|
|
@@ -3785,59 +3817,57 @@ class st {
|
|
|
3785
3817
|
const i = this.trySkippedMessageKeys(t, n, r);
|
|
3786
3818
|
if (i) return i;
|
|
3787
3819
|
this.skipMessageKeys(t.number, r);
|
|
3788
|
-
const [s, o] =
|
|
3820
|
+
const [s, o] = Oe(this.state.receivingChainKey, new Uint8Array([1]), 2);
|
|
3789
3821
|
this.state.receivingChainKey = s, this.state.receivingChainMessageNumber++;
|
|
3790
3822
|
try {
|
|
3791
3823
|
return q.decrypt(n, o);
|
|
3792
3824
|
} catch (c) {
|
|
3793
3825
|
throw console.error(this.name, "Decryption failed:", c, {
|
|
3794
|
-
messageKey:
|
|
3795
|
-
receivingChainKey:
|
|
3796
|
-
sendingChainKey: this.state.sendingChainKey &&
|
|
3797
|
-
rootKey:
|
|
3826
|
+
messageKey: P(o).slice(0, 4),
|
|
3827
|
+
receivingChainKey: P(this.state.receivingChainKey).slice(0, 4),
|
|
3828
|
+
sendingChainKey: this.state.sendingChainKey && P(this.state.sendingChainKey).slice(0, 4),
|
|
3829
|
+
rootKey: P(this.state.rootKey).slice(0, 4)
|
|
3798
3830
|
}), c;
|
|
3799
3831
|
}
|
|
3800
3832
|
}
|
|
3801
3833
|
ratchetStep(t) {
|
|
3802
3834
|
this.state.previousSendingChainMessageCount = this.state.sendingChainMessageNumber, this.state.sendingChainMessageNumber = 0, this.state.receivingChainMessageNumber = 0, this.state.theirNextNostrPublicKey = t;
|
|
3803
|
-
const n = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [r, i] =
|
|
3835
|
+
const n = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [r, i] = Oe(this.state.rootKey, n, 2);
|
|
3804
3836
|
this.state.receivingChainKey = i, this.state.ourCurrentNostrKey = this.state.ourNextNostrKey;
|
|
3805
3837
|
const s = _e();
|
|
3806
3838
|
this.state.ourNextNostrKey = {
|
|
3807
3839
|
publicKey: le(s),
|
|
3808
3840
|
privateKey: s
|
|
3809
3841
|
};
|
|
3810
|
-
const o = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [c, a] =
|
|
3842
|
+
const o = q.getConversationKey(this.state.ourNextNostrKey.privateKey, this.state.theirNextNostrPublicKey), [c, a] = Oe(r, o, 2);
|
|
3811
3843
|
this.state.rootKey = c, this.state.sendingChainKey = a;
|
|
3812
3844
|
}
|
|
3813
3845
|
// 3. MESSAGE KEY FUNCTIONS
|
|
3814
3846
|
skipMessageKeys(t, n) {
|
|
3815
|
-
if (this.state.receivingChainMessageNumber +
|
|
3847
|
+
if (this.state.receivingChainMessageNumber + Jc < t)
|
|
3816
3848
|
throw new Error("Too many skipped messages");
|
|
3817
|
-
|
|
3818
|
-
|
|
3819
|
-
|
|
3820
|
-
|
|
3821
|
-
|
|
3822
|
-
const
|
|
3823
|
-
|
|
3824
|
-
const a = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
|
|
3825
|
-
o.push(a);
|
|
3826
|
-
}
|
|
3827
|
-
const c = q.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
|
|
3828
|
-
o.push(c), this.state.skippedHeaderKeys[n] = o;
|
|
3849
|
+
if (!this.state.skippedKeys[n]) {
|
|
3850
|
+
if (this.state.skippedKeys[n] = {
|
|
3851
|
+
headerKeys: [],
|
|
3852
|
+
messageKeys: {}
|
|
3853
|
+
}, this.state.ourCurrentNostrKey) {
|
|
3854
|
+
const i = q.getConversationKey(this.state.ourCurrentNostrKey.privateKey, n);
|
|
3855
|
+
this.state.skippedKeys[n].headerKeys.push(i);
|
|
3829
3856
|
}
|
|
3830
|
-
this.state.
|
|
3857
|
+
const r = q.getConversationKey(this.state.ourNextNostrKey.privateKey, n);
|
|
3858
|
+
this.state.skippedKeys[n].headerKeys.push(r);
|
|
3859
|
+
}
|
|
3860
|
+
for (; this.state.receivingChainMessageNumber < t; ) {
|
|
3861
|
+
const [r, i] = Oe(this.state.receivingChainKey, new Uint8Array([1]), 2);
|
|
3862
|
+
this.state.receivingChainKey = r, this.state.skippedKeys[n].messageKeys[this.state.receivingChainMessageNumber] = i, this.state.receivingChainMessageNumber++;
|
|
3831
3863
|
}
|
|
3832
3864
|
}
|
|
3833
3865
|
trySkippedMessageKeys(t, n, r) {
|
|
3834
|
-
var
|
|
3835
|
-
const i =
|
|
3836
|
-
if (i
|
|
3837
|
-
|
|
3838
|
-
|
|
3839
|
-
}
|
|
3840
|
-
return null;
|
|
3866
|
+
var o;
|
|
3867
|
+
const i = this.state.skippedKeys[r];
|
|
3868
|
+
if (!i) return null;
|
|
3869
|
+
const s = i.messageKeys[t.number];
|
|
3870
|
+
return s ? (delete i.messageKeys[t.number], Object.keys(i.messageKeys).length === 0 && (delete this.state.skippedKeys[r], (o = this.nostrUnsubscribe) == null || o.call(this), this.nostrUnsubscribe = void 0), q.decrypt(n, s)) : null;
|
|
3841
3871
|
}
|
|
3842
3872
|
// 4. NOSTR EVENT HANDLING
|
|
3843
3873
|
decryptHeader(t) {
|
|
@@ -3854,9 +3884,9 @@ class st {
|
|
|
3854
3884
|
return [JSON.parse(q.decrypt(n, r)), !0, !1];
|
|
3855
3885
|
} catch {
|
|
3856
3886
|
}
|
|
3857
|
-
const i = this.state.
|
|
3858
|
-
if (i)
|
|
3859
|
-
for (const s of i)
|
|
3887
|
+
const i = this.state.skippedKeys[t.pubkey];
|
|
3888
|
+
if (i != null && i.headerKeys)
|
|
3889
|
+
for (const s of i.headerKeys)
|
|
3860
3890
|
try {
|
|
3861
3891
|
return [JSON.parse(q.decrypt(n, s)), !1, !0];
|
|
3862
3892
|
} catch {
|
|
@@ -3866,19 +3896,16 @@ class st {
|
|
|
3866
3896
|
handleNostrEvent(t) {
|
|
3867
3897
|
var c;
|
|
3868
3898
|
const [n, r, i] = this.decryptHeader(t);
|
|
3869
|
-
|
|
3870
|
-
|
|
3871
|
-
|
|
3872
|
-
|
|
3873
|
-
)), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey));
|
|
3874
|
-
else if (!(Lt(t.pubkey, n.number) in this.state.skippedMessageKeys))
|
|
3875
|
-
return;
|
|
3899
|
+
i || (this.state.theirNextNostrPublicKey !== n.nextPublicKey && (this.state.theirCurrentNostrPublicKey = this.state.theirNextNostrPublicKey, this.state.theirNextNostrPublicKey = n.nextPublicKey, (c = this.nostrUnsubscribe) == null || c.call(this), this.nostrUnsubscribe = this.nostrNextUnsubscribe, this.nostrNextUnsubscribe = this.nostrSubscribe(
|
|
3900
|
+
{ authors: [this.state.theirNextNostrPublicKey], kinds: [Ge] },
|
|
3901
|
+
(a) => this.handleNostrEvent(a)
|
|
3902
|
+
)), r && (this.skipMessageKeys(n.previousChainLength, t.pubkey), this.ratchetStep(n.nextPublicKey)));
|
|
3876
3903
|
const s = this.ratchetDecrypt(n, t.content, t.pubkey), o = JSON.parse(s);
|
|
3877
3904
|
if (!dt(o)) {
|
|
3878
3905
|
console.error("Invalid event received", o);
|
|
3879
3906
|
return;
|
|
3880
3907
|
}
|
|
3881
|
-
if (o.id !==
|
|
3908
|
+
if (o.id !== He(o)) {
|
|
3882
3909
|
console.error("Event hash does not match", o);
|
|
3883
3910
|
return;
|
|
3884
3911
|
}
|
|
@@ -3887,12 +3914,12 @@ class st {
|
|
|
3887
3914
|
subscribeToNostrEvents() {
|
|
3888
3915
|
if (this.nostrNextUnsubscribe) return;
|
|
3889
3916
|
this.nostrNextUnsubscribe = this.nostrSubscribe(
|
|
3890
|
-
{ authors: [this.state.theirNextNostrPublicKey], kinds: [
|
|
3917
|
+
{ authors: [this.state.theirNextNostrPublicKey], kinds: [Ge] },
|
|
3891
3918
|
(n) => this.handleNostrEvent(n)
|
|
3892
3919
|
);
|
|
3893
|
-
const t = Object.keys(this.state.
|
|
3920
|
+
const t = Object.keys(this.state.skippedKeys);
|
|
3894
3921
|
this.state.theirCurrentNostrPublicKey && !t.includes(this.state.theirCurrentNostrPublicKey) && t.push(this.state.theirCurrentNostrPublicKey), this.nostrUnsubscribe = this.nostrSubscribe(
|
|
3895
|
-
{ authors: t, kinds: [
|
|
3922
|
+
{ authors: t, kinds: [Ge] },
|
|
3896
3923
|
(n) => this.handleNostrEvent(n)
|
|
3897
3924
|
);
|
|
3898
3925
|
}
|
|
@@ -3900,9 +3927,10 @@ class st {
|
|
|
3900
3927
|
new TextDecoder("utf-8");
|
|
3901
3928
|
new TextEncoder();
|
|
3902
3929
|
function Qe(e, t) {
|
|
3903
|
-
const n =
|
|
3904
|
-
return
|
|
3930
|
+
const n = ke.getSharedSecret(e, "02" + t).subarray(1, 33);
|
|
3931
|
+
return rn(fe, n, "nip44-v2");
|
|
3905
3932
|
}
|
|
3933
|
+
const Xc = 2 * 24 * 60 * 60, Qc = () => Math.round(Date.now() / 1e3), eu = () => Math.round(Qc() - Math.random() * Xc);
|
|
3906
3934
|
class Pe {
|
|
3907
3935
|
constructor(t, n, r, i, s, o, c = []) {
|
|
3908
3936
|
this.inviterEphemeralPublicKey = t, this.sharedSecret = n, this.inviter = r, this.inviterEphemeralPrivateKey = i, this.label = s, this.maxUses = o, this.usedBy = c;
|
|
@@ -3910,7 +3938,7 @@ class Pe {
|
|
|
3910
3938
|
static createNew(t, n, r) {
|
|
3911
3939
|
if (!t)
|
|
3912
3940
|
throw new Error("Inviter public key is required");
|
|
3913
|
-
const i = _e(), s = le(i), o =
|
|
3941
|
+
const i = _e(), s = le(i), o = P(_e());
|
|
3914
3942
|
return new Pe(
|
|
3915
3943
|
s,
|
|
3916
3944
|
o,
|
|
@@ -3956,7 +3984,7 @@ class Pe {
|
|
|
3956
3984
|
var o, c;
|
|
3957
3985
|
if (!t.sig)
|
|
3958
3986
|
throw new Error("Event is not signed");
|
|
3959
|
-
if (!
|
|
3987
|
+
if (!pt(t))
|
|
3960
3988
|
throw new Error("Event signature is invalid");
|
|
3961
3989
|
const { tags: n } = t;
|
|
3962
3990
|
if (!n)
|
|
@@ -3972,7 +4000,7 @@ class Pe {
|
|
|
3972
4000
|
}
|
|
3973
4001
|
static fromUser(t, n, r) {
|
|
3974
4002
|
const i = {
|
|
3975
|
-
kinds: [
|
|
4003
|
+
kinds: [Dn],
|
|
3976
4004
|
authors: [t],
|
|
3977
4005
|
limit: 1,
|
|
3978
4006
|
"#d": ["double-ratchet/invites/public"]
|
|
@@ -4017,7 +4045,7 @@ class Pe {
|
|
|
4017
4045
|
}
|
|
4018
4046
|
getEvent() {
|
|
4019
4047
|
return {
|
|
4020
|
-
kind:
|
|
4048
|
+
kind: Dn,
|
|
4021
4049
|
pubkey: this.inviter,
|
|
4022
4050
|
content: "",
|
|
4023
4051
|
created_at: Math.floor(Date.now() / 1e3),
|
|
@@ -4045,25 +4073,24 @@ class Pe {
|
|
|
4045
4073
|
* so the inviter can create the session on their side.
|
|
4046
4074
|
*/
|
|
4047
4075
|
async accept(t, n, r) {
|
|
4048
|
-
const i = _e(), s = le(i), o = this.inviter || this.inviterEphemeralPublicKey, c =
|
|
4076
|
+
const i = _e(), s = le(i), o = this.inviter || this.inviterEphemeralPublicKey, c = z(this.sharedSecret), a = st.init(t, this.inviterEphemeralPublicKey, i, !0, c, void 0), f = await (typeof r == "function" ? r : (h, d) => Promise.resolve(q.encrypt(h, Qe(r, d))))(s, o), u = {
|
|
4049
4077
|
pubkey: n,
|
|
4050
|
-
|
|
4051
|
-
content: await q.encrypt(g, c),
|
|
4078
|
+
content: await q.encrypt(f, c),
|
|
4052
4079
|
created_at: Math.floor(Date.now() / 1e3)
|
|
4053
|
-
}, p = {
|
|
4054
|
-
kind:
|
|
4055
|
-
pubkey:
|
|
4056
|
-
content: q.encrypt(JSON.stringify(
|
|
4057
|
-
created_at:
|
|
4080
|
+
}, y = _e(), b = le(y), p = {
|
|
4081
|
+
kind: jn,
|
|
4082
|
+
pubkey: b,
|
|
4083
|
+
content: q.encrypt(JSON.stringify(u), Qe(y, this.inviterEphemeralPublicKey)),
|
|
4084
|
+
created_at: eu(),
|
|
4058
4085
|
tags: [["p", this.inviterEphemeralPublicKey]]
|
|
4059
4086
|
};
|
|
4060
|
-
return { session: a, event: X(p,
|
|
4087
|
+
return { session: a, event: X(p, y) };
|
|
4061
4088
|
}
|
|
4062
4089
|
listen(t, n, r) {
|
|
4063
4090
|
if (!this.inviterEphemeralPrivateKey)
|
|
4064
4091
|
throw new Error("Inviter session key is not available");
|
|
4065
4092
|
const i = {
|
|
4066
|
-
kinds: [
|
|
4093
|
+
kinds: [jn],
|
|
4067
4094
|
"#p": [this.inviterEphemeralPublicKey]
|
|
4068
4095
|
};
|
|
4069
4096
|
return n(i, async (s) => {
|
|
@@ -4072,14 +4099,9 @@ class Pe {
|
|
|
4072
4099
|
console.error("Invite has reached maximum number of uses");
|
|
4073
4100
|
return;
|
|
4074
4101
|
}
|
|
4075
|
-
const o = await q.decrypt(s.content, Qe(this.inviterEphemeralPrivateKey, s.pubkey)), c = JSON.parse(o);
|
|
4076
|
-
if (!c.tags || !c.tags.some(([h, d]) => h === "sharedSecret" && d === this.sharedSecret)) {
|
|
4077
|
-
console.error("Invalid secret from event", s);
|
|
4078
|
-
return;
|
|
4079
|
-
}
|
|
4080
|
-
const a = G(this.sharedSecret), l = c.pubkey;
|
|
4102
|
+
const o = await q.decrypt(s.content, Qe(this.inviterEphemeralPrivateKey, s.pubkey)), c = JSON.parse(o), a = z(this.sharedSecret), l = c.pubkey;
|
|
4081
4103
|
this.usedBy.push(l);
|
|
4082
|
-
const f = await q.decrypt(c.content, a),
|
|
4104
|
+
const f = await q.decrypt(c.content, a), y = await (typeof t == "function" ? t : (h, d) => Promise.resolve(q.decrypt(h, Qe(t, d))))(f, l), b = s.id, p = st.init(n, y, this.inviterEphemeralPrivateKey, !1, a, b);
|
|
4083
4105
|
r(p, l);
|
|
4084
4106
|
} catch (o) {
|
|
4085
4107
|
console.error("Error processing invite message:", o, "event", s);
|
|
@@ -4089,15 +4111,16 @@ class Pe {
|
|
|
4089
4111
|
}
|
|
4090
4112
|
export {
|
|
4091
4113
|
Gc as CHAT_MESSAGE_KIND,
|
|
4092
|
-
|
|
4114
|
+
Dn as INVITE_EVENT_KIND,
|
|
4115
|
+
jn as INVITE_RESPONSE_KIND,
|
|
4093
4116
|
Pe as Invite,
|
|
4094
|
-
|
|
4095
|
-
|
|
4117
|
+
au as MAX_SKIP,
|
|
4118
|
+
Ge as MESSAGE_EVENT_KIND,
|
|
4096
4119
|
st as Session,
|
|
4097
|
-
|
|
4098
|
-
|
|
4099
|
-
|
|
4100
|
-
|
|
4101
|
-
|
|
4102
|
-
|
|
4120
|
+
lu as createEventStream,
|
|
4121
|
+
uu as deserializeSessionState,
|
|
4122
|
+
hu as getMillisecondTimestamp,
|
|
4123
|
+
Oe as kdf,
|
|
4124
|
+
cu as serializeSessionState,
|
|
4125
|
+
fu as skippedMessageIndexKey
|
|
4103
4126
|
};
|