@honeybbq/teamspeak-client 0.2.2 → 0.3.0
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/README.md +1 -0
- package/dist/address-BR-5unVo.cjs +2 -0
- package/dist/address-BR-5unVo.cjs.map +1 -0
- package/dist/address-BfmovVpp.js +65 -0
- package/dist/address-BfmovVpp.js.map +1 -0
- package/dist/address.d.ts +9 -0
- package/dist/address.d.ts.map +1 -0
- package/dist/address.test.d.ts +2 -0
- package/dist/address.test.d.ts.map +1 -0
- package/dist/api.d.ts.map +1 -1
- package/dist/api.test.d.ts +2 -0
- package/dist/api.test.d.ts.map +1 -0
- package/dist/client.d.ts +2 -0
- package/dist/client.d.ts.map +1 -1
- package/dist/command/index.cjs +1 -1
- package/dist/command/index.mjs +2 -2
- package/dist/{command-caXc4h0n.js → command-BLe-C2L2.js} +2 -4
- package/dist/{command-caXc4h0n.js.map → command-BLe-C2L2.js.map} +1 -1
- package/dist/command-DAK4pUBP.cjs +4 -0
- package/dist/{command-Cu2v-5-K.cjs.map → command-DAK4pUBP.cjs.map} +1 -1
- package/dist/crypt-handshake-CQkQreLx.cjs +2 -0
- package/dist/{crypt-handshake-Dbj2cSBZ.cjs.map → crypt-handshake-CQkQreLx.cjs.map} +1 -1
- package/dist/crypt-handshake-DziOY4Lq.js +55 -0
- package/dist/{crypt-handshake-CHmvZ2qs.js.map → crypt-handshake-DziOY4Lq.js.map} +1 -1
- package/dist/{crypt-init2-DWX7Tp-_.js → crypt-init2-D70ha4LB.js} +25 -27
- package/dist/{crypt-init2-DWX7Tp-_.js.map → crypt-init2-D70ha4LB.js.map} +1 -1
- package/dist/crypt-init2-DparLekm.cjs +2 -0
- package/dist/{crypt-init2-C2oihZ7e.cjs.map → crypt-init2-DparLekm.cjs.map} +1 -1
- package/dist/crypto/identity.d.ts.map +1 -1
- package/dist/crypto/index.cjs +1 -1
- package/dist/crypto/index.mjs +2 -2
- package/dist/{crypto-VC7n6YJb.js → crypto-Bg02m4ZE.js} +9 -9
- package/dist/crypto-Bg02m4ZE.js.map +1 -0
- package/dist/crypto-CDlweUL3.cjs +2 -0
- package/dist/crypto-CDlweUL3.cjs.map +1 -0
- package/dist/discovery/index.cjs +1 -1
- package/dist/discovery/index.mjs +1 -1
- package/dist/discovery/resolver.d.ts.map +1 -1
- package/dist/{handler-C_JhqGTd.js → handler-DI_abe9c.js} +159 -131
- package/dist/handler-DI_abe9c.js.map +1 -0
- package/dist/handler-DuwoO5RC.cjs +2 -0
- package/dist/handler-DuwoO5RC.cjs.map +1 -0
- package/dist/handshake/index.cjs +1 -1
- package/dist/handshake/index.mjs +2 -2
- package/dist/helpers.d.ts.map +1 -1
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +155 -141
- package/dist/index.mjs.map +1 -1
- package/dist/{parser-DhAWj-TI.cjs → parser-CL33R9tr.cjs} +2 -2
- package/dist/{parser-DhAWj-TI.cjs.map → parser-CL33R9tr.cjs.map} +1 -1
- package/dist/{parser-CJjP3LlO.js → parser-DZMv3Jm-.js} +2 -2
- package/dist/{parser-CJjP3LlO.js.map → parser-DZMv3Jm-.js.map} +1 -1
- package/dist/primitives-cNNAeFCo.cjs +2 -0
- package/dist/primitives-cNNAeFCo.cjs.map +1 -0
- package/dist/primitives-xIr6Tjk4.js +1457 -0
- package/dist/primitives-xIr6Tjk4.js.map +1 -0
- package/dist/resolver-6B8dI9gr.js +141 -0
- package/dist/resolver-6B8dI9gr.js.map +1 -0
- package/dist/resolver-DCcmyWSK.cjs +4 -0
- package/dist/resolver-DCcmyWSK.cjs.map +1 -0
- package/dist/transport/handler.d.ts +2 -0
- package/dist/transport/handler.d.ts.map +1 -1
- package/dist/transport/index.cjs +1 -1
- package/dist/transport/index.mjs +1 -1
- package/dist/transport/whisper.test.d.ts +2 -0
- package/dist/transport/whisper.test.d.ts.map +1 -0
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +5 -5
- package/dist/command-Cu2v-5-K.cjs +0 -4
- package/dist/crypt-handshake-CHmvZ2qs.js +0 -55
- package/dist/crypt-handshake-Dbj2cSBZ.cjs +0 -2
- package/dist/crypt-init2-C2oihZ7e.cjs +0 -2
- package/dist/crypto-2veVY1fC.cjs +0 -2
- package/dist/crypto-2veVY1fC.cjs.map +0 -1
- package/dist/crypto-VC7n6YJb.js.map +0 -1
- package/dist/handler-C_JhqGTd.js.map +0 -1
- package/dist/handler-CqCD93f0.cjs +0 -2
- package/dist/handler-CqCD93f0.cjs.map +0 -1
- package/dist/primitives-BIAYfJ2Y.js +0 -1842
- package/dist/primitives-BIAYfJ2Y.js.map +0 -1
- package/dist/primitives-bj-ml31v.cjs +0 -2
- package/dist/primitives-bj-ml31v.cjs.map +0 -1
- package/dist/resolver-Br0QefWx.js +0 -162
- package/dist/resolver-Br0QefWx.js.map +0 -1
- package/dist/resolver-DDD2FFhD.cjs +0 -4
- package/dist/resolver-DDD2FFhD.cjs.map +0 -1
- package/dist/types-CGKgXvpG.js +0 -18
- package/dist/types-CGKgXvpG.js.map +0 -1
- package/dist/types-DrnoCdSW.cjs +0 -2
- package/dist/types-DrnoCdSW.cjs.map +0 -1
|
@@ -0,0 +1,1457 @@
|
|
|
1
|
+
import { createECDH as e, createHash as t, createPrivateKey as n, createPublicKey as r, createSign as i, createVerify as a, generateKeyPairSync as o, randomBytes as s } from "node:crypto";
|
|
2
|
+
//#region src/errors.ts
|
|
3
|
+
var c = class extends Error {
|
|
4
|
+
constructor(e, t) {
|
|
5
|
+
super(e, t), this.name = "TeamspeakError";
|
|
6
|
+
}
|
|
7
|
+
}, l = class extends c {
|
|
8
|
+
id;
|
|
9
|
+
serverMessage;
|
|
10
|
+
constructor(e, t) {
|
|
11
|
+
super(`TeamSpeak server error: ${t} (id=${e})`), this.name = "ServerError", this.id = e, this.serverMessage = t;
|
|
12
|
+
}
|
|
13
|
+
}, u = class extends c {
|
|
14
|
+
command;
|
|
15
|
+
constructor(e) {
|
|
16
|
+
super(`command timeout: ${e}`), this.name = "CommandTimeoutError", this.command = e;
|
|
17
|
+
}
|
|
18
|
+
}, d = class extends c {
|
|
19
|
+
constructor() {
|
|
20
|
+
super("already connecting or connected"), this.name = "AlreadyConnectedError";
|
|
21
|
+
}
|
|
22
|
+
}, f = class extends c {
|
|
23
|
+
constructor() {
|
|
24
|
+
super("EAX tag mismatch"), this.name = "EAXTagMismatchError";
|
|
25
|
+
}
|
|
26
|
+
}, p = class extends c {
|
|
27
|
+
constructor() {
|
|
28
|
+
super("fake signature mismatch"), this.name = "FakeSignatureMismatchError";
|
|
29
|
+
}
|
|
30
|
+
}, m = class extends c {
|
|
31
|
+
constructor(e, t) {
|
|
32
|
+
super(e, t), this.name = "FileTransferError";
|
|
33
|
+
}
|
|
34
|
+
}, h = class extends c {
|
|
35
|
+
constructor() {
|
|
36
|
+
super("timeout waiting for file transfer notification"), this.name = "FileTransferTimeoutError";
|
|
37
|
+
}
|
|
38
|
+
}, g = class extends c {
|
|
39
|
+
constructor(e, t) {
|
|
40
|
+
super(e, t), this.name = "CryptoInitError";
|
|
41
|
+
}
|
|
42
|
+
}, _ = class extends c {
|
|
43
|
+
constructor(e = "invalid identity format") {
|
|
44
|
+
super(e), this.name = "InvalidIdentityError";
|
|
45
|
+
}
|
|
46
|
+
}, v = 32, y = 65, b = 4, x = class {
|
|
47
|
+
privateKey;
|
|
48
|
+
offset;
|
|
49
|
+
constructor(e, t) {
|
|
50
|
+
this.privateKey = e, this.offset = t;
|
|
51
|
+
}
|
|
52
|
+
publicKeyBase64() {
|
|
53
|
+
let e = this.privateKey.export({ format: "jwk" });
|
|
54
|
+
return e.x === void 0 || e.y === void 0 || typeof e.x != "string" || typeof e.y != "string" ? "" : E(oe(e.x, v), oe(e.y, v));
|
|
55
|
+
}
|
|
56
|
+
toString() {
|
|
57
|
+
let e = this.privateKey.export({ format: "jwk" });
|
|
58
|
+
if (!e.d) return `:${this.offset}`;
|
|
59
|
+
let t = oe(e.d, v);
|
|
60
|
+
return `${Buffer.from(t).toString("base64")}:${this.offset}`;
|
|
61
|
+
}
|
|
62
|
+
securityLevel() {
|
|
63
|
+
let e = t("sha1");
|
|
64
|
+
return e.update(this.publicKeyBase64()), e.update(this.offset.toString(10)), se(e.digest());
|
|
65
|
+
}
|
|
66
|
+
async upgradeToLevel(e, n) {
|
|
67
|
+
let r = this.publicKeyBase64();
|
|
68
|
+
for (;;) {
|
|
69
|
+
if (n?.aborted) throw n.reason;
|
|
70
|
+
let i = t("sha1");
|
|
71
|
+
if (i.update(r), i.update(this.offset.toString(10)), se(i.digest()) >= e) return;
|
|
72
|
+
this.offset++, this.offset % 10000n == 0n && await new Promise((e) => setImmediate(e));
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
function S(t) {
|
|
77
|
+
let r = t.lastIndexOf(":");
|
|
78
|
+
if (r < 0) throw new _();
|
|
79
|
+
let i = t.slice(0, r), a = t.slice(r + 1), o = Buffer.from(i, "base64"), s = BigInt(a);
|
|
80
|
+
if (o.length > v) throw new _("private key scalar too large");
|
|
81
|
+
let c = Buffer.alloc(v);
|
|
82
|
+
o.copy(c, v - o.length);
|
|
83
|
+
let l = e("prime256v1");
|
|
84
|
+
l.setPrivateKey(c);
|
|
85
|
+
let u = l.getPublicKey(null, "uncompressed"), d = Buffer.from(u.slice(1, 33)).toString("base64url"), f = Buffer.from(u.slice(33, 65)).toString("base64url"), p = {
|
|
86
|
+
kty: "EC",
|
|
87
|
+
crv: "P-256",
|
|
88
|
+
d: c.toString("base64url"),
|
|
89
|
+
x: d,
|
|
90
|
+
y: f
|
|
91
|
+
};
|
|
92
|
+
return new x(n({
|
|
93
|
+
key: p,
|
|
94
|
+
format: "jwk"
|
|
95
|
+
}), s);
|
|
96
|
+
}
|
|
97
|
+
function C(e) {
|
|
98
|
+
let { privateKey: n } = o("ec", { namedCurve: "prime256v1" }), r = new x(n, 0n), i = r.publicKeyBase64();
|
|
99
|
+
for (;;) {
|
|
100
|
+
let n = t("sha1");
|
|
101
|
+
if (n.update(i), n.update(r.offset.toString(10)), se(n.digest()) >= e) return r;
|
|
102
|
+
r.offset++;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function w(e) {
|
|
106
|
+
let n = t("sha1").update(e).digest();
|
|
107
|
+
return Buffer.from(n).toString("base64");
|
|
108
|
+
}
|
|
109
|
+
function T(e) {
|
|
110
|
+
return t("sha512").update(e).digest();
|
|
111
|
+
}
|
|
112
|
+
function E(e, t) {
|
|
113
|
+
let n = O(3, Buffer.from([7, 0])), r = O(2, ae(32)), i = O(2, ae(e)), a = O(2, ae(t));
|
|
114
|
+
return O(48, Buffer.concat([
|
|
115
|
+
n,
|
|
116
|
+
r,
|
|
117
|
+
i,
|
|
118
|
+
a
|
|
119
|
+
])).toString("base64");
|
|
120
|
+
}
|
|
121
|
+
function ee(e) {
|
|
122
|
+
let t = D(e), n = {
|
|
123
|
+
kty: "EC",
|
|
124
|
+
crv: "P-256",
|
|
125
|
+
x: Buffer.from(t.slice(1, 33)).toString("base64url"),
|
|
126
|
+
y: Buffer.from(t.slice(33, 65)).toString("base64url")
|
|
127
|
+
};
|
|
128
|
+
return r({
|
|
129
|
+
key: n,
|
|
130
|
+
format: "jwk"
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
function D(e) {
|
|
134
|
+
try {
|
|
135
|
+
return te(e);
|
|
136
|
+
} catch {}
|
|
137
|
+
return ne(e);
|
|
138
|
+
}
|
|
139
|
+
function te(e) {
|
|
140
|
+
let t = k(e, 48).value, n = 0, r = k(t, 3, n);
|
|
141
|
+
n += r.consumed;
|
|
142
|
+
let i = k(t, 2, n);
|
|
143
|
+
n += i.consumed;
|
|
144
|
+
let a = k(t, 2, n);
|
|
145
|
+
n += a.consumed;
|
|
146
|
+
let o = k(t, 2, n);
|
|
147
|
+
return re(A(a.value, v), A(o.value, v));
|
|
148
|
+
}
|
|
149
|
+
function ne(e) {
|
|
150
|
+
let t = k(e, 48).value, n = 0, r = k(t, 2, n);
|
|
151
|
+
n += r.consumed;
|
|
152
|
+
let i = k(t, 2, n);
|
|
153
|
+
return re(A(r.value, v), A(i.value, v));
|
|
154
|
+
}
|
|
155
|
+
function re(e, t) {
|
|
156
|
+
if (e.length > v || t.length > v) throw Error("invalid public key point encoding");
|
|
157
|
+
let n = new Uint8Array(y);
|
|
158
|
+
return n[0] = b, n.set(e, 33 - e.length), n.set(t, 65 - t.length), n;
|
|
159
|
+
}
|
|
160
|
+
function O(e, t) {
|
|
161
|
+
let n = ie(t.length);
|
|
162
|
+
return Buffer.concat([
|
|
163
|
+
Buffer.from([e]),
|
|
164
|
+
n,
|
|
165
|
+
t
|
|
166
|
+
]);
|
|
167
|
+
}
|
|
168
|
+
function ie(e) {
|
|
169
|
+
return e < 128 ? Buffer.from([e]) : e < 256 ? Buffer.from([129, e]) : Buffer.from([
|
|
170
|
+
130,
|
|
171
|
+
e >> 8 & 255,
|
|
172
|
+
e & 255
|
|
173
|
+
]);
|
|
174
|
+
}
|
|
175
|
+
function ae(e) {
|
|
176
|
+
if (typeof e == "number") {
|
|
177
|
+
let t = [], n = e;
|
|
178
|
+
do
|
|
179
|
+
t.unshift(n & 255), n >>= 8;
|
|
180
|
+
while (n > 0);
|
|
181
|
+
return t[0] & 128 && t.unshift(0), Buffer.from(t);
|
|
182
|
+
}
|
|
183
|
+
let t = 0;
|
|
184
|
+
for (; t < e.length - 1 && e[t] === 0;) t++;
|
|
185
|
+
let n = e.slice(t);
|
|
186
|
+
return n[0] & 128 ? Buffer.concat([Buffer.from([0]), n]) : Buffer.from(n);
|
|
187
|
+
}
|
|
188
|
+
function k(e, t, n = 0) {
|
|
189
|
+
if (e[n] !== t) throw Error(`expected DER tag 0x${t.toString(16)}, got 0x${(e[n] ?? 0).toString(16)}`);
|
|
190
|
+
let r = n + 1, i, a = e[r++];
|
|
191
|
+
if (a < 128) i = a;
|
|
192
|
+
else if (a === 129) i = e[r++];
|
|
193
|
+
else if (a === 130) i = (e[r] << 8 | e[r + 1]) >>> 0, r += 2;
|
|
194
|
+
else throw Error("unsupported DER length encoding");
|
|
195
|
+
return {
|
|
196
|
+
value: e.slice(r, r + i),
|
|
197
|
+
consumed: r - n + i
|
|
198
|
+
};
|
|
199
|
+
}
|
|
200
|
+
function A(e, t) {
|
|
201
|
+
let n = 0;
|
|
202
|
+
for (; n < e.length - 1 && e[n] === 0;) n++;
|
|
203
|
+
let r = e.slice(n);
|
|
204
|
+
if (r.length > t) throw Error("integer too large");
|
|
205
|
+
if (r.length === t) return r;
|
|
206
|
+
let i = new Uint8Array(t);
|
|
207
|
+
return i.set(r, t - r.length), i;
|
|
208
|
+
}
|
|
209
|
+
function oe(e, t) {
|
|
210
|
+
let n = Buffer.from(e, "base64url");
|
|
211
|
+
if (n.length === t) return n;
|
|
212
|
+
let r = Buffer.alloc(t);
|
|
213
|
+
return n.copy(r, t - n.length), r;
|
|
214
|
+
}
|
|
215
|
+
function se(e) {
|
|
216
|
+
let t = 0;
|
|
217
|
+
for (let n of e) if (n === 0) t += 8;
|
|
218
|
+
else for (let e = 0; e < 8; e++) if (!(n & 1 << e)) t++;
|
|
219
|
+
else return t;
|
|
220
|
+
return t;
|
|
221
|
+
}
|
|
222
|
+
//#endregion
|
|
223
|
+
//#region node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/_u64.js
|
|
224
|
+
var ce = /* @__PURE__ */ BigInt(2 ** 32 - 1), le = /* @__PURE__ */ BigInt(32);
|
|
225
|
+
function ue(e, t = !1) {
|
|
226
|
+
return t ? {
|
|
227
|
+
h: Number(e & ce),
|
|
228
|
+
l: Number(e >> le & ce)
|
|
229
|
+
} : {
|
|
230
|
+
h: Number(e >> le & ce) | 0,
|
|
231
|
+
l: Number(e & ce) | 0
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
function de(e, t = !1) {
|
|
235
|
+
let n = e.length, r = new Uint32Array(n), i = new Uint32Array(n);
|
|
236
|
+
for (let a = 0; a < n; a++) {
|
|
237
|
+
let { h: n, l: o } = ue(e[a], t);
|
|
238
|
+
[r[a], i[a]] = [n, o];
|
|
239
|
+
}
|
|
240
|
+
return [r, i];
|
|
241
|
+
}
|
|
242
|
+
var fe = (e) => e / 2 ** 32 | 0, pe = (e) => e >>> 0;
|
|
243
|
+
function me(e, t, n, r) {
|
|
244
|
+
let i = fe(n), a = pe(n);
|
|
245
|
+
e.setUint32(t, r ? a : i, r), e.setUint32(t + 4, r ? i : a, r);
|
|
246
|
+
}
|
|
247
|
+
var he = (e, t, n) => e >>> n, ge = (e, t, n) => e << 32 - n | t >>> n, j = (e, t, n) => e >>> n | t << 32 - n, M = (e, t, n) => e << 32 - n | t >>> n, _e = (e, t, n) => e << 64 - n | t >>> n - 32, ve = (e, t, n) => e >>> n - 32 | t << 64 - n;
|
|
248
|
+
function N(e, t, n, r) {
|
|
249
|
+
let i = (t >>> 0) + (r >>> 0);
|
|
250
|
+
return {
|
|
251
|
+
h: e + n + (i / 2 ** 32 | 0) | 0,
|
|
252
|
+
l: i | 0
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
var ye = (e, t, n) => (e >>> 0) + (t >>> 0) + (n >>> 0), be = (e, t, n, r) => t + n + r + (e / 2 ** 32 | 0) | 0, xe = (e, t, n, r) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0), Se = (e, t, n, r, i) => t + n + r + i + (e / 2 ** 32 | 0) | 0, Ce = (e, t, n, r, i) => (e >>> 0) + (t >>> 0) + (n >>> 0) + (r >>> 0) + (i >>> 0), we = (e, t, n, r, i, a) => t + n + r + i + a + (e / 2 ** 32 | 0) | 0;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region node_modules/.pnpm/@noble+hashes@2.4.0/node_modules/@noble/hashes/utils.js
|
|
258
|
+
function Te(e) {
|
|
259
|
+
return e instanceof Uint8Array || ArrayBuffer.isView(e) && e.constructor.name === "Uint8Array" && "BYTES_PER_ELEMENT" in e && e.BYTES_PER_ELEMENT === 1;
|
|
260
|
+
}
|
|
261
|
+
var Ee = (e) => e ? `"${e}" ` : "";
|
|
262
|
+
function P(e, t = "") {
|
|
263
|
+
if (typeof e != "number") throw TypeError(Ee(t) + "expected number, got " + typeof e);
|
|
264
|
+
if (!Number.isSafeInteger(e) || e < 0) throw RangeError(Ee(t) + "expected integer >= 0, got " + e);
|
|
265
|
+
return e;
|
|
266
|
+
}
|
|
267
|
+
function F(e, t, n = "") {
|
|
268
|
+
if (Te(e) && (t === void 0 || e.length === t)) return e;
|
|
269
|
+
t !== void 0 && P(t, "length");
|
|
270
|
+
let r = Te(e), i = t === void 0 ? "" : ` of length ${t}`, a = r ? `length=${e.length}` : `type=${typeof e}`, o = Ee(n) + "expected Uint8Array" + i + ", got " + a;
|
|
271
|
+
throw r ? RangeError(o) : TypeError(o);
|
|
272
|
+
}
|
|
273
|
+
var De = (e, t) => {
|
|
274
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError((t === "object" ? "" : `"${t}" `) + "expected object, got type=" + typeof e);
|
|
275
|
+
}, Oe = (e, t) => {
|
|
276
|
+
De(e, t);
|
|
277
|
+
let n = Object.getPrototypeOf(e);
|
|
278
|
+
if (n !== Object.prototype && n !== null) throw TypeError(`"${t}" expected plain object`);
|
|
279
|
+
if (Object.hasOwn(e, "__proto__")) throw TypeError(`"${t}.__proto__" is not allowed`);
|
|
280
|
+
};
|
|
281
|
+
function ke(e, t = !0) {
|
|
282
|
+
if (e.destroyed) throw Error("hash was destroyed");
|
|
283
|
+
if (t && e.finished) throw Error("digest() was already called");
|
|
284
|
+
}
|
|
285
|
+
function Ae(e, t) {
|
|
286
|
+
F(e, void 0, "output");
|
|
287
|
+
let n = t.outputLen;
|
|
288
|
+
if (!(e.length >= n)) throw RangeError("\"output\" expected length >= " + n);
|
|
289
|
+
}
|
|
290
|
+
function je(...e) {
|
|
291
|
+
for (let t = 0; t < e.length; t++) e[t].fill(0);
|
|
292
|
+
}
|
|
293
|
+
function Me(e) {
|
|
294
|
+
return new DataView(e.buffer, e.byteOffset, e.byteLength);
|
|
295
|
+
}
|
|
296
|
+
var Ne = typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", Pe = /* @__PURE__ */ Array.from({ length: 256 }, (e, t) => t.toString(16).padStart(2, "0"));
|
|
297
|
+
function Fe(e) {
|
|
298
|
+
if (F(e), Ne) return e.toHex();
|
|
299
|
+
let t = "";
|
|
300
|
+
for (let n = 0; n < e.length; n++) t += Pe[e[n]];
|
|
301
|
+
return t;
|
|
302
|
+
}
|
|
303
|
+
function Ie(e) {
|
|
304
|
+
return e >= 48 && e <= 57 ? e - 48 : e >= 65 && e <= 70 ? e - 55 : e >= 97 && e <= 102 ? e - 87 : void 0;
|
|
305
|
+
}
|
|
306
|
+
function Le(e) {
|
|
307
|
+
if (typeof e != "string") throw TypeError("hex string expected, got " + typeof e);
|
|
308
|
+
if (Ne) try {
|
|
309
|
+
return Uint8Array.fromHex(e);
|
|
310
|
+
} catch (e) {
|
|
311
|
+
throw e instanceof SyntaxError ? RangeError(e.message) : e;
|
|
312
|
+
}
|
|
313
|
+
let t = e.length, n = t / 2;
|
|
314
|
+
if (t % 2) throw RangeError("hex string expected, got unpadded hex of length " + t);
|
|
315
|
+
let r = new Uint8Array(n);
|
|
316
|
+
for (let t = 0, i = 0; t < n; t++, i += 2) {
|
|
317
|
+
let n = Ie(e.charCodeAt(i)), a = Ie(e.charCodeAt(i + 1));
|
|
318
|
+
if (n === void 0 || a === void 0) {
|
|
319
|
+
let t = e[i] + e[i + 1];
|
|
320
|
+
throw RangeError("hex string expected, got non-hex character \"" + t + "\" at index " + i);
|
|
321
|
+
}
|
|
322
|
+
r[t] = n * 16 + a;
|
|
323
|
+
}
|
|
324
|
+
return r;
|
|
325
|
+
}
|
|
326
|
+
function Re(...e) {
|
|
327
|
+
let t = 0;
|
|
328
|
+
for (let n = 0; n < e.length; n++) {
|
|
329
|
+
let r = e[n];
|
|
330
|
+
F(r), t += r.length;
|
|
331
|
+
}
|
|
332
|
+
let n = new Uint8Array(t);
|
|
333
|
+
for (let t = 0, r = 0; t < e.length; t++) {
|
|
334
|
+
let i = e[t];
|
|
335
|
+
n.set(i, r), r += i.length;
|
|
336
|
+
}
|
|
337
|
+
return n;
|
|
338
|
+
}
|
|
339
|
+
function ze(e, t, n = "opts") {
|
|
340
|
+
return Oe(e, "defaults"), t !== void 0 && Oe(t, n), Object.assign(Object.create(null), e, t);
|
|
341
|
+
}
|
|
342
|
+
function Be(e, t = {}) {
|
|
343
|
+
if (typeof e != "function") throw TypeError("\"hashCons\" expected function, got type=" + typeof e);
|
|
344
|
+
t = ze({}, t, "info");
|
|
345
|
+
let n = (t, n) => e(n).update(t).digest(), r = e(void 0);
|
|
346
|
+
return n.outputLen = r.outputLen, n.blockLen = r.blockLen, n.canXOF = r.canXOF, n.create = (t) => e(t), Object.assign(n, t), Object.freeze(n);
|
|
347
|
+
}
|
|
348
|
+
function Ve(e = 32) {
|
|
349
|
+
P(e, "bytesLength");
|
|
350
|
+
let t = typeof globalThis == "object" ? globalThis.crypto : null;
|
|
351
|
+
if (typeof t?.getRandomValues != "function") throw Error("crypto.getRandomValues must be defined");
|
|
352
|
+
if (e > 65536) throw RangeError(`"bytesLength" expected <= 65536, got ${e}`);
|
|
353
|
+
return t.getRandomValues(new Uint8Array(e));
|
|
354
|
+
}
|
|
355
|
+
var He = (e) => ({ oid: Uint8Array.from([
|
|
356
|
+
6,
|
|
357
|
+
9,
|
|
358
|
+
96,
|
|
359
|
+
134,
|
|
360
|
+
72,
|
|
361
|
+
1,
|
|
362
|
+
101,
|
|
363
|
+
3,
|
|
364
|
+
4,
|
|
365
|
+
2,
|
|
366
|
+
e
|
|
367
|
+
]) }), Ue = class {
|
|
368
|
+
blockLen;
|
|
369
|
+
outputLen;
|
|
370
|
+
canXOF = !1;
|
|
371
|
+
padOffset;
|
|
372
|
+
isLE;
|
|
373
|
+
buffer;
|
|
374
|
+
view;
|
|
375
|
+
finished = !1;
|
|
376
|
+
length = 0;
|
|
377
|
+
pos = 0;
|
|
378
|
+
destroyed = !1;
|
|
379
|
+
constructor(e, t, n, r) {
|
|
380
|
+
this.blockLen = e, this.outputLen = t, this.padOffset = n, this.isLE = r, this.buffer = new Uint8Array(e), this.view = Me(this.buffer);
|
|
381
|
+
}
|
|
382
|
+
update(e) {
|
|
383
|
+
ke(this), F(e);
|
|
384
|
+
let { view: t, buffer: n, blockLen: r } = this, i = e.length, a = !1;
|
|
385
|
+
for (let o = 0; o < i;) {
|
|
386
|
+
let s = Math.min(r - this.pos, i - o);
|
|
387
|
+
if (s === r) {
|
|
388
|
+
let t = Me(e);
|
|
389
|
+
for (; r <= i - o; o += r) this.process(t, o);
|
|
390
|
+
a = !0;
|
|
391
|
+
continue;
|
|
392
|
+
}
|
|
393
|
+
n.set(o === 0 && s === i ? e : e.subarray(o, o + s), this.pos), this.pos += s, o += s, this.pos === r && (this.process(t, 0), this.pos = 0, a = !0);
|
|
394
|
+
}
|
|
395
|
+
return this.length += e.length, a && this.roundClean(), this;
|
|
396
|
+
}
|
|
397
|
+
digestInto(e) {
|
|
398
|
+
ke(this), Ae(e, this), this.finished = !0;
|
|
399
|
+
let { buffer: t, view: n, blockLen: r, isLE: i } = this, { pos: a } = this;
|
|
400
|
+
t[a++] = 128, t.fill(0, a), this.padOffset > r - a && (this.process(n, 0), t.fill(0)), me(n, r - 8, this.length * 8, i), this.process(n, 0), this.roundClean();
|
|
401
|
+
let o = e === t ? n : Me(e), s = this.outputLen, c = s / 4, l = this.get();
|
|
402
|
+
if (s % 4 || c > l.length) throw Error("invalid outputLen");
|
|
403
|
+
for (let e = 0; e < c; e++) o.setUint32(4 * e, l[e], i);
|
|
404
|
+
}
|
|
405
|
+
digest() {
|
|
406
|
+
let { buffer: e, outputLen: t } = this;
|
|
407
|
+
this.digestInto(e);
|
|
408
|
+
let n = e.slice(0, t);
|
|
409
|
+
return this.destroy(), n;
|
|
410
|
+
}
|
|
411
|
+
_cloneIntoMeta(e) {
|
|
412
|
+
let { buffer: t, length: n, finished: r, destroyed: i, pos: a } = this;
|
|
413
|
+
return e.destroyed = i, e.finished = r, e.length = n, e.pos = a, a && e.buffer.set(t), e;
|
|
414
|
+
}
|
|
415
|
+
clone() {
|
|
416
|
+
return this._cloneInto();
|
|
417
|
+
}
|
|
418
|
+
}, We = /* @__PURE__ */ Uint32Array.from([
|
|
419
|
+
1779033703,
|
|
420
|
+
4089235720,
|
|
421
|
+
3144134277,
|
|
422
|
+
2227873595,
|
|
423
|
+
1013904242,
|
|
424
|
+
4271175723,
|
|
425
|
+
2773480762,
|
|
426
|
+
1595750129,
|
|
427
|
+
1359893119,
|
|
428
|
+
2917565137,
|
|
429
|
+
2600822924,
|
|
430
|
+
725511199,
|
|
431
|
+
528734635,
|
|
432
|
+
4215389547,
|
|
433
|
+
1541459225,
|
|
434
|
+
327033209
|
|
435
|
+
]), Ge = /* @__PURE__ */ de((/* @__PURE__ */ "0x428a2f98d728ae22.0x7137449123ef65cd.0xb5c0fbcfec4d3b2f.0xe9b5dba58189dbbc.0x3956c25bf348b538.0x59f111f1b605d019.0x923f82a4af194f9b.0xab1c5ed5da6d8118.0xd807aa98a3030242.0x12835b0145706fbe.0x243185be4ee4b28c.0x550c7dc3d5ffb4e2.0x72be5d74f27b896f.0x80deb1fe3b1696b1.0x9bdc06a725c71235.0xc19bf174cf692694.0xe49b69c19ef14ad2.0xefbe4786384f25e3.0x0fc19dc68b8cd5b5.0x240ca1cc77ac9c65.0x2de92c6f592b0275.0x4a7484aa6ea6e483.0x5cb0a9dcbd41fbd4.0x76f988da831153b5.0x983e5152ee66dfab.0xa831c66d2db43210.0xb00327c898fb213f.0xbf597fc7beef0ee4.0xc6e00bf33da88fc2.0xd5a79147930aa725.0x06ca6351e003826f.0x142929670a0e6e70.0x27b70a8546d22ffc.0x2e1b21385c26c926.0x4d2c6dfc5ac42aed.0x53380d139d95b3df.0x650a73548baf63de.0x766a0abb3c77b2a8.0x81c2c92e47edaee6.0x92722c851482353b.0xa2bfe8a14cf10364.0xa81a664bbc423001.0xc24b8b70d0f89791.0xc76c51a30654be30.0xd192e819d6ef5218.0xd69906245565a910.0xf40e35855771202a.0x106aa07032bbd1b8.0x19a4c116b8d2d0c8.0x1e376c085141ab53.0x2748774cdf8eeb99.0x34b0bcb5e19b48a8.0x391c0cb3c5c95a63.0x4ed8aa4ae3418acb.0x5b9cca4f7763e373.0x682e6ff3d6b2b8a3.0x748f82ee5defb2fc.0x78a5636f43172f60.0x84c87814a1f0ab72.0x8cc702081a6439ec.0x90befffa23631e28.0xa4506cebde82bde9.0xbef9a3f7b2c67915.0xc67178f2e372532b.0xca273eceea26619c.0xd186b8c721c0c207.0xeada7dd6cde0eb1e.0xf57d4f7fee6ed178.0x06f067aa72176fba.0x0a637dc5a2c898a6.0x113f9804bef90dae.0x1b710b35131c471b.0x28db77f523047d84.0x32caab7b40c72493.0x3c9ebe0a15c9bebc.0x431d67c49c100d4c.0x4cc5d4becb3e42b6.0x597f299cfc657e2a.0x5fcb6fab3ad6faec.0x6c44198c4a475817".split(".")).map((e) => BigInt(e))), Ke = Ge[0], qe = Ge[1], I = /* @__PURE__ */ new Uint32Array(80), L = /* @__PURE__ */ new Uint32Array(80), Je = class extends Ue {
|
|
436
|
+
Ah = 0;
|
|
437
|
+
Al = 0;
|
|
438
|
+
Bh = 0;
|
|
439
|
+
Bl = 0;
|
|
440
|
+
Ch = 0;
|
|
441
|
+
Cl = 0;
|
|
442
|
+
Dh = 0;
|
|
443
|
+
Dl = 0;
|
|
444
|
+
Eh = 0;
|
|
445
|
+
El = 0;
|
|
446
|
+
Fh = 0;
|
|
447
|
+
Fl = 0;
|
|
448
|
+
Gh = 0;
|
|
449
|
+
Gl = 0;
|
|
450
|
+
Hh = 0;
|
|
451
|
+
Hl = 0;
|
|
452
|
+
constructor(e, t) {
|
|
453
|
+
super(128, e, 16, !1), this.Ah = t[0] | 0, this.Al = t[1] | 0, this.Bh = t[2] | 0, this.Bl = t[3] | 0, this.Ch = t[4] | 0, this.Cl = t[5] | 0, this.Dh = t[6] | 0, this.Dl = t[7] | 0, this.Eh = t[8] | 0, this.El = t[9] | 0, this.Fh = t[10] | 0, this.Fl = t[11] | 0, this.Gh = t[12] | 0, this.Gl = t[13] | 0, this.Hh = t[14] | 0, this.Hl = t[15] | 0;
|
|
454
|
+
}
|
|
455
|
+
get() {
|
|
456
|
+
let { Ah: e, Al: t, Bh: n, Bl: r, Ch: i, Cl: a, Dh: o, Dl: s, Eh: c, El: l, Fh: u, Fl: d, Gh: f, Gl: p, Hh: m, Hl: h } = this;
|
|
457
|
+
return [
|
|
458
|
+
e,
|
|
459
|
+
t,
|
|
460
|
+
n,
|
|
461
|
+
r,
|
|
462
|
+
i,
|
|
463
|
+
a,
|
|
464
|
+
o,
|
|
465
|
+
s,
|
|
466
|
+
c,
|
|
467
|
+
l,
|
|
468
|
+
u,
|
|
469
|
+
d,
|
|
470
|
+
f,
|
|
471
|
+
p,
|
|
472
|
+
m,
|
|
473
|
+
h
|
|
474
|
+
];
|
|
475
|
+
}
|
|
476
|
+
set(e, t, n, r, i, a, o, s, c, l, u, d, f, p, m, h) {
|
|
477
|
+
this.Ah = e | 0, this.Al = t | 0, this.Bh = n | 0, this.Bl = r | 0, this.Ch = i | 0, this.Cl = a | 0, this.Dh = o | 0, this.Dl = s | 0, this.Eh = c | 0, this.El = l | 0, this.Fh = u | 0, this.Fl = d | 0, this.Gh = f | 0, this.Gl = p | 0, this.Hh = m | 0, this.Hl = h | 0;
|
|
478
|
+
}
|
|
479
|
+
_cloneInto(e) {
|
|
480
|
+
return (e ||= new this.constructor()).set(...this.get()), this._cloneIntoMeta(e);
|
|
481
|
+
}
|
|
482
|
+
process(e, t) {
|
|
483
|
+
for (let n = 0; n < 16; n++, t += 4) I[n] = e.getUint32(t), L[n] = e.getUint32(t += 4);
|
|
484
|
+
for (let e = 16; e < 80; e++) {
|
|
485
|
+
let t = I[e - 15] | 0, n = L[e - 15] | 0, r = j(t, n, 1) ^ j(t, n, 8) ^ he(t, n, 7), i = M(t, n, 1) ^ M(t, n, 8) ^ ge(t, n, 7), a = I[e - 2] | 0, o = L[e - 2] | 0, s = j(a, o, 19) ^ _e(a, o, 61) ^ he(a, o, 6), c = xe(i, M(a, o, 19) ^ ve(a, o, 61) ^ ge(a, o, 6), L[e - 7], L[e - 16]), l = Se(c, r, s, I[e - 7], I[e - 16]);
|
|
486
|
+
I[e] = l | 0, L[e] = c | 0;
|
|
487
|
+
}
|
|
488
|
+
let { Ah: n, Al: r, Bh: i, Bl: a, Ch: o, Cl: s, Dh: c, Dl: l, Eh: u, El: d, Fh: f, Fl: p, Gh: m, Gl: h, Hh: g, Hl: _ } = this;
|
|
489
|
+
for (let e = 0; e < 80; e++) {
|
|
490
|
+
let t = j(u, d, 14) ^ j(u, d, 18) ^ _e(u, d, 41), v = M(u, d, 14) ^ M(u, d, 18) ^ ve(u, d, 41), y = u & f ^ ~u & m, b = d & p ^ ~d & h, x = Ce(_, v, b, qe[e], L[e]), S = we(x, g, t, y, Ke[e], I[e]), C = x | 0, w = j(n, r, 28) ^ _e(n, r, 34) ^ _e(n, r, 39), T = M(n, r, 28) ^ ve(n, r, 34) ^ ve(n, r, 39), E = n & i ^ n & o ^ i & o, ee = r & a ^ r & s ^ a & s;
|
|
491
|
+
g = m | 0, _ = h | 0, m = f | 0, h = p | 0, f = u | 0, p = d | 0, {h: u, l: d} = N(c | 0, l | 0, S | 0, C | 0), c = o | 0, l = s | 0, o = i | 0, s = a | 0, i = n | 0, a = r | 0;
|
|
492
|
+
let D = ye(C, T, ee);
|
|
493
|
+
n = be(D, S, w, E), r = D | 0;
|
|
494
|
+
}
|
|
495
|
+
({h: n, l: r} = N(this.Ah | 0, this.Al | 0, n | 0, r | 0)), {h: i, l: a} = N(this.Bh | 0, this.Bl | 0, i | 0, a | 0), {h: o, l: s} = N(this.Ch | 0, this.Cl | 0, o | 0, s | 0), {h: c, l: l} = N(this.Dh | 0, this.Dl | 0, c | 0, l | 0), {h: u, l: d} = N(this.Eh | 0, this.El | 0, u | 0, d | 0), {h: f, l: p} = N(this.Fh | 0, this.Fl | 0, f | 0, p | 0), {h: m, l: h} = N(this.Gh | 0, this.Gl | 0, m | 0, h | 0), {h: g, l: _} = N(this.Hh | 0, this.Hl | 0, g | 0, _ | 0), this.set(n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _);
|
|
496
|
+
}
|
|
497
|
+
roundClean() {
|
|
498
|
+
je(I, L);
|
|
499
|
+
}
|
|
500
|
+
destroy() {
|
|
501
|
+
this.destroyed = !0, je(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
|
|
502
|
+
}
|
|
503
|
+
}, Ye = class extends Je {
|
|
504
|
+
constructor() {
|
|
505
|
+
super(64, We);
|
|
506
|
+
}
|
|
507
|
+
}, Xe = /* @__PURE__ */ Be(() => new Ye(), /* @__PURE__ */ He(3));
|
|
508
|
+
//#endregion
|
|
509
|
+
//#region node_modules/.pnpm/@noble+curves@2.4.0/node_modules/@noble/curves/utils.js
|
|
510
|
+
function Ze(e, t, n = () => {}) {
|
|
511
|
+
if (!Array.isArray(e)) throw TypeError(`"${t}" expected array, got type=${typeof e}`);
|
|
512
|
+
for (let r = 0; r < e.length; r++) n(e[r], `${t}[${r}]`);
|
|
513
|
+
return e;
|
|
514
|
+
}
|
|
515
|
+
var R = (e, t, n) => F(e, t, n), Qe = P;
|
|
516
|
+
function z(e, t = "object") {
|
|
517
|
+
if (typeof e != "object" || !e || Array.isArray(e)) throw TypeError(t === "object" ? "expected valid options object" : `"${t}" expected object, got type=${typeof e}`);
|
|
518
|
+
return e;
|
|
519
|
+
}
|
|
520
|
+
function B(e, t) {
|
|
521
|
+
if (typeof e != "function") throw TypeError(`"${t}" is invalid: expected function, got ${typeof e}`);
|
|
522
|
+
return e;
|
|
523
|
+
}
|
|
524
|
+
var $e = Fe, et = (...e) => Re(...e), tt = (e) => Le(e), nt = Te, rt = (e) => Ve(e), it = /* @__PURE__ */ BigInt(0), at = /* @__PURE__ */ BigInt(1), ot = (e) => e ? `"${e}" ` : "";
|
|
525
|
+
function V(e, t = "") {
|
|
526
|
+
if (typeof e != "boolean") throw TypeError(ot(t) + "expected boolean, got type=" + typeof e);
|
|
527
|
+
return e;
|
|
528
|
+
}
|
|
529
|
+
function st(e) {
|
|
530
|
+
if (typeof e == "bigint") {
|
|
531
|
+
if (!U(e)) throw RangeError("positive bigint expected, got " + e);
|
|
532
|
+
} else Qe(e);
|
|
533
|
+
return e;
|
|
534
|
+
}
|
|
535
|
+
function H(e, t = "") {
|
|
536
|
+
if (typeof e != "number") {
|
|
537
|
+
let n = t && `"${t}" `;
|
|
538
|
+
throw TypeError(n + "expected number, got type=" + typeof e);
|
|
539
|
+
}
|
|
540
|
+
if (!Number.isSafeInteger(e)) {
|
|
541
|
+
let n = t && `"${t}" `;
|
|
542
|
+
throw RangeError(n + "expected safe integer, got " + e);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
function ct(e) {
|
|
546
|
+
if (typeof e != "string") throw TypeError("hex string expected, got " + typeof e);
|
|
547
|
+
return e === "" ? it : BigInt("0x" + e);
|
|
548
|
+
}
|
|
549
|
+
function lt(e) {
|
|
550
|
+
return ct(Fe(e));
|
|
551
|
+
}
|
|
552
|
+
function ut(e) {
|
|
553
|
+
return ct(Fe(pt(F(e)).reverse()));
|
|
554
|
+
}
|
|
555
|
+
function dt(e, t) {
|
|
556
|
+
if (P(t), t === 0) throw Error("zero output length is invalid");
|
|
557
|
+
e = st(e);
|
|
558
|
+
let n = t * 2, r = e.toString(16);
|
|
559
|
+
if (r.length > n) throw RangeError("number is too large");
|
|
560
|
+
return Le(r.padStart(n, "0"));
|
|
561
|
+
}
|
|
562
|
+
function ft(e, t) {
|
|
563
|
+
return dt(e, t).reverse();
|
|
564
|
+
}
|
|
565
|
+
function pt(e) {
|
|
566
|
+
return Uint8Array.from(R(e));
|
|
567
|
+
}
|
|
568
|
+
function U(e) {
|
|
569
|
+
return typeof e == "bigint" && it <= e;
|
|
570
|
+
}
|
|
571
|
+
function mt(e, t, n) {
|
|
572
|
+
return U(e) && U(t) && U(n) && t <= e && e < n;
|
|
573
|
+
}
|
|
574
|
+
function ht(e, t, n, r) {
|
|
575
|
+
if (!mt(t, n, r)) throw RangeError("expected valid " + e + ": " + n + " <= n < " + r + ", got " + t);
|
|
576
|
+
}
|
|
577
|
+
function gt(e) {
|
|
578
|
+
if (e < it) throw Error("expected non-negative bigint, got " + e);
|
|
579
|
+
return e === it ? 0 : e.toString(2).length;
|
|
580
|
+
}
|
|
581
|
+
var _t = (e) => (H(e, "n"), (at << BigInt(e)) - at);
|
|
582
|
+
function W(e, t = {}, n = {}, r = "object") {
|
|
583
|
+
z(e, r), z(t, "fields"), z(n, "optFields");
|
|
584
|
+
function i(t, n, i) {
|
|
585
|
+
let a = r === "object" ? `param "${String(t)}"` : `"${r}.${String(t)}"`, o = e[t];
|
|
586
|
+
if (!Object.hasOwn(e, t) && (i ? o !== void 0 : n !== "function")) throw TypeError(`${a} is invalid: expected own property`);
|
|
587
|
+
if (i && o === void 0) return;
|
|
588
|
+
let s = typeof o;
|
|
589
|
+
if (s !== n || o === null) throw TypeError(`${a} is invalid: expected ${n}, got ${s}`);
|
|
590
|
+
}
|
|
591
|
+
let a = (e, t) => Object.entries(e).forEach(([e, n]) => i(e, n, t));
|
|
592
|
+
a(t, !1), a(n, !0);
|
|
593
|
+
}
|
|
594
|
+
//#endregion
|
|
595
|
+
//#region node_modules/.pnpm/@noble+curves@2.4.0/node_modules/@noble/curves/abstract/modular.js
|
|
596
|
+
var G = /* @__PURE__ */ BigInt(0), K = /* @__PURE__ */ BigInt(1), q = /* @__PURE__ */ BigInt(2), vt = /* @__PURE__ */ BigInt(3), yt = /* @__PURE__ */ BigInt(4), bt = /* @__PURE__ */ BigInt(5), xt = /* @__PURE__ */ BigInt(7), St = /* @__PURE__ */ BigInt(8), Ct = /* @__PURE__ */ BigInt(9), wt = /* @__PURE__ */ BigInt(15), Tt = /* @__PURE__ */ BigInt(16), Et = /* @__PURE__ */ BigInt("0x10000000000000000");
|
|
597
|
+
function J(e, t) {
|
|
598
|
+
if (t <= G) throw Error("mod: expected positive modulus, got " + t);
|
|
599
|
+
let n = e % t;
|
|
600
|
+
return n >= G ? n : t + n;
|
|
601
|
+
}
|
|
602
|
+
function Dt(e, t, n) {
|
|
603
|
+
if (n <= K) throw Error("pow: expected modulus > 1, got " + n);
|
|
604
|
+
if (typeof t != "bigint") throw TypeError("invalid exponent: expected bigint, got " + typeof t);
|
|
605
|
+
if (t < G) throw Error("invalid exponent, negatives unsupported");
|
|
606
|
+
if (t === G) return K;
|
|
607
|
+
if (t === K) return e;
|
|
608
|
+
let r = e % n;
|
|
609
|
+
if (r < G && (r += n), t < Et) {
|
|
610
|
+
let e = K;
|
|
611
|
+
for (; t > G;) t & K && (e = e * r % n), r = r * r % n, t >>= K;
|
|
612
|
+
return e;
|
|
613
|
+
}
|
|
614
|
+
let i = [];
|
|
615
|
+
for (; t > G;) i.push(Number(t & wt)), t >>= yt;
|
|
616
|
+
let a = Array(16);
|
|
617
|
+
a[0] = K, a[1] = r;
|
|
618
|
+
for (let e = 2; e < 16; e++) a[e] = a[e - 1] * r % n;
|
|
619
|
+
let o = a[i[i.length - 1]];
|
|
620
|
+
for (let e = i.length - 2; e >= 0; e--) {
|
|
621
|
+
o = o * o % n, o = o * o % n, o = o * o % n, o = o * o % n;
|
|
622
|
+
let t = i[e];
|
|
623
|
+
t !== 0 && (o = o * a[t] % n);
|
|
624
|
+
}
|
|
625
|
+
return o;
|
|
626
|
+
}
|
|
627
|
+
function Y(e, t, n) {
|
|
628
|
+
if (n <= K) throw Error("pow2: expected modulus > 1, got " + n);
|
|
629
|
+
if (t < G) throw Error("pow2: expected non-negative exponent, got " + t);
|
|
630
|
+
let r = e;
|
|
631
|
+
for (; t-- > G;) r *= r, r %= n;
|
|
632
|
+
return r;
|
|
633
|
+
}
|
|
634
|
+
function Ot(e, t) {
|
|
635
|
+
if (e === G) throw Error("invert: expected non-zero number");
|
|
636
|
+
if (t <= K) throw Error("invert: expected modulus > 1, got " + t);
|
|
637
|
+
let n = J(e, t), r = t, i = G, a = K;
|
|
638
|
+
for (; n !== G;) {
|
|
639
|
+
let e = r / n, t = r - n * e, o = i - a * e;
|
|
640
|
+
r = n, n = t, i = a, a = o;
|
|
641
|
+
}
|
|
642
|
+
if (r !== K) throw Error("invert: does not exist");
|
|
643
|
+
return J(i, t);
|
|
644
|
+
}
|
|
645
|
+
function kt(e, t, n) {
|
|
646
|
+
let r = e;
|
|
647
|
+
if (!r.eql(r.sqr(t), n)) throw Error("Cannot find square root");
|
|
648
|
+
}
|
|
649
|
+
function At(e, t) {
|
|
650
|
+
if ((e & K) === G) throw Error(t + ": expected odd modulus, got " + e);
|
|
651
|
+
}
|
|
652
|
+
function jt(e, t) {
|
|
653
|
+
let n = e, r = (n.ORDER + K) / yt, i = n.pow(t, r);
|
|
654
|
+
return kt(n, i, t), i;
|
|
655
|
+
}
|
|
656
|
+
function Mt(e, t) {
|
|
657
|
+
let n = e, r = (n.ORDER - bt) / St, i = n.mul(t, q), a = n.pow(i, r), o = n.mul(t, a), s = n.mul(n.mul(o, q), a), c = n.mul(o, n.sub(s, n.ONE));
|
|
658
|
+
return kt(n, c, t), c;
|
|
659
|
+
}
|
|
660
|
+
function Nt(e) {
|
|
661
|
+
let t = Ut(e), n = Pt(e), r = n(t, t.neg(t.ONE)), i = n(t, r), a = n(t, t.neg(r)), o = (e + xt) / Tt;
|
|
662
|
+
return ((e, t) => {
|
|
663
|
+
let n = e, s = n.pow(t, o), c = n.mul(s, r), l = n.mul(s, i), u = n.mul(s, a), d = n.eql(n.sqr(c), t), f = n.eql(n.sqr(l), t);
|
|
664
|
+
s = n.cmov(s, c, d), c = n.cmov(u, l, f);
|
|
665
|
+
let p = n.eql(n.sqr(c), t), m = n.cmov(s, c, p);
|
|
666
|
+
return kt(n, m, t), m;
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
function Pt(e) {
|
|
670
|
+
if (e < vt) throw Error("sqrt is not defined for small field");
|
|
671
|
+
At(e, "tonelliShanks");
|
|
672
|
+
let t = e - K, n = 0;
|
|
673
|
+
for (; t % q === G;) t /= q, n++;
|
|
674
|
+
let r = q, i = Ut(e);
|
|
675
|
+
for (; zt(i, r) === 1;) if (r++ > 1e3) throw Error("Cannot find square root: probably non-prime P");
|
|
676
|
+
if (n === 1) return jt;
|
|
677
|
+
let a = i.pow(r, t), o = (t + K) / q;
|
|
678
|
+
return function(e, r) {
|
|
679
|
+
let i = e;
|
|
680
|
+
if (i.is0(r)) return r;
|
|
681
|
+
if (zt(i, r) !== 1) throw Error("Cannot find square root");
|
|
682
|
+
let s = n, c = i.mul(i.ONE, a), l = i.pow(r, t), u = i.pow(r, o);
|
|
683
|
+
for (; !i.eql(l, i.ONE);) {
|
|
684
|
+
if (i.is0(l)) throw Error("Cannot find square root: probably non-prime P");
|
|
685
|
+
let e = 1, t = i.sqr(l);
|
|
686
|
+
for (; !i.eql(t, i.ONE);) if (e++, t = i.sqr(t), e === s) throw Error("Cannot find square root");
|
|
687
|
+
let n = K << BigInt(s - e - 1), r = i.pow(c, n);
|
|
688
|
+
s = e, c = i.sqr(r), l = i.mul(l, c), u = i.mul(u, r);
|
|
689
|
+
}
|
|
690
|
+
return u;
|
|
691
|
+
};
|
|
692
|
+
}
|
|
693
|
+
function Ft(e) {
|
|
694
|
+
return At(e, "Fp.sqrt"), e % yt === vt ? jt : e % St === bt ? Mt : e % Tt === Ct ? Nt(e) : Pt(e);
|
|
695
|
+
}
|
|
696
|
+
var It = (e, t) => (J(e, t) & K) === K, Lt = [
|
|
697
|
+
"create",
|
|
698
|
+
"isValid",
|
|
699
|
+
"is0",
|
|
700
|
+
"neg",
|
|
701
|
+
"inv",
|
|
702
|
+
"sqrt",
|
|
703
|
+
"sqr",
|
|
704
|
+
"eql",
|
|
705
|
+
"add",
|
|
706
|
+
"sub",
|
|
707
|
+
"mul",
|
|
708
|
+
"pow",
|
|
709
|
+
"div",
|
|
710
|
+
"addN",
|
|
711
|
+
"subN",
|
|
712
|
+
"mulN",
|
|
713
|
+
"sqrN"
|
|
714
|
+
];
|
|
715
|
+
function X(e) {
|
|
716
|
+
if (z(e, "field"), typeof e.ORDER != "bigint") throw TypeError("param \"ORDER\" is invalid: expected bigint, got " + typeof e.ORDER);
|
|
717
|
+
H(e.BYTES, "BYTES"), H(e.BITS, "BITS");
|
|
718
|
+
for (let t of Lt) B(e[t], "field." + t);
|
|
719
|
+
if (e.BYTES < 1 || e.BITS < 1) throw Error("invalid field: expected BYTES/BITS > 0");
|
|
720
|
+
if (e.ORDER <= K) throw Error("invalid field: expected ORDER > 1, got " + e.ORDER);
|
|
721
|
+
return e;
|
|
722
|
+
}
|
|
723
|
+
function Rt(e, t, n = !1) {
|
|
724
|
+
X(e), Ze(t, "nums"), V(n, "passZero");
|
|
725
|
+
let r = e, i = Array(t.length).fill(n ? r.ZERO : void 0), a = t.reduce((e, t, n) => r.is0(t) ? e : (i[n] = e, r.mul(e, t)), r.ONE), o = r.inv(a);
|
|
726
|
+
return t.reduceRight((e, t, n) => r.is0(t) ? e : (i[n] = r.mul(e, i[n]), r.mul(e, t)), o), i;
|
|
727
|
+
}
|
|
728
|
+
function zt(e, t) {
|
|
729
|
+
X(e);
|
|
730
|
+
let n = e;
|
|
731
|
+
At(n.ORDER, "FpLegendre");
|
|
732
|
+
let r = (n.ORDER - K) / q, i = n.pow(t, r), a = n.eql(i, n.ONE), o = n.eql(i, n.ZERO), s = n.eql(i, n.neg(n.ONE));
|
|
733
|
+
if (!a && !o && !s) throw Error("invalid Legendre symbol result");
|
|
734
|
+
return a ? 1 : o ? 0 : -1;
|
|
735
|
+
}
|
|
736
|
+
function Bt(e, t) {
|
|
737
|
+
if (t !== void 0 && Qe(t), e <= G) throw Error("invalid n length: expected positive n, got " + e);
|
|
738
|
+
if (t !== void 0 && t < 1) throw Error("invalid n length: expected positive bit length, got " + t);
|
|
739
|
+
let n = gt(e);
|
|
740
|
+
if (t !== void 0 && t < n) throw Error(`invalid n length: expected nBitLength (${t}) >= bitLen(n) (${n})`);
|
|
741
|
+
let r = t === void 0 ? n : t;
|
|
742
|
+
return {
|
|
743
|
+
nBitLength: r,
|
|
744
|
+
nByteLength: Math.ceil(r / 8)
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
var Vt = /* @__PURE__ */ new WeakMap(), Ht = class {
|
|
748
|
+
ORDER;
|
|
749
|
+
BITS;
|
|
750
|
+
BYTES;
|
|
751
|
+
isLE;
|
|
752
|
+
ZERO = G;
|
|
753
|
+
ONE = K;
|
|
754
|
+
_lengths;
|
|
755
|
+
_mod;
|
|
756
|
+
constructor(e, t = {}) {
|
|
757
|
+
if (e <= K) throw Error("invalid field: expected ORDER > 1, got " + e);
|
|
758
|
+
let n;
|
|
759
|
+
this.isLE = !1, typeof t == "object" && t && (typeof t.BITS == "number" && (n = t.BITS), typeof t.sqrt == "function" && Object.defineProperty(this, "sqrt", {
|
|
760
|
+
value: t.sqrt,
|
|
761
|
+
enumerable: !0
|
|
762
|
+
}), typeof t.isLE == "boolean" && (this.isLE = t.isLE), t.allowedLengths && (this._lengths = Object.freeze(t.allowedLengths.slice())), typeof t.modFromBytes == "boolean" && (this._mod = t.modFromBytes));
|
|
763
|
+
let { nBitLength: r, nByteLength: i } = Bt(e, n);
|
|
764
|
+
if (i > 2048) throw Error("invalid field: expected ORDER of <= 2048 bytes");
|
|
765
|
+
this.ORDER = e, this.BITS = r, this.BYTES = i, Object.freeze(this);
|
|
766
|
+
}
|
|
767
|
+
create(e) {
|
|
768
|
+
return J(e, this.ORDER);
|
|
769
|
+
}
|
|
770
|
+
isValid(e) {
|
|
771
|
+
if (typeof e != "bigint") throw TypeError("invalid field element: expected bigint, got " + typeof e);
|
|
772
|
+
return G <= e && e < this.ORDER;
|
|
773
|
+
}
|
|
774
|
+
is0(e) {
|
|
775
|
+
return e === G;
|
|
776
|
+
}
|
|
777
|
+
isValidNot0(e) {
|
|
778
|
+
return !this.is0(e) && this.isValid(e);
|
|
779
|
+
}
|
|
780
|
+
isOdd(e) {
|
|
781
|
+
return (e & K) === K;
|
|
782
|
+
}
|
|
783
|
+
neg(e) {
|
|
784
|
+
return J(-e, this.ORDER);
|
|
785
|
+
}
|
|
786
|
+
eql(e, t) {
|
|
787
|
+
return e === t;
|
|
788
|
+
}
|
|
789
|
+
sqr(e) {
|
|
790
|
+
return J(e * e, this.ORDER);
|
|
791
|
+
}
|
|
792
|
+
add(e, t) {
|
|
793
|
+
return J(e + t, this.ORDER);
|
|
794
|
+
}
|
|
795
|
+
sub(e, t) {
|
|
796
|
+
return J(e - t, this.ORDER);
|
|
797
|
+
}
|
|
798
|
+
mul(e, t) {
|
|
799
|
+
return J(e * t, this.ORDER);
|
|
800
|
+
}
|
|
801
|
+
pow(e, t) {
|
|
802
|
+
return Dt(e, t, this.ORDER);
|
|
803
|
+
}
|
|
804
|
+
div(e, t) {
|
|
805
|
+
return J(e * Ot(t, this.ORDER), this.ORDER);
|
|
806
|
+
}
|
|
807
|
+
sqrN(e) {
|
|
808
|
+
return e * e;
|
|
809
|
+
}
|
|
810
|
+
addN(e, t) {
|
|
811
|
+
return e + t;
|
|
812
|
+
}
|
|
813
|
+
subN(e, t) {
|
|
814
|
+
return e - t;
|
|
815
|
+
}
|
|
816
|
+
mulN(e, t) {
|
|
817
|
+
return e * t;
|
|
818
|
+
}
|
|
819
|
+
inv(e) {
|
|
820
|
+
return Ot(e, this.ORDER);
|
|
821
|
+
}
|
|
822
|
+
sqrt(e) {
|
|
823
|
+
let t = Vt.get(this);
|
|
824
|
+
return t || Vt.set(this, t = Ft(this.ORDER)), t(this, e);
|
|
825
|
+
}
|
|
826
|
+
toBytes(e) {
|
|
827
|
+
return this.isLE ? ft(e, this.BYTES) : dt(e, this.BYTES);
|
|
828
|
+
}
|
|
829
|
+
fromBytes(e, t = !1) {
|
|
830
|
+
R(e);
|
|
831
|
+
let { _lengths: n, BYTES: r, isLE: i, ORDER: a, _mod: o } = this;
|
|
832
|
+
if (n) {
|
|
833
|
+
if (e.length < 1 || !n.includes(e.length) || e.length > r) throw Error("Field.fromBytes: expected " + n + " bytes, got " + e.length);
|
|
834
|
+
let t = new Uint8Array(r);
|
|
835
|
+
t.set(e, i ? 0 : t.length - e.length), e = t;
|
|
836
|
+
}
|
|
837
|
+
if (e.length !== r) throw Error("Field.fromBytes: expected " + r + " bytes, got " + e.length);
|
|
838
|
+
let s = i ? ut(e) : lt(e);
|
|
839
|
+
if (o && (s = J(s, a)), !t && !this.isValid(s)) throw Error("invalid field element: outside of range 0..ORDER");
|
|
840
|
+
return s;
|
|
841
|
+
}
|
|
842
|
+
invertBatch(e) {
|
|
843
|
+
return Rt(this, e, !0);
|
|
844
|
+
}
|
|
845
|
+
cmov(e, t, n) {
|
|
846
|
+
return V(n, "condition"), n ? t : e;
|
|
847
|
+
}
|
|
848
|
+
};
|
|
849
|
+
function Ut(e, t = {}) {
|
|
850
|
+
return Object.freeze(Ht.prototype), new Ht(e, t);
|
|
851
|
+
}
|
|
852
|
+
//#endregion
|
|
853
|
+
//#region node_modules/.pnpm/@noble+curves@2.4.0/node_modules/@noble/curves/abstract/curve.js
|
|
854
|
+
var Wt = /* @__PURE__ */ BigInt(0), Z = /* @__PURE__ */ BigInt(1), Gt = /* @__PURE__ */ BigInt(4), Kt = 16, qt = 128, Jt = 5, Yt = 2 ** 31;
|
|
855
|
+
function Xt(e) {
|
|
856
|
+
let t = e;
|
|
857
|
+
if (typeof t != "function") throw TypeError("\"Point\" expected constructor, got type=" + typeof e);
|
|
858
|
+
B(t.fromAffine, "Point.fromAffine"), B(t.fromBytes, "Point.fromBytes"), B(t.fromHex, "Point.fromHex"), z(t.BASE, "Point.BASE"), z(t.ZERO, "Point.ZERO"), X(t.Fp), X(t.Fn);
|
|
859
|
+
}
|
|
860
|
+
function Zt(e, t) {
|
|
861
|
+
Xt(e), tn(t, e);
|
|
862
|
+
let n = Rt(e.Fp, t.map((e) => e.Z));
|
|
863
|
+
return t.map((t, r) => e.fromAffine(t.toAffine(n[r])));
|
|
864
|
+
}
|
|
865
|
+
function Qt(e, t, n = 1) {
|
|
866
|
+
if (!Number.isSafeInteger(e) || e < n || e > t) throw Error("invalid window size, expected [" + n + ".." + t + "], got W=" + e);
|
|
867
|
+
}
|
|
868
|
+
function $t(e, t) {
|
|
869
|
+
let n = e * (4 * t + 128);
|
|
870
|
+
if (n > Yt) throw Error("invalid window size: table would need ~" + Math.ceil(n / 2 ** 20) + " MiB, max " + Yt / 2 ** 20 + " MiB");
|
|
871
|
+
}
|
|
872
|
+
function en(e, t) {
|
|
873
|
+
if (e !== void 0) {
|
|
874
|
+
B(e, "randomBytes");
|
|
875
|
+
try {
|
|
876
|
+
let n = e(t);
|
|
877
|
+
if (!nt(n) || n.length !== t) return;
|
|
878
|
+
} catch {
|
|
879
|
+
return;
|
|
880
|
+
}
|
|
881
|
+
return e;
|
|
882
|
+
}
|
|
883
|
+
}
|
|
884
|
+
function tn(e, t) {
|
|
885
|
+
Ze(e, "points"), e.forEach((e, n) => {
|
|
886
|
+
if (!(e instanceof t)) throw Error("invalid point at index " + n);
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
function nn(e, t, n) {
|
|
890
|
+
if (!Array.isArray(e)) throw Error("array of scalars expected");
|
|
891
|
+
e.forEach((e, r) => {
|
|
892
|
+
if (!(n === void 0 ? t.isValid(e) : U(e) && e < n)) throw Error("invalid scalar at index " + r);
|
|
893
|
+
});
|
|
894
|
+
}
|
|
895
|
+
var rn = /* @__PURE__ */ new WeakMap();
|
|
896
|
+
function an(e) {
|
|
897
|
+
return rn.get(e) || 1;
|
|
898
|
+
}
|
|
899
|
+
function on(e, t) {
|
|
900
|
+
let n = e.double(), r = [e];
|
|
901
|
+
for (let e = 1; e < t; e++) r.push(r[e - 1].add(n));
|
|
902
|
+
return r;
|
|
903
|
+
}
|
|
904
|
+
function sn(e, t) {
|
|
905
|
+
let n = 2 ** t, r = n / 2, i = BigInt(n - 1), a = [];
|
|
906
|
+
for (; e > Wt;) {
|
|
907
|
+
let t = 0;
|
|
908
|
+
e & Z && (t = Number(e & i), t >= r && (t -= n), e -= BigInt(t)), a.push(t), e >>= Z;
|
|
909
|
+
}
|
|
910
|
+
return a;
|
|
911
|
+
}
|
|
912
|
+
function cn(e, t, n) {
|
|
913
|
+
let r = 2 ** t, i = r / 2, a = BigInt(r - 1), o = BigInt(t), s = [];
|
|
914
|
+
for (let t = 0; t < n; t++) {
|
|
915
|
+
let t = Number(e & a);
|
|
916
|
+
e >>= o, t > i && (t -= r, e += Z), s.push(t);
|
|
917
|
+
}
|
|
918
|
+
if (e !== Wt) throw Error("invalid wnaf");
|
|
919
|
+
return s;
|
|
920
|
+
}
|
|
921
|
+
function ln(e, t, n) {
|
|
922
|
+
let r = 0;
|
|
923
|
+
for (let e of n) r = Math.max(r, e.length);
|
|
924
|
+
let i = e;
|
|
925
|
+
for (let e = r - 1; e >= 0; e--) {
|
|
926
|
+
e !== r - 1 && (i = i.double());
|
|
927
|
+
for (let r = 0; r < n.length; r++) {
|
|
928
|
+
let a = n[r][e];
|
|
929
|
+
if (a) {
|
|
930
|
+
let e = t[r][Math.abs(a) - 1 >> 1];
|
|
931
|
+
i = i.add(a < 0 ? e.negate() : e);
|
|
932
|
+
}
|
|
933
|
+
}
|
|
934
|
+
}
|
|
935
|
+
return i;
|
|
936
|
+
}
|
|
937
|
+
var un = class {
|
|
938
|
+
Point;
|
|
939
|
+
BASE;
|
|
940
|
+
ZERO;
|
|
941
|
+
randomBytes;
|
|
942
|
+
wnafPrecomputes = /* @__PURE__ */ new WeakMap();
|
|
943
|
+
baseCanBeBlinded;
|
|
944
|
+
bits;
|
|
945
|
+
constructor(e, t) {
|
|
946
|
+
Xt(e), this.randomBytes = en(t, Kt), this.Point = e, this.BASE = e.BASE, this.ZERO = e.ZERO, this.bits = e.Fn.BITS;
|
|
947
|
+
}
|
|
948
|
+
buildWnafTable(e, t, n) {
|
|
949
|
+
let r = Math.ceil(n / t) + 1, i = 2 ** (t - 1), a = [], o = e;
|
|
950
|
+
for (let e = 0; e < r; e++) {
|
|
951
|
+
let e = o;
|
|
952
|
+
for (let t = 0; t < i; t++) a.push(e), e = e.add(o);
|
|
953
|
+
o = a[a.length - 1].double();
|
|
954
|
+
}
|
|
955
|
+
return {
|
|
956
|
+
W: t,
|
|
957
|
+
bits: n,
|
|
958
|
+
windows: r,
|
|
959
|
+
comp: a
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
wnafCachedCT(e, t) {
|
|
963
|
+
let { W: n, windows: r, comp: i } = e, a = 2 ** (n - 1), o = cn(t, n, r), s = this.ZERO, c = this.BASE;
|
|
964
|
+
for (let e = 0; e < r; e++) {
|
|
965
|
+
let t = o[e], n = e * a, r = Math.abs(t) - 1, l = i[n];
|
|
966
|
+
for (let e = 1; e < a; e++) l = e === r ? i[n + e] : l;
|
|
967
|
+
let u = l.negate();
|
|
968
|
+
t === 0 ? c = c.add(i[n]) : s = s.add(t < 0 ? u : l);
|
|
969
|
+
}
|
|
970
|
+
return {
|
|
971
|
+
p: s,
|
|
972
|
+
f: c
|
|
973
|
+
};
|
|
974
|
+
}
|
|
975
|
+
getWnafPrecomputes(e, t, n, r) {
|
|
976
|
+
let i = this.wnafPrecomputes.get(t), a = i?.find((t) => t.W === e && t.bits === n);
|
|
977
|
+
return a || (a = this.buildWnafTable(t, e, n), typeof r == "function" && (a = {
|
|
978
|
+
...a,
|
|
979
|
+
comp: r(a.comp)
|
|
980
|
+
}), i || (i = [], this.wnafPrecomputes.set(t, i)), i.push(a)), a;
|
|
981
|
+
}
|
|
982
|
+
assertPoint(e) {
|
|
983
|
+
if (!(e instanceof this.Point)) throw TypeError("\"point\" expected Point instance, got type=" + typeof e);
|
|
984
|
+
}
|
|
985
|
+
validateMulInput(e, t) {
|
|
986
|
+
if (this.assertPoint(e), !mt(t, Z, this.Point.Fn.ORDER)) throw Error("invalid scalar");
|
|
987
|
+
}
|
|
988
|
+
runCT(e, t, n, r) {
|
|
989
|
+
let i = an(e);
|
|
990
|
+
return i === 1 ? this.fixedWindowCT(e, t, n) : this.wnafCachedCT(this.getWnafPrecomputes(i, e, n, r), t);
|
|
991
|
+
}
|
|
992
|
+
mulCT(e, t, n) {
|
|
993
|
+
return this.validateMulInput(e, t), this.runCT(e, t, this.bits, n);
|
|
994
|
+
}
|
|
995
|
+
mulCTBlinded(e, t, n) {
|
|
996
|
+
if (this.validateMulInput(e, t), this.randomBytes === void 0) throw Error("randomBytes is required for scalar blinding");
|
|
997
|
+
let r = this.Point.Fn.BITS + qt, i = this.randomBytes(Kt);
|
|
998
|
+
if (!nt(i) || i.length !== Kt) throw Error("randomBytes returned invalid byte array");
|
|
999
|
+
i[0] = i[0] & 63 | 128;
|
|
1000
|
+
let a = t + lt(i) * this.Point.Fn.ORDER;
|
|
1001
|
+
return this.runCT(e, a, r, n);
|
|
1002
|
+
}
|
|
1003
|
+
fixedWindowCT(e, t, n) {
|
|
1004
|
+
let r = Jt, i = _t(r), a = Array(32);
|
|
1005
|
+
a[0] = this.ZERO;
|
|
1006
|
+
for (let t = 1; t < 32; t++) a[t] = a[t - 1].add(e);
|
|
1007
|
+
let o = Math.ceil(n / r), s = this.ZERO;
|
|
1008
|
+
for (let e = o - 1; e >= 0; e--) {
|
|
1009
|
+
if (e !== o - 1) for (let e = 0; e < r; e++) s = s.double();
|
|
1010
|
+
let n = Number(t >> BigInt(e * r) & i), c = a[0];
|
|
1011
|
+
for (let e = 1; e < 32; e++) c = e === n ? a[e] : c;
|
|
1012
|
+
s = s.add(c);
|
|
1013
|
+
}
|
|
1014
|
+
return {
|
|
1015
|
+
p: s,
|
|
1016
|
+
f: s
|
|
1017
|
+
};
|
|
1018
|
+
}
|
|
1019
|
+
shouldBlind(e, t) {
|
|
1020
|
+
return this.randomBytes === void 0 ? !1 : t === Z || e === this.BASE && (this.baseCanBeBlinded === void 0 && (this.baseCanBeBlinded = this.mulUnsafe(this.BASE, this.Point.Fn.ORDER).is0()), this.baseCanBeBlinded);
|
|
1021
|
+
}
|
|
1022
|
+
mulSecret(e, t, n, r) {
|
|
1023
|
+
return this.shouldBlind(e, n) ? this.mulCTBlinded(e, t, r) : this.mulCT(e, t, r);
|
|
1024
|
+
}
|
|
1025
|
+
mulUnsafe(e, t, n) {
|
|
1026
|
+
if (this.assertPoint(e), !U(t)) throw Error("invalid scalar");
|
|
1027
|
+
let r = an(e);
|
|
1028
|
+
if (r === 1 || t >= this.Point.Fn.ORDER) return dn(this.Point, [e], [t], !0);
|
|
1029
|
+
let i = this.getWnafPrecomputes(r, e, this.bits, n);
|
|
1030
|
+
return this.wnafCachedCT(i, t).p;
|
|
1031
|
+
}
|
|
1032
|
+
setWindowSize(e, t) {
|
|
1033
|
+
this.assertPoint(e), Qt(t, this.bits), $t((Math.ceil((this.bits + qt) / t) + 1) * 2 ** (t - 1), this.Point.Fp.BYTES), rn.set(e, t), this.wnafPrecomputes.delete(e);
|
|
1034
|
+
}
|
|
1035
|
+
hasWindowSize(e) {
|
|
1036
|
+
return an(e) !== 1;
|
|
1037
|
+
}
|
|
1038
|
+
};
|
|
1039
|
+
function dn(e, t, n, r = !1) {
|
|
1040
|
+
if (Xt(e), tn(t, e), V(r, "allowOversized"), nn(n, e.Fn, r ? e.Fn.ORDER ** Gt : void 0), t.length !== n.length) throw Error("arrays of points and scalars must have equal length");
|
|
1041
|
+
let i = t.map((e) => on(e, 4)), a = n.map((e) => sn(e, 4));
|
|
1042
|
+
return ln(e.ZERO, i, a);
|
|
1043
|
+
}
|
|
1044
|
+
function fn(e, t, n) {
|
|
1045
|
+
if (t) {
|
|
1046
|
+
if (t.ORDER !== e) throw Error("Field.ORDER must match order: Fp == p, Fn == n");
|
|
1047
|
+
return X(t), t;
|
|
1048
|
+
}
|
|
1049
|
+
return Ut(e, { isLE: n });
|
|
1050
|
+
}
|
|
1051
|
+
function pn(e, t, n = {}, r) {
|
|
1052
|
+
if (e !== "weierstrass" && e !== "edwards") throw Error("expected curve type \"weierstrass\" or \"edwards\"");
|
|
1053
|
+
if (r === void 0 && (r = e === "edwards"), !t || typeof t != "object") throw Error(`expected valid ${e} CURVE object`);
|
|
1054
|
+
W(n);
|
|
1055
|
+
for (let e of [
|
|
1056
|
+
"p",
|
|
1057
|
+
"n",
|
|
1058
|
+
"h"
|
|
1059
|
+
]) {
|
|
1060
|
+
let n = t[e];
|
|
1061
|
+
if (!(U(n) && n !== Wt)) throw Error(`CURVE.${e} must be positive bigint`);
|
|
1062
|
+
}
|
|
1063
|
+
let i = fn(t.p, n.Fp, r), a = fn(t.n, n.Fn, r), o = [
|
|
1064
|
+
"Gx",
|
|
1065
|
+
"Gy",
|
|
1066
|
+
"a",
|
|
1067
|
+
e === "weierstrass" ? "b" : "d"
|
|
1068
|
+
];
|
|
1069
|
+
for (let e of o) if (!i.isValid(t[e])) throw Error(`CURVE.${e} must be valid field element of CURVE.Fp`);
|
|
1070
|
+
return t = Object.freeze(Object.assign({}, t)), {
|
|
1071
|
+
CURVE: t,
|
|
1072
|
+
Fp: i,
|
|
1073
|
+
Fn: a
|
|
1074
|
+
};
|
|
1075
|
+
}
|
|
1076
|
+
function mn(e, t) {
|
|
1077
|
+
return function(n) {
|
|
1078
|
+
let r = e(n);
|
|
1079
|
+
return {
|
|
1080
|
+
secretKey: r,
|
|
1081
|
+
publicKey: t(r)
|
|
1082
|
+
};
|
|
1083
|
+
};
|
|
1084
|
+
}
|
|
1085
|
+
//#endregion
|
|
1086
|
+
//#region node_modules/.pnpm/@noble+curves@2.4.0/node_modules/@noble/curves/abstract/edwards.js
|
|
1087
|
+
var hn = /* @__PURE__ */ BigInt(0), gn = /* @__PURE__ */ BigInt(1), _n = /* @__PURE__ */ BigInt(2), vn = /* @__PURE__ */ BigInt(4), yn = /* @__PURE__ */ BigInt(8);
|
|
1088
|
+
function bn(e, t, n, r) {
|
|
1089
|
+
let i = e.sqr(n), a = e.sqr(r), o = e.add(e.mul(t.a, i), a), s = e.add(e.ONE, e.mul(t.d, e.mul(i, a)));
|
|
1090
|
+
return e.eql(o, s);
|
|
1091
|
+
}
|
|
1092
|
+
function xn(e, t = {}) {
|
|
1093
|
+
W(t, {}, {}, "extraOpts");
|
|
1094
|
+
let n = t, r = pn("edwards", e, n, n.FpFnLE), { Fp: i, Fn: a } = r, o = r.CURVE, { h: s } = o;
|
|
1095
|
+
if (zt(i, o.a) !== 1) throw Error("edwards: CURVE.a must be a square in Fp for complete addition formulas");
|
|
1096
|
+
if (zt(i, o.d) !== -1) throw Error("edwards: CURVE.d must be a non-square in Fp for complete addition formulas");
|
|
1097
|
+
W(n, {}, {
|
|
1098
|
+
uvRatio: "function",
|
|
1099
|
+
randomBytes: "function"
|
|
1100
|
+
});
|
|
1101
|
+
let c = n.randomBytes === void 0 ? rt : n.randomBytes, l = _n << BigInt(i.BYTES * 8) - gn;
|
|
1102
|
+
function u(e) {
|
|
1103
|
+
if (!i.isOdd) throw Error("Field does not have .isOdd()");
|
|
1104
|
+
return i.isOdd(e);
|
|
1105
|
+
}
|
|
1106
|
+
let d = n.uvRatio === void 0 ? (e, t) => {
|
|
1107
|
+
try {
|
|
1108
|
+
return {
|
|
1109
|
+
isValid: !0,
|
|
1110
|
+
value: i.sqrt(i.div(e, t))
|
|
1111
|
+
};
|
|
1112
|
+
} catch {
|
|
1113
|
+
return {
|
|
1114
|
+
isValid: !1,
|
|
1115
|
+
value: hn
|
|
1116
|
+
};
|
|
1117
|
+
}
|
|
1118
|
+
} : n.uvRatio;
|
|
1119
|
+
if (!bn(i, o, o.Gx, o.Gy)) throw Error("bad curve params: generator point");
|
|
1120
|
+
let f = i.eql(o.a, i.neg(i.ONE)) ? (e) => i.neg(e) : i.eql(o.a, i.ONE) ? (e) => e : (e) => i.mul(o.a, e);
|
|
1121
|
+
function p(e, t, n = !1) {
|
|
1122
|
+
let r = n ? gn : hn;
|
|
1123
|
+
return ht("coordinate " + e, t, r, l), t;
|
|
1124
|
+
}
|
|
1125
|
+
function m(e) {
|
|
1126
|
+
if (!(e instanceof h)) throw Error("EdwardsPoint expected");
|
|
1127
|
+
}
|
|
1128
|
+
class h {
|
|
1129
|
+
static BASE = new h(o.Gx, o.Gy, i.ONE, i.mul(o.Gx, o.Gy));
|
|
1130
|
+
static ZERO = new h(i.ZERO, i.ONE, i.ONE, i.ZERO);
|
|
1131
|
+
static Fp = i;
|
|
1132
|
+
static Fn = a;
|
|
1133
|
+
X;
|
|
1134
|
+
Y;
|
|
1135
|
+
Z;
|
|
1136
|
+
T;
|
|
1137
|
+
constructor(e, t, n, r) {
|
|
1138
|
+
this.X = p("x", e), this.Y = p("y", t), this.Z = p("z", n, !0), this.T = p("t", r), Object.freeze(this);
|
|
1139
|
+
}
|
|
1140
|
+
static CURVE() {
|
|
1141
|
+
return o;
|
|
1142
|
+
}
|
|
1143
|
+
static fromAffine(e) {
|
|
1144
|
+
if (e instanceof h) throw Error("extended point not allowed");
|
|
1145
|
+
let { x: t, y: n } = e || {};
|
|
1146
|
+
return p("x", t), p("y", n), new h(t, n, i.ONE, i.mul(t, n));
|
|
1147
|
+
}
|
|
1148
|
+
static fromBytes(e, t = !1) {
|
|
1149
|
+
let n = i.BYTES, { a: r, d: a } = o;
|
|
1150
|
+
e = pt(R(e, n, "point")), V(t, "zip215");
|
|
1151
|
+
let s = pt(e), c = e[n - 1];
|
|
1152
|
+
s[n - 1] = c & -129;
|
|
1153
|
+
let f = ut(s);
|
|
1154
|
+
ht("point.y", f, hn, t ? l : i.ORDER);
|
|
1155
|
+
let p = i.sqr(f), m = i.sub(p, i.ONE), g = i.sub(i.mulN(a, p), r), { isValid: _, value: v } = d(m, g);
|
|
1156
|
+
if (!_) throw Error("bad point: invalid y coordinate");
|
|
1157
|
+
let y = u(v), b = !!(c & 128);
|
|
1158
|
+
if (!t && i.is0(v) && b) throw Error("bad point: x=0 and x_0=1");
|
|
1159
|
+
return b !== y && (v = i.neg(v)), h.fromAffine({
|
|
1160
|
+
x: v,
|
|
1161
|
+
y: f
|
|
1162
|
+
});
|
|
1163
|
+
}
|
|
1164
|
+
static fromHex(e, t = !1) {
|
|
1165
|
+
return h.fromBytes(tt(e), t);
|
|
1166
|
+
}
|
|
1167
|
+
get x() {
|
|
1168
|
+
return this.toAffine().x;
|
|
1169
|
+
}
|
|
1170
|
+
get y() {
|
|
1171
|
+
return this.toAffine().y;
|
|
1172
|
+
}
|
|
1173
|
+
precompute(e = 6, t = !0) {
|
|
1174
|
+
return _.setWindowSize(this, e), t || this.multiply(_n), this;
|
|
1175
|
+
}
|
|
1176
|
+
assertValidity() {
|
|
1177
|
+
let e = this, { a: t, d: n } = o;
|
|
1178
|
+
if (e.is0()) throw Error("bad point: ZERO");
|
|
1179
|
+
let { X: r, Y: a, Z: s, T: c } = e, l = i.sqr(r), u = i.sqr(a), d = i.sqr(s), f = i.sqr(d), p = i.mul(l, t), m = i.mul(i.add(p, u), d), h = i.add(f, i.mul(n, i.mul(l, u)));
|
|
1180
|
+
if (!i.eql(m, h)) throw Error("bad point: equation left != right (1)");
|
|
1181
|
+
let g = i.mul(r, a), _ = i.mul(s, c);
|
|
1182
|
+
if (!i.eql(g, _)) throw Error("bad point: equation left != right (2)");
|
|
1183
|
+
}
|
|
1184
|
+
equals(e) {
|
|
1185
|
+
m(e);
|
|
1186
|
+
let { X: t, Y: n, Z: r } = this, { X: a, Y: o, Z: s } = e, c = i.mul(t, s), l = i.mul(a, r), u = i.mul(n, s), d = i.mul(o, r);
|
|
1187
|
+
return i.eql(c, l) && i.eql(u, d);
|
|
1188
|
+
}
|
|
1189
|
+
is0() {
|
|
1190
|
+
return this.equals(h.ZERO);
|
|
1191
|
+
}
|
|
1192
|
+
negate() {
|
|
1193
|
+
return new h(i.neg(this.X), this.Y, this.Z, i.neg(this.T));
|
|
1194
|
+
}
|
|
1195
|
+
double() {
|
|
1196
|
+
let { X: e, Y: t, Z: n } = this, r = i.sqr(e), a = i.sqr(t), o = i.mul(i.sqr(n), _n), s = f(r), c = i.addN(e, t), l = i.sub(i.subN(i.sqr(c), r), a), u = i.addN(s, a), d = i.subN(u, o), p = i.subN(s, a), m = i.mul(l, d), g = i.mul(u, p), _ = i.mul(l, p), v = i.mul(d, u);
|
|
1197
|
+
return new h(m, g, v, _);
|
|
1198
|
+
}
|
|
1199
|
+
add(e) {
|
|
1200
|
+
m(e);
|
|
1201
|
+
let { d: t } = o, { X: n, Y: r, Z: a, T: s } = this, { X: c, Y: l, Z: u, T: d } = e, p = i.mul(n, c), g = i.mul(r, l), _ = i.mul(i.mulN(s, t), d), v = i.mul(a, u), y = i.sub(i.subN(i.mulN(i.addN(n, r), i.addN(c, l)), p), g), b = i.subN(v, _), x = i.addN(v, _), S = i.sub(g, f(p)), C = i.mul(y, b), w = i.mul(x, S), T = i.mul(y, S), E = i.mul(b, x);
|
|
1202
|
+
return new h(C, w, E, T);
|
|
1203
|
+
}
|
|
1204
|
+
subtract(e) {
|
|
1205
|
+
return m(e), this.add(e.negate());
|
|
1206
|
+
}
|
|
1207
|
+
multiply(e) {
|
|
1208
|
+
if (!a.isValidNot0(e)) throw RangeError("invalid scalar: expected 1 <= sc < curve.n");
|
|
1209
|
+
let { p: t, f: n } = _.mulSecret(this, e, s, g);
|
|
1210
|
+
return g([t, n])[0];
|
|
1211
|
+
}
|
|
1212
|
+
multiplyUnsafe(e) {
|
|
1213
|
+
if (!a.isValid(e)) throw RangeError("invalid scalar: expected 0 <= sc < curve.n");
|
|
1214
|
+
return e === hn ? h.ZERO : this.is0() || e === gn ? this : _.mulUnsafe(this, e, g);
|
|
1215
|
+
}
|
|
1216
|
+
isSmallOrder() {
|
|
1217
|
+
return this.clearCofactor().is0();
|
|
1218
|
+
}
|
|
1219
|
+
isTorsionFree() {
|
|
1220
|
+
return _.mulUnsafe(this, o.n).is0();
|
|
1221
|
+
}
|
|
1222
|
+
toAffine(e) {
|
|
1223
|
+
let t = this, n = e;
|
|
1224
|
+
if (n != null && typeof n != "bigint") throw TypeError("\"invertedZ\" expected bigint, got type=" + typeof n);
|
|
1225
|
+
let { X: r, Y: a, Z: o } = t, s = t.is0();
|
|
1226
|
+
n ??= s ? i.create(yn) : i.inv(o);
|
|
1227
|
+
let c = i.mul(r, n), l = i.mul(a, n), u = i.mul(o, n);
|
|
1228
|
+
if (s) return {
|
|
1229
|
+
x: i.ZERO,
|
|
1230
|
+
y: i.ONE
|
|
1231
|
+
};
|
|
1232
|
+
if (!i.eql(u, i.ONE)) throw Error("invZ was invalid");
|
|
1233
|
+
return {
|
|
1234
|
+
x: c,
|
|
1235
|
+
y: l
|
|
1236
|
+
};
|
|
1237
|
+
}
|
|
1238
|
+
clearCofactor() {
|
|
1239
|
+
return s === gn ? this : s === _n ? this.double() : s === vn ? this.double().double() : s === yn ? this.double().double().double() : this.multiplyUnsafe(s);
|
|
1240
|
+
}
|
|
1241
|
+
toBytes() {
|
|
1242
|
+
let { x: e, y: t } = this.toAffine(), n = i.toBytes(t);
|
|
1243
|
+
return n[n.length - 1] |= u(e) ? 128 : 0, n;
|
|
1244
|
+
}
|
|
1245
|
+
toHex() {
|
|
1246
|
+
return $e(this.toBytes());
|
|
1247
|
+
}
|
|
1248
|
+
toString() {
|
|
1249
|
+
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
|
1250
|
+
}
|
|
1251
|
+
}
|
|
1252
|
+
let g = (e) => Zt(h, e), _ = new un(h, c);
|
|
1253
|
+
return _.bits >= 6 && h.BASE.precompute(6), Object.freeze(h.prototype), Object.freeze(h), h;
|
|
1254
|
+
}
|
|
1255
|
+
function Sn(e, t, n = {}) {
|
|
1256
|
+
if (Xt(e), typeof t != "function") throw Error("\"hash\" function param is required");
|
|
1257
|
+
let r = t, i = n;
|
|
1258
|
+
W(i, {}, {
|
|
1259
|
+
adjustScalarBytes: "function",
|
|
1260
|
+
randomBytes: "function",
|
|
1261
|
+
domain: "function",
|
|
1262
|
+
prehash: "function",
|
|
1263
|
+
zip215: "boolean",
|
|
1264
|
+
mapToCurve: "function",
|
|
1265
|
+
toMontgomery: "function",
|
|
1266
|
+
toMontgomerySecret: "function"
|
|
1267
|
+
});
|
|
1268
|
+
let { prehash: a } = i, { BASE: o, Fp: s, Fn: c } = e, l = r.outputLen, u = 2 * s.BYTES;
|
|
1269
|
+
if (l !== void 0 && (H(l, "hash.outputLen"), l !== u)) throw Error(`hash.outputLen must be ${u}, got ${l}`);
|
|
1270
|
+
let d = i.randomBytes === void 0 ? rt : i.randomBytes, f = i.toMontgomery, p = i.toMontgomerySecret, m = i.adjustScalarBytes === void 0 ? (e) => e : i.adjustScalarBytes, h = i.domain === void 0 ? (e, t, n) => {
|
|
1271
|
+
if (V(n, "phflag"), t.length || n) throw Error("Contexts/pre-hash are not supported");
|
|
1272
|
+
return e;
|
|
1273
|
+
} : i.domain;
|
|
1274
|
+
function g(e) {
|
|
1275
|
+
return c.create(ut(e));
|
|
1276
|
+
}
|
|
1277
|
+
function _(e) {
|
|
1278
|
+
let t = T.secretKey;
|
|
1279
|
+
R(e, T.secretKey, "secretKey");
|
|
1280
|
+
let n = R(r(e), 2 * t, "hashedSecretKey"), i = m(n.slice(0, t));
|
|
1281
|
+
return {
|
|
1282
|
+
head: i,
|
|
1283
|
+
prefix: n.slice(t, 2 * t),
|
|
1284
|
+
scalar: g(i)
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
function v(e) {
|
|
1288
|
+
let { head: t, prefix: n, scalar: r } = _(e), i = o.multiply(r);
|
|
1289
|
+
return {
|
|
1290
|
+
head: t,
|
|
1291
|
+
prefix: n,
|
|
1292
|
+
scalar: r,
|
|
1293
|
+
point: i,
|
|
1294
|
+
pointBytes: i.toBytes()
|
|
1295
|
+
};
|
|
1296
|
+
}
|
|
1297
|
+
function y(e) {
|
|
1298
|
+
return v(e).pointBytes;
|
|
1299
|
+
}
|
|
1300
|
+
function b(e = Uint8Array.of(), ...t) {
|
|
1301
|
+
let n = et(...t);
|
|
1302
|
+
return g(r(h(n, R(e, void 0, "context"), !!a)));
|
|
1303
|
+
}
|
|
1304
|
+
function x(e, t, n = {}) {
|
|
1305
|
+
W(n, {}, {}, "options"), e = pt(R(e, void 0, "message")), a && (e = a(e));
|
|
1306
|
+
let { prefix: r, scalar: i, pointBytes: s } = v(t), l = b(n.context, r, e), u = o.multiply(l).toBytes(), d = b(n.context, u, s, e), f = c.create(l + d * i);
|
|
1307
|
+
if (!c.isValid(f)) throw Error("sign failed: invalid s");
|
|
1308
|
+
return R(et(u, c.toBytes(f)), T.signature, "result");
|
|
1309
|
+
}
|
|
1310
|
+
let S = { zip215: i.zip215 };
|
|
1311
|
+
function C(t, n, r, i = S) {
|
|
1312
|
+
W(i);
|
|
1313
|
+
let { context: s } = i, c = i.zip215 === void 0 ? !!S.zip215 : i.zip215, l = T.signature;
|
|
1314
|
+
t = R(t, l, "signature"), n = R(n, void 0, "message"), r = R(r, T.publicKey, "publicKey"), c !== void 0 && V(c, "zip215"), a && (n = a(n));
|
|
1315
|
+
let u = l / 2, d = t.subarray(0, u), f = ut(t.subarray(u, l)), p, m, h;
|
|
1316
|
+
try {
|
|
1317
|
+
p = e.fromBytes(r, c), m = e.fromBytes(d, c), h = o.multiplyUnsafe(f);
|
|
1318
|
+
} catch {
|
|
1319
|
+
return !1;
|
|
1320
|
+
}
|
|
1321
|
+
if (!c && p.isSmallOrder()) return !1;
|
|
1322
|
+
let g = b(s, d, r, n);
|
|
1323
|
+
return m.add(p.multiplyUnsafe(g)).subtract(h).clearCofactor().is0();
|
|
1324
|
+
}
|
|
1325
|
+
let w = s.BYTES, T = {
|
|
1326
|
+
secretKey: w,
|
|
1327
|
+
publicKey: w,
|
|
1328
|
+
signature: 2 * w,
|
|
1329
|
+
seed: w
|
|
1330
|
+
};
|
|
1331
|
+
function E(e) {
|
|
1332
|
+
return e = e === void 0 ? d(T.seed) : e, R(e, T.seed, "seed");
|
|
1333
|
+
}
|
|
1334
|
+
function ee(e) {
|
|
1335
|
+
return nt(e) && e.length === T.secretKey;
|
|
1336
|
+
}
|
|
1337
|
+
function D(t, n) {
|
|
1338
|
+
try {
|
|
1339
|
+
return !!e.fromBytes(t, n === void 0 ? S.zip215 : n);
|
|
1340
|
+
} catch {
|
|
1341
|
+
return !1;
|
|
1342
|
+
}
|
|
1343
|
+
}
|
|
1344
|
+
let te = {
|
|
1345
|
+
getExtendedPublicKey: v,
|
|
1346
|
+
randomSecretKey: E,
|
|
1347
|
+
isValidSecretKey: ee,
|
|
1348
|
+
isValidPublicKey: D,
|
|
1349
|
+
toMontgomery(t) {
|
|
1350
|
+
if (f === void 0) throw Error("Montgomery conversion is not supported for this curve");
|
|
1351
|
+
return f(e.fromBytes(t));
|
|
1352
|
+
},
|
|
1353
|
+
toMontgomerySecret(e) {
|
|
1354
|
+
if (p === void 0) throw Error("Montgomery conversion is not supported for this curve");
|
|
1355
|
+
return p(e);
|
|
1356
|
+
}
|
|
1357
|
+
};
|
|
1358
|
+
return Object.freeze(T), Object.freeze(te), Object.freeze({
|
|
1359
|
+
keygen: mn(E, y),
|
|
1360
|
+
getPublicKey: y,
|
|
1361
|
+
sign: x,
|
|
1362
|
+
verify: C,
|
|
1363
|
+
utils: te,
|
|
1364
|
+
Point: e,
|
|
1365
|
+
lengths: T
|
|
1366
|
+
});
|
|
1367
|
+
}
|
|
1368
|
+
//#endregion
|
|
1369
|
+
//#region node_modules/.pnpm/@noble+curves@2.4.0/node_modules/@noble/curves/ed25519.js
|
|
1370
|
+
var Cn = /* @__PURE__ */ BigInt(1), wn = /* @__PURE__ */ BigInt(2), Tn = /* @__PURE__ */ BigInt(5), En = /* @__PURE__ */ BigInt(8), Dn = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"), On = {
|
|
1371
|
+
p: Dn,
|
|
1372
|
+
n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
|
|
1373
|
+
h: En,
|
|
1374
|
+
a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
|
|
1375
|
+
d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
|
|
1376
|
+
Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
|
|
1377
|
+
Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
|
|
1378
|
+
};
|
|
1379
|
+
function kn(e) {
|
|
1380
|
+
let t = BigInt(10), n = BigInt(20), r = BigInt(40), i = BigInt(80), a = Dn, o = e * e % a * e % a, s = Y(Y(o, wn, a) * o % a, Cn, a) * e % a, c = Y(s, Tn, a) * s % a, l = Y(c, t, a) * c % a, u = Y(l, n, a) * l % a, d = Y(u, r, a) * u % a;
|
|
1381
|
+
return {
|
|
1382
|
+
pow_p_5_8: Y(Y(Y(Y(d, i, a) * d % a, i, a) * d % a, t, a) * c % a, wn, a) * e % a,
|
|
1383
|
+
b2: o
|
|
1384
|
+
};
|
|
1385
|
+
}
|
|
1386
|
+
function An(e) {
|
|
1387
|
+
return e[0] &= 248, e[31] &= 127, e[31] |= 64, e;
|
|
1388
|
+
}
|
|
1389
|
+
var jn = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
|
1390
|
+
function Mn(e, t) {
|
|
1391
|
+
let n = Dn, r = J(t * t * t, n), i = kn(e * J(r * r * t, n)).pow_p_5_8, a = J(e * r * i, n), o = J(t * a * a, n), s = a, c = J(a * jn, n), l = o === e, u = o === J(-e, n), d = o === J(-e * jn, n);
|
|
1392
|
+
return l && (a = s), (u || d) && (a = c), It(a, n) && (a = J(-a, n)), {
|
|
1393
|
+
isValid: l || u,
|
|
1394
|
+
value: a
|
|
1395
|
+
};
|
|
1396
|
+
}
|
|
1397
|
+
var Nn = /* @__PURE__ */ xn(On, { uvRatio: Mn }), Pn = Nn.Fp;
|
|
1398
|
+
function Fn(e) {
|
|
1399
|
+
let { y: t } = e;
|
|
1400
|
+
return Pn.toBytes(Pn.div(Cn + t, Cn - t));
|
|
1401
|
+
}
|
|
1402
|
+
function In(e) {
|
|
1403
|
+
let t = Nn.Fp.BYTES;
|
|
1404
|
+
return F(e, t), An(Xe(e.subarray(0, t))).subarray(0, t);
|
|
1405
|
+
}
|
|
1406
|
+
function Ln(e) {
|
|
1407
|
+
return Sn(Nn, Xe, Object.assign({
|
|
1408
|
+
adjustScalarBytes: An,
|
|
1409
|
+
toMontgomery: Fn,
|
|
1410
|
+
toMontgomerySecret: In,
|
|
1411
|
+
zip215: !0
|
|
1412
|
+
}, e));
|
|
1413
|
+
}
|
|
1414
|
+
var Q = /* @__PURE__ */ Ln({}), $ = 32, Rn = 248, zn = 127, Bn = 64, Vn = 128, Hn = 127;
|
|
1415
|
+
function Un(e) {
|
|
1416
|
+
e.length < $ || (e[0] = (e[0] ?? 0) & Rn, e[31] = (e[31] ?? 0) & zn | Bn);
|
|
1417
|
+
}
|
|
1418
|
+
function Wn() {
|
|
1419
|
+
let e = new Uint8Array(s($));
|
|
1420
|
+
Un(e);
|
|
1421
|
+
let t = Yn(e) % Q.Point.CURVE().n;
|
|
1422
|
+
return [Q.Point.BASE.multiply(t).toBytes(), Uint8Array.from(e)];
|
|
1423
|
+
}
|
|
1424
|
+
function Gn(e, t) {
|
|
1425
|
+
let n = i("SHA256");
|
|
1426
|
+
return n.update(t), n.sign(e);
|
|
1427
|
+
}
|
|
1428
|
+
function Kn(e, t, n) {
|
|
1429
|
+
try {
|
|
1430
|
+
let r = a("SHA256");
|
|
1431
|
+
return r.update(t), r.verify(e, Buffer.from(n));
|
|
1432
|
+
} catch {
|
|
1433
|
+
return !1;
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
function qn(e, n) {
|
|
1437
|
+
if (e.length !== $ || n.length !== $) throw Error("invalid key length");
|
|
1438
|
+
let r = Uint8Array.from(n);
|
|
1439
|
+
r[31] = (r[31] ?? 0) & Hn;
|
|
1440
|
+
let i = Yn(r), a = Jn(Q.Point.fromBytes(e).negate(), i).toBytes();
|
|
1441
|
+
return a[31] = (a[31] ?? 0) ^ Vn, t("sha512").update(a).digest();
|
|
1442
|
+
}
|
|
1443
|
+
function Jn(e, t) {
|
|
1444
|
+
let n = Q.Point.CURVE().n;
|
|
1445
|
+
if (t < n) return t === 0n ? Q.Point.ZERO : e.multiply(t);
|
|
1446
|
+
let r = t % n, i = t / n, a = r === 0n ? Q.Point.ZERO : e.multiply(r), o = e.multiply(n - 1n).add(e).multiply(i);
|
|
1447
|
+
return a.add(o);
|
|
1448
|
+
}
|
|
1449
|
+
function Yn(e) {
|
|
1450
|
+
let t = 0n;
|
|
1451
|
+
for (let n = e.length - 1; n >= 0; n--) t = t << 8n | BigInt(e[n]);
|
|
1452
|
+
return t;
|
|
1453
|
+
}
|
|
1454
|
+
//#endregion
|
|
1455
|
+
export { l as C, _ as S, g as _, Jn as a, m as b, Q as c, w as d, T as f, u as g, d as h, qn as i, x as l, ee as m, Un as n, Gn as o, S as p, Wn as r, Kn as s, Yn as t, C as u, f as v, c as w, h as x, p as y };
|
|
1456
|
+
|
|
1457
|
+
//# sourceMappingURL=primitives-xIr6Tjk4.js.map
|