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