@prosopo/procaptcha-bundle 3.0.8 → 3.0.10

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.
Files changed (151) hide show
  1. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.d.ts +1 -0
  2. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
  3. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -0
  4. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
  5. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.d.ts +1 -0
  6. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
  7. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaType.d.ts +2 -1
  8. package/.rollup.cache/home/runner/work/captcha/captcha/packages/procaptcha-bundle/dist/bundle/util/captcha/captchaType.d.ts.map +1 -1
  9. package/CHANGELOG.md +38 -0
  10. package/dist/bundle/ProcaptchaWidget-48FxVPQd.js +187 -0
  11. package/dist/bundle/ProcaptchaWidget-B2BzhXLv.js +992 -0
  12. package/dist/bundle/builder-DNHtDoNG.js +44 -0
  13. package/dist/bundle/{captchaComponentProvider-Dw6ydLe3.js → captchaComponentProvider-B7Vxx339.js} +266 -100
  14. package/dist/bundle/{captchaRenderer-CY8KuZK-.js → captchaRenderer-DdOlOCKw.js} +3 -3
  15. package/dist/bundle/{commonChunk-24zMb_mF.js → commonChunk-HCVkoCqn.js} +9 -12
  16. package/dist/bundle/{emotion-element-5486c51c.browser.esm-PRDDgd_k.js → emotion-element-5486c51c.browser.esm-D7qvHZDV.js} +1 -1
  17. package/dist/bundle/{fp.esm-BADUiinQ.js → fp.esm-DYWeNGcH.js} +648 -548
  18. package/dist/bundle/index-7Xh-Mf8v.js +1318 -0
  19. package/dist/bundle/{index-DqwVRCwA.js → index-C00_J7av.js} +48 -12
  20. package/dist/bundle/{index-BzOMq-ud.js → index-DyYmvHVN.js} +1 -1
  21. package/dist/bundle/locales/ar/translation.json +12 -11
  22. package/dist/bundle/locales/az/translation.json +12 -11
  23. package/dist/bundle/locales/cs/translation.json +12 -11
  24. package/dist/bundle/locales/de/translation.json +12 -11
  25. package/dist/bundle/locales/el/translation.json +12 -11
  26. package/dist/bundle/locales/en/translation.json +4 -3
  27. package/dist/bundle/locales/es/translation.json +12 -11
  28. package/dist/bundle/locales/fi/translation.json +29 -28
  29. package/dist/bundle/locales/fr/translation.json +12 -11
  30. package/dist/bundle/locales/hi/translation.json +41 -40
  31. package/dist/bundle/locales/hu/translation.json +12 -11
  32. package/dist/bundle/locales/id/translation.json +12 -11
  33. package/dist/bundle/locales/it/translation.json +12 -11
  34. package/dist/bundle/locales/ja/translation.json +12 -11
  35. package/dist/bundle/locales/jv/translation.json +12 -11
  36. package/dist/bundle/locales/ko/translation.json +7 -6
  37. package/dist/bundle/locales/ml/translation.json +12 -11
  38. package/dist/bundle/locales/ms/translation.json +12 -11
  39. package/dist/bundle/locales/nl/translation.json +12 -11
  40. package/dist/bundle/locales/no/translation.json +12 -11
  41. package/dist/bundle/locales/pl/translation.json +12 -11
  42. package/dist/bundle/locales/pt/translation.json +12 -11
  43. package/dist/bundle/locales/pt-BR/translation.json +12 -11
  44. package/dist/bundle/locales/ro/translation.json +12 -11
  45. package/dist/bundle/locales/ru/translation.json +12 -11
  46. package/dist/bundle/locales/sr/translation.json +12 -11
  47. package/dist/bundle/locales/sv/translation.json +12 -11
  48. package/dist/bundle/locales/th/translation.json +12 -11
  49. package/dist/bundle/locales/tr/translation.json +7 -6
  50. package/dist/bundle/locales/uk/translation.json +12 -11
  51. package/dist/bundle/locales/vi/translation.json +12 -11
  52. package/dist/bundle/locales/zh-CN/translation.json +12 -11
  53. package/dist/bundle/nobleChunk-Qozzkbsq.js +3648 -0
  54. package/dist/bundle/procaptcha.bundle.js +2 -2
  55. package/dist/bundle/util/captcha/captchaComponentProvider.d.ts +1 -0
  56. package/dist/bundle/util/captcha/captchaComponentProvider.d.ts.map +1 -1
  57. package/dist/bundle/util/captcha/captchaComponentsList.d.ts +1 -0
  58. package/dist/bundle/util/captcha/captchaComponentsList.d.ts.map +1 -1
  59. package/dist/bundle/util/captcha/captchaRenderer.d.ts +1 -0
  60. package/dist/bundle/util/captcha/captchaRenderer.d.ts.map +1 -1
  61. package/dist/bundle/util/captcha/captchaType.d.ts +2 -1
  62. package/dist/bundle/util/captcha/captchaType.d.ts.map +1 -1
  63. package/dist/bundle/{utilCryptoChunk-CIPUtfoO.js → utilCryptoChunk-qm-BM2eT.js} +618 -647
  64. package/dist/bundle/{web2Chunk-7Vd8yt2r.js → web2Chunk-DCsWA5PR.js} +1150 -994
  65. package/dist/bundle/{web3Chunk-DrUvbVNW.js → web3Chunk-B8txCqUJ.js} +3 -3
  66. package/dist/index.js +142 -108
  67. package/dist/util/captcha/captchaComponentProvider.js +18 -10
  68. package/dist/util/captcha/captchaComponentsList.js +6 -5
  69. package/dist/util/captcha/captchaRenderer.js +58 -40
  70. package/dist/util/captcha/captchaType.js +9 -5
  71. package/dist/util/captcha/components/frictionlessCaptcha.js +19 -9
  72. package/dist/util/captcha/components/imageCaptcha.js +13 -5
  73. package/dist/util/captcha/components/powCaptcha.js +13 -5
  74. package/dist/util/config.js +15 -12
  75. package/dist/util/configCreator.js +21 -22
  76. package/dist/util/language.js +14 -13
  77. package/dist/util/timeout.js +13 -8
  78. package/dist/util/widgetFactory.js +77 -55
  79. package/dist/util/widgetThemeResolver.js +14 -17
  80. package/package.json +23 -20
  81. package/stats.html +1 -1
  82. package/vite.cjs.config.ts +2 -3
  83. package/vite.esm.config.ts +20 -0
  84. package/vite.test.config.ts +9 -5
  85. package/dist/bundle/ProcaptchaWidget-BpzncYOb.js +0 -612
  86. package/dist/bundle/ProcaptchaWidget-D961oZ27.js +0 -148
  87. package/dist/bundle/builder-CQlqPNRd.js +0 -37
  88. package/dist/bundle/index-BRg_gWPo.js +0 -1328
  89. package/dist/bundle/nobleChunk-Xl5XLrx3.js +0 -3635
  90. package/dist/components.d.ts +0 -5
  91. package/dist/components.d.ts.map +0 -1
  92. package/dist/components.js +0 -5
  93. package/dist/components.js.map +0 -1
  94. package/dist/index.d.ts +0 -16
  95. package/dist/index.d.ts.map +0 -1
  96. package/dist/index.js.map +0 -1
  97. package/dist/tests/util/captchaType.test.d.ts +0 -2
  98. package/dist/tests/util/captchaType.test.d.ts.map +0 -1
  99. package/dist/tests/util/captchaType.test.js +0 -36
  100. package/dist/tests/util/captchaType.test.js.map +0 -1
  101. package/dist/tests/util/config.test.d.ts +0 -2
  102. package/dist/tests/util/config.test.d.ts.map +0 -1
  103. package/dist/tests/util/config.test.js +0 -69
  104. package/dist/tests/util/config.test.js.map +0 -1
  105. package/dist/tests/util/renderLogic.test.d.ts +0 -2
  106. package/dist/tests/util/renderLogic.test.d.ts.map +0 -1
  107. package/dist/tests/util/renderLogic.test.js +0 -126
  108. package/dist/tests/util/renderLogic.test.js.map +0 -1
  109. package/dist/util/captcha/captchaComponentProvider.d.ts +0 -8
  110. package/dist/util/captcha/captchaComponentProvider.d.ts.map +0 -1
  111. package/dist/util/captcha/captchaComponentProvider.js.map +0 -1
  112. package/dist/util/captcha/captchaComponentsList.d.ts +0 -6
  113. package/dist/util/captcha/captchaComponentsList.d.ts.map +0 -1
  114. package/dist/util/captcha/captchaComponentsList.js.map +0 -1
  115. package/dist/util/captcha/captchaProps.d.ts +0 -9
  116. package/dist/util/captcha/captchaProps.d.ts.map +0 -1
  117. package/dist/util/captcha/captchaProps.js +0 -2
  118. package/dist/util/captcha/captchaProps.js.map +0 -1
  119. package/dist/util/captcha/captchaRenderer.d.ts +0 -24
  120. package/dist/util/captcha/captchaRenderer.d.ts.map +0 -1
  121. package/dist/util/captcha/captchaRenderer.js.map +0 -1
  122. package/dist/util/captcha/captchaType.d.ts +0 -3
  123. package/dist/util/captcha/captchaType.d.ts.map +0 -1
  124. package/dist/util/captcha/captchaType.js.map +0 -1
  125. package/dist/util/captcha/components/frictionlessCaptcha.d.ts +0 -4
  126. package/dist/util/captcha/components/frictionlessCaptcha.d.ts.map +0 -1
  127. package/dist/util/captcha/components/frictionlessCaptcha.js.map +0 -1
  128. package/dist/util/captcha/components/imageCaptcha.d.ts +0 -4
  129. package/dist/util/captcha/components/imageCaptcha.d.ts.map +0 -1
  130. package/dist/util/captcha/components/imageCaptcha.js.map +0 -1
  131. package/dist/util/captcha/components/powCaptcha.d.ts +0 -4
  132. package/dist/util/captcha/components/powCaptcha.d.ts.map +0 -1
  133. package/dist/util/captcha/components/powCaptcha.js.map +0 -1
  134. package/dist/util/config.d.ts +0 -6
  135. package/dist/util/config.d.ts.map +0 -1
  136. package/dist/util/config.js.map +0 -1
  137. package/dist/util/configCreator.d.ts +0 -5
  138. package/dist/util/configCreator.d.ts.map +0 -1
  139. package/dist/util/configCreator.js.map +0 -1
  140. package/dist/util/language.d.ts +0 -3
  141. package/dist/util/language.d.ts.map +0 -1
  142. package/dist/util/language.js.map +0 -1
  143. package/dist/util/timeout.d.ts +0 -3
  144. package/dist/util/timeout.d.ts.map +0 -1
  145. package/dist/util/timeout.js.map +0 -1
  146. package/dist/util/widgetFactory.d.ts +0 -18
  147. package/dist/util/widgetFactory.d.ts.map +0 -1
  148. package/dist/util/widgetFactory.js.map +0 -1
  149. package/dist/util/widgetThemeResolver.d.ts +0 -9
  150. package/dist/util/widgetThemeResolver.d.ts.map +0 -1
  151. package/dist/util/widgetThemeResolver.js.map +0 -1
@@ -1,3635 +0,0 @@
1
- function Hs(t) {
2
- return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
3
- }
4
- function et(t) {
5
- if (!Number.isSafeInteger(t) || t < 0)
6
- throw new Error("positive integer expected, got " + t);
7
- }
8
- function oe(t, ...e) {
9
- if (!Hs(t))
10
- throw new Error("Uint8Array expected");
11
- if (e.length > 0 && !e.includes(t.length))
12
- throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
13
- }
14
- function kn(t) {
15
- if (typeof t != "function" || typeof t.create != "function")
16
- throw new Error("Hash should be wrapped by utils.createHasher");
17
- et(t.outputLen), et(t.blockLen);
18
- }
19
- function te(t, e = !0) {
20
- if (t.destroyed)
21
- throw new Error("Hash instance has been destroyed");
22
- if (e && t.finished)
23
- throw new Error("Hash#digest() has already been called");
24
- }
25
- function On(t, e) {
26
- oe(t);
27
- const n = e.outputLen;
28
- if (t.length < n)
29
- throw new Error("digestInto() expects output buffer of length at least " + n);
30
- }
31
- function Gt(t) {
32
- return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
33
- }
34
- function ot(...t) {
35
- for (let e = 0; e < t.length; e++)
36
- t[e].fill(0);
37
- }
38
- function Ae(t) {
39
- return new DataView(t.buffer, t.byteOffset, t.byteLength);
40
- }
41
- function ct(t, e) {
42
- return t << 32 - e | t >>> e;
43
- }
44
- function N(t, e) {
45
- return t << e | t >>> 32 - e >>> 0;
46
- }
47
- const Rn = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
48
- function Tn(t) {
49
- return t << 24 & 4278190080 | t << 8 & 16711680 | t >>> 8 & 65280 | t >>> 24 & 255;
50
- }
51
- const xt = Rn ? (t) => t : (t) => Tn(t);
52
- function Ss(t) {
53
- for (let e = 0; e < t.length; e++)
54
- t[e] = Tn(t[e]);
55
- return t;
56
- }
57
- const Dt = Rn ? (t) => t : Ss;
58
- function Nn(t) {
59
- if (typeof t != "string")
60
- throw new Error("string expected");
61
- return new Uint8Array(new TextEncoder().encode(t));
62
- }
63
- function Rt(t) {
64
- return typeof t == "string" && (t = Nn(t)), oe(t), t;
65
- }
66
- function fn(t) {
67
- return typeof t == "string" && (t = Nn(t)), oe(t), t;
68
- }
69
- function qn(t, e) {
70
- if (e !== void 0 && {}.toString.call(e) !== "[object Object]")
71
- throw new Error("options should be object or undefined");
72
- return Object.assign(t, e);
73
- }
74
- let Fe = class {
75
- };
76
- function Gn(t) {
77
- const e = (s) => t().update(Rt(s)).digest(), n = t();
78
- return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
79
- }
80
- function Is(t) {
81
- const e = (s, r) => t(r).update(Rt(s)).digest(), n = t({});
82
- return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = (s) => t(s), e;
83
- }
84
- const vs = /* @__PURE__ */ Uint8Array.from([
85
- 0,
86
- 1,
87
- 2,
88
- 3,
89
- 4,
90
- 5,
91
- 6,
92
- 7,
93
- 8,
94
- 9,
95
- 10,
96
- 11,
97
- 12,
98
- 13,
99
- 14,
100
- 15,
101
- 14,
102
- 10,
103
- 4,
104
- 8,
105
- 9,
106
- 15,
107
- 13,
108
- 6,
109
- 1,
110
- 12,
111
- 0,
112
- 2,
113
- 11,
114
- 7,
115
- 5,
116
- 3,
117
- 11,
118
- 8,
119
- 12,
120
- 0,
121
- 5,
122
- 2,
123
- 15,
124
- 13,
125
- 10,
126
- 14,
127
- 3,
128
- 6,
129
- 7,
130
- 1,
131
- 9,
132
- 4,
133
- 7,
134
- 9,
135
- 3,
136
- 1,
137
- 13,
138
- 12,
139
- 11,
140
- 14,
141
- 2,
142
- 6,
143
- 5,
144
- 10,
145
- 4,
146
- 0,
147
- 15,
148
- 8,
149
- 9,
150
- 0,
151
- 5,
152
- 7,
153
- 2,
154
- 4,
155
- 10,
156
- 15,
157
- 14,
158
- 1,
159
- 11,
160
- 12,
161
- 6,
162
- 8,
163
- 3,
164
- 13,
165
- 2,
166
- 12,
167
- 6,
168
- 10,
169
- 0,
170
- 11,
171
- 8,
172
- 3,
173
- 4,
174
- 13,
175
- 7,
176
- 5,
177
- 15,
178
- 14,
179
- 1,
180
- 9,
181
- 12,
182
- 5,
183
- 1,
184
- 15,
185
- 14,
186
- 13,
187
- 4,
188
- 10,
189
- 0,
190
- 7,
191
- 6,
192
- 3,
193
- 9,
194
- 2,
195
- 8,
196
- 11,
197
- 13,
198
- 11,
199
- 7,
200
- 14,
201
- 12,
202
- 1,
203
- 3,
204
- 9,
205
- 5,
206
- 0,
207
- 15,
208
- 4,
209
- 8,
210
- 6,
211
- 2,
212
- 10,
213
- 6,
214
- 15,
215
- 14,
216
- 9,
217
- 11,
218
- 3,
219
- 0,
220
- 8,
221
- 12,
222
- 2,
223
- 13,
224
- 7,
225
- 1,
226
- 4,
227
- 10,
228
- 5,
229
- 10,
230
- 2,
231
- 8,
232
- 4,
233
- 7,
234
- 6,
235
- 1,
236
- 5,
237
- 15,
238
- 11,
239
- 9,
240
- 14,
241
- 3,
242
- 12,
243
- 13,
244
- 0,
245
- 0,
246
- 1,
247
- 2,
248
- 3,
249
- 4,
250
- 5,
251
- 6,
252
- 7,
253
- 8,
254
- 9,
255
- 10,
256
- 11,
257
- 12,
258
- 13,
259
- 14,
260
- 15,
261
- 14,
262
- 10,
263
- 4,
264
- 8,
265
- 9,
266
- 15,
267
- 13,
268
- 6,
269
- 1,
270
- 12,
271
- 0,
272
- 2,
273
- 11,
274
- 7,
275
- 5,
276
- 3,
277
- // Blake1, unused in others
278
- 11,
279
- 8,
280
- 12,
281
- 0,
282
- 5,
283
- 2,
284
- 15,
285
- 13,
286
- 10,
287
- 14,
288
- 3,
289
- 6,
290
- 7,
291
- 1,
292
- 9,
293
- 4,
294
- 7,
295
- 9,
296
- 3,
297
- 1,
298
- 13,
299
- 12,
300
- 11,
301
- 14,
302
- 2,
303
- 6,
304
- 5,
305
- 10,
306
- 4,
307
- 0,
308
- 15,
309
- 8,
310
- 9,
311
- 0,
312
- 5,
313
- 7,
314
- 2,
315
- 4,
316
- 10,
317
- 15,
318
- 14,
319
- 1,
320
- 11,
321
- 12,
322
- 6,
323
- 8,
324
- 3,
325
- 13,
326
- 2,
327
- 12,
328
- 6,
329
- 10,
330
- 0,
331
- 11,
332
- 8,
333
- 3,
334
- 4,
335
- 13,
336
- 7,
337
- 5,
338
- 15,
339
- 14,
340
- 1,
341
- 9
342
- ]);
343
- function Ls(t, e, n, s) {
344
- if (typeof t.setBigUint64 == "function")
345
- return t.setBigUint64(e, n, s);
346
- const r = BigInt(32), i = BigInt(4294967295), o = Number(n >> r & i), c = Number(n & i), f = s ? 4 : 0, l = s ? 0 : 4;
347
- t.setUint32(e + f, o, s), t.setUint32(e + l, c, s);
348
- }
349
- function Us(t, e, n) {
350
- return t & e ^ ~t & n;
351
- }
352
- function $s(t, e, n) {
353
- return t & e ^ t & n ^ e & n;
354
- }
355
- let Mn = class extends Fe {
356
- constructor(e, n, s, r) {
357
- super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(e), this.view = Ae(this.buffer);
358
- }
359
- update(e) {
360
- te(this), e = Rt(e), oe(e);
361
- const { view: n, buffer: s, blockLen: r } = this, i = e.length;
362
- for (let o = 0; o < i; ) {
363
- const c = Math.min(r - this.pos, i - o);
364
- if (c === r) {
365
- const f = Ae(e);
366
- for (; r <= i - o; o += r)
367
- this.process(f, o);
368
- continue;
369
- }
370
- s.set(e.subarray(o, o + c), this.pos), this.pos += c, o += c, this.pos === r && (this.process(n, 0), this.pos = 0);
371
- }
372
- return this.length += e.length, this.roundClean(), this;
373
- }
374
- digestInto(e) {
375
- te(this), On(e, this), this.finished = !0;
376
- const { buffer: n, view: s, blockLen: r, isLE: i } = this;
377
- let { pos: o } = this;
378
- n[o++] = 128, ot(this.buffer.subarray(o)), this.padOffset > r - o && (this.process(s, 0), o = 0);
379
- for (let a = o; a < r; a++)
380
- n[a] = 0;
381
- Ls(s, r - 8, BigInt(this.length * 8), i), this.process(s, 0);
382
- const c = Ae(e), f = this.outputLen;
383
- if (f % 4)
384
- throw new Error("_sha2: outputLen should be aligned to 32bit");
385
- const l = f / 4, h = this.get();
386
- if (l > h.length)
387
- throw new Error("_sha2: outputLen bigger than state");
388
- for (let a = 0; a < l; a++)
389
- c.setUint32(4 * a, h[a], i);
390
- }
391
- digest() {
392
- const { buffer: e, outputLen: n } = this;
393
- this.digestInto(e);
394
- const s = e.slice(0, n);
395
- return this.destroy(), s;
396
- }
397
- _cloneInto(e) {
398
- e || (e = new this.constructor()), e.set(...this.get());
399
- const { blockLen: n, buffer: s, length: r, finished: i, destroyed: o, pos: c } = this;
400
- return e.destroyed = o, e.finished = i, e.length = r, e.pos = c, r % n && e.buffer.set(s), e;
401
- }
402
- clone() {
403
- return this._cloneInto();
404
- }
405
- };
406
- const yt = /* @__PURE__ */ Uint32Array.from([
407
- 1779033703,
408
- 3144134277,
409
- 1013904242,
410
- 2773480762,
411
- 1359893119,
412
- 2600822924,
413
- 528734635,
414
- 1541459225
415
- ]);
416
- const F = /* @__PURE__ */ Uint32Array.from([
417
- 1779033703,
418
- 4089235720,
419
- 3144134277,
420
- 2227873595,
421
- 1013904242,
422
- 4271175723,
423
- 2773480762,
424
- 1595750129,
425
- 1359893119,
426
- 2917565137,
427
- 2600822924,
428
- 725511199,
429
- 528734635,
430
- 4215389547,
431
- 1541459225,
432
- 327033209
433
- ]), xe = /* @__PURE__ */ BigInt(2 ** 32 - 1), an = /* @__PURE__ */ BigInt(32);
434
- function Vn(t, e = !1) {
435
- return e ? { h: Number(t & xe), l: Number(t >> an & xe) } : { h: Number(t >> an & xe) | 0, l: Number(t & xe) | 0 };
436
- }
437
- function Ds(t, e = !1) {
438
- const n = t.length;
439
- let s = new Uint32Array(n), r = new Uint32Array(n);
440
- for (let i = 0; i < n; i++) {
441
- const { h: o, l: c } = Vn(t[i], e);
442
- [s[i], r[i]] = [o, c];
443
- }
444
- return [s, r];
445
- }
446
- const hn = (t, e, n) => t >>> n, ln = (t, e, n) => t << 32 - n | e >>> n, Ct = (t, e, n) => t >>> n | e << 32 - n, kt = (t, e, n) => t << 32 - n | e >>> n, fe = (t, e, n) => t << 64 - n | e >>> n - 32, ae = (t, e, n) => t >>> n - 32 | e << 64 - n, Cs = (t, e) => e, ks = (t, e) => t;
447
- function rt(t, e, n, s) {
448
- const r = (e >>> 0) + (s >>> 0);
449
- return { h: t + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
450
- }
451
- const Pe = (t, e, n) => (t >>> 0) + (e >>> 0) + (n >>> 0), Qe = (t, e, n, s) => e + n + s + (t / 2 ** 32 | 0) | 0, Os = (t, e, n, s) => (t >>> 0) + (e >>> 0) + (n >>> 0) + (s >>> 0), Rs = (t, e, n, s, r) => e + n + s + r + (t / 2 ** 32 | 0) | 0, Ts = (t, e, n, s, r) => (t >>> 0) + (e >>> 0) + (n >>> 0) + (s >>> 0) + (r >>> 0), Ns = (t, e, n, s, r, i) => e + n + s + r + i + (t / 2 ** 32 | 0) | 0, j = /* @__PURE__ */ Uint32Array.from([
452
- 4089235720,
453
- 1779033703,
454
- 2227873595,
455
- 3144134277,
456
- 4271175723,
457
- 1013904242,
458
- 1595750129,
459
- 2773480762,
460
- 2917565137,
461
- 1359893119,
462
- 725511199,
463
- 2600822924,
464
- 4215389547,
465
- 528734635,
466
- 327033209,
467
- 1541459225
468
- ]), v = /* @__PURE__ */ new Uint32Array(32);
469
- function pt(t, e, n, s, r, i) {
470
- const o = r[i], c = r[i + 1];
471
- let f = v[2 * t], l = v[2 * t + 1], h = v[2 * e], a = v[2 * e + 1], d = v[2 * n], u = v[2 * n + 1], y = v[2 * s], b = v[2 * s + 1], w = Pe(f, h, o);
472
- l = Qe(w, l, a, c), f = w | 0, { Dh: b, Dl: y } = { Dh: b ^ l, Dl: y ^ f }, { Dh: b, Dl: y } = { Dh: Cs(b, y), Dl: ks(b) }, { h: u, l: d } = rt(u, d, b, y), { Bh: a, Bl: h } = { Bh: a ^ u, Bl: h ^ d }, { Bh: a, Bl: h } = { Bh: Ct(a, h, 24), Bl: kt(a, h, 24) }, v[2 * t] = f, v[2 * t + 1] = l, v[2 * e] = h, v[2 * e + 1] = a, v[2 * n] = d, v[2 * n + 1] = u, v[2 * s] = y, v[2 * s + 1] = b;
473
- }
474
- function mt(t, e, n, s, r, i) {
475
- const o = r[i], c = r[i + 1];
476
- let f = v[2 * t], l = v[2 * t + 1], h = v[2 * e], a = v[2 * e + 1], d = v[2 * n], u = v[2 * n + 1], y = v[2 * s], b = v[2 * s + 1], w = Pe(f, h, o);
477
- l = Qe(w, l, a, c), f = w | 0, { Dh: b, Dl: y } = { Dh: b ^ l, Dl: y ^ f }, { Dh: b, Dl: y } = { Dh: Ct(b, y, 16), Dl: kt(b, y, 16) }, { h: u, l: d } = rt(u, d, b, y), { Bh: a, Bl: h } = { Bh: a ^ u, Bl: h ^ d }, { Bh: a, Bl: h } = { Bh: fe(a, h, 63), Bl: ae(a, h, 63) }, v[2 * t] = f, v[2 * t + 1] = l, v[2 * e] = h, v[2 * e + 1] = a, v[2 * n] = d, v[2 * n + 1] = u, v[2 * s] = y, v[2 * s + 1] = b;
478
- }
479
- function qs(t, e = {}, n, s, r) {
480
- if (et(n), t < 0 || t > n)
481
- throw new Error("outputLen bigger than keyLen");
482
- const { key: i, salt: o, personalization: c } = e;
483
- if (i !== void 0 && (i.length < 1 || i.length > n))
484
- throw new Error("key length must be undefined or 1.." + n);
485
- if (o !== void 0 && o.length !== s)
486
- throw new Error("salt must be undefined or " + s);
487
- if (c !== void 0 && c.length !== r)
488
- throw new Error("personalization must be undefined or " + r);
489
- }
490
- class Gs extends Fe {
491
- constructor(e, n) {
492
- super(), this.finished = !1, this.destroyed = !1, this.length = 0, this.pos = 0, et(e), et(n), this.blockLen = e, this.outputLen = n, this.buffer = new Uint8Array(e), this.buffer32 = Gt(this.buffer);
493
- }
494
- update(e) {
495
- te(this), e = Rt(e), oe(e);
496
- const { blockLen: n, buffer: s, buffer32: r } = this, i = e.length, o = e.byteOffset, c = e.buffer;
497
- for (let f = 0; f < i; ) {
498
- this.pos === n && (Dt(r), this.compress(r, 0, !1), Dt(r), this.pos = 0);
499
- const l = Math.min(n - this.pos, i - f), h = o + f;
500
- if (l === n && !(h % 4) && f + l < i) {
501
- const a = new Uint32Array(c, h, Math.floor((i - f) / 4));
502
- Dt(a);
503
- for (let d = 0; f + n < i; d += r.length, f += n)
504
- this.length += n, this.compress(a, d, !1);
505
- Dt(a);
506
- continue;
507
- }
508
- s.set(e.subarray(f, f + l), this.pos), this.pos += l, this.length += l, f += l;
509
- }
510
- return this;
511
- }
512
- digestInto(e) {
513
- te(this), On(e, this);
514
- const { pos: n, buffer32: s } = this;
515
- this.finished = !0, ot(this.buffer.subarray(n)), Dt(s), this.compress(s, 0, !0), Dt(s);
516
- const r = Gt(e);
517
- this.get().forEach((i, o) => r[o] = xt(i));
518
- }
519
- digest() {
520
- const { buffer: e, outputLen: n } = this;
521
- this.digestInto(e);
522
- const s = e.slice(0, n);
523
- return this.destroy(), s;
524
- }
525
- _cloneInto(e) {
526
- const { buffer: n, length: s, finished: r, destroyed: i, outputLen: o, pos: c } = this;
527
- return e || (e = new this.constructor({ dkLen: o })), e.set(...this.get()), e.buffer.set(n), e.destroyed = i, e.finished = r, e.length = s, e.pos = c, e.outputLen = o, e;
528
- }
529
- clone() {
530
- return this._cloneInto();
531
- }
532
- }
533
- class Ms extends Gs {
534
- constructor(e = {}) {
535
- const n = e.dkLen === void 0 ? 64 : e.dkLen;
536
- super(128, n), this.v0l = j[0] | 0, this.v0h = j[1] | 0, this.v1l = j[2] | 0, this.v1h = j[3] | 0, this.v2l = j[4] | 0, this.v2h = j[5] | 0, this.v3l = j[6] | 0, this.v3h = j[7] | 0, this.v4l = j[8] | 0, this.v4h = j[9] | 0, this.v5l = j[10] | 0, this.v5h = j[11] | 0, this.v6l = j[12] | 0, this.v6h = j[13] | 0, this.v7l = j[14] | 0, this.v7h = j[15] | 0, qs(n, e, 64, 16, 16);
537
- let { key: s, personalization: r, salt: i } = e, o = 0;
538
- if (s !== void 0 && (s = Rt(s), o = s.length), this.v0l ^= this.outputLen | o << 8 | 65536 | 1 << 24, i !== void 0) {
539
- i = Rt(i);
540
- const c = Gt(i);
541
- this.v4l ^= xt(c[0]), this.v4h ^= xt(c[1]), this.v5l ^= xt(c[2]), this.v5h ^= xt(c[3]);
542
- }
543
- if (r !== void 0) {
544
- r = Rt(r);
545
- const c = Gt(r);
546
- this.v6l ^= xt(c[0]), this.v6h ^= xt(c[1]), this.v7l ^= xt(c[2]), this.v7h ^= xt(c[3]);
547
- }
548
- if (s !== void 0) {
549
- const c = new Uint8Array(this.blockLen);
550
- c.set(s), this.update(c);
551
- }
552
- }
553
- // prettier-ignore
554
- get() {
555
- let { v0l: e, v0h: n, v1l: s, v1h: r, v2l: i, v2h: o, v3l: c, v3h: f, v4l: l, v4h: h, v5l: a, v5h: d, v6l: u, v6h: y, v7l: b, v7h: w } = this;
556
- return [e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w];
557
- }
558
- // prettier-ignore
559
- set(e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w) {
560
- this.v0l = e | 0, this.v0h = n | 0, this.v1l = s | 0, this.v1h = r | 0, this.v2l = i | 0, this.v2h = o | 0, this.v3l = c | 0, this.v3h = f | 0, this.v4l = l | 0, this.v4h = h | 0, this.v5l = a | 0, this.v5h = d | 0, this.v6l = u | 0, this.v6h = y | 0, this.v7l = b | 0, this.v7h = w | 0;
561
- }
562
- compress(e, n, s) {
563
- this.get().forEach((f, l) => v[l] = f), v.set(j, 16);
564
- let { h: r, l: i } = Vn(BigInt(this.length));
565
- v[24] = j[8] ^ i, v[25] = j[9] ^ r, s && (v[28] = ~v[28], v[29] = ~v[29]);
566
- let o = 0;
567
- const c = vs;
568
- for (let f = 0; f < 12; f++)
569
- pt(0, 4, 8, 12, e, n + 2 * c[o++]), mt(0, 4, 8, 12, e, n + 2 * c[o++]), pt(1, 5, 9, 13, e, n + 2 * c[o++]), mt(1, 5, 9, 13, e, n + 2 * c[o++]), pt(2, 6, 10, 14, e, n + 2 * c[o++]), mt(2, 6, 10, 14, e, n + 2 * c[o++]), pt(3, 7, 11, 15, e, n + 2 * c[o++]), mt(3, 7, 11, 15, e, n + 2 * c[o++]), pt(0, 5, 10, 15, e, n + 2 * c[o++]), mt(0, 5, 10, 15, e, n + 2 * c[o++]), pt(1, 6, 11, 12, e, n + 2 * c[o++]), mt(1, 6, 11, 12, e, n + 2 * c[o++]), pt(2, 7, 8, 13, e, n + 2 * c[o++]), mt(2, 7, 8, 13, e, n + 2 * c[o++]), pt(3, 4, 9, 14, e, n + 2 * c[o++]), mt(3, 4, 9, 14, e, n + 2 * c[o++]);
570
- this.v0l ^= v[0] ^ v[16], this.v0h ^= v[1] ^ v[17], this.v1l ^= v[2] ^ v[18], this.v1h ^= v[3] ^ v[19], this.v2l ^= v[4] ^ v[20], this.v2h ^= v[5] ^ v[21], this.v3l ^= v[6] ^ v[22], this.v3h ^= v[7] ^ v[23], this.v4l ^= v[8] ^ v[24], this.v4h ^= v[9] ^ v[25], this.v5l ^= v[10] ^ v[26], this.v5h ^= v[11] ^ v[27], this.v6l ^= v[12] ^ v[28], this.v6h ^= v[13] ^ v[29], this.v7l ^= v[14] ^ v[30], this.v7h ^= v[15] ^ v[31], ot(v);
571
- }
572
- destroy() {
573
- this.destroyed = !0, ot(this.buffer32), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
574
- }
575
- }
576
- const Vs = /* @__PURE__ */ Is((t) => new Ms(t));
577
- const ri = Vs;
578
- let Zn = class extends Fe {
579
- constructor(e, n) {
580
- super(), this.finished = !1, this.destroyed = !1, kn(e);
581
- const s = Rt(n);
582
- if (this.iHash = e.create(), typeof this.iHash.update != "function")
583
- throw new Error("Expected instance of class which extends utils.Hash");
584
- this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
585
- const r = this.blockLen, i = new Uint8Array(r);
586
- i.set(s.length > r ? e.create().update(s).digest() : s);
587
- for (let o = 0; o < i.length; o++)
588
- i[o] ^= 54;
589
- this.iHash.update(i), this.oHash = e.create();
590
- for (let o = 0; o < i.length; o++)
591
- i[o] ^= 106;
592
- this.oHash.update(i), ot(i);
593
- }
594
- update(e) {
595
- return te(this), this.iHash.update(e), this;
596
- }
597
- digestInto(e) {
598
- te(this), oe(e, this.outputLen), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
599
- }
600
- digest() {
601
- const e = new Uint8Array(this.oHash.outputLen);
602
- return this.digestInto(e), e;
603
- }
604
- _cloneInto(e) {
605
- e || (e = Object.create(Object.getPrototypeOf(this), {}));
606
- const { oHash: n, iHash: s, finished: r, destroyed: i, blockLen: o, outputLen: c } = this;
607
- return e = e, e.finished = r, e.destroyed = i, e.blockLen = o, e.outputLen = c, e.oHash = n._cloneInto(e.oHash), e.iHash = s._cloneInto(e.iHash), e;
608
- }
609
- clone() {
610
- return this._cloneInto();
611
- }
612
- destroy() {
613
- this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
614
- }
615
- };
616
- const zn = (t, e, n) => new Zn(t, e).update(n).digest();
617
- zn.create = (t, e) => new Zn(t, e);
618
- function Zs(t, e, n, s) {
619
- kn(t);
620
- const r = qn({ dkLen: 32, asyncTick: 10 }, s), { c: i, dkLen: o, asyncTick: c } = r;
621
- if (et(i), et(o), et(c), i < 1)
622
- throw new Error("iterations (c) should be >= 1");
623
- const f = fn(e), l = fn(n), h = new Uint8Array(o), a = zn.create(t, f), d = a._cloneInto().update(l);
624
- return { c: i, dkLen: o, asyncTick: c, DK: h, PRF: a, PRFSalt: d };
625
- }
626
- function zs(t, e, n, s, r) {
627
- return t.destroy(), e.destroy(), s && s.destroy(), ot(r), n;
628
- }
629
- function jn(t, e, n, s) {
630
- const { c: r, dkLen: i, DK: o, PRF: c, PRFSalt: f } = Zs(t, e, n, s);
631
- let l;
632
- const h = new Uint8Array(4), a = Ae(h), d = new Uint8Array(c.outputLen);
633
- for (let u = 1, y = 0; y < i; u++, y += c.outputLen) {
634
- const b = o.subarray(y, y + c.outputLen);
635
- a.setInt32(0, u, !1), (l = f._cloneInto(l)).update(h).digestInto(d), b.set(d.subarray(0, b.length));
636
- for (let w = 1; w < r; w++) {
637
- c._cloneInto(l).update(d).digestInto(d);
638
- for (let _ = 0; _ < b.length; _++)
639
- b[_] ^= d[_];
640
- }
641
- }
642
- return zs(c, f, o, l, d);
643
- }
644
- const js = /* @__PURE__ */ Uint32Array.from([
645
- 1116352408,
646
- 1899447441,
647
- 3049323471,
648
- 3921009573,
649
- 961987163,
650
- 1508970993,
651
- 2453635748,
652
- 2870763221,
653
- 3624381080,
654
- 310598401,
655
- 607225278,
656
- 1426881987,
657
- 1925078388,
658
- 2162078206,
659
- 2614888103,
660
- 3248222580,
661
- 3835390401,
662
- 4022224774,
663
- 264347078,
664
- 604807628,
665
- 770255983,
666
- 1249150122,
667
- 1555081692,
668
- 1996064986,
669
- 2554220882,
670
- 2821834349,
671
- 2952996808,
672
- 3210313671,
673
- 3336571891,
674
- 3584528711,
675
- 113926993,
676
- 338241895,
677
- 666307205,
678
- 773529912,
679
- 1294757372,
680
- 1396182291,
681
- 1695183700,
682
- 1986661051,
683
- 2177026350,
684
- 2456956037,
685
- 2730485921,
686
- 2820302411,
687
- 3259730800,
688
- 3345764771,
689
- 3516065817,
690
- 3600352804,
691
- 4094571909,
692
- 275423344,
693
- 430227734,
694
- 506948616,
695
- 659060556,
696
- 883997877,
697
- 958139571,
698
- 1322822218,
699
- 1537002063,
700
- 1747873779,
701
- 1955562222,
702
- 2024104815,
703
- 2227730452,
704
- 2361852424,
705
- 2428436474,
706
- 2756734187,
707
- 3204031479,
708
- 3329325298
709
- ]), Bt = /* @__PURE__ */ new Uint32Array(64);
710
- let Ws = class extends Mn {
711
- constructor(e = 32) {
712
- super(64, e, 8, !1), this.A = yt[0] | 0, this.B = yt[1] | 0, this.C = yt[2] | 0, this.D = yt[3] | 0, this.E = yt[4] | 0, this.F = yt[5] | 0, this.G = yt[6] | 0, this.H = yt[7] | 0;
713
- }
714
- get() {
715
- const { A: e, B: n, C: s, D: r, E: i, F: o, G: c, H: f } = this;
716
- return [e, n, s, r, i, o, c, f];
717
- }
718
- // prettier-ignore
719
- set(e, n, s, r, i, o, c, f) {
720
- this.A = e | 0, this.B = n | 0, this.C = s | 0, this.D = r | 0, this.E = i | 0, this.F = o | 0, this.G = c | 0, this.H = f | 0;
721
- }
722
- process(e, n) {
723
- for (let a = 0; a < 16; a++, n += 4)
724
- Bt[a] = e.getUint32(n, !1);
725
- for (let a = 16; a < 64; a++) {
726
- const d = Bt[a - 15], u = Bt[a - 2], y = ct(d, 7) ^ ct(d, 18) ^ d >>> 3, b = ct(u, 17) ^ ct(u, 19) ^ u >>> 10;
727
- Bt[a] = b + Bt[a - 7] + y + Bt[a - 16] | 0;
728
- }
729
- let { A: s, B: r, C: i, D: o, E: c, F: f, G: l, H: h } = this;
730
- for (let a = 0; a < 64; a++) {
731
- const d = ct(c, 6) ^ ct(c, 11) ^ ct(c, 25), u = h + d + Us(c, f, l) + js[a] + Bt[a] | 0, b = (ct(s, 2) ^ ct(s, 13) ^ ct(s, 22)) + $s(s, r, i) | 0;
732
- h = l, l = f, f = c, c = o + u | 0, o = i, i = r, r = s, s = u + b | 0;
733
- }
734
- s = s + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, h = h + this.H | 0, this.set(s, r, i, o, c, f, l, h);
735
- }
736
- roundClean() {
737
- ot(Bt);
738
- }
739
- destroy() {
740
- this.set(0, 0, 0, 0, 0, 0, 0, 0), ot(this.buffer);
741
- }
742
- };
743
- const Wn = Ds([
744
- "0x428a2f98d728ae22",
745
- "0x7137449123ef65cd",
746
- "0xb5c0fbcfec4d3b2f",
747
- "0xe9b5dba58189dbbc",
748
- "0x3956c25bf348b538",
749
- "0x59f111f1b605d019",
750
- "0x923f82a4af194f9b",
751
- "0xab1c5ed5da6d8118",
752
- "0xd807aa98a3030242",
753
- "0x12835b0145706fbe",
754
- "0x243185be4ee4b28c",
755
- "0x550c7dc3d5ffb4e2",
756
- "0x72be5d74f27b896f",
757
- "0x80deb1fe3b1696b1",
758
- "0x9bdc06a725c71235",
759
- "0xc19bf174cf692694",
760
- "0xe49b69c19ef14ad2",
761
- "0xefbe4786384f25e3",
762
- "0x0fc19dc68b8cd5b5",
763
- "0x240ca1cc77ac9c65",
764
- "0x2de92c6f592b0275",
765
- "0x4a7484aa6ea6e483",
766
- "0x5cb0a9dcbd41fbd4",
767
- "0x76f988da831153b5",
768
- "0x983e5152ee66dfab",
769
- "0xa831c66d2db43210",
770
- "0xb00327c898fb213f",
771
- "0xbf597fc7beef0ee4",
772
- "0xc6e00bf33da88fc2",
773
- "0xd5a79147930aa725",
774
- "0x06ca6351e003826f",
775
- "0x142929670a0e6e70",
776
- "0x27b70a8546d22ffc",
777
- "0x2e1b21385c26c926",
778
- "0x4d2c6dfc5ac42aed",
779
- "0x53380d139d95b3df",
780
- "0x650a73548baf63de",
781
- "0x766a0abb3c77b2a8",
782
- "0x81c2c92e47edaee6",
783
- "0x92722c851482353b",
784
- "0xa2bfe8a14cf10364",
785
- "0xa81a664bbc423001",
786
- "0xc24b8b70d0f89791",
787
- "0xc76c51a30654be30",
788
- "0xd192e819d6ef5218",
789
- "0xd69906245565a910",
790
- "0xf40e35855771202a",
791
- "0x106aa07032bbd1b8",
792
- "0x19a4c116b8d2d0c8",
793
- "0x1e376c085141ab53",
794
- "0x2748774cdf8eeb99",
795
- "0x34b0bcb5e19b48a8",
796
- "0x391c0cb3c5c95a63",
797
- "0x4ed8aa4ae3418acb",
798
- "0x5b9cca4f7763e373",
799
- "0x682e6ff3d6b2b8a3",
800
- "0x748f82ee5defb2fc",
801
- "0x78a5636f43172f60",
802
- "0x84c87814a1f0ab72",
803
- "0x8cc702081a6439ec",
804
- "0x90befffa23631e28",
805
- "0xa4506cebde82bde9",
806
- "0xbef9a3f7b2c67915",
807
- "0xc67178f2e372532b",
808
- "0xca273eceea26619c",
809
- "0xd186b8c721c0c207",
810
- "0xeada7dd6cde0eb1e",
811
- "0xf57d4f7fee6ed178",
812
- "0x06f067aa72176fba",
813
- "0x0a637dc5a2c898a6",
814
- "0x113f9804bef90dae",
815
- "0x1b710b35131c471b",
816
- "0x28db77f523047d84",
817
- "0x32caab7b40c72493",
818
- "0x3c9ebe0a15c9bebc",
819
- "0x431d67c49c100d4c",
820
- "0x4cc5d4becb3e42b6",
821
- "0x597f299cfc657e2a",
822
- "0x5fcb6fab3ad6faec",
823
- "0x6c44198c4a475817"
824
- ].map((t) => BigInt(t))), Ks = Wn[0], Ys = Wn[1], Et = /* @__PURE__ */ new Uint32Array(80), At = /* @__PURE__ */ new Uint32Array(80);
825
- let Xs = class extends Mn {
826
- constructor(e = 64) {
827
- super(128, e, 16, !1), this.Ah = F[0] | 0, this.Al = F[1] | 0, this.Bh = F[2] | 0, this.Bl = F[3] | 0, this.Ch = F[4] | 0, this.Cl = F[5] | 0, this.Dh = F[6] | 0, this.Dl = F[7] | 0, this.Eh = F[8] | 0, this.El = F[9] | 0, this.Fh = F[10] | 0, this.Fl = F[11] | 0, this.Gh = F[12] | 0, this.Gl = F[13] | 0, this.Hh = F[14] | 0, this.Hl = F[15] | 0;
828
- }
829
- // prettier-ignore
830
- get() {
831
- const { Ah: e, Al: n, Bh: s, Bl: r, Ch: i, Cl: o, Dh: c, Dl: f, Eh: l, El: h, Fh: a, Fl: d, Gh: u, Gl: y, Hh: b, Hl: w } = this;
832
- return [e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w];
833
- }
834
- // prettier-ignore
835
- set(e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w) {
836
- this.Ah = e | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = i | 0, this.Cl = o | 0, this.Dh = c | 0, this.Dl = f | 0, this.Eh = l | 0, this.El = h | 0, this.Fh = a | 0, this.Fl = d | 0, this.Gh = u | 0, this.Gl = y | 0, this.Hh = b | 0, this.Hl = w | 0;
837
- }
838
- process(e, n) {
839
- for (let p = 0; p < 16; p++, n += 4)
840
- Et[p] = e.getUint32(n), At[p] = e.getUint32(n += 4);
841
- for (let p = 16; p < 80; p++) {
842
- const D = Et[p - 15] | 0, m = At[p - 15] | 0, U = Ct(D, m, 1) ^ Ct(D, m, 8) ^ hn(D, m, 7), C = kt(D, m, 1) ^ kt(D, m, 8) ^ ln(D, m, 7), H = Et[p - 2] | 0, x = At[p - 2] | 0, E = Ct(H, x, 19) ^ fe(H, x, 61) ^ hn(H, x, 6), g = kt(H, x, 19) ^ ae(H, x, 61) ^ ln(H, x, 6), B = Os(C, g, At[p - 7], At[p - 16]), A = Rs(B, U, E, Et[p - 7], Et[p - 16]);
843
- Et[p] = A | 0, At[p] = B | 0;
844
- }
845
- let { Ah: s, Al: r, Bh: i, Bl: o, Ch: c, Cl: f, Dh: l, Dl: h, Eh: a, El: d, Fh: u, Fl: y, Gh: b, Gl: w, Hh: _, Hl: L } = this;
846
- for (let p = 0; p < 80; p++) {
847
- const D = Ct(a, d, 14) ^ Ct(a, d, 18) ^ fe(a, d, 41), m = kt(a, d, 14) ^ kt(a, d, 18) ^ ae(a, d, 41), U = a & u ^ ~a & b, C = d & y ^ ~d & w, H = Ts(L, m, C, Ys[p], At[p]), x = Ns(H, _, D, U, Ks[p], Et[p]), E = H | 0, g = Ct(s, r, 28) ^ fe(s, r, 34) ^ fe(s, r, 39), B = kt(s, r, 28) ^ ae(s, r, 34) ^ ae(s, r, 39), A = s & i ^ s & c ^ i & c, I = r & o ^ r & f ^ o & f;
848
- _ = b | 0, L = w | 0, b = u | 0, w = y | 0, u = a | 0, y = d | 0, { h: a, l: d } = rt(l | 0, h | 0, x | 0, E | 0), l = c | 0, h = f | 0, c = i | 0, f = o | 0, i = s | 0, o = r | 0;
849
- const S = Pe(E, B, I);
850
- s = Qe(S, x, g, A), r = S | 0;
851
- }
852
- ({ h: s, l: r } = rt(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: i, l: o } = rt(this.Bh | 0, this.Bl | 0, i | 0, o | 0), { h: c, l: f } = rt(this.Ch | 0, this.Cl | 0, c | 0, f | 0), { h: l, l: h } = rt(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: a, l: d } = rt(this.Eh | 0, this.El | 0, a | 0, d | 0), { h: u, l: y } = rt(this.Fh | 0, this.Fl | 0, u | 0, y | 0), { h: b, l: w } = rt(this.Gh | 0, this.Gl | 0, b | 0, w | 0), { h: _, l: L } = rt(this.Hh | 0, this.Hl | 0, _ | 0, L | 0), this.set(s, r, i, o, c, f, l, h, a, d, u, y, b, w, _, L);
853
- }
854
- roundClean() {
855
- ot(Et, At);
856
- }
857
- destroy() {
858
- ot(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
859
- }
860
- };
861
- const Je = /* @__PURE__ */ Gn(() => new Ws()), Fs = /* @__PURE__ */ Gn(() => new Xs());
862
- function dn(t, e, n, s, r, i) {
863
- let o = t[e++] ^ n[s++], c = t[e++] ^ n[s++], f = t[e++] ^ n[s++], l = t[e++] ^ n[s++], h = t[e++] ^ n[s++], a = t[e++] ^ n[s++], d = t[e++] ^ n[s++], u = t[e++] ^ n[s++], y = t[e++] ^ n[s++], b = t[e++] ^ n[s++], w = t[e++] ^ n[s++], _ = t[e++] ^ n[s++], L = t[e++] ^ n[s++], p = t[e++] ^ n[s++], D = t[e++] ^ n[s++], m = t[e++] ^ n[s++], U = o, C = c, H = f, x = l, E = h, g = a, B = d, A = u, I = y, S = b, $ = w, O = _, k = L, q = p, T = D, R = m;
864
- for (let M = 0; M < 8; M += 2)
865
- E ^= N(U + k | 0, 7), I ^= N(E + U | 0, 9), k ^= N(I + E | 0, 13), U ^= N(k + I | 0, 18), S ^= N(g + C | 0, 7), q ^= N(S + g | 0, 9), C ^= N(q + S | 0, 13), g ^= N(C + q | 0, 18), T ^= N($ + B | 0, 7), H ^= N(T + $ | 0, 9), B ^= N(H + T | 0, 13), $ ^= N(B + H | 0, 18), x ^= N(R + O | 0, 7), A ^= N(x + R | 0, 9), O ^= N(A + x | 0, 13), R ^= N(O + A | 0, 18), C ^= N(U + x | 0, 7), H ^= N(C + U | 0, 9), x ^= N(H + C | 0, 13), U ^= N(x + H | 0, 18), B ^= N(g + E | 0, 7), A ^= N(B + g | 0, 9), E ^= N(A + B | 0, 13), g ^= N(E + A | 0, 18), O ^= N($ + S | 0, 7), I ^= N(O + $ | 0, 9), S ^= N(I + O | 0, 13), $ ^= N(S + I | 0, 18), k ^= N(R + T | 0, 7), q ^= N(k + R | 0, 9), T ^= N(q + k | 0, 13), R ^= N(T + q | 0, 18);
866
- r[i++] = o + U | 0, r[i++] = c + C | 0, r[i++] = f + H | 0, r[i++] = l + x | 0, r[i++] = h + E | 0, r[i++] = a + g | 0, r[i++] = d + B | 0, r[i++] = u + A | 0, r[i++] = y + I | 0, r[i++] = b + S | 0, r[i++] = w + $ | 0, r[i++] = _ + O | 0, r[i++] = L + k | 0, r[i++] = p + q | 0, r[i++] = D + T | 0, r[i++] = m + R | 0;
867
- }
868
- function Ce(t, e, n, s, r) {
869
- let i = s + 0, o = s + 16 * r;
870
- for (let c = 0; c < 16; c++)
871
- n[o + c] = t[e + (2 * r - 1) * 16 + c];
872
- for (let c = 0; c < r; c++, i += 16, e += 16)
873
- dn(n, o, t, e, n, i), c > 0 && (o += 16), dn(n, i, t, e += 16, n, o);
874
- }
875
- function Ps(t, e, n) {
876
- const s = qn({
877
- dkLen: 32,
878
- asyncTick: 10,
879
- maxmem: 1073742848
880
- }, n), { N: r, r: i, p: o, dkLen: c, asyncTick: f, maxmem: l, onProgress: h } = s;
881
- if (et(r), et(i), et(o), et(c), et(f), et(l), h !== void 0 && typeof h != "function")
882
- throw new Error("progressCb should be function");
883
- const a = 128 * i, d = a / 4, u = Math.pow(2, 32);
884
- if (r <= 1 || (r & r - 1) !== 0 || r > u)
885
- throw new Error("Scrypt: N must be larger than 1, a power of 2, and less than 2^32");
886
- if (o < 0 || o > (u - 1) * 32 / a)
887
- throw new Error("Scrypt: p must be a positive integer less than or equal to ((2^32 - 1) * 32) / (128 * r)");
888
- if (c < 0 || c > (u - 1) * 32)
889
- throw new Error("Scrypt: dkLen should be positive integer less than or equal to (2^32 - 1) * 32");
890
- if (a * (r + o) > l)
891
- throw new Error("Scrypt: memused is bigger than maxMem. Expected 128 * r * (N + p) > maxmem of " + l);
892
- const b = jn(Je, t, e, { c: 1, dkLen: a * o }), w = Gt(b), _ = Gt(new Uint8Array(a * r)), L = Gt(new Uint8Array(a));
893
- let p = () => {
894
- };
895
- if (h) {
896
- const D = 2 * r * o, m = Math.max(Math.floor(D / 1e4), 1);
897
- let U = 0;
898
- p = () => {
899
- U++, h && (!(U % m) || U === D) && h(U / D);
900
- };
901
- }
902
- return { N: r, r: i, p: o, dkLen: c, blockSize32: d, V: _, B32: w, B: b, tmp: L, blockMixCb: p, asyncTick: f };
903
- }
904
- function Qs(t, e, n, s, r) {
905
- const i = jn(Je, t, n, { c: 1, dkLen: e });
906
- return ot(n, s, r), i;
907
- }
908
- function fi(t, e, n) {
909
- const { N: s, r, p: i, dkLen: o, blockSize32: c, V: f, B32: l, B: h, tmp: a, blockMixCb: d } = Ps(t, e, n);
910
- Dt(l);
911
- for (let u = 0; u < i; u++) {
912
- const y = c * u;
913
- for (let b = 0; b < c; b++)
914
- f[b] = l[y + b];
915
- for (let b = 0, w = 0; b < s - 1; b++)
916
- Ce(f, w, f, w += c, r), d();
917
- Ce(f, (s - 1) * c, l, y, r), d();
918
- for (let b = 0; b < s; b++) {
919
- const w = l[y + c - 16] % s;
920
- for (let _ = 0; _ < c; _++)
921
- a[_] = l[y + _] ^ f[w * c + _];
922
- Ce(a, 0, l, y, r), d();
923
- }
924
- }
925
- return Dt(l), Qs(t, o, h, f, a);
926
- }
927
- const Wt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
928
- function tn(t) {
929
- return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
930
- }
931
- function ze(t) {
932
- if (!Number.isSafeInteger(t) || t < 0)
933
- throw new Error("positive integer expected, got " + t);
934
- }
935
- function it(t, ...e) {
936
- if (!tn(t))
937
- throw new Error("Uint8Array expected");
938
- if (e.length > 0 && !e.includes(t.length))
939
- throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
940
- }
941
- function Js(t) {
942
- if (typeof t != "function" || typeof t.create != "function")
943
- throw new Error("Hash should be wrapped by utils.createHasher");
944
- ze(t.outputLen), ze(t.blockLen);
945
- }
946
- function _e(t, e = !0) {
947
- if (t.destroyed)
948
- throw new Error("Hash instance has been destroyed");
949
- if (e && t.finished)
950
- throw new Error("Hash#digest() has already been called");
951
- }
952
- function tr(t, e) {
953
- it(t);
954
- const n = e.outputLen;
955
- if (t.length < n)
956
- throw new Error("digestInto() expects output buffer of length at least " + n);
957
- }
958
- function ee(...t) {
959
- for (let e = 0; e < t.length; e++)
960
- t[e].fill(0);
961
- }
962
- function ke(t) {
963
- return new DataView(t.buffer, t.byteOffset, t.byteLength);
964
- }
965
- function ft(t, e) {
966
- return t << 32 - e | t >>> e;
967
- }
968
- const Kn = /* @ts-ignore */ typeof Uint8Array.from([]).toHex == "function" && typeof Uint8Array.fromHex == "function", er = /* @__PURE__ */ Array.from({ length: 256 }, (t, e) => e.toString(16).padStart(2, "0"));
969
- function Mt(t) {
970
- if (it(t), Kn)
971
- return t.toHex();
972
- let e = "";
973
- for (let n = 0; n < t.length; n++)
974
- e += er[t[n]];
975
- return e;
976
- }
977
- const lt = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
978
- function un(t) {
979
- if (t >= lt._0 && t <= lt._9)
980
- return t - lt._0;
981
- if (t >= lt.A && t <= lt.F)
982
- return t - (lt.A - 10);
983
- if (t >= lt.a && t <= lt.f)
984
- return t - (lt.a - 10);
985
- }
986
- function en(t) {
987
- if (typeof t != "string")
988
- throw new Error("hex string expected, got " + typeof t);
989
- if (Kn)
990
- return Uint8Array.fromHex(t);
991
- const e = t.length, n = e / 2;
992
- if (e % 2)
993
- throw new Error("hex string expected, got unpadded hex of length " + e);
994
- const s = new Uint8Array(n);
995
- for (let r = 0, i = 0; r < n; r++, i += 2) {
996
- const o = un(t.charCodeAt(i)), c = un(t.charCodeAt(i + 1));
997
- if (o === void 0 || c === void 0) {
998
- const f = t[i] + t[i + 1];
999
- throw new Error('hex string expected, got non-hex character "' + f + '" at index ' + i);
1000
- }
1001
- s[r] = o * 16 + c;
1002
- }
1003
- return s;
1004
- }
1005
- function nr(t) {
1006
- if (typeof t != "string")
1007
- throw new Error("string expected");
1008
- return new Uint8Array(new TextEncoder().encode(t));
1009
- }
1010
- function nn(t) {
1011
- return typeof t == "string" && (t = nr(t)), it(t), t;
1012
- }
1013
- function wt(...t) {
1014
- let e = 0;
1015
- for (let s = 0; s < t.length; s++) {
1016
- const r = t[s];
1017
- it(r), e += r.length;
1018
- }
1019
- const n = new Uint8Array(e);
1020
- for (let s = 0, r = 0; s < t.length; s++) {
1021
- const i = t[s];
1022
- n.set(i, r), r += i.length;
1023
- }
1024
- return n;
1025
- }
1026
- let Yn = class {
1027
- };
1028
- function Xn(t) {
1029
- const e = (s) => t().update(nn(s)).digest(), n = t();
1030
- return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
1031
- }
1032
- function Fn(t = 32) {
1033
- if (Wt && typeof Wt.getRandomValues == "function")
1034
- return Wt.getRandomValues(new Uint8Array(t));
1035
- if (Wt && typeof Wt.randomBytes == "function")
1036
- return Uint8Array.from(Wt.randomBytes(t));
1037
- throw new Error("crypto.getRandomValues must be defined");
1038
- }
1039
- const sn = /* @__PURE__ */ BigInt(0), je = /* @__PURE__ */ BigInt(1);
1040
- function Vt(t, e) {
1041
- if (typeof e != "boolean")
1042
- throw new Error(t + " boolean expected, got " + e);
1043
- }
1044
- function be(t) {
1045
- const e = t.toString(16);
1046
- return e.length & 1 ? "0" + e : e;
1047
- }
1048
- function Pn(t) {
1049
- if (typeof t != "string")
1050
- throw new Error("hex string expected, got " + typeof t);
1051
- return t === "" ? sn : BigInt("0x" + t);
1052
- }
1053
- function ve(t) {
1054
- return Pn(Mt(t));
1055
- }
1056
- function ne(t) {
1057
- return it(t), Pn(Mt(Uint8Array.from(t).reverse()));
1058
- }
1059
- function rn(t, e) {
1060
- return en(t.toString(16).padStart(e * 2, "0"));
1061
- }
1062
- function se(t, e) {
1063
- return rn(t, e).reverse();
1064
- }
1065
- function V(t, e, n) {
1066
- let s;
1067
- if (typeof e == "string")
1068
- try {
1069
- s = en(e);
1070
- } catch (i) {
1071
- throw new Error(t + " must be hex string or Uint8Array, cause: " + i);
1072
- }
1073
- else if (tn(e))
1074
- s = Uint8Array.from(e);
1075
- else
1076
- throw new Error(t + " must be hex string or Uint8Array");
1077
- const r = s.length;
1078
- if (typeof n == "number" && r !== n)
1079
- throw new Error(t + " of length " + n + " expected, got " + r);
1080
- return s;
1081
- }
1082
- function sr(t, e) {
1083
- if (t.length !== e.length)
1084
- return !1;
1085
- let n = 0;
1086
- for (let s = 0; s < t.length; s++)
1087
- n |= t[s] ^ e[s];
1088
- return n === 0;
1089
- }
1090
- const Oe = (t) => typeof t == "bigint" && sn <= t;
1091
- function rr(t, e, n) {
1092
- return Oe(t) && Oe(e) && Oe(n) && e <= t && t < n;
1093
- }
1094
- function Jt(t, e, n, s) {
1095
- if (!rr(e, n, s))
1096
- throw new Error("expected valid " + t + ": " + n + " <= n < " + s + ", got " + e);
1097
- }
1098
- function or(t) {
1099
- let e;
1100
- for (e = 0; t > sn; t >>= je, e += 1)
1101
- ;
1102
- return e;
1103
- }
1104
- const Le = (t) => (je << BigInt(t)) - je;
1105
- function ir(t, e, n) {
1106
- if (typeof t != "number" || t < 2)
1107
- throw new Error("hashLen must be a number");
1108
- if (typeof e != "number" || e < 2)
1109
- throw new Error("qByteLen must be a number");
1110
- if (typeof n != "function")
1111
- throw new Error("hmacFn must be a function");
1112
- const s = (u) => new Uint8Array(u), r = (u) => Uint8Array.of(u);
1113
- let i = s(t), o = s(t), c = 0;
1114
- const f = () => {
1115
- i.fill(1), o.fill(0), c = 0;
1116
- }, l = (...u) => n(o, i, ...u), h = (u = s(0)) => {
1117
- o = l(r(0), u), i = l(), u.length !== 0 && (o = l(r(1), u), i = l());
1118
- }, a = () => {
1119
- if (c++ >= 1e3)
1120
- throw new Error("drbg: tried 1000 values");
1121
- let u = 0;
1122
- const y = [];
1123
- for (; u < e; ) {
1124
- i = l();
1125
- const b = i.slice();
1126
- y.push(b), u += i.length;
1127
- }
1128
- return wt(...y);
1129
- };
1130
- return (u, y) => {
1131
- f(), h(u);
1132
- let b;
1133
- for (; !(b = y(a())); )
1134
- h();
1135
- return f(), b;
1136
- };
1137
- }
1138
- function ue(t, e, n = {}) {
1139
- if (!t || typeof t != "object")
1140
- throw new Error("expected valid options object");
1141
- function s(r, i, o) {
1142
- const c = t[r];
1143
- if (o && c === void 0)
1144
- return;
1145
- const f = typeof c;
1146
- if (f !== i || c === null)
1147
- throw new Error(`param "${r}" is invalid: expected ${i}, got ${f}`);
1148
- }
1149
- Object.entries(e).forEach(([r, i]) => s(r, i, !1)), Object.entries(n).forEach(([r, i]) => s(r, i, !0));
1150
- }
1151
- function He(t) {
1152
- const e = /* @__PURE__ */ new WeakMap();
1153
- return (n, ...s) => {
1154
- const r = e.get(n);
1155
- if (r !== void 0)
1156
- return r;
1157
- const i = t(n, ...s);
1158
- return e.set(n, i), i;
1159
- };
1160
- }
1161
- const nt = BigInt(0), Y = BigInt(1), Nt = /* @__PURE__ */ BigInt(2), cr = /* @__PURE__ */ BigInt(3), Qn = /* @__PURE__ */ BigInt(4), Jn = /* @__PURE__ */ BigInt(5), ts = /* @__PURE__ */ BigInt(8);
1162
- function z(t, e) {
1163
- const n = t % e;
1164
- return n >= nt ? n : e + n;
1165
- }
1166
- function Z(t, e, n) {
1167
- let s = t;
1168
- for (; e-- > nt; )
1169
- s *= s, s %= n;
1170
- return s;
1171
- }
1172
- function xn(t, e) {
1173
- if (t === nt)
1174
- throw new Error("invert: expected non-zero number");
1175
- if (e <= nt)
1176
- throw new Error("invert: expected positive modulus, got " + e);
1177
- let n = z(t, e), s = e, r = nt, i = Y;
1178
- for (; n !== nt; ) {
1179
- const c = s / n, f = s % n, l = r - i * c;
1180
- s = n, n = f, r = i, i = l;
1181
- }
1182
- if (s !== Y)
1183
- throw new Error("invert: does not exist");
1184
- return z(r, e);
1185
- }
1186
- function es(t, e) {
1187
- const n = (t.ORDER + Y) / Qn, s = t.pow(e, n);
1188
- if (!t.eql(t.sqr(s), e))
1189
- throw new Error("Cannot find square root");
1190
- return s;
1191
- }
1192
- function fr(t, e) {
1193
- const n = (t.ORDER - Jn) / ts, s = t.mul(e, Nt), r = t.pow(s, n), i = t.mul(e, r), o = t.mul(t.mul(i, Nt), r), c = t.mul(i, t.sub(o, t.ONE));
1194
- if (!t.eql(t.sqr(c), e))
1195
- throw new Error("Cannot find square root");
1196
- return c;
1197
- }
1198
- function ar(t) {
1199
- if (t < BigInt(3))
1200
- throw new Error("sqrt is not defined for small field");
1201
- let e = t - Y, n = 0;
1202
- for (; e % Nt === nt; )
1203
- e /= Nt, n++;
1204
- let s = Nt;
1205
- const r = Zt(t);
1206
- for (; bn(r, s) === 1; )
1207
- if (s++ > 1e3)
1208
- throw new Error("Cannot find square root: probably non-prime P");
1209
- if (n === 1)
1210
- return es;
1211
- let i = r.pow(s, e);
1212
- const o = (e + Y) / Nt;
1213
- return function(f, l) {
1214
- if (f.is0(l))
1215
- return l;
1216
- if (bn(f, l) !== 1)
1217
- throw new Error("Cannot find square root");
1218
- let h = n, a = f.mul(f.ONE, i), d = f.pow(l, e), u = f.pow(l, o);
1219
- for (; !f.eql(d, f.ONE); ) {
1220
- if (f.is0(d))
1221
- return f.ZERO;
1222
- let y = 1, b = f.sqr(d);
1223
- for (; !f.eql(b, f.ONE); )
1224
- if (y++, b = f.sqr(b), y === h)
1225
- throw new Error("Cannot find square root");
1226
- const w = Y << BigInt(h - y - 1), _ = f.pow(a, w);
1227
- h = y, a = f.sqr(_), d = f.mul(d, a), u = f.mul(u, _);
1228
- }
1229
- return u;
1230
- };
1231
- }
1232
- function hr(t) {
1233
- return t % Qn === cr ? es : t % ts === Jn ? fr : ar(t);
1234
- }
1235
- const Ot = (t, e) => (z(t, e) & Y) === Y, lr = [
1236
- "create",
1237
- "isValid",
1238
- "is0",
1239
- "neg",
1240
- "inv",
1241
- "sqrt",
1242
- "sqr",
1243
- "eql",
1244
- "add",
1245
- "sub",
1246
- "mul",
1247
- "pow",
1248
- "div",
1249
- "addN",
1250
- "subN",
1251
- "mulN",
1252
- "sqrN"
1253
- ];
1254
- function dr(t) {
1255
- const e = {
1256
- ORDER: "bigint",
1257
- MASK: "bigint",
1258
- BYTES: "number",
1259
- BITS: "number"
1260
- }, n = lr.reduce((s, r) => (s[r] = "function", s), e);
1261
- return ue(t, n), t;
1262
- }
1263
- function ur(t, e, n) {
1264
- if (n < nt)
1265
- throw new Error("invalid exponent, negatives unsupported");
1266
- if (n === nt)
1267
- return t.ONE;
1268
- if (n === Y)
1269
- return e;
1270
- let s = t.ONE, r = e;
1271
- for (; n > nt; )
1272
- n & Y && (s = t.mul(s, r)), r = t.sqr(r), n >>= Y;
1273
- return s;
1274
- }
1275
- function ns(t, e, n = !1) {
1276
- const s = new Array(e.length).fill(n ? t.ZERO : void 0), r = e.reduce((o, c, f) => t.is0(c) ? o : (s[f] = o, t.mul(o, c)), t.ONE), i = t.inv(r);
1277
- return e.reduceRight((o, c, f) => t.is0(c) ? o : (s[f] = t.mul(o, s[f]), t.mul(o, c)), i), s;
1278
- }
1279
- function bn(t, e) {
1280
- const n = (t.ORDER - Y) / Nt, s = t.pow(e, n), r = t.eql(s, t.ONE), i = t.eql(s, t.ZERO), o = t.eql(s, t.neg(t.ONE));
1281
- if (!r && !i && !o)
1282
- throw new Error("invalid Legendre symbol result");
1283
- return r ? 1 : i ? 0 : -1;
1284
- }
1285
- function xr(t, e) {
1286
- e !== void 0 && ze(e);
1287
- const n = e !== void 0 ? e : t.toString(2).length, s = Math.ceil(n / 8);
1288
- return { nBitLength: n, nByteLength: s };
1289
- }
1290
- function Zt(t, e, n = !1, s = {}) {
1291
- if (t <= nt)
1292
- throw new Error("invalid field: expected ORDER > 0, got " + t);
1293
- let r, i;
1294
- if (typeof e == "object" && e != null) {
1295
- if (s.sqrt || n)
1296
- throw new Error("cannot specify opts in two arguments");
1297
- const h = e;
1298
- h.BITS && (r = h.BITS), h.sqrt && (i = h.sqrt), typeof h.isLE == "boolean" && (n = h.isLE);
1299
- } else
1300
- typeof e == "number" && (r = e), s.sqrt && (i = s.sqrt);
1301
- const { nBitLength: o, nByteLength: c } = xr(t, r);
1302
- if (c > 2048)
1303
- throw new Error("invalid field: expected ORDER of <= 2048 bytes");
1304
- let f;
1305
- const l = Object.freeze({
1306
- ORDER: t,
1307
- isLE: n,
1308
- BITS: o,
1309
- BYTES: c,
1310
- MASK: Le(o),
1311
- ZERO: nt,
1312
- ONE: Y,
1313
- create: (h) => z(h, t),
1314
- isValid: (h) => {
1315
- if (typeof h != "bigint")
1316
- throw new Error("invalid field element: expected bigint, got " + typeof h);
1317
- return nt <= h && h < t;
1318
- },
1319
- is0: (h) => h === nt,
1320
- // is valid and invertible
1321
- isValidNot0: (h) => !l.is0(h) && l.isValid(h),
1322
- isOdd: (h) => (h & Y) === Y,
1323
- neg: (h) => z(-h, t),
1324
- eql: (h, a) => h === a,
1325
- sqr: (h) => z(h * h, t),
1326
- add: (h, a) => z(h + a, t),
1327
- sub: (h, a) => z(h - a, t),
1328
- mul: (h, a) => z(h * a, t),
1329
- pow: (h, a) => ur(l, h, a),
1330
- div: (h, a) => z(h * xn(a, t), t),
1331
- // Same as above, but doesn't normalize
1332
- sqrN: (h) => h * h,
1333
- addN: (h, a) => h + a,
1334
- subN: (h, a) => h - a,
1335
- mulN: (h, a) => h * a,
1336
- inv: (h) => xn(h, t),
1337
- sqrt: i || ((h) => (f || (f = hr(t)), f(l, h))),
1338
- toBytes: (h) => n ? se(h, c) : rn(h, c),
1339
- fromBytes: (h) => {
1340
- if (h.length !== c)
1341
- throw new Error("Field.fromBytes: expected " + c + " bytes, got " + h.length);
1342
- return n ? ne(h) : ve(h);
1343
- },
1344
- // TODO: we don't need it here, move out to separate fn
1345
- invertBatch: (h) => ns(l, h),
1346
- // We can't move this out because Fp6, Fp12 implement it
1347
- // and it's unclear what to return in there.
1348
- cmov: (h, a, d) => d ? a : h
1349
- });
1350
- return Object.freeze(l);
1351
- }
1352
- function ss(t) {
1353
- if (typeof t != "bigint")
1354
- throw new Error("field order must be bigint");
1355
- const e = t.toString(2).length;
1356
- return Math.ceil(e / 8);
1357
- }
1358
- function rs(t) {
1359
- const e = ss(t);
1360
- return e + Math.ceil(e / 2);
1361
- }
1362
- function br(t, e, n = !1) {
1363
- const s = t.length, r = ss(e), i = rs(e);
1364
- if (s < 16 || s < i || s > 1024)
1365
- throw new Error("expected " + i + "-1024 bytes of input, got " + s);
1366
- const o = n ? ne(t) : ve(t), c = z(o, e - Y) + Y;
1367
- return n ? se(c, r) : rn(c, r);
1368
- }
1369
- function wr(t, e, n, s) {
1370
- if (typeof t.setBigUint64 == "function")
1371
- return t.setBigUint64(e, n, s);
1372
- const r = BigInt(32), i = BigInt(4294967295), o = Number(n >> r & i), c = Number(n & i), f = s ? 4 : 0, l = s ? 0 : 4;
1373
- t.setUint32(e + f, o, s), t.setUint32(e + l, c, s);
1374
- }
1375
- function gr(t, e, n) {
1376
- return t & e ^ ~t & n;
1377
- }
1378
- function yr(t, e, n) {
1379
- return t & e ^ t & n ^ e & n;
1380
- }
1381
- let os = class extends Yn {
1382
- constructor(e, n, s, r) {
1383
- super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(e), this.view = ke(this.buffer);
1384
- }
1385
- update(e) {
1386
- _e(this), e = nn(e), it(e);
1387
- const { view: n, buffer: s, blockLen: r } = this, i = e.length;
1388
- for (let o = 0; o < i; ) {
1389
- const c = Math.min(r - this.pos, i - o);
1390
- if (c === r) {
1391
- const f = ke(e);
1392
- for (; r <= i - o; o += r)
1393
- this.process(f, o);
1394
- continue;
1395
- }
1396
- s.set(e.subarray(o, o + c), this.pos), this.pos += c, o += c, this.pos === r && (this.process(n, 0), this.pos = 0);
1397
- }
1398
- return this.length += e.length, this.roundClean(), this;
1399
- }
1400
- digestInto(e) {
1401
- _e(this), tr(e, this), this.finished = !0;
1402
- const { buffer: n, view: s, blockLen: r, isLE: i } = this;
1403
- let { pos: o } = this;
1404
- n[o++] = 128, ee(this.buffer.subarray(o)), this.padOffset > r - o && (this.process(s, 0), o = 0);
1405
- for (let a = o; a < r; a++)
1406
- n[a] = 0;
1407
- wr(s, r - 8, BigInt(this.length * 8), i), this.process(s, 0);
1408
- const c = ke(e), f = this.outputLen;
1409
- if (f % 4)
1410
- throw new Error("_sha2: outputLen should be aligned to 32bit");
1411
- const l = f / 4, h = this.get();
1412
- if (l > h.length)
1413
- throw new Error("_sha2: outputLen bigger than state");
1414
- for (let a = 0; a < l; a++)
1415
- c.setUint32(4 * a, h[a], i);
1416
- }
1417
- digest() {
1418
- const { buffer: e, outputLen: n } = this;
1419
- this.digestInto(e);
1420
- const s = e.slice(0, n);
1421
- return this.destroy(), s;
1422
- }
1423
- _cloneInto(e) {
1424
- e || (e = new this.constructor()), e.set(...this.get());
1425
- const { blockLen: n, buffer: s, length: r, finished: i, destroyed: o, pos: c } = this;
1426
- return e.destroyed = o, e.finished = i, e.length = r, e.pos = c, r % n && e.buffer.set(s), e;
1427
- }
1428
- clone() {
1429
- return this._cloneInto();
1430
- }
1431
- };
1432
- const _t = /* @__PURE__ */ Uint32Array.from([
1433
- 1779033703,
1434
- 3144134277,
1435
- 1013904242,
1436
- 2773480762,
1437
- 1359893119,
1438
- 2600822924,
1439
- 528734635,
1440
- 1541459225
1441
- ]);
1442
- const P = /* @__PURE__ */ Uint32Array.from([
1443
- 1779033703,
1444
- 4089235720,
1445
- 3144134277,
1446
- 2227873595,
1447
- 1013904242,
1448
- 4271175723,
1449
- 2773480762,
1450
- 1595750129,
1451
- 1359893119,
1452
- 2917565137,
1453
- 2600822924,
1454
- 725511199,
1455
- 528734635,
1456
- 4215389547,
1457
- 1541459225,
1458
- 327033209
1459
- ]), we = /* @__PURE__ */ BigInt(2 ** 32 - 1), wn = /* @__PURE__ */ BigInt(32);
1460
- function pr(t, e = !1) {
1461
- return e ? { h: Number(t & we), l: Number(t >> wn & we) } : { h: Number(t >> wn & we) | 0, l: Number(t & we) | 0 };
1462
- }
1463
- function mr(t, e = !1) {
1464
- const n = t.length;
1465
- let s = new Uint32Array(n), r = new Uint32Array(n);
1466
- for (let i = 0; i < n; i++) {
1467
- const { h: o, l: c } = pr(t[i], e);
1468
- [s[i], r[i]] = [o, c];
1469
- }
1470
- return [s, r];
1471
- }
1472
- const gn = (t, e, n) => t >>> n, yn = (t, e, n) => t << 32 - n | e >>> n, Kt = (t, e, n) => t >>> n | e << 32 - n, Yt = (t, e, n) => t << 32 - n | e >>> n, ge = (t, e, n) => t << 64 - n | e >>> n - 32, ye = (t, e, n) => t >>> n - 32 | e << 64 - n;
1473
- function dt(t, e, n, s) {
1474
- const r = (e >>> 0) + (s >>> 0);
1475
- return { h: t + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
1476
- }
1477
- const Br = (t, e, n) => (t >>> 0) + (e >>> 0) + (n >>> 0), Er = (t, e, n, s) => e + n + s + (t / 2 ** 32 | 0) | 0, Ar = (t, e, n, s) => (t >>> 0) + (e >>> 0) + (n >>> 0) + (s >>> 0), _r = (t, e, n, s, r) => e + n + s + r + (t / 2 ** 32 | 0) | 0, Hr = (t, e, n, s, r) => (t >>> 0) + (e >>> 0) + (n >>> 0) + (s >>> 0) + (r >>> 0), Sr = (t, e, n, s, r, i) => e + n + s + r + i + (t / 2 ** 32 | 0) | 0, Ir = /* @__PURE__ */ Uint32Array.from([
1478
- 1116352408,
1479
- 1899447441,
1480
- 3049323471,
1481
- 3921009573,
1482
- 961987163,
1483
- 1508970993,
1484
- 2453635748,
1485
- 2870763221,
1486
- 3624381080,
1487
- 310598401,
1488
- 607225278,
1489
- 1426881987,
1490
- 1925078388,
1491
- 2162078206,
1492
- 2614888103,
1493
- 3248222580,
1494
- 3835390401,
1495
- 4022224774,
1496
- 264347078,
1497
- 604807628,
1498
- 770255983,
1499
- 1249150122,
1500
- 1555081692,
1501
- 1996064986,
1502
- 2554220882,
1503
- 2821834349,
1504
- 2952996808,
1505
- 3210313671,
1506
- 3336571891,
1507
- 3584528711,
1508
- 113926993,
1509
- 338241895,
1510
- 666307205,
1511
- 773529912,
1512
- 1294757372,
1513
- 1396182291,
1514
- 1695183700,
1515
- 1986661051,
1516
- 2177026350,
1517
- 2456956037,
1518
- 2730485921,
1519
- 2820302411,
1520
- 3259730800,
1521
- 3345764771,
1522
- 3516065817,
1523
- 3600352804,
1524
- 4094571909,
1525
- 275423344,
1526
- 430227734,
1527
- 506948616,
1528
- 659060556,
1529
- 883997877,
1530
- 958139571,
1531
- 1322822218,
1532
- 1537002063,
1533
- 1747873779,
1534
- 1955562222,
1535
- 2024104815,
1536
- 2227730452,
1537
- 2361852424,
1538
- 2428436474,
1539
- 2756734187,
1540
- 3204031479,
1541
- 3329325298
1542
- ]), Ht = /* @__PURE__ */ new Uint32Array(64);
1543
- let vr = class extends os {
1544
- constructor(e = 32) {
1545
- super(64, e, 8, !1), this.A = _t[0] | 0, this.B = _t[1] | 0, this.C = _t[2] | 0, this.D = _t[3] | 0, this.E = _t[4] | 0, this.F = _t[5] | 0, this.G = _t[6] | 0, this.H = _t[7] | 0;
1546
- }
1547
- get() {
1548
- const { A: e, B: n, C: s, D: r, E: i, F: o, G: c, H: f } = this;
1549
- return [e, n, s, r, i, o, c, f];
1550
- }
1551
- // prettier-ignore
1552
- set(e, n, s, r, i, o, c, f) {
1553
- this.A = e | 0, this.B = n | 0, this.C = s | 0, this.D = r | 0, this.E = i | 0, this.F = o | 0, this.G = c | 0, this.H = f | 0;
1554
- }
1555
- process(e, n) {
1556
- for (let a = 0; a < 16; a++, n += 4)
1557
- Ht[a] = e.getUint32(n, !1);
1558
- for (let a = 16; a < 64; a++) {
1559
- const d = Ht[a - 15], u = Ht[a - 2], y = ft(d, 7) ^ ft(d, 18) ^ d >>> 3, b = ft(u, 17) ^ ft(u, 19) ^ u >>> 10;
1560
- Ht[a] = b + Ht[a - 7] + y + Ht[a - 16] | 0;
1561
- }
1562
- let { A: s, B: r, C: i, D: o, E: c, F: f, G: l, H: h } = this;
1563
- for (let a = 0; a < 64; a++) {
1564
- const d = ft(c, 6) ^ ft(c, 11) ^ ft(c, 25), u = h + d + gr(c, f, l) + Ir[a] + Ht[a] | 0, b = (ft(s, 2) ^ ft(s, 13) ^ ft(s, 22)) + yr(s, r, i) | 0;
1565
- h = l, l = f, f = c, c = o + u | 0, o = i, i = r, r = s, s = u + b | 0;
1566
- }
1567
- s = s + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, h = h + this.H | 0, this.set(s, r, i, o, c, f, l, h);
1568
- }
1569
- roundClean() {
1570
- ee(Ht);
1571
- }
1572
- destroy() {
1573
- this.set(0, 0, 0, 0, 0, 0, 0, 0), ee(this.buffer);
1574
- }
1575
- };
1576
- const is = mr([
1577
- "0x428a2f98d728ae22",
1578
- "0x7137449123ef65cd",
1579
- "0xb5c0fbcfec4d3b2f",
1580
- "0xe9b5dba58189dbbc",
1581
- "0x3956c25bf348b538",
1582
- "0x59f111f1b605d019",
1583
- "0x923f82a4af194f9b",
1584
- "0xab1c5ed5da6d8118",
1585
- "0xd807aa98a3030242",
1586
- "0x12835b0145706fbe",
1587
- "0x243185be4ee4b28c",
1588
- "0x550c7dc3d5ffb4e2",
1589
- "0x72be5d74f27b896f",
1590
- "0x80deb1fe3b1696b1",
1591
- "0x9bdc06a725c71235",
1592
- "0xc19bf174cf692694",
1593
- "0xe49b69c19ef14ad2",
1594
- "0xefbe4786384f25e3",
1595
- "0x0fc19dc68b8cd5b5",
1596
- "0x240ca1cc77ac9c65",
1597
- "0x2de92c6f592b0275",
1598
- "0x4a7484aa6ea6e483",
1599
- "0x5cb0a9dcbd41fbd4",
1600
- "0x76f988da831153b5",
1601
- "0x983e5152ee66dfab",
1602
- "0xa831c66d2db43210",
1603
- "0xb00327c898fb213f",
1604
- "0xbf597fc7beef0ee4",
1605
- "0xc6e00bf33da88fc2",
1606
- "0xd5a79147930aa725",
1607
- "0x06ca6351e003826f",
1608
- "0x142929670a0e6e70",
1609
- "0x27b70a8546d22ffc",
1610
- "0x2e1b21385c26c926",
1611
- "0x4d2c6dfc5ac42aed",
1612
- "0x53380d139d95b3df",
1613
- "0x650a73548baf63de",
1614
- "0x766a0abb3c77b2a8",
1615
- "0x81c2c92e47edaee6",
1616
- "0x92722c851482353b",
1617
- "0xa2bfe8a14cf10364",
1618
- "0xa81a664bbc423001",
1619
- "0xc24b8b70d0f89791",
1620
- "0xc76c51a30654be30",
1621
- "0xd192e819d6ef5218",
1622
- "0xd69906245565a910",
1623
- "0xf40e35855771202a",
1624
- "0x106aa07032bbd1b8",
1625
- "0x19a4c116b8d2d0c8",
1626
- "0x1e376c085141ab53",
1627
- "0x2748774cdf8eeb99",
1628
- "0x34b0bcb5e19b48a8",
1629
- "0x391c0cb3c5c95a63",
1630
- "0x4ed8aa4ae3418acb",
1631
- "0x5b9cca4f7763e373",
1632
- "0x682e6ff3d6b2b8a3",
1633
- "0x748f82ee5defb2fc",
1634
- "0x78a5636f43172f60",
1635
- "0x84c87814a1f0ab72",
1636
- "0x8cc702081a6439ec",
1637
- "0x90befffa23631e28",
1638
- "0xa4506cebde82bde9",
1639
- "0xbef9a3f7b2c67915",
1640
- "0xc67178f2e372532b",
1641
- "0xca273eceea26619c",
1642
- "0xd186b8c721c0c207",
1643
- "0xeada7dd6cde0eb1e",
1644
- "0xf57d4f7fee6ed178",
1645
- "0x06f067aa72176fba",
1646
- "0x0a637dc5a2c898a6",
1647
- "0x113f9804bef90dae",
1648
- "0x1b710b35131c471b",
1649
- "0x28db77f523047d84",
1650
- "0x32caab7b40c72493",
1651
- "0x3c9ebe0a15c9bebc",
1652
- "0x431d67c49c100d4c",
1653
- "0x4cc5d4becb3e42b6",
1654
- "0x597f299cfc657e2a",
1655
- "0x5fcb6fab3ad6faec",
1656
- "0x6c44198c4a475817"
1657
- ].map((t) => BigInt(t))), Lr = is[0], Ur = is[1], St = /* @__PURE__ */ new Uint32Array(80), It = /* @__PURE__ */ new Uint32Array(80);
1658
- let $r = class extends os {
1659
- constructor(e = 64) {
1660
- super(128, e, 16, !1), this.Ah = P[0] | 0, this.Al = P[1] | 0, this.Bh = P[2] | 0, this.Bl = P[3] | 0, this.Ch = P[4] | 0, this.Cl = P[5] | 0, this.Dh = P[6] | 0, this.Dl = P[7] | 0, this.Eh = P[8] | 0, this.El = P[9] | 0, this.Fh = P[10] | 0, this.Fl = P[11] | 0, this.Gh = P[12] | 0, this.Gl = P[13] | 0, this.Hh = P[14] | 0, this.Hl = P[15] | 0;
1661
- }
1662
- // prettier-ignore
1663
- get() {
1664
- const { Ah: e, Al: n, Bh: s, Bl: r, Ch: i, Cl: o, Dh: c, Dl: f, Eh: l, El: h, Fh: a, Fl: d, Gh: u, Gl: y, Hh: b, Hl: w } = this;
1665
- return [e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w];
1666
- }
1667
- // prettier-ignore
1668
- set(e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w) {
1669
- this.Ah = e | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = i | 0, this.Cl = o | 0, this.Dh = c | 0, this.Dl = f | 0, this.Eh = l | 0, this.El = h | 0, this.Fh = a | 0, this.Fl = d | 0, this.Gh = u | 0, this.Gl = y | 0, this.Hh = b | 0, this.Hl = w | 0;
1670
- }
1671
- process(e, n) {
1672
- for (let p = 0; p < 16; p++, n += 4)
1673
- St[p] = e.getUint32(n), It[p] = e.getUint32(n += 4);
1674
- for (let p = 16; p < 80; p++) {
1675
- const D = St[p - 15] | 0, m = It[p - 15] | 0, U = Kt(D, m, 1) ^ Kt(D, m, 8) ^ gn(D, m, 7), C = Yt(D, m, 1) ^ Yt(D, m, 8) ^ yn(D, m, 7), H = St[p - 2] | 0, x = It[p - 2] | 0, E = Kt(H, x, 19) ^ ge(H, x, 61) ^ gn(H, x, 6), g = Yt(H, x, 19) ^ ye(H, x, 61) ^ yn(H, x, 6), B = Ar(C, g, It[p - 7], It[p - 16]), A = _r(B, U, E, St[p - 7], St[p - 16]);
1676
- St[p] = A | 0, It[p] = B | 0;
1677
- }
1678
- let { Ah: s, Al: r, Bh: i, Bl: o, Ch: c, Cl: f, Dh: l, Dl: h, Eh: a, El: d, Fh: u, Fl: y, Gh: b, Gl: w, Hh: _, Hl: L } = this;
1679
- for (let p = 0; p < 80; p++) {
1680
- const D = Kt(a, d, 14) ^ Kt(a, d, 18) ^ ge(a, d, 41), m = Yt(a, d, 14) ^ Yt(a, d, 18) ^ ye(a, d, 41), U = a & u ^ ~a & b, C = d & y ^ ~d & w, H = Hr(L, m, C, Ur[p], It[p]), x = Sr(H, _, D, U, Lr[p], St[p]), E = H | 0, g = Kt(s, r, 28) ^ ge(s, r, 34) ^ ge(s, r, 39), B = Yt(s, r, 28) ^ ye(s, r, 34) ^ ye(s, r, 39), A = s & i ^ s & c ^ i & c, I = r & o ^ r & f ^ o & f;
1681
- _ = b | 0, L = w | 0, b = u | 0, w = y | 0, u = a | 0, y = d | 0, { h: a, l: d } = dt(l | 0, h | 0, x | 0, E | 0), l = c | 0, h = f | 0, c = i | 0, f = o | 0, i = s | 0, o = r | 0;
1682
- const S = Br(E, B, I);
1683
- s = Er(S, x, g, A), r = S | 0;
1684
- }
1685
- ({ h: s, l: r } = dt(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: i, l: o } = dt(this.Bh | 0, this.Bl | 0, i | 0, o | 0), { h: c, l: f } = dt(this.Ch | 0, this.Cl | 0, c | 0, f | 0), { h: l, l: h } = dt(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: a, l: d } = dt(this.Eh | 0, this.El | 0, a | 0, d | 0), { h: u, l: y } = dt(this.Fh | 0, this.Fl | 0, u | 0, y | 0), { h: b, l: w } = dt(this.Gh | 0, this.Gl | 0, b | 0, w | 0), { h: _, l: L } = dt(this.Hh | 0, this.Hl | 0, _ | 0, L | 0), this.set(s, r, i, o, c, f, l, h, a, d, u, y, b, w, _, L);
1686
- }
1687
- roundClean() {
1688
- ee(St, It);
1689
- }
1690
- destroy() {
1691
- ee(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
1692
- }
1693
- };
1694
- const Dr = /* @__PURE__ */ Xn(() => new vr()), Cr = /* @__PURE__ */ Xn(() => new $r());
1695
- const re = BigInt(0), qt = BigInt(1);
1696
- function he(t, e) {
1697
- const n = e.negate();
1698
- return t ? n : e;
1699
- }
1700
- function cs(t, e, n) {
1701
- const s = e === "pz" ? (o) => o.pz : (o) => o.ez, r = ns(t.Fp, n.map(s));
1702
- return n.map((o, c) => o.toAffine(r[c])).map(t.fromAffine);
1703
- }
1704
- function fs(t, e) {
1705
- if (!Number.isSafeInteger(t) || t <= 0 || t > e)
1706
- throw new Error("invalid window size, expected [1.." + e + "], got W=" + t);
1707
- }
1708
- function Re(t, e) {
1709
- fs(t, e);
1710
- const n = Math.ceil(e / t) + 1, s = 2 ** (t - 1), r = 2 ** t, i = Le(t), o = BigInt(t);
1711
- return { windows: n, windowSize: s, mask: i, maxNumber: r, shiftBy: o };
1712
- }
1713
- function pn(t, e, n) {
1714
- const { windowSize: s, mask: r, maxNumber: i, shiftBy: o } = n;
1715
- let c = Number(t & r), f = t >> o;
1716
- c > s && (c -= i, f += qt);
1717
- const l = e * s, h = l + Math.abs(c) - 1, a = c === 0, d = c < 0, u = e % 2 !== 0;
1718
- return { nextN: f, offset: h, isZero: a, isNeg: d, isNegF: u, offsetF: l };
1719
- }
1720
- function kr(t, e) {
1721
- if (!Array.isArray(t))
1722
- throw new Error("array expected");
1723
- t.forEach((n, s) => {
1724
- if (!(n instanceof e))
1725
- throw new Error("invalid point at index " + s);
1726
- });
1727
- }
1728
- function Or(t, e) {
1729
- if (!Array.isArray(t))
1730
- throw new Error("array of scalars expected");
1731
- t.forEach((n, s) => {
1732
- if (!e.isValid(n))
1733
- throw new Error("invalid scalar at index " + s);
1734
- });
1735
- }
1736
- const Te = /* @__PURE__ */ new WeakMap(), as = /* @__PURE__ */ new WeakMap();
1737
- function Ne(t) {
1738
- return as.get(t) || 1;
1739
- }
1740
- function mn(t) {
1741
- if (t !== re)
1742
- throw new Error("invalid wNAF");
1743
- }
1744
- function hs(t, e) {
1745
- return {
1746
- constTimeNegate: he,
1747
- hasPrecomputes(n) {
1748
- return Ne(n) !== 1;
1749
- },
1750
- // non-const time multiplication ladder
1751
- unsafeLadder(n, s, r = t.ZERO) {
1752
- let i = n;
1753
- for (; s > re; )
1754
- s & qt && (r = r.add(i)), i = i.double(), s >>= qt;
1755
- return r;
1756
- },
1757
- /**
1758
- * Creates a wNAF precomputation window. Used for caching.
1759
- * Default window size is set by `utils.precompute()` and is equal to 8.
1760
- * Number of precomputed points depends on the curve size:
1761
- * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
1762
- * - 𝑊 is the window size
1763
- * - 𝑛 is the bitlength of the curve order.
1764
- * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
1765
- * @param elm Point instance
1766
- * @param W window size
1767
- * @returns precomputed point tables flattened to a single array
1768
- */
1769
- precomputeWindow(n, s) {
1770
- const { windows: r, windowSize: i } = Re(s, e), o = [];
1771
- let c = n, f = c;
1772
- for (let l = 0; l < r; l++) {
1773
- f = c, o.push(f);
1774
- for (let h = 1; h < i; h++)
1775
- f = f.add(c), o.push(f);
1776
- c = f.double();
1777
- }
1778
- return o;
1779
- },
1780
- /**
1781
- * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
1782
- * @param W window size
1783
- * @param precomputes precomputed tables
1784
- * @param n scalar (we don't check here, but should be less than curve order)
1785
- * @returns real and fake (for const-time) points
1786
- */
1787
- wNAF(n, s, r) {
1788
- let i = t.ZERO, o = t.BASE;
1789
- const c = Re(n, e);
1790
- for (let f = 0; f < c.windows; f++) {
1791
- const { nextN: l, offset: h, isZero: a, isNeg: d, isNegF: u, offsetF: y } = pn(r, f, c);
1792
- r = l, a ? o = o.add(he(u, s[y])) : i = i.add(he(d, s[h]));
1793
- }
1794
- return mn(r), { p: i, f: o };
1795
- },
1796
- /**
1797
- * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
1798
- * @param W window size
1799
- * @param precomputes precomputed tables
1800
- * @param n scalar (we don't check here, but should be less than curve order)
1801
- * @param acc accumulator point to add result of multiplication
1802
- * @returns point
1803
- */
1804
- wNAFUnsafe(n, s, r, i = t.ZERO) {
1805
- const o = Re(n, e);
1806
- for (let c = 0; c < o.windows && r !== re; c++) {
1807
- const { nextN: f, offset: l, isZero: h, isNeg: a } = pn(r, c, o);
1808
- if (r = f, !h) {
1809
- const d = s[l];
1810
- i = i.add(a ? d.negate() : d);
1811
- }
1812
- }
1813
- return mn(r), i;
1814
- },
1815
- getPrecomputes(n, s, r) {
1816
- let i = Te.get(s);
1817
- return i || (i = this.precomputeWindow(s, n), n !== 1 && (typeof r == "function" && (i = r(i)), Te.set(s, i))), i;
1818
- },
1819
- wNAFCached(n, s, r) {
1820
- const i = Ne(n);
1821
- return this.wNAF(i, this.getPrecomputes(i, n, r), s);
1822
- },
1823
- wNAFCachedUnsafe(n, s, r, i) {
1824
- const o = Ne(n);
1825
- return o === 1 ? this.unsafeLadder(n, s, i) : this.wNAFUnsafe(o, this.getPrecomputes(o, n, r), s, i);
1826
- },
1827
- // We calculate precomputes for elliptic curve point multiplication
1828
- // using windowed method. This specifies window size and
1829
- // stores precomputed values. Usually only base point would be precomputed.
1830
- setWindowSize(n, s) {
1831
- fs(s, e), as.set(n, s), Te.delete(n);
1832
- }
1833
- };
1834
- }
1835
- function Rr(t, e, n, s) {
1836
- let r = e, i = t.ZERO, o = t.ZERO;
1837
- for (; n > re || s > re; )
1838
- n & qt && (i = i.add(r)), s & qt && (o = o.add(r)), r = r.double(), n >>= qt, s >>= qt;
1839
- return { p1: i, p2: o };
1840
- }
1841
- function on(t, e, n, s) {
1842
- kr(n, t), Or(s, e);
1843
- const r = n.length, i = s.length;
1844
- if (r !== i)
1845
- throw new Error("arrays of points and scalars must have equal length");
1846
- const o = t.ZERO, c = or(BigInt(r));
1847
- let f = 1;
1848
- c > 12 ? f = c - 3 : c > 4 ? f = c - 2 : c > 0 && (f = 2);
1849
- const l = Le(f), h = new Array(Number(l) + 1).fill(o), a = Math.floor((e.BITS - 1) / f) * f;
1850
- let d = o;
1851
- for (let u = a; u >= 0; u -= f) {
1852
- h.fill(o);
1853
- for (let b = 0; b < i; b++) {
1854
- const w = s[b], _ = Number(w >> BigInt(u) & l);
1855
- h[_] = h[_].add(n[b]);
1856
- }
1857
- let y = o;
1858
- for (let b = h.length - 1, w = o; b > 0; b--)
1859
- w = w.add(h[b]), y = y.add(w);
1860
- if (d = d.add(y), u !== 0)
1861
- for (let b = 0; b < f; b++)
1862
- d = d.double();
1863
- }
1864
- return d;
1865
- }
1866
- function Bn(t, e) {
1867
- if (e) {
1868
- if (e.ORDER !== t)
1869
- throw new Error("Field.ORDER must match order: Fp == p, Fn == n");
1870
- return dr(e), e;
1871
- } else
1872
- return Zt(t);
1873
- }
1874
- function ls(t, e, n = {}) {
1875
- if (!e || typeof e != "object")
1876
- throw new Error(`expected valid ${t} CURVE object`);
1877
- for (const c of ["p", "n", "h"]) {
1878
- const f = e[c];
1879
- if (!(typeof f == "bigint" && f > re))
1880
- throw new Error(`CURVE.${c} must be positive bigint`);
1881
- }
1882
- const s = Bn(e.p, n.Fp), r = Bn(e.n, n.Fn), o = ["Gx", "Gy", "a", t === "weierstrass" ? "b" : "d"];
1883
- for (const c of o)
1884
- if (!s.isValid(e[c]))
1885
- throw new Error(`CURVE.${c} must be valid field element of CURVE.Fp`);
1886
- return { Fp: s, Fn: r };
1887
- }
1888
- const ht = BigInt(0), tt = BigInt(1), qe = BigInt(2), Tr = BigInt(8), Nr = { zip215: !0 };
1889
- function qr(t, e, n, s) {
1890
- const r = t.sqr(n), i = t.sqr(s), o = t.add(t.mul(e.a, r), i), c = t.add(t.ONE, t.mul(e.d, t.mul(r, i)));
1891
- return t.eql(o, c);
1892
- }
1893
- function Gr(t, e = {}) {
1894
- const { Fp: n, Fn: s } = ls("edwards", t, e), { h: r, n: i } = t;
1895
- ue(e, {}, { uvRatio: "function" });
1896
- const o = qe << BigInt(s.BYTES * 8) - tt, c = (b) => n.create(b), f = e.uvRatio || ((b, w) => {
1897
- try {
1898
- return { isValid: !0, value: n.sqrt(n.div(b, w)) };
1899
- } catch {
1900
- return { isValid: !1, value: ht };
1901
- }
1902
- });
1903
- if (!qr(n, t, t.Gx, t.Gy))
1904
- throw new Error("bad curve params: generator point");
1905
- function l(b, w, _ = !1) {
1906
- const L = _ ? tt : ht;
1907
- return Jt("coordinate " + b, w, L, o), w;
1908
- }
1909
- function h(b) {
1910
- if (!(b instanceof u))
1911
- throw new Error("ExtendedPoint expected");
1912
- }
1913
- const a = He((b, w) => {
1914
- const { ex: _, ey: L, ez: p } = b, D = b.is0();
1915
- w == null && (w = D ? Tr : n.inv(p));
1916
- const m = c(_ * w), U = c(L * w), C = c(p * w);
1917
- if (D)
1918
- return { x: ht, y: tt };
1919
- if (C !== tt)
1920
- throw new Error("invZ was invalid");
1921
- return { x: m, y: U };
1922
- }), d = He((b) => {
1923
- const { a: w, d: _ } = t;
1924
- if (b.is0())
1925
- throw new Error("bad point: ZERO");
1926
- const { ex: L, ey: p, ez: D, et: m } = b, U = c(L * L), C = c(p * p), H = c(D * D), x = c(H * H), E = c(U * w), g = c(H * c(E + C)), B = c(x + c(_ * c(U * C)));
1927
- if (g !== B)
1928
- throw new Error("bad point: equation left != right (1)");
1929
- const A = c(L * p), I = c(D * m);
1930
- if (A !== I)
1931
- throw new Error("bad point: equation left != right (2)");
1932
- return !0;
1933
- });
1934
- class u {
1935
- constructor(w, _, L, p) {
1936
- this.ex = l("x", w), this.ey = l("y", _), this.ez = l("z", L, !0), this.et = l("t", p), Object.freeze(this);
1937
- }
1938
- get x() {
1939
- return this.toAffine().x;
1940
- }
1941
- get y() {
1942
- return this.toAffine().y;
1943
- }
1944
- static fromAffine(w) {
1945
- if (w instanceof u)
1946
- throw new Error("extended point not allowed");
1947
- const { x: _, y: L } = w || {};
1948
- return l("x", _), l("y", L), new u(_, L, tt, c(_ * L));
1949
- }
1950
- static normalizeZ(w) {
1951
- return cs(u, "ez", w);
1952
- }
1953
- // Multiscalar Multiplication
1954
- static msm(w, _) {
1955
- return on(u, s, w, _);
1956
- }
1957
- // "Private method", don't use it directly
1958
- _setWindowSize(w) {
1959
- this.precompute(w);
1960
- }
1961
- precompute(w = 8, _ = !0) {
1962
- return y.setWindowSize(this, w), _ || this.multiply(qe), this;
1963
- }
1964
- // Not required for fromHex(), which always creates valid points.
1965
- // Could be useful for fromAffine().
1966
- assertValidity() {
1967
- d(this);
1968
- }
1969
- // Compare one point to another.
1970
- equals(w) {
1971
- h(w);
1972
- const { ex: _, ey: L, ez: p } = this, { ex: D, ey: m, ez: U } = w, C = c(_ * U), H = c(D * p), x = c(L * U), E = c(m * p);
1973
- return C === H && x === E;
1974
- }
1975
- is0() {
1976
- return this.equals(u.ZERO);
1977
- }
1978
- negate() {
1979
- return new u(c(-this.ex), this.ey, this.ez, c(-this.et));
1980
- }
1981
- // Fast algo for doubling Extended Point.
1982
- // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#doubling-dbl-2008-hwcd
1983
- // Cost: 4M + 4S + 1*a + 6add + 1*2.
1984
- double() {
1985
- const { a: w } = t, { ex: _, ey: L, ez: p } = this, D = c(_ * _), m = c(L * L), U = c(qe * c(p * p)), C = c(w * D), H = _ + L, x = c(c(H * H) - D - m), E = C + m, g = E - U, B = C - m, A = c(x * g), I = c(E * B), S = c(x * B), $ = c(g * E);
1986
- return new u(A, I, $, S);
1987
- }
1988
- // Fast algo for adding 2 Extended Points.
1989
- // https://hyperelliptic.org/EFD/g1p/auto-twisted-extended.html#addition-add-2008-hwcd
1990
- // Cost: 9M + 1*a + 1*d + 7add.
1991
- add(w) {
1992
- h(w);
1993
- const { a: _, d: L } = t, { ex: p, ey: D, ez: m, et: U } = this, { ex: C, ey: H, ez: x, et: E } = w, g = c(p * C), B = c(D * H), A = c(U * L * E), I = c(m * x), S = c((p + D) * (C + H) - g - B), $ = I - A, O = I + A, k = c(B - _ * g), q = c(S * $), T = c(O * k), R = c(S * k), M = c($ * O);
1994
- return new u(q, T, M, R);
1995
- }
1996
- subtract(w) {
1997
- return this.add(w.negate());
1998
- }
1999
- // Constant-time multiplication.
2000
- multiply(w) {
2001
- const _ = w;
2002
- Jt("scalar", _, tt, i);
2003
- const { p: L, f: p } = y.wNAFCached(this, _, u.normalizeZ);
2004
- return u.normalizeZ([L, p])[0];
2005
- }
2006
- // Non-constant-time multiplication. Uses double-and-add algorithm.
2007
- // It's faster, but should only be used when you don't care about
2008
- // an exposed private key e.g. sig verification.
2009
- // Does NOT allow scalars higher than CURVE.n.
2010
- // Accepts optional accumulator to merge with multiply (important for sparse scalars)
2011
- multiplyUnsafe(w, _ = u.ZERO) {
2012
- const L = w;
2013
- return Jt("scalar", L, ht, i), L === ht ? u.ZERO : this.is0() || L === tt ? this : y.wNAFCachedUnsafe(this, L, u.normalizeZ, _);
2014
- }
2015
- // Checks if point is of small order.
2016
- // If you add something to small order point, you will have "dirty"
2017
- // point with torsion component.
2018
- // Multiplies point by cofactor and checks if the result is 0.
2019
- isSmallOrder() {
2020
- return this.multiplyUnsafe(r).is0();
2021
- }
2022
- // Multiplies point by curve order and checks if the result is 0.
2023
- // Returns `false` is the point is dirty.
2024
- isTorsionFree() {
2025
- return y.wNAFCachedUnsafe(this, i).is0();
2026
- }
2027
- // Converts Extended point to default (x, y) coordinates.
2028
- // Can accept precomputed Z^-1 - for example, from invertBatch.
2029
- toAffine(w) {
2030
- return a(this, w);
2031
- }
2032
- clearCofactor() {
2033
- return r === tt ? this : this.multiplyUnsafe(r);
2034
- }
2035
- static fromBytes(w, _ = !1) {
2036
- return it(w), this.fromHex(w, _);
2037
- }
2038
- // Converts hash string or Uint8Array to Point.
2039
- // Uses algo from RFC8032 5.1.3.
2040
- static fromHex(w, _ = !1) {
2041
- const { d: L, a: p } = t, D = n.BYTES;
2042
- w = V("pointHex", w, D), Vt("zip215", _);
2043
- const m = w.slice(), U = w[D - 1];
2044
- m[D - 1] = U & -129;
2045
- const C = ne(m), H = _ ? o : n.ORDER;
2046
- Jt("pointHex.y", C, ht, H);
2047
- const x = c(C * C), E = c(x - tt), g = c(L * x - p);
2048
- let { isValid: B, value: A } = f(E, g);
2049
- if (!B)
2050
- throw new Error("Point.fromHex: invalid y coordinate");
2051
- const I = (A & tt) === tt, S = (U & 128) !== 0;
2052
- if (!_ && A === ht && S)
2053
- throw new Error("Point.fromHex: x=0 and x_0=1");
2054
- return S !== I && (A = c(-A)), u.fromAffine({ x: A, y: C });
2055
- }
2056
- static fromPrivateScalar(w) {
2057
- return u.BASE.multiply(w);
2058
- }
2059
- toBytes() {
2060
- const { x: w, y: _ } = this.toAffine(), L = se(_, n.BYTES);
2061
- return L[L.length - 1] |= w & tt ? 128 : 0, L;
2062
- }
2063
- /** @deprecated use `toBytes` */
2064
- toRawBytes() {
2065
- return this.toBytes();
2066
- }
2067
- toHex() {
2068
- return Mt(this.toBytes());
2069
- }
2070
- toString() {
2071
- return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
2072
- }
2073
- }
2074
- u.BASE = new u(t.Gx, t.Gy, tt, c(t.Gx * t.Gy)), u.ZERO = new u(ht, tt, tt, ht), u.Fp = n, u.Fn = s;
2075
- const y = hs(u, s.BYTES * 8);
2076
- return u;
2077
- }
2078
- function Mr(t, e) {
2079
- ue(e, {
2080
- hash: "function"
2081
- }, {
2082
- adjustScalarBytes: "function",
2083
- randomBytes: "function",
2084
- domain: "function",
2085
- prehash: "function",
2086
- mapToCurve: "function"
2087
- });
2088
- const { prehash: n, hash: s } = e, { BASE: r, Fp: i, Fn: o } = t, c = o.ORDER, f = e.randomBytes || Fn, l = e.adjustScalarBytes || ((m) => m), h = e.domain || ((m, U, C) => {
2089
- if (Vt("phflag", C), U.length || C)
2090
- throw new Error("Contexts/pre-hash are not supported");
2091
- return m;
2092
- });
2093
- function a(m) {
2094
- return o.create(m);
2095
- }
2096
- function d(m) {
2097
- return a(ne(m));
2098
- }
2099
- function u(m) {
2100
- const U = i.BYTES;
2101
- m = V("private key", m, U);
2102
- const C = V("hashed private key", s(m), 2 * U), H = l(C.slice(0, U)), x = C.slice(U, 2 * U), E = d(H);
2103
- return { head: H, prefix: x, scalar: E };
2104
- }
2105
- function y(m) {
2106
- const { head: U, prefix: C, scalar: H } = u(m), x = r.multiply(H), E = x.toBytes();
2107
- return { head: U, prefix: C, scalar: H, point: x, pointBytes: E };
2108
- }
2109
- function b(m) {
2110
- return y(m).pointBytes;
2111
- }
2112
- function w(m = Uint8Array.of(), ...U) {
2113
- const C = wt(...U);
2114
- return d(s(h(C, V("context", m), !!n)));
2115
- }
2116
- function _(m, U, C = {}) {
2117
- m = V("message", m), n && (m = n(m));
2118
- const { prefix: H, scalar: x, pointBytes: E } = y(U), g = w(C.context, H, m), B = r.multiply(g).toBytes(), A = w(C.context, B, E, m), I = a(g + A * x);
2119
- Jt("signature.s", I, ht, c);
2120
- const S = i.BYTES, $ = wt(B, se(I, S));
2121
- return V("result", $, S * 2);
2122
- }
2123
- const L = Nr;
2124
- function p(m, U, C, H = L) {
2125
- const { context: x, zip215: E } = H, g = i.BYTES;
2126
- m = V("signature", m, 2 * g), U = V("message", U), C = V("publicKey", C, g), E !== void 0 && Vt("zip215", E), n && (U = n(U));
2127
- const B = ne(m.slice(g, 2 * g));
2128
- let A, I, S;
2129
- try {
2130
- A = t.fromHex(C, E), I = t.fromHex(m.slice(0, g), E), S = r.multiplyUnsafe(B);
2131
- } catch {
2132
- return !1;
2133
- }
2134
- if (!E && A.isSmallOrder())
2135
- return !1;
2136
- const $ = w(x, I.toBytes(), A.toBytes(), U);
2137
- return I.add(A.multiplyUnsafe($)).subtract(S).clearCofactor().is0();
2138
- }
2139
- return r.precompute(8), { getPublicKey: b, sign: _, verify: p, utils: {
2140
- getExtendedPublicKey: y,
2141
- /** ed25519 priv keys are uniform 32b. No need to check for modulo bias, like in secp256k1. */
2142
- randomPrivateKey: () => f(i.BYTES),
2143
- /**
2144
- * We're doing scalar multiplication (used in getPublicKey etc) with precomputed BASE_POINT
2145
- * values. This slows down first getPublicKey() by milliseconds (see Speed section),
2146
- * but allows to speed-up subsequent getPublicKey() calls up to 20x.
2147
- * @param windowSize 2, 4, 8, 16
2148
- */
2149
- precompute(m = 8, U = t.BASE) {
2150
- return U.precompute(m, !1);
2151
- }
2152
- }, Point: t };
2153
- }
2154
- function Vr(t) {
2155
- const e = {
2156
- a: t.a,
2157
- d: t.d,
2158
- p: t.Fp.ORDER,
2159
- n: t.n,
2160
- h: t.h,
2161
- Gx: t.Gx,
2162
- Gy: t.Gy
2163
- }, n = t.Fp, s = Zt(e.n, t.nBitLength, !0), r = { Fp: n, Fn: s, uvRatio: t.uvRatio }, i = {
2164
- hash: t.hash,
2165
- randomBytes: t.randomBytes,
2166
- adjustScalarBytes: t.adjustScalarBytes,
2167
- domain: t.domain,
2168
- prehash: t.prehash,
2169
- mapToCurve: t.mapToCurve
2170
- };
2171
- return { CURVE: e, curveOpts: r, eddsaOpts: i };
2172
- }
2173
- function Zr(t, e) {
2174
- return Object.assign({}, e, { ExtendedPoint: e.Point, CURVE: t });
2175
- }
2176
- function zr(t) {
2177
- const { CURVE: e, curveOpts: n, eddsaOpts: s } = Vr(t), r = Gr(e, n), i = Mr(r, s);
2178
- return Zr(t, i);
2179
- }
2180
- const ui = BigInt(0), xi = BigInt(1), bi = BigInt(2);
2181
- const jr = BigInt(0), gt = BigInt(1), En = BigInt(2), wi = BigInt(3), Wr = BigInt(5), Kr = BigInt(8), Ue = {
2182
- p: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),
2183
- n: BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),
2184
- h: Kr,
2185
- a: BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),
2186
- d: BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),
2187
- Gx: BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),
2188
- Gy: BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")
2189
- };
2190
- function Yr(t) {
2191
- const e = BigInt(10), n = BigInt(20), s = BigInt(40), r = BigInt(80), i = Ue.p, c = t * t % i * t % i, f = Z(c, En, i) * c % i, l = Z(f, gt, i) * t % i, h = Z(l, Wr, i) * l % i, a = Z(h, e, i) * h % i, d = Z(a, n, i) * a % i, u = Z(d, s, i) * d % i, y = Z(u, r, i) * u % i, b = Z(y, r, i) * u % i, w = Z(b, e, i) * h % i;
2192
- return { pow_p_5_8: Z(w, En, i) * t % i, b2: c };
2193
- }
2194
- function Xr(t) {
2195
- return t[0] &= 248, t[31] &= 127, t[31] |= 64, t;
2196
- }
2197
- const We = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
2198
- function cn(t, e) {
2199
- const n = Ue.p, s = z(e * e * e, n), r = z(s * s * e, n), i = Yr(t * r).pow_p_5_8;
2200
- let o = z(t * s * i, n);
2201
- const c = z(e * o * o, n), f = o, l = z(o * We, n), h = c === t, a = c === z(-t, n), d = c === z(-t * We, n);
2202
- return h && (o = f), (a || d) && (o = l), Ot(o, n) && (o = z(-o, n)), { isValid: h || a, value: o };
2203
- }
2204
- const Qt = Zt(Ue.p, void 0, !0), Fr = {
2205
- ...Ue,
2206
- Fp: Qt,
2207
- hash: Cr,
2208
- adjustScalarBytes: Xr,
2209
- // dom2
2210
- // Ratio of u to v. Allows us to combine inversion and square root. Uses algo from RFC8032 5.1.3.
2211
- // Constant-time, u/√v
2212
- uvRatio: cn
2213
- }, st = zr(Fr);
2214
- function Ge(t) {
2215
- if (!(t instanceof W))
2216
- throw new Error("RistrettoPoint expected");
2217
- }
2218
- const Ke = We, Pr = /* @__PURE__ */ BigInt("25063068953384623474111414158702152701244531502492656460079210482610430750235"), Qr = /* @__PURE__ */ BigInt("54469307008909316920995813868745141605393597292927456921205312896311721017578"), Jr = /* @__PURE__ */ BigInt("1159843021668779879193775521855586647937357759715417654439879720876111806838"), to = /* @__PURE__ */ BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952"), An = (t) => cn(gt, t), eo = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"), Me = (t) => st.CURVE.Fp.create(ne(t) & eo);
2219
- function _n(t) {
2220
- const { d: e } = st.CURVE, n = st.CURVE.Fp.ORDER, s = st.CURVE.Fp.create, r = s(Ke * t * t), i = s((r + gt) * Jr);
2221
- let o = BigInt(-1);
2222
- const c = s((o - e * r) * s(r + e));
2223
- let { isValid: f, value: l } = cn(i, c), h = s(l * t);
2224
- Ot(h, n) || (h = s(-h)), f || (l = h), f || (o = r);
2225
- const a = s(o * (r - gt) * to - c), d = l * l, u = s((l + l) * c), y = s(a * Pr), b = s(gt - d), w = s(gt + d);
2226
- return new st.Point(s(u * w), s(b * y), s(y * w), s(u * b));
2227
- }
2228
- class W {
2229
- // Private property to discourage combining ExtendedPoint + RistrettoPoint
2230
- // Always use Ristretto encoding/decoding instead.
2231
- constructor(e) {
2232
- this.ep = e;
2233
- }
2234
- static fromAffine(e) {
2235
- return new W(st.Point.fromAffine(e));
2236
- }
2237
- /**
2238
- * Takes uniform output of 64-byte hash function like sha512 and converts it to `RistrettoPoint`.
2239
- * The hash-to-group operation applies Elligator twice and adds the results.
2240
- * **Note:** this is one-way map, there is no conversion from point to hash.
2241
- * Described in [RFC9380](https://www.rfc-editor.org/rfc/rfc9380#appendix-B) and on
2242
- * the [website](https://ristretto.group/formulas/elligator.html).
2243
- * @param hex 64-byte output of a hash function
2244
- */
2245
- static hashToCurve(e) {
2246
- e = V("ristrettoHash", e, 64);
2247
- const n = Me(e.slice(0, 32)), s = _n(n), r = Me(e.slice(32, 64)), i = _n(r);
2248
- return new W(s.add(i));
2249
- }
2250
- static fromBytes(e) {
2251
- return it(e), this.fromHex(e);
2252
- }
2253
- /**
2254
- * Converts ristretto-encoded string to ristretto point.
2255
- * Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-decode).
2256
- * @param hex Ristretto-encoded 32 bytes. Not every 32-byte string is valid ristretto encoding
2257
- */
2258
- static fromHex(e) {
2259
- e = V("ristrettoHex", e, 32);
2260
- const { a: n, d: s } = st.CURVE, r = Qt.ORDER, i = Qt.create, o = "RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint", c = Me(e);
2261
- if (!sr(se(c, 32), e) || Ot(c, r))
2262
- throw new Error(o);
2263
- const f = i(c * c), l = i(gt + n * f), h = i(gt - n * f), a = i(l * l), d = i(h * h), u = i(n * s * a - d), { isValid: y, value: b } = An(i(u * d)), w = i(b * h), _ = i(b * w * u);
2264
- let L = i((c + c) * w);
2265
- Ot(L, r) && (L = i(-L));
2266
- const p = i(l * _), D = i(L * p);
2267
- if (!y || Ot(D, r) || p === jr)
2268
- throw new Error(o);
2269
- return new W(new st.Point(L, p, gt, D));
2270
- }
2271
- static msm(e, n) {
2272
- const s = Zt(st.CURVE.n, st.CURVE.nBitLength);
2273
- return on(W, s, e, n);
2274
- }
2275
- /**
2276
- * Encodes ristretto point to Uint8Array.
2277
- * Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-encode).
2278
- */
2279
- toBytes() {
2280
- let { ex: e, ey: n, ez: s, et: r } = this.ep;
2281
- const i = Qt.ORDER, o = Qt.create, c = o(o(s + n) * o(s - n)), f = o(e * n), l = o(f * f), { value: h } = An(o(c * l)), a = o(h * c), d = o(h * f), u = o(a * d * r);
2282
- let y;
2283
- if (Ot(r * u, i)) {
2284
- let w = o(n * Ke), _ = o(e * Ke);
2285
- e = w, n = _, y = o(a * Qr);
2286
- } else
2287
- y = d;
2288
- Ot(e * u, i) && (n = o(-n));
2289
- let b = o((s - n) * y);
2290
- return Ot(b, i) && (b = o(-b)), se(b, 32);
2291
- }
2292
- /** @deprecated use `toBytes` */
2293
- toRawBytes() {
2294
- return this.toBytes();
2295
- }
2296
- toHex() {
2297
- return Mt(this.toBytes());
2298
- }
2299
- toString() {
2300
- return this.toHex();
2301
- }
2302
- /**
2303
- * Compares two Ristretto points.
2304
- * Described in [RFC9496](https://www.rfc-editor.org/rfc/rfc9496#name-equals).
2305
- */
2306
- equals(e) {
2307
- Ge(e);
2308
- const { ex: n, ey: s } = this.ep, { ex: r, ey: i } = e.ep, o = Qt.create, c = o(n * i) === o(s * r), f = o(s * i) === o(n * r);
2309
- return c || f;
2310
- }
2311
- add(e) {
2312
- return Ge(e), new W(this.ep.add(e.ep));
2313
- }
2314
- subtract(e) {
2315
- return Ge(e), new W(this.ep.subtract(e.ep));
2316
- }
2317
- multiply(e) {
2318
- return new W(this.ep.multiply(e));
2319
- }
2320
- multiplyUnsafe(e) {
2321
- return new W(this.ep.multiplyUnsafe(e));
2322
- }
2323
- double() {
2324
- return new W(this.ep.double());
2325
- }
2326
- negate() {
2327
- return new W(this.ep.negate());
2328
- }
2329
- }
2330
- const gi = (W.BASE || (W.BASE = new W(st.Point.BASE)), W.ZERO || (W.ZERO = new W(st.Point.ZERO)), W), pe = /* @__PURE__ */ BigInt(2 ** 32 - 1), Hn = /* @__PURE__ */ BigInt(32);
2331
- function no(t, e = !1) {
2332
- return e ? { h: Number(t & pe), l: Number(t >> Hn & pe) } : { h: Number(t >> Hn & pe) | 0, l: Number(t & pe) | 0 };
2333
- }
2334
- function ds(t, e = !1) {
2335
- const n = t.length;
2336
- let s = new Uint32Array(n), r = new Uint32Array(n);
2337
- for (let i = 0; i < n; i++) {
2338
- const { h: o, l: c } = no(t[i], e);
2339
- [s[i], r[i]] = [o, c];
2340
- }
2341
- return [s, r];
2342
- }
2343
- const Sn = (t, e, n) => t >>> n, In = (t, e, n) => t << 32 - n | e >>> n, Xt = (t, e, n) => t >>> n | e << 32 - n, Ft = (t, e, n) => t << 32 - n | e >>> n, me = (t, e, n) => t << 64 - n | e >>> n - 32, Be = (t, e, n) => t >>> n - 32 | e << 64 - n, so = (t, e, n) => t << n | e >>> 32 - n, ro = (t, e, n) => e << n | t >>> 32 - n, oo = (t, e, n) => e << n - 32 | t >>> 64 - n, io = (t, e, n) => t << n - 32 | e >>> 64 - n;
2344
- function ut(t, e, n, s) {
2345
- const r = (e >>> 0) + (s >>> 0);
2346
- return { h: t + n + (r / 2 ** 32 | 0) | 0, l: r | 0 };
2347
- }
2348
- const co = (t, e, n) => (t >>> 0) + (e >>> 0) + (n >>> 0), fo = (t, e, n, s) => e + n + s + (t / 2 ** 32 | 0) | 0, ao = (t, e, n, s) => (t >>> 0) + (e >>> 0) + (n >>> 0) + (s >>> 0), ho = (t, e, n, s, r) => e + n + s + r + (t / 2 ** 32 | 0) | 0, lo = (t, e, n, s, r) => (t >>> 0) + (e >>> 0) + (n >>> 0) + (s >>> 0) + (r >>> 0), uo = (t, e, n, s, r, i) => e + n + s + r + i + (t / 2 ** 32 | 0) | 0, Pt = typeof globalThis == "object" && "crypto" in globalThis ? globalThis.crypto : void 0;
2349
- function xo(t) {
2350
- return t instanceof Uint8Array || ArrayBuffer.isView(t) && t.constructor.name === "Uint8Array";
2351
- }
2352
- function $e(t, ...e) {
2353
- if (!xo(t))
2354
- throw new Error("Uint8Array expected");
2355
- if (e.length > 0 && !e.includes(t.length))
2356
- throw new Error("Uint8Array expected of length " + e + ", got length=" + t.length);
2357
- }
2358
- function vn(t, e = !0) {
2359
- if (t.destroyed)
2360
- throw new Error("Hash instance has been destroyed");
2361
- if (e && t.finished)
2362
- throw new Error("Hash#digest() has already been called");
2363
- }
2364
- function bo(t, e) {
2365
- $e(t);
2366
- const n = e.outputLen;
2367
- if (t.length < n)
2368
- throw new Error("digestInto() expects output buffer of length at least " + n);
2369
- }
2370
- function yi(t) {
2371
- return new Uint32Array(t.buffer, t.byteOffset, Math.floor(t.byteLength / 4));
2372
- }
2373
- function Se(...t) {
2374
- for (let e = 0; e < t.length; e++)
2375
- t[e].fill(0);
2376
- }
2377
- function Ve(t) {
2378
- return new DataView(t.buffer, t.byteOffset, t.byteLength);
2379
- }
2380
- function wo(t) {
2381
- if (typeof t != "string")
2382
- throw new Error("string expected");
2383
- return new Uint8Array(new TextEncoder().encode(t));
2384
- }
2385
- function us(t) {
2386
- return typeof t == "string" && (t = wo(t)), $e(t), t;
2387
- }
2388
- function pi(...t) {
2389
- let e = 0;
2390
- for (let s = 0; s < t.length; s++) {
2391
- const r = t[s];
2392
- $e(r), e += r.length;
2393
- }
2394
- const n = new Uint8Array(e);
2395
- for (let s = 0, r = 0; s < t.length; s++) {
2396
- const i = t[s];
2397
- n.set(i, r), r += i.length;
2398
- }
2399
- return n;
2400
- }
2401
- let go = class {
2402
- };
2403
- function yo(t) {
2404
- const e = (s) => t().update(us(s)).digest(), n = t();
2405
- return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
2406
- }
2407
- function Bi(t = 32) {
2408
- if (Pt && typeof Pt.getRandomValues == "function")
2409
- return Pt.getRandomValues(new Uint8Array(t));
2410
- if (Pt && typeof Pt.randomBytes == "function")
2411
- return Uint8Array.from(Pt.randomBytes(t));
2412
- throw new Error("crypto.getRandomValues must be defined");
2413
- }
2414
- const po = BigInt(0), ce = BigInt(1), mo = BigInt(2), Bo = BigInt(7), Eo = BigInt(256), Ao = BigInt(113), xs = [], bs = [], ws = [];
2415
- for (let t = 0, e = ce, n = 1, s = 0; t < 24; t++) {
2416
- [n, s] = [s, (2 * n + 3 * s) % 5], xs.push(2 * (5 * s + n)), bs.push((t + 1) * (t + 2) / 2 % 64);
2417
- let r = po;
2418
- for (let i = 0; i < 7; i++)
2419
- e = (e << ce ^ (e >> Bo) * Ao) % Eo, e & mo && (r ^= ce << (ce << /* @__PURE__ */ BigInt(i)) - ce);
2420
- ws.push(r);
2421
- }
2422
- const gs = ds(ws, !0), _o = gs[0], Ho = gs[1], Ln = (t, e, n) => n > 32 ? oo(t, e, n) : so(t, e, n), Un = (t, e, n) => n > 32 ? io(t, e, n) : ro(t, e, n);
2423
- function Ei(t, e = 24) {
2424
- const n = new Uint32Array(10);
2425
- for (let s = 24 - e; s < 24; s++) {
2426
- for (let o = 0; o < 10; o++)
2427
- n[o] = t[o] ^ t[o + 10] ^ t[o + 20] ^ t[o + 30] ^ t[o + 40];
2428
- for (let o = 0; o < 10; o += 2) {
2429
- const c = (o + 8) % 10, f = (o + 2) % 10, l = n[f], h = n[f + 1], a = Ln(l, h, 1) ^ n[c], d = Un(l, h, 1) ^ n[c + 1];
2430
- for (let u = 0; u < 50; u += 10)
2431
- t[o + u] ^= a, t[o + u + 1] ^= d;
2432
- }
2433
- let r = t[2], i = t[3];
2434
- for (let o = 0; o < 24; o++) {
2435
- const c = bs[o], f = Ln(r, i, c), l = Un(r, i, c), h = xs[o];
2436
- r = t[h], i = t[h + 1], t[h] = f, t[h + 1] = l;
2437
- }
2438
- for (let o = 0; o < 50; o += 10) {
2439
- for (let c = 0; c < 10; c++)
2440
- n[c] = t[o + c];
2441
- for (let c = 0; c < 10; c++)
2442
- t[o + c] ^= ~n[(c + 2) % 10] & n[(c + 4) % 10];
2443
- }
2444
- t[0] ^= _o[s], t[1] ^= Ho[s];
2445
- }
2446
- Se(n);
2447
- }
2448
- function So(t, e, n, s) {
2449
- if (typeof t.setBigUint64 == "function")
2450
- return t.setBigUint64(e, n, s);
2451
- const r = BigInt(32), i = BigInt(4294967295), o = Number(n >> r & i), c = Number(n & i), f = s ? 4 : 0, l = s ? 0 : 4;
2452
- t.setUint32(e + f, o, s), t.setUint32(e + l, c, s);
2453
- }
2454
- let Io = class extends go {
2455
- constructor(e, n, s, r) {
2456
- super(), this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.blockLen = e, this.outputLen = n, this.padOffset = s, this.isLE = r, this.buffer = new Uint8Array(e), this.view = Ve(this.buffer);
2457
- }
2458
- update(e) {
2459
- vn(this), e = us(e), $e(e);
2460
- const { view: n, buffer: s, blockLen: r } = this, i = e.length;
2461
- for (let o = 0; o < i; ) {
2462
- const c = Math.min(r - this.pos, i - o);
2463
- if (c === r) {
2464
- const f = Ve(e);
2465
- for (; r <= i - o; o += r)
2466
- this.process(f, o);
2467
- continue;
2468
- }
2469
- s.set(e.subarray(o, o + c), this.pos), this.pos += c, o += c, this.pos === r && (this.process(n, 0), this.pos = 0);
2470
- }
2471
- return this.length += e.length, this.roundClean(), this;
2472
- }
2473
- digestInto(e) {
2474
- vn(this), bo(e, this), this.finished = !0;
2475
- const { buffer: n, view: s, blockLen: r, isLE: i } = this;
2476
- let { pos: o } = this;
2477
- n[o++] = 128, Se(this.buffer.subarray(o)), this.padOffset > r - o && (this.process(s, 0), o = 0);
2478
- for (let a = o; a < r; a++)
2479
- n[a] = 0;
2480
- So(s, r - 8, BigInt(this.length * 8), i), this.process(s, 0);
2481
- const c = Ve(e), f = this.outputLen;
2482
- if (f % 4)
2483
- throw new Error("_sha2: outputLen should be aligned to 32bit");
2484
- const l = f / 4, h = this.get();
2485
- if (l > h.length)
2486
- throw new Error("_sha2: outputLen bigger than state");
2487
- for (let a = 0; a < l; a++)
2488
- c.setUint32(4 * a, h[a], i);
2489
- }
2490
- digest() {
2491
- const { buffer: e, outputLen: n } = this;
2492
- this.digestInto(e);
2493
- const s = e.slice(0, n);
2494
- return this.destroy(), s;
2495
- }
2496
- _cloneInto(e) {
2497
- e || (e = new this.constructor()), e.set(...this.get());
2498
- const { blockLen: n, buffer: s, length: r, finished: i, destroyed: o, pos: c } = this;
2499
- return e.destroyed = o, e.finished = i, e.length = r, e.pos = c, r % n && e.buffer.set(s), e;
2500
- }
2501
- clone() {
2502
- return this._cloneInto();
2503
- }
2504
- };
2505
- const Q = /* @__PURE__ */ Uint32Array.from([
2506
- 1779033703,
2507
- 4089235720,
2508
- 3144134277,
2509
- 2227873595,
2510
- 1013904242,
2511
- 4271175723,
2512
- 2773480762,
2513
- 1595750129,
2514
- 1359893119,
2515
- 2917565137,
2516
- 2600822924,
2517
- 725511199,
2518
- 528734635,
2519
- 4215389547,
2520
- 1541459225,
2521
- 327033209
2522
- ]);
2523
- const ys = ds([
2524
- "0x428a2f98d728ae22",
2525
- "0x7137449123ef65cd",
2526
- "0xb5c0fbcfec4d3b2f",
2527
- "0xe9b5dba58189dbbc",
2528
- "0x3956c25bf348b538",
2529
- "0x59f111f1b605d019",
2530
- "0x923f82a4af194f9b",
2531
- "0xab1c5ed5da6d8118",
2532
- "0xd807aa98a3030242",
2533
- "0x12835b0145706fbe",
2534
- "0x243185be4ee4b28c",
2535
- "0x550c7dc3d5ffb4e2",
2536
- "0x72be5d74f27b896f",
2537
- "0x80deb1fe3b1696b1",
2538
- "0x9bdc06a725c71235",
2539
- "0xc19bf174cf692694",
2540
- "0xe49b69c19ef14ad2",
2541
- "0xefbe4786384f25e3",
2542
- "0x0fc19dc68b8cd5b5",
2543
- "0x240ca1cc77ac9c65",
2544
- "0x2de92c6f592b0275",
2545
- "0x4a7484aa6ea6e483",
2546
- "0x5cb0a9dcbd41fbd4",
2547
- "0x76f988da831153b5",
2548
- "0x983e5152ee66dfab",
2549
- "0xa831c66d2db43210",
2550
- "0xb00327c898fb213f",
2551
- "0xbf597fc7beef0ee4",
2552
- "0xc6e00bf33da88fc2",
2553
- "0xd5a79147930aa725",
2554
- "0x06ca6351e003826f",
2555
- "0x142929670a0e6e70",
2556
- "0x27b70a8546d22ffc",
2557
- "0x2e1b21385c26c926",
2558
- "0x4d2c6dfc5ac42aed",
2559
- "0x53380d139d95b3df",
2560
- "0x650a73548baf63de",
2561
- "0x766a0abb3c77b2a8",
2562
- "0x81c2c92e47edaee6",
2563
- "0x92722c851482353b",
2564
- "0xa2bfe8a14cf10364",
2565
- "0xa81a664bbc423001",
2566
- "0xc24b8b70d0f89791",
2567
- "0xc76c51a30654be30",
2568
- "0xd192e819d6ef5218",
2569
- "0xd69906245565a910",
2570
- "0xf40e35855771202a",
2571
- "0x106aa07032bbd1b8",
2572
- "0x19a4c116b8d2d0c8",
2573
- "0x1e376c085141ab53",
2574
- "0x2748774cdf8eeb99",
2575
- "0x34b0bcb5e19b48a8",
2576
- "0x391c0cb3c5c95a63",
2577
- "0x4ed8aa4ae3418acb",
2578
- "0x5b9cca4f7763e373",
2579
- "0x682e6ff3d6b2b8a3",
2580
- "0x748f82ee5defb2fc",
2581
- "0x78a5636f43172f60",
2582
- "0x84c87814a1f0ab72",
2583
- "0x8cc702081a6439ec",
2584
- "0x90befffa23631e28",
2585
- "0xa4506cebde82bde9",
2586
- "0xbef9a3f7b2c67915",
2587
- "0xc67178f2e372532b",
2588
- "0xca273eceea26619c",
2589
- "0xd186b8c721c0c207",
2590
- "0xeada7dd6cde0eb1e",
2591
- "0xf57d4f7fee6ed178",
2592
- "0x06f067aa72176fba",
2593
- "0x0a637dc5a2c898a6",
2594
- "0x113f9804bef90dae",
2595
- "0x1b710b35131c471b",
2596
- "0x28db77f523047d84",
2597
- "0x32caab7b40c72493",
2598
- "0x3c9ebe0a15c9bebc",
2599
- "0x431d67c49c100d4c",
2600
- "0x4cc5d4becb3e42b6",
2601
- "0x597f299cfc657e2a",
2602
- "0x5fcb6fab3ad6faec",
2603
- "0x6c44198c4a475817"
2604
- ].map((t) => BigInt(t))), vo = ys[0], Lo = ys[1], vt = /* @__PURE__ */ new Uint32Array(80), Lt = /* @__PURE__ */ new Uint32Array(80);
2605
- class Uo extends Io {
2606
- constructor(e = 64) {
2607
- super(128, e, 16, !1), this.Ah = Q[0] | 0, this.Al = Q[1] | 0, this.Bh = Q[2] | 0, this.Bl = Q[3] | 0, this.Ch = Q[4] | 0, this.Cl = Q[5] | 0, this.Dh = Q[6] | 0, this.Dl = Q[7] | 0, this.Eh = Q[8] | 0, this.El = Q[9] | 0, this.Fh = Q[10] | 0, this.Fl = Q[11] | 0, this.Gh = Q[12] | 0, this.Gl = Q[13] | 0, this.Hh = Q[14] | 0, this.Hl = Q[15] | 0;
2608
- }
2609
- // prettier-ignore
2610
- get() {
2611
- const { Ah: e, Al: n, Bh: s, Bl: r, Ch: i, Cl: o, Dh: c, Dl: f, Eh: l, El: h, Fh: a, Fl: d, Gh: u, Gl: y, Hh: b, Hl: w } = this;
2612
- return [e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w];
2613
- }
2614
- // prettier-ignore
2615
- set(e, n, s, r, i, o, c, f, l, h, a, d, u, y, b, w) {
2616
- this.Ah = e | 0, this.Al = n | 0, this.Bh = s | 0, this.Bl = r | 0, this.Ch = i | 0, this.Cl = o | 0, this.Dh = c | 0, this.Dl = f | 0, this.Eh = l | 0, this.El = h | 0, this.Fh = a | 0, this.Fl = d | 0, this.Gh = u | 0, this.Gl = y | 0, this.Hh = b | 0, this.Hl = w | 0;
2617
- }
2618
- process(e, n) {
2619
- for (let p = 0; p < 16; p++, n += 4)
2620
- vt[p] = e.getUint32(n), Lt[p] = e.getUint32(n += 4);
2621
- for (let p = 16; p < 80; p++) {
2622
- const D = vt[p - 15] | 0, m = Lt[p - 15] | 0, U = Xt(D, m, 1) ^ Xt(D, m, 8) ^ Sn(D, m, 7), C = Ft(D, m, 1) ^ Ft(D, m, 8) ^ In(D, m, 7), H = vt[p - 2] | 0, x = Lt[p - 2] | 0, E = Xt(H, x, 19) ^ me(H, x, 61) ^ Sn(H, x, 6), g = Ft(H, x, 19) ^ Be(H, x, 61) ^ In(H, x, 6), B = ao(C, g, Lt[p - 7], Lt[p - 16]), A = ho(B, U, E, vt[p - 7], vt[p - 16]);
2623
- vt[p] = A | 0, Lt[p] = B | 0;
2624
- }
2625
- let { Ah: s, Al: r, Bh: i, Bl: o, Ch: c, Cl: f, Dh: l, Dl: h, Eh: a, El: d, Fh: u, Fl: y, Gh: b, Gl: w, Hh: _, Hl: L } = this;
2626
- for (let p = 0; p < 80; p++) {
2627
- const D = Xt(a, d, 14) ^ Xt(a, d, 18) ^ me(a, d, 41), m = Ft(a, d, 14) ^ Ft(a, d, 18) ^ Be(a, d, 41), U = a & u ^ ~a & b, C = d & y ^ ~d & w, H = lo(L, m, C, Lo[p], Lt[p]), x = uo(H, _, D, U, vo[p], vt[p]), E = H | 0, g = Xt(s, r, 28) ^ me(s, r, 34) ^ me(s, r, 39), B = Ft(s, r, 28) ^ Be(s, r, 34) ^ Be(s, r, 39), A = s & i ^ s & c ^ i & c, I = r & o ^ r & f ^ o & f;
2628
- _ = b | 0, L = w | 0, b = u | 0, w = y | 0, u = a | 0, y = d | 0, { h: a, l: d } = ut(l | 0, h | 0, x | 0, E | 0), l = c | 0, h = f | 0, c = i | 0, f = o | 0, i = s | 0, o = r | 0;
2629
- const S = co(E, B, I);
2630
- s = fo(S, x, g, A), r = S | 0;
2631
- }
2632
- ({ h: s, l: r } = ut(this.Ah | 0, this.Al | 0, s | 0, r | 0)), { h: i, l: o } = ut(this.Bh | 0, this.Bl | 0, i | 0, o | 0), { h: c, l: f } = ut(this.Ch | 0, this.Cl | 0, c | 0, f | 0), { h: l, l: h } = ut(this.Dh | 0, this.Dl | 0, l | 0, h | 0), { h: a, l: d } = ut(this.Eh | 0, this.El | 0, a | 0, d | 0), { h: u, l: y } = ut(this.Fh | 0, this.Fl | 0, u | 0, y | 0), { h: b, l: w } = ut(this.Gh | 0, this.Gl | 0, b | 0, w | 0), { h: _, l: L } = ut(this.Hh | 0, this.Hl | 0, _ | 0, L | 0), this.set(s, r, i, o, c, f, l, h, a, d, u, y, b, w, _, L);
2633
- }
2634
- roundClean() {
2635
- Se(vt, Lt);
2636
- }
2637
- destroy() {
2638
- Se(this.buffer), this.set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
2639
- }
2640
- }
2641
- const $o = /* @__PURE__ */ yo(() => new Uo()), _i = $o, Hi = Fs, Si = Je;
2642
- class ps extends Yn {
2643
- constructor(e, n) {
2644
- super(), this.finished = !1, this.destroyed = !1, Js(e);
2645
- const s = nn(n);
2646
- if (this.iHash = e.create(), typeof this.iHash.update != "function")
2647
- throw new Error("Expected instance of class which extends utils.Hash");
2648
- this.blockLen = this.iHash.blockLen, this.outputLen = this.iHash.outputLen;
2649
- const r = this.blockLen, i = new Uint8Array(r);
2650
- i.set(s.length > r ? e.create().update(s).digest() : s);
2651
- for (let o = 0; o < i.length; o++)
2652
- i[o] ^= 54;
2653
- this.iHash.update(i), this.oHash = e.create();
2654
- for (let o = 0; o < i.length; o++)
2655
- i[o] ^= 106;
2656
- this.oHash.update(i), ee(i);
2657
- }
2658
- update(e) {
2659
- return _e(this), this.iHash.update(e), this;
2660
- }
2661
- digestInto(e) {
2662
- _e(this), it(e, this.outputLen), this.finished = !0, this.iHash.digestInto(e), this.oHash.update(e), this.oHash.digestInto(e), this.destroy();
2663
- }
2664
- digest() {
2665
- const e = new Uint8Array(this.oHash.outputLen);
2666
- return this.digestInto(e), e;
2667
- }
2668
- _cloneInto(e) {
2669
- e || (e = Object.create(Object.getPrototypeOf(this), {}));
2670
- const { oHash: n, iHash: s, finished: r, destroyed: i, blockLen: o, outputLen: c } = this;
2671
- return e = e, e.finished = r, e.destroyed = i, e.blockLen = o, e.outputLen = c, e.oHash = n._cloneInto(e.oHash), e.iHash = s._cloneInto(e.iHash), e;
2672
- }
2673
- clone() {
2674
- return this._cloneInto();
2675
- }
2676
- destroy() {
2677
- this.destroyed = !0, this.oHash.destroy(), this.iHash.destroy();
2678
- }
2679
- }
2680
- const ms = (t, e, n) => new ps(t, e).update(n).digest();
2681
- ms.create = (t, e) => new ps(t, e);
2682
- function $n(t) {
2683
- t.lowS !== void 0 && Vt("lowS", t.lowS), t.prehash !== void 0 && Vt("prehash", t.prehash);
2684
- }
2685
- class Do extends Error {
2686
- constructor(e = "") {
2687
- super(e);
2688
- }
2689
- }
2690
- const bt = {
2691
- // asn.1 DER encoding utils
2692
- Err: Do,
2693
- // Basic building block is TLV (Tag-Length-Value)
2694
- _tlv: {
2695
- encode: (t, e) => {
2696
- const { Err: n } = bt;
2697
- if (t < 0 || t > 256)
2698
- throw new n("tlv.encode: wrong tag");
2699
- if (e.length & 1)
2700
- throw new n("tlv.encode: unpadded data");
2701
- const s = e.length / 2, r = be(s);
2702
- if (r.length / 2 & 128)
2703
- throw new n("tlv.encode: long form length too big");
2704
- const i = s > 127 ? be(r.length / 2 | 128) : "";
2705
- return be(t) + i + r + e;
2706
- },
2707
- // v - value, l - left bytes (unparsed)
2708
- decode(t, e) {
2709
- const { Err: n } = bt;
2710
- let s = 0;
2711
- if (t < 0 || t > 256)
2712
- throw new n("tlv.encode: wrong tag");
2713
- if (e.length < 2 || e[s++] !== t)
2714
- throw new n("tlv.decode: wrong tlv");
2715
- const r = e[s++], i = !!(r & 128);
2716
- let o = 0;
2717
- if (!i)
2718
- o = r;
2719
- else {
2720
- const f = r & 127;
2721
- if (!f)
2722
- throw new n("tlv.decode(long): indefinite length not supported");
2723
- if (f > 4)
2724
- throw new n("tlv.decode(long): byte length is too big");
2725
- const l = e.subarray(s, s + f);
2726
- if (l.length !== f)
2727
- throw new n("tlv.decode: length bytes not complete");
2728
- if (l[0] === 0)
2729
- throw new n("tlv.decode(long): zero leftmost byte");
2730
- for (const h of l)
2731
- o = o << 8 | h;
2732
- if (s += f, o < 128)
2733
- throw new n("tlv.decode(long): not minimal encoding");
2734
- }
2735
- const c = e.subarray(s, s + o);
2736
- if (c.length !== o)
2737
- throw new n("tlv.decode: wrong value length");
2738
- return { v: c, l: e.subarray(s + o) };
2739
- }
2740
- },
2741
- // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
2742
- // since we always use positive integers here. It must always be empty:
2743
- // - add zero byte if exists
2744
- // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
2745
- _int: {
2746
- encode(t) {
2747
- const { Err: e } = bt;
2748
- if (t < le)
2749
- throw new e("integer: negative integers are not allowed");
2750
- let n = be(t);
2751
- if (Number.parseInt(n[0], 16) & 8 && (n = "00" + n), n.length & 1)
2752
- throw new e("unexpected DER parsing assertion: unpadded hex");
2753
- return n;
2754
- },
2755
- decode(t) {
2756
- const { Err: e } = bt;
2757
- if (t[0] & 128)
2758
- throw new e("invalid signature integer: negative");
2759
- if (t[0] === 0 && !(t[1] & 128))
2760
- throw new e("invalid signature integer: unnecessary leading zero");
2761
- return ve(t);
2762
- }
2763
- },
2764
- toSig(t) {
2765
- const { Err: e, _int: n, _tlv: s } = bt, r = V("signature", t), { v: i, l: o } = s.decode(48, r);
2766
- if (o.length)
2767
- throw new e("invalid signature: left bytes after parsing");
2768
- const { v: c, l: f } = s.decode(2, i), { v: l, l: h } = s.decode(2, f);
2769
- if (h.length)
2770
- throw new e("invalid signature: left bytes after parsing");
2771
- return { r: n.decode(c), s: n.decode(l) };
2772
- },
2773
- hexFromSig(t) {
2774
- const { _tlv: e, _int: n } = bt, s = e.encode(2, n.encode(t.r)), r = e.encode(2, n.encode(t.s)), i = s + r;
2775
- return e.encode(48, i);
2776
- }
2777
- }, le = BigInt(0), de = BigInt(1), Co = BigInt(2), Ee = BigInt(3), ko = BigInt(4);
2778
- function Oo(t, e, n) {
2779
- function s(r) {
2780
- const i = t.sqr(r), o = t.mul(i, r);
2781
- return t.add(t.add(o, t.mul(r, e)), n);
2782
- }
2783
- return s;
2784
- }
2785
- function Bs(t, e, n) {
2786
- const { BYTES: s } = t;
2787
- function r(i) {
2788
- let o;
2789
- if (typeof i == "bigint")
2790
- o = i;
2791
- else {
2792
- let c = V("private key", i);
2793
- if (e) {
2794
- if (!e.includes(c.length * 2))
2795
- throw new Error("invalid private key");
2796
- const f = new Uint8Array(s);
2797
- f.set(c, f.length - c.length), c = f;
2798
- }
2799
- try {
2800
- o = t.fromBytes(c);
2801
- } catch {
2802
- throw new Error(`invalid private key: expected ui8a of size ${s}, got ${typeof i}`);
2803
- }
2804
- }
2805
- if (n && (o = t.create(o)), !t.isValidNot0(o))
2806
- throw new Error("invalid private key: out of range [1..N-1]");
2807
- return o;
2808
- }
2809
- return r;
2810
- }
2811
- function Ro(t, e = {}) {
2812
- const { Fp: n, Fn: s } = ls("weierstrass", t, e), { h: r, n: i } = t;
2813
- ue(e, {}, {
2814
- allowInfinityPoint: "boolean",
2815
- clearCofactor: "function",
2816
- isTorsionFree: "function",
2817
- fromBytes: "function",
2818
- toBytes: "function",
2819
- endo: "object",
2820
- wrapPrivateKey: "boolean"
2821
- });
2822
- const { endo: o } = e;
2823
- if (o && (!n.is0(t.a) || typeof o.beta != "bigint" || typeof o.splitScalar != "function"))
2824
- throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');
2825
- function c() {
2826
- if (!n.isOdd)
2827
- throw new Error("compression is not supported: Field does not have .isOdd()");
2828
- }
2829
- function f(H, x, E) {
2830
- const { x: g, y: B } = x.toAffine(), A = n.toBytes(g);
2831
- if (Vt("isCompressed", E), E) {
2832
- c();
2833
- const I = !n.isOdd(B);
2834
- return wt(Es(I), A);
2835
- } else
2836
- return wt(Uint8Array.of(4), A, n.toBytes(B));
2837
- }
2838
- function l(H) {
2839
- it(H);
2840
- const x = n.BYTES, E = x + 1, g = 2 * x + 1, B = H.length, A = H[0], I = H.subarray(1);
2841
- if (B === E && (A === 2 || A === 3)) {
2842
- const S = n.fromBytes(I);
2843
- if (!n.isValid(S))
2844
- throw new Error("bad point: is not on curve, wrong x");
2845
- const $ = d(S);
2846
- let O;
2847
- try {
2848
- O = n.sqrt($);
2849
- } catch (T) {
2850
- const R = T instanceof Error ? ": " + T.message : "";
2851
- throw new Error("bad point: is not on curve, sqrt error" + R);
2852
- }
2853
- c();
2854
- const k = n.isOdd(O);
2855
- return (A & 1) === 1 !== k && (O = n.neg(O)), { x: S, y: O };
2856
- } else if (B === g && A === 4) {
2857
- const S = n.fromBytes(I.subarray(x * 0, x * 1)), $ = n.fromBytes(I.subarray(x * 1, x * 2));
2858
- if (!u(S, $))
2859
- throw new Error("bad point: is not on curve");
2860
- return { x: S, y: $ };
2861
- } else
2862
- throw new Error(`bad point: got length ${B}, expected compressed=${E} or uncompressed=${g}`);
2863
- }
2864
- const h = e.toBytes || f, a = e.fromBytes || l, d = Oo(n, t.a, t.b);
2865
- function u(H, x) {
2866
- const E = n.sqr(x), g = d(H);
2867
- return n.eql(E, g);
2868
- }
2869
- if (!u(t.Gx, t.Gy))
2870
- throw new Error("bad curve params: generator point");
2871
- const y = n.mul(n.pow(t.a, Ee), ko), b = n.mul(n.sqr(t.b), BigInt(27));
2872
- if (n.is0(n.add(y, b)))
2873
- throw new Error("bad curve params: a or b");
2874
- function w(H, x, E = !1) {
2875
- if (!n.isValid(x) || E && n.is0(x))
2876
- throw new Error(`bad point coordinate ${H}`);
2877
- return x;
2878
- }
2879
- function _(H) {
2880
- if (!(H instanceof m))
2881
- throw new Error("ProjectivePoint expected");
2882
- }
2883
- const L = He((H, x) => {
2884
- const { px: E, py: g, pz: B } = H;
2885
- if (n.eql(B, n.ONE))
2886
- return { x: E, y: g };
2887
- const A = H.is0();
2888
- x == null && (x = A ? n.ONE : n.inv(B));
2889
- const I = n.mul(E, x), S = n.mul(g, x), $ = n.mul(B, x);
2890
- if (A)
2891
- return { x: n.ZERO, y: n.ZERO };
2892
- if (!n.eql($, n.ONE))
2893
- throw new Error("invZ was invalid");
2894
- return { x: I, y: S };
2895
- }), p = He((H) => {
2896
- if (H.is0()) {
2897
- if (e.allowInfinityPoint && !n.is0(H.py))
2898
- return;
2899
- throw new Error("bad point: ZERO");
2900
- }
2901
- const { x, y: E } = H.toAffine();
2902
- if (!n.isValid(x) || !n.isValid(E))
2903
- throw new Error("bad point: x or y not field elements");
2904
- if (!u(x, E))
2905
- throw new Error("bad point: equation left != right");
2906
- if (!H.isTorsionFree())
2907
- throw new Error("bad point: not in prime-order subgroup");
2908
- return !0;
2909
- });
2910
- function D(H, x, E, g, B) {
2911
- return E = new m(n.mul(E.px, H), E.py, E.pz), x = he(g, x), E = he(B, E), x.add(E);
2912
- }
2913
- class m {
2914
- /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2915
- constructor(x, E, g) {
2916
- this.px = w("x", x), this.py = w("y", E, !0), this.pz = w("z", g), Object.freeze(this);
2917
- }
2918
- /** Does NOT validate if the point is valid. Use `.assertValidity()`. */
2919
- static fromAffine(x) {
2920
- const { x: E, y: g } = x || {};
2921
- if (!x || !n.isValid(E) || !n.isValid(g))
2922
- throw new Error("invalid affine point");
2923
- if (x instanceof m)
2924
- throw new Error("projective point not allowed");
2925
- return n.is0(E) && n.is0(g) ? m.ZERO : new m(E, g, n.ONE);
2926
- }
2927
- get x() {
2928
- return this.toAffine().x;
2929
- }
2930
- get y() {
2931
- return this.toAffine().y;
2932
- }
2933
- static normalizeZ(x) {
2934
- return cs(m, "pz", x);
2935
- }
2936
- static fromBytes(x) {
2937
- return it(x), m.fromHex(x);
2938
- }
2939
- /** Converts hash string or Uint8Array to Point. */
2940
- static fromHex(x) {
2941
- const E = m.fromAffine(a(V("pointHex", x)));
2942
- return E.assertValidity(), E;
2943
- }
2944
- /** Multiplies generator point by privateKey. */
2945
- static fromPrivateKey(x) {
2946
- const E = Bs(s, e.allowedPrivateKeyLengths, e.wrapPrivateKey);
2947
- return m.BASE.multiply(E(x));
2948
- }
2949
- /** Multiscalar Multiplication */
2950
- static msm(x, E) {
2951
- return on(m, s, x, E);
2952
- }
2953
- /**
2954
- *
2955
- * @param windowSize
2956
- * @param isLazy true will defer table computation until the first multiplication
2957
- * @returns
2958
- */
2959
- precompute(x = 8, E = !0) {
2960
- return C.setWindowSize(this, x), E || this.multiply(Ee), this;
2961
- }
2962
- /** "Private method", don't use it directly */
2963
- _setWindowSize(x) {
2964
- this.precompute(x);
2965
- }
2966
- // TODO: return `this`
2967
- /** A point on curve is valid if it conforms to equation. */
2968
- assertValidity() {
2969
- p(this);
2970
- }
2971
- hasEvenY() {
2972
- const { y: x } = this.toAffine();
2973
- if (!n.isOdd)
2974
- throw new Error("Field doesn't support isOdd");
2975
- return !n.isOdd(x);
2976
- }
2977
- /** Compare one point to another. */
2978
- equals(x) {
2979
- _(x);
2980
- const { px: E, py: g, pz: B } = this, { px: A, py: I, pz: S } = x, $ = n.eql(n.mul(E, S), n.mul(A, B)), O = n.eql(n.mul(g, S), n.mul(I, B));
2981
- return $ && O;
2982
- }
2983
- /** Flips point to one corresponding to (x, -y) in Affine coordinates. */
2984
- negate() {
2985
- return new m(this.px, n.neg(this.py), this.pz);
2986
- }
2987
- // Renes-Costello-Batina exception-free doubling formula.
2988
- // There is 30% faster Jacobian formula, but it is not complete.
2989
- // https://eprint.iacr.org/2015/1060, algorithm 3
2990
- // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
2991
- double() {
2992
- const { a: x, b: E } = t, g = n.mul(E, Ee), { px: B, py: A, pz: I } = this;
2993
- let S = n.ZERO, $ = n.ZERO, O = n.ZERO, k = n.mul(B, B), q = n.mul(A, A), T = n.mul(I, I), R = n.mul(B, A);
2994
- return R = n.add(R, R), O = n.mul(B, I), O = n.add(O, O), S = n.mul(x, O), $ = n.mul(g, T), $ = n.add(S, $), S = n.sub(q, $), $ = n.add(q, $), $ = n.mul(S, $), S = n.mul(R, S), O = n.mul(g, O), T = n.mul(x, T), R = n.sub(k, T), R = n.mul(x, R), R = n.add(R, O), O = n.add(k, k), k = n.add(O, k), k = n.add(k, T), k = n.mul(k, R), $ = n.add($, k), T = n.mul(A, I), T = n.add(T, T), k = n.mul(T, R), S = n.sub(S, k), O = n.mul(T, q), O = n.add(O, O), O = n.add(O, O), new m(S, $, O);
2995
- }
2996
- // Renes-Costello-Batina exception-free addition formula.
2997
- // There is 30% faster Jacobian formula, but it is not complete.
2998
- // https://eprint.iacr.org/2015/1060, algorithm 1
2999
- // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
3000
- add(x) {
3001
- _(x);
3002
- const { px: E, py: g, pz: B } = this, { px: A, py: I, pz: S } = x;
3003
- let $ = n.ZERO, O = n.ZERO, k = n.ZERO;
3004
- const q = t.a, T = n.mul(t.b, Ee);
3005
- let R = n.mul(E, A), M = n.mul(g, I), K = n.mul(B, S), X = n.add(E, g), G = n.add(A, I);
3006
- X = n.mul(X, G), G = n.add(R, M), X = n.sub(X, G), G = n.add(E, B);
3007
- let J = n.add(A, S);
3008
- return G = n.mul(G, J), J = n.add(R, K), G = n.sub(G, J), J = n.add(g, B), $ = n.add(I, S), J = n.mul(J, $), $ = n.add(M, K), J = n.sub(J, $), k = n.mul(q, G), $ = n.mul(T, K), k = n.add($, k), $ = n.sub(M, k), k = n.add(M, k), O = n.mul($, k), M = n.add(R, R), M = n.add(M, R), K = n.mul(q, K), G = n.mul(T, G), M = n.add(M, K), K = n.sub(R, K), K = n.mul(q, K), G = n.add(G, K), R = n.mul(M, G), O = n.add(O, R), R = n.mul(J, G), $ = n.mul(X, $), $ = n.sub($, R), R = n.mul(X, M), k = n.mul(J, k), k = n.add(k, R), new m($, O, k);
3009
- }
3010
- subtract(x) {
3011
- return this.add(x.negate());
3012
- }
3013
- is0() {
3014
- return this.equals(m.ZERO);
3015
- }
3016
- /**
3017
- * Constant time multiplication.
3018
- * Uses wNAF method. Windowed method may be 10% faster,
3019
- * but takes 2x longer to generate and consumes 2x memory.
3020
- * Uses precomputes when available.
3021
- * Uses endomorphism for Koblitz curves.
3022
- * @param scalar by which the point would be multiplied
3023
- * @returns New point
3024
- */
3025
- multiply(x) {
3026
- const { endo: E } = e;
3027
- if (!s.isValidNot0(x))
3028
- throw new Error("invalid scalar: out of range");
3029
- let g, B;
3030
- const A = (I) => C.wNAFCached(this, I, m.normalizeZ);
3031
- if (E) {
3032
- const { k1neg: I, k1: S, k2neg: $, k2: O } = E.splitScalar(x), { p: k, f: q } = A(S), { p: T, f: R } = A(O);
3033
- B = q.add(R), g = D(E.beta, k, T, I, $);
3034
- } else {
3035
- const { p: I, f: S } = A(x);
3036
- g = I, B = S;
3037
- }
3038
- return m.normalizeZ([g, B])[0];
3039
- }
3040
- /**
3041
- * Non-constant-time multiplication. Uses double-and-add algorithm.
3042
- * It's faster, but should only be used when you don't care about
3043
- * an exposed private key e.g. sig verification, which works over *public* keys.
3044
- */
3045
- multiplyUnsafe(x) {
3046
- const { endo: E } = e, g = this;
3047
- if (!s.isValid(x))
3048
- throw new Error("invalid scalar: out of range");
3049
- if (x === le || g.is0())
3050
- return m.ZERO;
3051
- if (x === de)
3052
- return g;
3053
- if (C.hasPrecomputes(this))
3054
- return this.multiply(x);
3055
- if (E) {
3056
- const { k1neg: B, k1: A, k2neg: I, k2: S } = E.splitScalar(x), { p1: $, p2: O } = Rr(m, g, A, S);
3057
- return D(E.beta, $, O, B, I);
3058
- } else
3059
- return C.wNAFCachedUnsafe(g, x);
3060
- }
3061
- multiplyAndAddUnsafe(x, E, g) {
3062
- const B = this.multiplyUnsafe(E).add(x.multiplyUnsafe(g));
3063
- return B.is0() ? void 0 : B;
3064
- }
3065
- /**
3066
- * Converts Projective point to affine (x, y) coordinates.
3067
- * @param invertedZ Z^-1 (inverted zero) - optional, precomputation is useful for invertBatch
3068
- */
3069
- toAffine(x) {
3070
- return L(this, x);
3071
- }
3072
- /**
3073
- * Checks whether Point is free of torsion elements (is in prime subgroup).
3074
- * Always torsion-free for cofactor=1 curves.
3075
- */
3076
- isTorsionFree() {
3077
- const { isTorsionFree: x } = e;
3078
- return r === de ? !0 : x ? x(m, this) : C.wNAFCachedUnsafe(this, i).is0();
3079
- }
3080
- clearCofactor() {
3081
- const { clearCofactor: x } = e;
3082
- return r === de ? this : x ? x(m, this) : this.multiplyUnsafe(r);
3083
- }
3084
- toBytes(x = !0) {
3085
- return Vt("isCompressed", x), this.assertValidity(), h(m, this, x);
3086
- }
3087
- /** @deprecated use `toBytes` */
3088
- toRawBytes(x = !0) {
3089
- return this.toBytes(x);
3090
- }
3091
- toHex(x = !0) {
3092
- return Mt(this.toBytes(x));
3093
- }
3094
- toString() {
3095
- return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
3096
- }
3097
- }
3098
- m.BASE = new m(t.Gx, t.Gy, n.ONE), m.ZERO = new m(n.ZERO, n.ONE, n.ZERO), m.Fp = n, m.Fn = s;
3099
- const U = s.BITS, C = hs(m, e.endo ? Math.ceil(U / 2) : U);
3100
- return m;
3101
- }
3102
- function Es(t) {
3103
- return Uint8Array.of(t ? 2 : 3);
3104
- }
3105
- function To(t, e, n = {}) {
3106
- ue(e, { hash: "function" }, {
3107
- hmac: "function",
3108
- lowS: "boolean",
3109
- randomBytes: "function",
3110
- bits2int: "function",
3111
- bits2int_modN: "function"
3112
- });
3113
- const s = e.randomBytes || Fn, r = e.hmac || ((g, ...B) => ms(e.hash, g, wt(...B))), { Fp: i, Fn: o } = t, { ORDER: c, BITS: f } = o;
3114
- function l(g) {
3115
- const B = c >> de;
3116
- return g > B;
3117
- }
3118
- function h(g) {
3119
- return l(g) ? o.neg(g) : g;
3120
- }
3121
- function a(g, B) {
3122
- if (!o.isValidNot0(B))
3123
- throw new Error(`invalid signature ${g}: out of range 1..CURVE.n`);
3124
- }
3125
- class d {
3126
- constructor(B, A, I) {
3127
- a("r", B), a("s", A), this.r = B, this.s = A, I != null && (this.recovery = I), Object.freeze(this);
3128
- }
3129
- // pair (bytes of r, bytes of s)
3130
- static fromCompact(B) {
3131
- const A = o.BYTES, I = V("compactSignature", B, A * 2);
3132
- return new d(o.fromBytes(I.subarray(0, A)), o.fromBytes(I.subarray(A, A * 2)));
3133
- }
3134
- // DER encoded ECDSA signature
3135
- // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
3136
- static fromDER(B) {
3137
- const { r: A, s: I } = bt.toSig(V("DER", B));
3138
- return new d(A, I);
3139
- }
3140
- /**
3141
- * @todo remove
3142
- * @deprecated
3143
- */
3144
- assertValidity() {
3145
- }
3146
- addRecoveryBit(B) {
3147
- return new d(this.r, this.s, B);
3148
- }
3149
- // ProjPointType<bigint>
3150
- recoverPublicKey(B) {
3151
- const A = i.ORDER, { r: I, s: S, recovery: $ } = this;
3152
- if ($ == null || ![0, 1, 2, 3].includes($))
3153
- throw new Error("recovery id invalid");
3154
- if (c * Co < A && $ > 1)
3155
- throw new Error("recovery id is ambiguous for h>1 curve");
3156
- const k = $ === 2 || $ === 3 ? I + c : I;
3157
- if (!i.isValid(k))
3158
- throw new Error("recovery id 2 or 3 invalid");
3159
- const q = i.toBytes(k), T = t.fromHex(wt(Es(($ & 1) === 0), q)), R = o.inv(k), M = p(V("msgHash", B)), K = o.create(-M * R), X = o.create(S * R), G = t.BASE.multiplyUnsafe(K).add(T.multiplyUnsafe(X));
3160
- if (G.is0())
3161
- throw new Error("point at infinify");
3162
- return G.assertValidity(), G;
3163
- }
3164
- // Signatures should be low-s, to prevent malleability.
3165
- hasHighS() {
3166
- return l(this.s);
3167
- }
3168
- normalizeS() {
3169
- return this.hasHighS() ? new d(this.r, o.neg(this.s), this.recovery) : this;
3170
- }
3171
- toBytes(B) {
3172
- if (B === "compact")
3173
- return wt(o.toBytes(this.r), o.toBytes(this.s));
3174
- if (B === "der")
3175
- return en(bt.hexFromSig(this));
3176
- throw new Error("invalid format");
3177
- }
3178
- // DER-encoded
3179
- toDERRawBytes() {
3180
- return this.toBytes("der");
3181
- }
3182
- toDERHex() {
3183
- return Mt(this.toBytes("der"));
3184
- }
3185
- // padded bytes of r, then padded bytes of s
3186
- toCompactRawBytes() {
3187
- return this.toBytes("compact");
3188
- }
3189
- toCompactHex() {
3190
- return Mt(this.toBytes("compact"));
3191
- }
3192
- }
3193
- const u = Bs(o, n.allowedPrivateKeyLengths, n.wrapPrivateKey), y = {
3194
- isValidPrivateKey(g) {
3195
- try {
3196
- return u(g), !0;
3197
- } catch {
3198
- return !1;
3199
- }
3200
- },
3201
- normPrivateKeyToScalar: u,
3202
- /**
3203
- * Produces cryptographically secure private key from random of size
3204
- * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
3205
- */
3206
- randomPrivateKey: () => {
3207
- const g = c;
3208
- return br(s(rs(g)), g);
3209
- },
3210
- precompute(g = 8, B = t.BASE) {
3211
- return B.precompute(g, !1);
3212
- }
3213
- };
3214
- function b(g, B = !0) {
3215
- return t.fromPrivateKey(g).toBytes(B);
3216
- }
3217
- function w(g) {
3218
- if (typeof g == "bigint")
3219
- return !1;
3220
- if (g instanceof t)
3221
- return !0;
3222
- const A = V("key", g).length, I = i.BYTES, S = I + 1, $ = 2 * I + 1;
3223
- if (!(n.allowedPrivateKeyLengths || o.BYTES === S))
3224
- return A === S || A === $;
3225
- }
3226
- function _(g, B, A = !0) {
3227
- if (w(g) === !0)
3228
- throw new Error("first arg must be private key");
3229
- if (w(B) === !1)
3230
- throw new Error("second arg must be public key");
3231
- return t.fromHex(B).multiply(u(g)).toBytes(A);
3232
- }
3233
- const L = e.bits2int || function(g) {
3234
- if (g.length > 8192)
3235
- throw new Error("input is too large");
3236
- const B = ve(g), A = g.length * 8 - f;
3237
- return A > 0 ? B >> BigInt(A) : B;
3238
- }, p = e.bits2int_modN || function(g) {
3239
- return o.create(L(g));
3240
- }, D = Le(f);
3241
- function m(g) {
3242
- return Jt("num < 2^" + f, g, le, D), o.toBytes(g);
3243
- }
3244
- function U(g, B, A = C) {
3245
- if (["recovered", "canonical"].some((X) => X in A))
3246
- throw new Error("sign() legacy options not supported");
3247
- const { hash: I } = e;
3248
- let { lowS: S, prehash: $, extraEntropy: O } = A;
3249
- S == null && (S = !0), g = V("msgHash", g), $n(A), $ && (g = V("prehashed msgHash", I(g)));
3250
- const k = p(g), q = u(B), T = [m(q), m(k)];
3251
- if (O != null && O !== !1) {
3252
- const X = O === !0 ? s(i.BYTES) : O;
3253
- T.push(V("extraEntropy", X));
3254
- }
3255
- const R = wt(...T), M = k;
3256
- function K(X) {
3257
- const G = L(X);
3258
- if (!o.isValidNot0(G))
3259
- return;
3260
- const J = o.inv(G), ie = t.BASE.multiply(G).toAffine(), zt = o.create(ie.x);
3261
- if (zt === le)
3262
- return;
3263
- const Tt = o.create(J * o.create(M + zt * q));
3264
- if (Tt === le)
3265
- return;
3266
- let De = (ie.x === zt ? 0 : 2) | Number(ie.y & de), jt = Tt;
3267
- return S && l(Tt) && (jt = h(Tt), De ^= 1), new d(zt, jt, De);
3268
- }
3269
- return { seed: R, k2sig: K };
3270
- }
3271
- const C = { lowS: e.lowS, prehash: !1 }, H = { lowS: e.lowS, prehash: !1 };
3272
- function x(g, B, A = C) {
3273
- const { seed: I, k2sig: S } = U(g, B, A);
3274
- return ir(e.hash.outputLen, o.BYTES, r)(I, S);
3275
- }
3276
- t.BASE.precompute(8);
3277
- function E(g, B, A, I = H) {
3278
- const S = g;
3279
- B = V("msgHash", B), A = V("publicKey", A), $n(I);
3280
- const { lowS: $, prehash: O, format: k } = I;
3281
- if ("strict" in I)
3282
- throw new Error("options.strict was renamed to lowS");
3283
- if (k !== void 0 && !["compact", "der", "js"].includes(k))
3284
- throw new Error('format must be "compact", "der" or "js"');
3285
- const q = typeof S == "string" || tn(S), T = !q && !k && typeof S == "object" && S !== null && typeof S.r == "bigint" && typeof S.s == "bigint";
3286
- if (!q && !T)
3287
- throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
3288
- let R, M;
3289
- try {
3290
- if (T)
3291
- if (k === void 0 || k === "js")
3292
- R = new d(S.r, S.s);
3293
- else
3294
- throw new Error("invalid format");
3295
- if (q) {
3296
- try {
3297
- k !== "compact" && (R = d.fromDER(S));
3298
- } catch (jt) {
3299
- if (!(jt instanceof bt.Err))
3300
- throw jt;
3301
- }
3302
- !R && k !== "der" && (R = d.fromCompact(S));
3303
- }
3304
- M = t.fromHex(A);
3305
- } catch {
3306
- return !1;
3307
- }
3308
- if (!R || $ && R.hasHighS())
3309
- return !1;
3310
- O && (B = e.hash(B));
3311
- const { r: K, s: X } = R, G = p(B), J = o.inv(X), ie = o.create(G * J), zt = o.create(K * J), Tt = t.BASE.multiplyUnsafe(ie).add(M.multiplyUnsafe(zt));
3312
- return Tt.is0() ? !1 : o.create(Tt.x) === K;
3313
- }
3314
- return Object.freeze({
3315
- getPublicKey: b,
3316
- getSharedSecret: _,
3317
- sign: x,
3318
- verify: E,
3319
- utils: y,
3320
- Point: t,
3321
- Signature: d
3322
- });
3323
- }
3324
- function No(t) {
3325
- const e = {
3326
- a: t.a,
3327
- b: t.b,
3328
- p: t.Fp.ORDER,
3329
- n: t.n,
3330
- h: t.h,
3331
- Gx: t.Gx,
3332
- Gy: t.Gy
3333
- }, n = t.Fp, s = Zt(e.n, t.nBitLength), r = {
3334
- Fp: n,
3335
- Fn: s,
3336
- allowedPrivateKeyLengths: t.allowedPrivateKeyLengths,
3337
- allowInfinityPoint: t.allowInfinityPoint,
3338
- endo: t.endo,
3339
- wrapPrivateKey: t.wrapPrivateKey,
3340
- isTorsionFree: t.isTorsionFree,
3341
- clearCofactor: t.clearCofactor,
3342
- fromBytes: t.fromBytes,
3343
- toBytes: t.toBytes
3344
- };
3345
- return { CURVE: e, curveOpts: r };
3346
- }
3347
- function qo(t) {
3348
- const { CURVE: e, curveOpts: n } = No(t), s = {
3349
- hash: t.hash,
3350
- hmac: t.hmac,
3351
- randomBytes: t.randomBytes,
3352
- lowS: t.lowS,
3353
- bits2int: t.bits2int,
3354
- bits2int_modN: t.bits2int_modN
3355
- };
3356
- return { CURVE: e, curveOpts: n, ecdsaOpts: s };
3357
- }
3358
- function Go(t, e) {
3359
- return Object.assign({}, e, {
3360
- ProjectivePoint: e.Point,
3361
- CURVE: t
3362
- });
3363
- }
3364
- function Mo(t) {
3365
- const { CURVE: e, curveOpts: n, ecdsaOpts: s } = qo(t), r = Ro(e, n), i = To(r, s, n);
3366
- return Go(t, i);
3367
- }
3368
- function Vo(t, e) {
3369
- const n = (s) => Mo({ ...t, hash: s });
3370
- return { ...n(e), create: n };
3371
- }
3372
- const Ie = {
3373
- p: BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),
3374
- n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
3375
- h: BigInt(1),
3376
- a: BigInt(0),
3377
- b: BigInt(7),
3378
- Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
3379
- Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
3380
- };
3381
- BigInt(0);
3382
- const Zo = BigInt(1), Ye = BigInt(2), Dn = (t, e) => (t + e / Ye) / e;
3383
- function zo(t) {
3384
- const e = Ie.p, n = BigInt(3), s = BigInt(6), r = BigInt(11), i = BigInt(22), o = BigInt(23), c = BigInt(44), f = BigInt(88), l = t * t * t % e, h = l * l * t % e, a = Z(h, n, e) * h % e, d = Z(a, n, e) * h % e, u = Z(d, Ye, e) * l % e, y = Z(u, r, e) * u % e, b = Z(y, i, e) * y % e, w = Z(b, c, e) * b % e, _ = Z(w, f, e) * w % e, L = Z(_, c, e) * b % e, p = Z(L, n, e) * h % e, D = Z(p, o, e) * y % e, m = Z(D, s, e) * l % e, U = Z(m, Ye, e);
3385
- if (!Xe.eql(Xe.sqr(U), t))
3386
- throw new Error("Cannot find square root");
3387
- return U;
3388
- }
3389
- const Xe = Zt(Ie.p, void 0, void 0, { sqrt: zo }), Ii = Vo({
3390
- ...Ie,
3391
- Fp: Xe,
3392
- lowS: !0,
3393
- // Allow only low-S signatures by default in sign() and verify()
3394
- endo: {
3395
- // Endomorphism, see above
3396
- beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
3397
- splitScalar: (t) => {
3398
- const e = Ie.n, n = BigInt("0x3086d221a7d46bcde86c90e49284eb15"), s = -Zo * BigInt("0xe4437ed6010e88286f547fa90abfe4c3"), r = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"), i = n, o = BigInt("0x100000000000000000000000000000000"), c = Dn(i * t, e), f = Dn(-s * t, e);
3399
- let l = z(t - c * n - f * r, e), h = z(-c * s - f * i, e);
3400
- const a = l > o, d = h > o;
3401
- if (a && (l = e - l), d && (h = e - h), l > o || h > o)
3402
- throw new Error("splitScalar: Endomorphism failed, k=" + t);
3403
- return { k1neg: a, k1: l, k2neg: d, k2: h };
3404
- }
3405
- }
3406
- }, Dr);
3407
- function jo(t) {
3408
- return t instanceof Uint8Array || t != null && typeof t == "object" && t.constructor.name === "Uint8Array";
3409
- }
3410
- function As(t, ...e) {
3411
- if (!jo(t))
3412
- throw new Error("Uint8Array expected");
3413
- if (e.length > 0 && !e.includes(t.length))
3414
- throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`);
3415
- }
3416
- function Cn(t, e = !0) {
3417
- if (t.destroyed)
3418
- throw new Error("Hash instance has been destroyed");
3419
- if (e && t.finished)
3420
- throw new Error("Hash#digest() has already been called");
3421
- }
3422
- function Wo(t, e) {
3423
- As(t);
3424
- const n = e.outputLen;
3425
- if (t.length < n)
3426
- throw new Error(`digestInto() expects output buffer of length at least ${n}`);
3427
- }
3428
- const Ze = (t) => new DataView(t.buffer, t.byteOffset, t.byteLength), at = (t, e) => t << 32 - e | t >>> e;
3429
- function Ko(t) {
3430
- if (typeof t != "string")
3431
- throw new Error(`utf8ToBytes expected string, got ${typeof t}`);
3432
- return new Uint8Array(new TextEncoder().encode(t));
3433
- }
3434
- function _s(t) {
3435
- return typeof t == "string" && (t = Ko(t)), As(t), t;
3436
- }
3437
- class Yo {
3438
- // Safe version that clones internal state
3439
- clone() {
3440
- return this._cloneInto();
3441
- }
3442
- }
3443
- function Xo(t) {
3444
- const e = (s) => t().update(_s(s)).digest(), n = t();
3445
- return e.outputLen = n.outputLen, e.blockLen = n.blockLen, e.create = () => t(), e;
3446
- }
3447
- function Fo(t, e, n, s) {
3448
- if (typeof t.setBigUint64 == "function")
3449
- return t.setBigUint64(e, n, s);
3450
- const r = BigInt(32), i = BigInt(4294967295), o = Number(n >> r & i), c = Number(n & i), f = s ? 4 : 0, l = s ? 0 : 4;
3451
- t.setUint32(e + f, o, s), t.setUint32(e + l, c, s);
3452
- }
3453
- const Po = (t, e, n) => t & e ^ ~t & n, Qo = (t, e, n) => t & e ^ t & n ^ e & n;
3454
- class Jo extends Yo {
3455
- constructor(e, n, s, r) {
3456
- super(), this.blockLen = e, this.outputLen = n, this.padOffset = s, this.isLE = r, this.finished = !1, this.length = 0, this.pos = 0, this.destroyed = !1, this.buffer = new Uint8Array(e), this.view = Ze(this.buffer);
3457
- }
3458
- update(e) {
3459
- Cn(this);
3460
- const { view: n, buffer: s, blockLen: r } = this;
3461
- e = _s(e);
3462
- const i = e.length;
3463
- for (let o = 0; o < i; ) {
3464
- const c = Math.min(r - this.pos, i - o);
3465
- if (c === r) {
3466
- const f = Ze(e);
3467
- for (; r <= i - o; o += r)
3468
- this.process(f, o);
3469
- continue;
3470
- }
3471
- s.set(e.subarray(o, o + c), this.pos), this.pos += c, o += c, this.pos === r && (this.process(n, 0), this.pos = 0);
3472
- }
3473
- return this.length += e.length, this.roundClean(), this;
3474
- }
3475
- digestInto(e) {
3476
- Cn(this), Wo(e, this), this.finished = !0;
3477
- const { buffer: n, view: s, blockLen: r, isLE: i } = this;
3478
- let { pos: o } = this;
3479
- n[o++] = 128, this.buffer.subarray(o).fill(0), this.padOffset > r - o && (this.process(s, 0), o = 0);
3480
- for (let a = o; a < r; a++)
3481
- n[a] = 0;
3482
- Fo(s, r - 8, BigInt(this.length * 8), i), this.process(s, 0);
3483
- const c = Ze(e), f = this.outputLen;
3484
- if (f % 4)
3485
- throw new Error("_sha2: outputLen should be aligned to 32bit");
3486
- const l = f / 4, h = this.get();
3487
- if (l > h.length)
3488
- throw new Error("_sha2: outputLen bigger than state");
3489
- for (let a = 0; a < l; a++)
3490
- c.setUint32(4 * a, h[a], i);
3491
- }
3492
- digest() {
3493
- const { buffer: e, outputLen: n } = this;
3494
- this.digestInto(e);
3495
- const s = e.slice(0, n);
3496
- return this.destroy(), s;
3497
- }
3498
- _cloneInto(e) {
3499
- e || (e = new this.constructor()), e.set(...this.get());
3500
- const { blockLen: n, buffer: s, length: r, finished: i, destroyed: o, pos: c } = this;
3501
- return e.length = r, e.pos = c, e.finished = i, e.destroyed = o, r % n && e.buffer.set(s), e;
3502
- }
3503
- }
3504
- const ti = /* @__PURE__ */ new Uint32Array([
3505
- 1116352408,
3506
- 1899447441,
3507
- 3049323471,
3508
- 3921009573,
3509
- 961987163,
3510
- 1508970993,
3511
- 2453635748,
3512
- 2870763221,
3513
- 3624381080,
3514
- 310598401,
3515
- 607225278,
3516
- 1426881987,
3517
- 1925078388,
3518
- 2162078206,
3519
- 2614888103,
3520
- 3248222580,
3521
- 3835390401,
3522
- 4022224774,
3523
- 264347078,
3524
- 604807628,
3525
- 770255983,
3526
- 1249150122,
3527
- 1555081692,
3528
- 1996064986,
3529
- 2554220882,
3530
- 2821834349,
3531
- 2952996808,
3532
- 3210313671,
3533
- 3336571891,
3534
- 3584528711,
3535
- 113926993,
3536
- 338241895,
3537
- 666307205,
3538
- 773529912,
3539
- 1294757372,
3540
- 1396182291,
3541
- 1695183700,
3542
- 1986661051,
3543
- 2177026350,
3544
- 2456956037,
3545
- 2730485921,
3546
- 2820302411,
3547
- 3259730800,
3548
- 3345764771,
3549
- 3516065817,
3550
- 3600352804,
3551
- 4094571909,
3552
- 275423344,
3553
- 430227734,
3554
- 506948616,
3555
- 659060556,
3556
- 883997877,
3557
- 958139571,
3558
- 1322822218,
3559
- 1537002063,
3560
- 1747873779,
3561
- 1955562222,
3562
- 2024104815,
3563
- 2227730452,
3564
- 2361852424,
3565
- 2428436474,
3566
- 2756734187,
3567
- 3204031479,
3568
- 3329325298
3569
- ]), Ut = /* @__PURE__ */ new Uint32Array([
3570
- 1779033703,
3571
- 3144134277,
3572
- 1013904242,
3573
- 2773480762,
3574
- 1359893119,
3575
- 2600822924,
3576
- 528734635,
3577
- 1541459225
3578
- ]), $t = /* @__PURE__ */ new Uint32Array(64);
3579
- class ei extends Jo {
3580
- constructor() {
3581
- super(64, 32, 8, !1), this.A = Ut[0] | 0, this.B = Ut[1] | 0, this.C = Ut[2] | 0, this.D = Ut[3] | 0, this.E = Ut[4] | 0, this.F = Ut[5] | 0, this.G = Ut[6] | 0, this.H = Ut[7] | 0;
3582
- }
3583
- get() {
3584
- const { A: e, B: n, C: s, D: r, E: i, F: o, G: c, H: f } = this;
3585
- return [e, n, s, r, i, o, c, f];
3586
- }
3587
- // prettier-ignore
3588
- set(e, n, s, r, i, o, c, f) {
3589
- this.A = e | 0, this.B = n | 0, this.C = s | 0, this.D = r | 0, this.E = i | 0, this.F = o | 0, this.G = c | 0, this.H = f | 0;
3590
- }
3591
- process(e, n) {
3592
- for (let a = 0; a < 16; a++, n += 4)
3593
- $t[a] = e.getUint32(n, !1);
3594
- for (let a = 16; a < 64; a++) {
3595
- const d = $t[a - 15], u = $t[a - 2], y = at(d, 7) ^ at(d, 18) ^ d >>> 3, b = at(u, 17) ^ at(u, 19) ^ u >>> 10;
3596
- $t[a] = b + $t[a - 7] + y + $t[a - 16] | 0;
3597
- }
3598
- let { A: s, B: r, C: i, D: o, E: c, F: f, G: l, H: h } = this;
3599
- for (let a = 0; a < 64; a++) {
3600
- const d = at(c, 6) ^ at(c, 11) ^ at(c, 25), u = h + d + Po(c, f, l) + ti[a] + $t[a] | 0, b = (at(s, 2) ^ at(s, 13) ^ at(s, 22)) + Qo(s, r, i) | 0;
3601
- h = l, l = f, f = c, c = o + u | 0, o = i, i = r, r = s, s = u + b | 0;
3602
- }
3603
- s = s + this.A | 0, r = r + this.B | 0, i = i + this.C | 0, o = o + this.D | 0, c = c + this.E | 0, f = f + this.F | 0, l = l + this.G | 0, h = h + this.H | 0, this.set(s, r, i, o, c, f, l, h);
3604
- }
3605
- roundClean() {
3606
- $t.fill(0);
3607
- }
3608
- destroy() {
3609
- this.set(0, 0, 0, 0, 0, 0, 0, 0), this.buffer.fill(0);
3610
- }
3611
- }
3612
- const vi = /* @__PURE__ */ Xo(() => new ei());
3613
- export {
3614
- gi as R,
3615
- _i as a,
3616
- ri as b,
3617
- pi as c,
3618
- ne as d,
3619
- Jt as e,
3620
- st as f,
3621
- yi as g,
3622
- Le as h,
3623
- tn as i,
3624
- Hi as j,
3625
- Ei as k,
3626
- Si as l,
3627
- z as m,
3628
- se as n,
3629
- Ii as o,
3630
- jn as p,
3631
- vi as q,
3632
- Bi as r,
3633
- fi as s,
3634
- wo as u
3635
- };