@latticexyz/world-module-erc20 2.2.18-f0433092876e2ac9b5b12cd0ecae9c120a2d0368 → 2.2.18

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 (120) hide show
  1. package/dist/_esm-H47RQ4ED.js +3915 -0
  2. package/dist/{_esm-BQNWKNND.js.map → _esm-H47RQ4ED.js.map} +1 -1
  3. package/dist/ccip-VJWDNI4X.js +15 -0
  4. package/dist/chunk-2VXHCW2O.js +132 -0
  5. package/dist/{chunk-TJJDXMQ6.js.map → chunk-2VXHCW2O.js.map} +1 -1
  6. package/dist/chunk-LIWKL347.js +3833 -0
  7. package/dist/{chunk-GSBUANUZ.js.map → chunk-LIWKL347.js.map} +1 -1
  8. package/dist/chunk-PR4QN5HX.js +43 -0
  9. package/dist/internal.js +27 -1
  10. package/dist/internal.js.map +1 -1
  11. package/dist/mud.config.js +83 -1
  12. package/dist/mud.config.js.map +1 -1
  13. package/dist/secp256k1-XVT662DN.js +2395 -0
  14. package/dist/{secp256k1-UMYSD4MC.js.map → secp256k1-XVT662DN.js.map} +1 -1
  15. package/out/AccessManagementSystem.sol/AccessManagementSystem.json +1 -1
  16. package/out/BalanceTransferSystem.sol/BalanceTransferSystem.json +1 -1
  17. package/out/BatchCallSystem.sol/BatchCallSystem.json +1 -1
  18. package/out/Constants.sol/ERC20TableNames.json +1 -1
  19. package/out/Constants.sol/ModuleConstants.json +1 -1
  20. package/out/Constants.sol/OwnableTableNames.json +1 -1
  21. package/out/Constants.sol/PausableTableNames.json +1 -1
  22. package/out/Context.sol/Context.abi.json +15 -1
  23. package/out/Context.sol/Context.abi.json.d.ts +17 -0
  24. package/out/Context.sol/Context.json +1 -1
  25. package/out/Delegation.sol/Delegation.json +1 -1
  26. package/out/ERC20BaseTest.t.sol/ERC20BehaviorTest.json +1 -1
  27. package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreBehaviorTest.json +1 -1
  28. package/out/ERC20BaseTest.t.sol/ERC20WithInternalStoreTest.json +1 -1
  29. package/out/ERC20BaseTest.t.sol/ERC20WithWorldBehaviorTest.json +1 -1
  30. package/out/ERC20BaseTest.t.sol/ERC20WithWorldTest.json +1 -1
  31. package/out/ERC20BaseTest.t.sol/MockERC20Base.abi.json +13 -0
  32. package/out/ERC20BaseTest.t.sol/MockERC20Base.abi.json.d.ts +13 -0
  33. package/out/ERC20BaseTest.t.sol/MockERC20Base.json +1 -1
  34. package/out/ERC20BaseTest.t.sol/MockERC20WithInternalStore.abi.json +13 -0
  35. package/out/ERC20BaseTest.t.sol/MockERC20WithInternalStore.abi.json.d.ts +13 -0
  36. package/out/ERC20BaseTest.t.sol/MockERC20WithInternalStore.json +1 -1
  37. package/out/ERC20BaseTest.t.sol/MockERC20WithWorld.abi.json +95 -3
  38. package/out/ERC20BaseTest.t.sol/MockERC20WithWorld.abi.json.d.ts +95 -3
  39. package/out/ERC20BaseTest.t.sol/MockERC20WithWorld.json +1 -1
  40. package/out/ERC20BaseTest.t.sol/TestConstants.json +1 -1
  41. package/out/ERC20Burnable.sol/ERC20Burnable.abi.json +13 -0
  42. package/out/ERC20Burnable.sol/ERC20Burnable.abi.json.d.ts +13 -0
  43. package/out/ERC20Burnable.sol/ERC20Burnable.json +1 -1
  44. package/out/ERC20Burnable.t.sol/ERC20BurnableTest.json +1 -1
  45. package/out/ERC20Burnable.t.sol/ERC20BurnableWithInternalStoreTest.json +1 -1
  46. package/out/ERC20Burnable.t.sol/ERC20BurnableWithWorldTest.json +1 -1
  47. package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.abi.json +13 -0
  48. package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.abi.json.d.ts +13 -0
  49. package/out/ERC20Burnable.t.sol/MockERC20WithInternalStoreBurnable.json +1 -1
  50. package/out/ERC20Burnable.t.sol/MockERC20WithWorldBurnable.abi.json +95 -3
  51. package/out/ERC20Burnable.t.sol/MockERC20WithWorldBurnable.abi.json.d.ts +95 -3
  52. package/out/ERC20Burnable.t.sol/MockERC20WithWorldBurnable.json +1 -1
  53. package/out/ERC20Module.sol/ERC20Module.json +1 -1
  54. package/out/ERC20Module.sol/ERC20RegistryLib.json +1 -1
  55. package/out/ERC20Module.t.sol/ERC20ModuleTest.json +1 -1
  56. package/out/ERC20Module.t.sol/TestConstants.json +1 -1
  57. package/out/ERC20Pausable.sol/ERC20Pausable.abi.json +13 -0
  58. package/out/ERC20Pausable.sol/ERC20Pausable.abi.json.d.ts +13 -0
  59. package/out/ERC20Pausable.sol/ERC20Pausable.json +1 -1
  60. package/out/ERC20Pausable.t.sol/ERC20PausableBehaviorTest.json +1 -1
  61. package/out/ERC20Pausable.t.sol/ERC20PausableWithInternalStoreTest.json +1 -1
  62. package/out/ERC20Pausable.t.sol/ERC20PausableWithWorldTest.json +1 -1
  63. package/out/ERC20Pausable.t.sol/MockERC20Pausable.abi.json +13 -0
  64. package/out/ERC20Pausable.t.sol/MockERC20Pausable.abi.json.d.ts +13 -0
  65. package/out/ERC20Pausable.t.sol/MockERC20Pausable.json +1 -1
  66. package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.abi.json +13 -0
  67. package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.abi.json.d.ts +13 -0
  68. package/out/ERC20Pausable.t.sol/MockERC20WithInternalStorePausable.json +1 -1
  69. package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.abi.json +95 -3
  70. package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.abi.json.d.ts +95 -3
  71. package/out/ERC20Pausable.t.sol/MockERC20WithWorldPausable.json +1 -1
  72. package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.abi.json +13 -0
  73. package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.abi.json.d.ts +13 -0
  74. package/out/ERC20WithInternalStore.sol/ERC20WithInternalStore.json +1 -1
  75. package/out/ERC20WithWorld.sol/ERC20WithWorld.abi.json +95 -3
  76. package/out/ERC20WithWorld.sol/ERC20WithWorld.abi.json.d.ts +95 -3
  77. package/out/ERC20WithWorld.sol/ERC20WithWorld.json +1 -1
  78. package/out/IBaseWorld.sol/IBaseWorld.json +1 -1
  79. package/out/IWorldRegistrationSystem.sol/IWorldRegistrationSystem.json +1 -1
  80. package/out/InitModule.sol/InitModule.json +1 -1
  81. package/out/MUDERC20.sol/MUDERC20.abi.json +13 -0
  82. package/out/MUDERC20.sol/MUDERC20.abi.json.d.ts +13 -0
  83. package/out/MUDERC20.sol/MUDERC20.json +1 -1
  84. package/out/Module.sol/Module.json +1 -1
  85. package/out/ModuleInstallationSystem.sol/ModuleInstallationSystem.json +1 -1
  86. package/out/Ownable.sol/Ownable.abi.json +13 -0
  87. package/out/Ownable.sol/Ownable.abi.json.d.ts +13 -0
  88. package/out/Ownable.sol/Ownable.json +1 -1
  89. package/out/Pausable.sol/Pausable.abi.json +13 -0
  90. package/out/Pausable.sol/Pausable.abi.json.d.ts +13 -0
  91. package/out/Pausable.sol/Pausable.json +1 -1
  92. package/out/RegistrationSystem.sol/RegistrationSystem.json +1 -1
  93. package/out/StoreConsumer.sol/StoreConsumer.json +1 -1
  94. package/out/StoreRegistrationSystem.sol/StoreRegistrationSystem.json +1 -1
  95. package/out/System.sol/System.json +1 -1
  96. package/out/SystemCall.sol/SystemCall.json +1 -1
  97. package/out/WithStore.sol/WithStore.abi.json +13 -0
  98. package/out/WithStore.sol/WithStore.abi.json.d.ts +13 -0
  99. package/out/WithStore.sol/WithStore.json +1 -1
  100. package/out/WithWorld.sol/WithWorld.abi.json +95 -3
  101. package/out/WithWorld.sol/WithWorld.abi.json.d.ts +95 -3
  102. package/out/WithWorld.sol/WithWorld.json +1 -1
  103. package/out/World.sol/World.json +1 -1
  104. package/out/WorldContext.sol/WorldContextConsumer.json +1 -1
  105. package/out/WorldContext.sol/WorldContextConsumerLib.json +1 -1
  106. package/out/WorldContext.sol/WorldContextProviderLib.json +1 -1
  107. package/out/WorldRegistrationSystem.sol/WorldRegistrationSystem.json +1 -1
  108. package/out/build-info/{04cd01b00610d99132b6410373c2f462.json → 60c60a9593fdb00b3264c36836a28f39.json} +1 -1
  109. package/package.json +8 -8
  110. package/src/examples/ERC20WithWorld.sol +5 -0
  111. package/src/experimental/Constants.sol +7 -7
  112. package/src/experimental/ERC20Module.sol +9 -1
  113. package/dist/_esm-BQNWKNND.js +0 -10
  114. package/dist/ccip-YAWUVTAX.js +0 -2
  115. package/dist/chunk-GSBUANUZ.js +0 -30
  116. package/dist/chunk-LURIOADG.js +0 -2
  117. package/dist/chunk-TJJDXMQ6.js +0 -7
  118. package/dist/secp256k1-UMYSD4MC.js +0 -22
  119. /package/dist/{ccip-YAWUVTAX.js.map → ccip-VJWDNI4X.js.map} +0 -0
  120. /package/dist/{chunk-LURIOADG.js.map → chunk-PR4QN5HX.js.map} +0 -0
@@ -0,0 +1,2395 @@
1
+ import {
2
+ Hash,
3
+ bytes,
4
+ concatBytes,
5
+ createView,
6
+ exists,
7
+ hash,
8
+ output,
9
+ randomBytes,
10
+ rotr,
11
+ toBytes,
12
+ wrapConstructor
13
+ } from "./chunk-2VXHCW2O.js";
14
+ import {
15
+ __export
16
+ } from "./chunk-PR4QN5HX.js";
17
+
18
+ // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/_md.js
19
+ function setBigUint64(view, byteOffset, value, isLE) {
20
+ if (typeof view.setBigUint64 === "function")
21
+ return view.setBigUint64(byteOffset, value, isLE);
22
+ const _32n = BigInt(32);
23
+ const _u32_max = BigInt(4294967295);
24
+ const wh = Number(value >> _32n & _u32_max);
25
+ const wl = Number(value & _u32_max);
26
+ const h = isLE ? 4 : 0;
27
+ const l = isLE ? 0 : 4;
28
+ view.setUint32(byteOffset + h, wh, isLE);
29
+ view.setUint32(byteOffset + l, wl, isLE);
30
+ }
31
+ var Chi = (a, b, c) => a & b ^ ~a & c;
32
+ var Maj = (a, b, c) => a & b ^ a & c ^ b & c;
33
+ var HashMD = class extends Hash {
34
+ constructor(blockLen, outputLen, padOffset, isLE) {
35
+ super();
36
+ this.blockLen = blockLen;
37
+ this.outputLen = outputLen;
38
+ this.padOffset = padOffset;
39
+ this.isLE = isLE;
40
+ this.finished = false;
41
+ this.length = 0;
42
+ this.pos = 0;
43
+ this.destroyed = false;
44
+ this.buffer = new Uint8Array(blockLen);
45
+ this.view = createView(this.buffer);
46
+ }
47
+ update(data) {
48
+ exists(this);
49
+ const { view, buffer, blockLen } = this;
50
+ data = toBytes(data);
51
+ const len = data.length;
52
+ for (let pos = 0; pos < len; ) {
53
+ const take = Math.min(blockLen - this.pos, len - pos);
54
+ if (take === blockLen) {
55
+ const dataView = createView(data);
56
+ for (; blockLen <= len - pos; pos += blockLen)
57
+ this.process(dataView, pos);
58
+ continue;
59
+ }
60
+ buffer.set(data.subarray(pos, pos + take), this.pos);
61
+ this.pos += take;
62
+ pos += take;
63
+ if (this.pos === blockLen) {
64
+ this.process(view, 0);
65
+ this.pos = 0;
66
+ }
67
+ }
68
+ this.length += data.length;
69
+ this.roundClean();
70
+ return this;
71
+ }
72
+ digestInto(out) {
73
+ exists(this);
74
+ output(out, this);
75
+ this.finished = true;
76
+ const { buffer, view, blockLen, isLE } = this;
77
+ let { pos } = this;
78
+ buffer[pos++] = 128;
79
+ this.buffer.subarray(pos).fill(0);
80
+ if (this.padOffset > blockLen - pos) {
81
+ this.process(view, 0);
82
+ pos = 0;
83
+ }
84
+ for (let i = pos; i < blockLen; i++)
85
+ buffer[i] = 0;
86
+ setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
87
+ this.process(view, 0);
88
+ const oview = createView(out);
89
+ const len = this.outputLen;
90
+ if (len % 4)
91
+ throw new Error("_sha2: outputLen should be aligned to 32bit");
92
+ const outLen = len / 4;
93
+ const state = this.get();
94
+ if (outLen > state.length)
95
+ throw new Error("_sha2: outputLen bigger than state");
96
+ for (let i = 0; i < outLen; i++)
97
+ oview.setUint32(4 * i, state[i], isLE);
98
+ }
99
+ digest() {
100
+ const { buffer, outputLen } = this;
101
+ this.digestInto(buffer);
102
+ const res = buffer.slice(0, outputLen);
103
+ this.destroy();
104
+ return res;
105
+ }
106
+ _cloneInto(to) {
107
+ to || (to = new this.constructor());
108
+ to.set(...this.get());
109
+ const { blockLen, buffer, length, finished, destroyed, pos } = this;
110
+ to.length = length;
111
+ to.pos = pos;
112
+ to.finished = finished;
113
+ to.destroyed = destroyed;
114
+ if (length % blockLen)
115
+ to.buffer.set(buffer);
116
+ return to;
117
+ }
118
+ };
119
+
120
+ // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/sha256.js
121
+ var SHA256_K = /* @__PURE__ */ new Uint32Array([
122
+ 1116352408,
123
+ 1899447441,
124
+ 3049323471,
125
+ 3921009573,
126
+ 961987163,
127
+ 1508970993,
128
+ 2453635748,
129
+ 2870763221,
130
+ 3624381080,
131
+ 310598401,
132
+ 607225278,
133
+ 1426881987,
134
+ 1925078388,
135
+ 2162078206,
136
+ 2614888103,
137
+ 3248222580,
138
+ 3835390401,
139
+ 4022224774,
140
+ 264347078,
141
+ 604807628,
142
+ 770255983,
143
+ 1249150122,
144
+ 1555081692,
145
+ 1996064986,
146
+ 2554220882,
147
+ 2821834349,
148
+ 2952996808,
149
+ 3210313671,
150
+ 3336571891,
151
+ 3584528711,
152
+ 113926993,
153
+ 338241895,
154
+ 666307205,
155
+ 773529912,
156
+ 1294757372,
157
+ 1396182291,
158
+ 1695183700,
159
+ 1986661051,
160
+ 2177026350,
161
+ 2456956037,
162
+ 2730485921,
163
+ 2820302411,
164
+ 3259730800,
165
+ 3345764771,
166
+ 3516065817,
167
+ 3600352804,
168
+ 4094571909,
169
+ 275423344,
170
+ 430227734,
171
+ 506948616,
172
+ 659060556,
173
+ 883997877,
174
+ 958139571,
175
+ 1322822218,
176
+ 1537002063,
177
+ 1747873779,
178
+ 1955562222,
179
+ 2024104815,
180
+ 2227730452,
181
+ 2361852424,
182
+ 2428436474,
183
+ 2756734187,
184
+ 3204031479,
185
+ 3329325298
186
+ ]);
187
+ var SHA256_IV = /* @__PURE__ */ new Uint32Array([
188
+ 1779033703,
189
+ 3144134277,
190
+ 1013904242,
191
+ 2773480762,
192
+ 1359893119,
193
+ 2600822924,
194
+ 528734635,
195
+ 1541459225
196
+ ]);
197
+ var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
198
+ var SHA256 = class extends HashMD {
199
+ constructor() {
200
+ super(64, 32, 8, false);
201
+ this.A = SHA256_IV[0] | 0;
202
+ this.B = SHA256_IV[1] | 0;
203
+ this.C = SHA256_IV[2] | 0;
204
+ this.D = SHA256_IV[3] | 0;
205
+ this.E = SHA256_IV[4] | 0;
206
+ this.F = SHA256_IV[5] | 0;
207
+ this.G = SHA256_IV[6] | 0;
208
+ this.H = SHA256_IV[7] | 0;
209
+ }
210
+ get() {
211
+ const { A, B, C, D, E, F, G, H } = this;
212
+ return [A, B, C, D, E, F, G, H];
213
+ }
214
+ // prettier-ignore
215
+ set(A, B, C, D, E, F, G, H) {
216
+ this.A = A | 0;
217
+ this.B = B | 0;
218
+ this.C = C | 0;
219
+ this.D = D | 0;
220
+ this.E = E | 0;
221
+ this.F = F | 0;
222
+ this.G = G | 0;
223
+ this.H = H | 0;
224
+ }
225
+ process(view, offset) {
226
+ for (let i = 0; i < 16; i++, offset += 4)
227
+ SHA256_W[i] = view.getUint32(offset, false);
228
+ for (let i = 16; i < 64; i++) {
229
+ const W15 = SHA256_W[i - 15];
230
+ const W2 = SHA256_W[i - 2];
231
+ const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
232
+ const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
233
+ SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
234
+ }
235
+ let { A, B, C, D, E, F, G, H } = this;
236
+ for (let i = 0; i < 64; i++) {
237
+ const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
238
+ const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
239
+ const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
240
+ const T2 = sigma0 + Maj(A, B, C) | 0;
241
+ H = G;
242
+ G = F;
243
+ F = E;
244
+ E = D + T1 | 0;
245
+ D = C;
246
+ C = B;
247
+ B = A;
248
+ A = T1 + T2 | 0;
249
+ }
250
+ A = A + this.A | 0;
251
+ B = B + this.B | 0;
252
+ C = C + this.C | 0;
253
+ D = D + this.D | 0;
254
+ E = E + this.E | 0;
255
+ F = F + this.F | 0;
256
+ G = G + this.G | 0;
257
+ H = H + this.H | 0;
258
+ this.set(A, B, C, D, E, F, G, H);
259
+ }
260
+ roundClean() {
261
+ SHA256_W.fill(0);
262
+ }
263
+ destroy() {
264
+ this.set(0, 0, 0, 0, 0, 0, 0, 0);
265
+ this.buffer.fill(0);
266
+ }
267
+ };
268
+ var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
269
+
270
+ // ../../node_modules/.pnpm/@noble+hashes@1.5.0/node_modules/@noble/hashes/esm/hmac.js
271
+ var HMAC = class extends Hash {
272
+ constructor(hash2, _key) {
273
+ super();
274
+ this.finished = false;
275
+ this.destroyed = false;
276
+ hash(hash2);
277
+ const key = toBytes(_key);
278
+ this.iHash = hash2.create();
279
+ if (typeof this.iHash.update !== "function")
280
+ throw new Error("Expected instance of class which extends utils.Hash");
281
+ this.blockLen = this.iHash.blockLen;
282
+ this.outputLen = this.iHash.outputLen;
283
+ const blockLen = this.blockLen;
284
+ const pad = new Uint8Array(blockLen);
285
+ pad.set(key.length > blockLen ? hash2.create().update(key).digest() : key);
286
+ for (let i = 0; i < pad.length; i++)
287
+ pad[i] ^= 54;
288
+ this.iHash.update(pad);
289
+ this.oHash = hash2.create();
290
+ for (let i = 0; i < pad.length; i++)
291
+ pad[i] ^= 54 ^ 92;
292
+ this.oHash.update(pad);
293
+ pad.fill(0);
294
+ }
295
+ update(buf) {
296
+ exists(this);
297
+ this.iHash.update(buf);
298
+ return this;
299
+ }
300
+ digestInto(out) {
301
+ exists(this);
302
+ bytes(out, this.outputLen);
303
+ this.finished = true;
304
+ this.iHash.digestInto(out);
305
+ this.oHash.update(out);
306
+ this.oHash.digestInto(out);
307
+ this.destroy();
308
+ }
309
+ digest() {
310
+ const out = new Uint8Array(this.oHash.outputLen);
311
+ this.digestInto(out);
312
+ return out;
313
+ }
314
+ _cloneInto(to) {
315
+ to || (to = Object.create(Object.getPrototypeOf(this), {}));
316
+ const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
317
+ to = to;
318
+ to.finished = finished;
319
+ to.destroyed = destroyed;
320
+ to.blockLen = blockLen;
321
+ to.outputLen = outputLen;
322
+ to.oHash = oHash._cloneInto(to.oHash);
323
+ to.iHash = iHash._cloneInto(to.iHash);
324
+ return to;
325
+ }
326
+ destroy() {
327
+ this.destroyed = true;
328
+ this.oHash.destroy();
329
+ this.iHash.destroy();
330
+ }
331
+ };
332
+ var hmac = (hash2, key, message) => new HMAC(hash2, key).update(message).digest();
333
+ hmac.create = (hash2, key) => new HMAC(hash2, key);
334
+
335
+ // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/utils.js
336
+ var utils_exports = {};
337
+ __export(utils_exports, {
338
+ aInRange: () => aInRange,
339
+ abool: () => abool,
340
+ abytes: () => abytes,
341
+ bitGet: () => bitGet,
342
+ bitLen: () => bitLen,
343
+ bitMask: () => bitMask,
344
+ bitSet: () => bitSet,
345
+ bytesToHex: () => bytesToHex,
346
+ bytesToNumberBE: () => bytesToNumberBE,
347
+ bytesToNumberLE: () => bytesToNumberLE,
348
+ concatBytes: () => concatBytes2,
349
+ createHmacDrbg: () => createHmacDrbg,
350
+ ensureBytes: () => ensureBytes,
351
+ equalBytes: () => equalBytes,
352
+ hexToBytes: () => hexToBytes,
353
+ hexToNumber: () => hexToNumber,
354
+ inRange: () => inRange,
355
+ isBytes: () => isBytes,
356
+ memoized: () => memoized,
357
+ notImplemented: () => notImplemented,
358
+ numberToBytesBE: () => numberToBytesBE,
359
+ numberToBytesLE: () => numberToBytesLE,
360
+ numberToHexUnpadded: () => numberToHexUnpadded,
361
+ numberToVarBytesBE: () => numberToVarBytesBE,
362
+ utf8ToBytes: () => utf8ToBytes,
363
+ validateObject: () => validateObject
364
+ });
365
+ var _0n = /* @__PURE__ */ BigInt(0);
366
+ var _1n = /* @__PURE__ */ BigInt(1);
367
+ var _2n = /* @__PURE__ */ BigInt(2);
368
+ function isBytes(a) {
369
+ return a instanceof Uint8Array || a != null && typeof a === "object" && a.constructor.name === "Uint8Array";
370
+ }
371
+ function abytes(item) {
372
+ if (!isBytes(item))
373
+ throw new Error("Uint8Array expected");
374
+ }
375
+ function abool(title, value) {
376
+ if (typeof value !== "boolean")
377
+ throw new Error(`${title} must be valid boolean, got "${value}".`);
378
+ }
379
+ var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
380
+ function bytesToHex(bytes2) {
381
+ abytes(bytes2);
382
+ let hex = "";
383
+ for (let i = 0; i < bytes2.length; i++) {
384
+ hex += hexes[bytes2[i]];
385
+ }
386
+ return hex;
387
+ }
388
+ function numberToHexUnpadded(num2) {
389
+ const hex = num2.toString(16);
390
+ return hex.length & 1 ? `0${hex}` : hex;
391
+ }
392
+ function hexToNumber(hex) {
393
+ if (typeof hex !== "string")
394
+ throw new Error("hex string expected, got " + typeof hex);
395
+ return BigInt(hex === "" ? "0" : `0x${hex}`);
396
+ }
397
+ var asciis = { _0: 48, _9: 57, _A: 65, _F: 70, _a: 97, _f: 102 };
398
+ function asciiToBase16(char) {
399
+ if (char >= asciis._0 && char <= asciis._9)
400
+ return char - asciis._0;
401
+ if (char >= asciis._A && char <= asciis._F)
402
+ return char - (asciis._A - 10);
403
+ if (char >= asciis._a && char <= asciis._f)
404
+ return char - (asciis._a - 10);
405
+ return;
406
+ }
407
+ function hexToBytes(hex) {
408
+ if (typeof hex !== "string")
409
+ throw new Error("hex string expected, got " + typeof hex);
410
+ const hl = hex.length;
411
+ const al = hl / 2;
412
+ if (hl % 2)
413
+ throw new Error("padded hex string expected, got unpadded hex of length " + hl);
414
+ const array = new Uint8Array(al);
415
+ for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
416
+ const n1 = asciiToBase16(hex.charCodeAt(hi));
417
+ const n2 = asciiToBase16(hex.charCodeAt(hi + 1));
418
+ if (n1 === void 0 || n2 === void 0) {
419
+ const char = hex[hi] + hex[hi + 1];
420
+ throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
421
+ }
422
+ array[ai] = n1 * 16 + n2;
423
+ }
424
+ return array;
425
+ }
426
+ function bytesToNumberBE(bytes2) {
427
+ return hexToNumber(bytesToHex(bytes2));
428
+ }
429
+ function bytesToNumberLE(bytes2) {
430
+ abytes(bytes2);
431
+ return hexToNumber(bytesToHex(Uint8Array.from(bytes2).reverse()));
432
+ }
433
+ function numberToBytesBE(n, len) {
434
+ return hexToBytes(n.toString(16).padStart(len * 2, "0"));
435
+ }
436
+ function numberToBytesLE(n, len) {
437
+ return numberToBytesBE(n, len).reverse();
438
+ }
439
+ function numberToVarBytesBE(n) {
440
+ return hexToBytes(numberToHexUnpadded(n));
441
+ }
442
+ function ensureBytes(title, hex, expectedLength) {
443
+ let res;
444
+ if (typeof hex === "string") {
445
+ try {
446
+ res = hexToBytes(hex);
447
+ } catch (e) {
448
+ throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
449
+ }
450
+ } else if (isBytes(hex)) {
451
+ res = Uint8Array.from(hex);
452
+ } else {
453
+ throw new Error(`${title} must be hex string or Uint8Array`);
454
+ }
455
+ const len = res.length;
456
+ if (typeof expectedLength === "number" && len !== expectedLength)
457
+ throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`);
458
+ return res;
459
+ }
460
+ function concatBytes2(...arrays) {
461
+ let sum = 0;
462
+ for (let i = 0; i < arrays.length; i++) {
463
+ const a = arrays[i];
464
+ abytes(a);
465
+ sum += a.length;
466
+ }
467
+ const res = new Uint8Array(sum);
468
+ for (let i = 0, pad = 0; i < arrays.length; i++) {
469
+ const a = arrays[i];
470
+ res.set(a, pad);
471
+ pad += a.length;
472
+ }
473
+ return res;
474
+ }
475
+ function equalBytes(a, b) {
476
+ if (a.length !== b.length)
477
+ return false;
478
+ let diff = 0;
479
+ for (let i = 0; i < a.length; i++)
480
+ diff |= a[i] ^ b[i];
481
+ return diff === 0;
482
+ }
483
+ function utf8ToBytes(str) {
484
+ if (typeof str !== "string")
485
+ throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
486
+ return new Uint8Array(new TextEncoder().encode(str));
487
+ }
488
+ var isPosBig = (n) => typeof n === "bigint" && _0n <= n;
489
+ function inRange(n, min, max) {
490
+ return isPosBig(n) && isPosBig(min) && isPosBig(max) && min <= n && n < max;
491
+ }
492
+ function aInRange(title, n, min, max) {
493
+ if (!inRange(n, min, max))
494
+ throw new Error(`expected valid ${title}: ${min} <= n < ${max}, got ${typeof n} ${n}`);
495
+ }
496
+ function bitLen(n) {
497
+ let len;
498
+ for (len = 0; n > _0n; n >>= _1n, len += 1)
499
+ ;
500
+ return len;
501
+ }
502
+ function bitGet(n, pos) {
503
+ return n >> BigInt(pos) & _1n;
504
+ }
505
+ function bitSet(n, pos, value) {
506
+ return n | (value ? _1n : _0n) << BigInt(pos);
507
+ }
508
+ var bitMask = (n) => (_2n << BigInt(n - 1)) - _1n;
509
+ var u8n = (data) => new Uint8Array(data);
510
+ var u8fr = (arr) => Uint8Array.from(arr);
511
+ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
512
+ if (typeof hashLen !== "number" || hashLen < 2)
513
+ throw new Error("hashLen must be a number");
514
+ if (typeof qByteLen !== "number" || qByteLen < 2)
515
+ throw new Error("qByteLen must be a number");
516
+ if (typeof hmacFn !== "function")
517
+ throw new Error("hmacFn must be a function");
518
+ let v = u8n(hashLen);
519
+ let k = u8n(hashLen);
520
+ let i = 0;
521
+ const reset = () => {
522
+ v.fill(1);
523
+ k.fill(0);
524
+ i = 0;
525
+ };
526
+ const h = (...b) => hmacFn(k, v, ...b);
527
+ const reseed = (seed = u8n()) => {
528
+ k = h(u8fr([0]), seed);
529
+ v = h();
530
+ if (seed.length === 0)
531
+ return;
532
+ k = h(u8fr([1]), seed);
533
+ v = h();
534
+ };
535
+ const gen = () => {
536
+ if (i++ >= 1e3)
537
+ throw new Error("drbg: tried 1000 values");
538
+ let len = 0;
539
+ const out = [];
540
+ while (len < qByteLen) {
541
+ v = h();
542
+ const sl = v.slice();
543
+ out.push(sl);
544
+ len += v.length;
545
+ }
546
+ return concatBytes2(...out);
547
+ };
548
+ const genUntil = (seed, pred) => {
549
+ reset();
550
+ reseed(seed);
551
+ let res = void 0;
552
+ while (!(res = pred(gen())))
553
+ reseed();
554
+ reset();
555
+ return res;
556
+ };
557
+ return genUntil;
558
+ }
559
+ var validatorFns = {
560
+ bigint: (val) => typeof val === "bigint",
561
+ function: (val) => typeof val === "function",
562
+ boolean: (val) => typeof val === "boolean",
563
+ string: (val) => typeof val === "string",
564
+ stringOrUint8Array: (val) => typeof val === "string" || isBytes(val),
565
+ isSafeInteger: (val) => Number.isSafeInteger(val),
566
+ array: (val) => Array.isArray(val),
567
+ field: (val, object) => object.Fp.isValid(val),
568
+ hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
569
+ };
570
+ function validateObject(object, validators, optValidators = {}) {
571
+ const checkField = (fieldName, type, isOptional) => {
572
+ const checkVal = validatorFns[type];
573
+ if (typeof checkVal !== "function")
574
+ throw new Error(`Invalid validator "${type}", expected function`);
575
+ const val = object[fieldName];
576
+ if (isOptional && val === void 0)
577
+ return;
578
+ if (!checkVal(val, object)) {
579
+ throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}`);
580
+ }
581
+ };
582
+ for (const [fieldName, type] of Object.entries(validators))
583
+ checkField(fieldName, type, false);
584
+ for (const [fieldName, type] of Object.entries(optValidators))
585
+ checkField(fieldName, type, true);
586
+ return object;
587
+ }
588
+ var notImplemented = () => {
589
+ throw new Error("not implemented");
590
+ };
591
+ function memoized(fn) {
592
+ const map = /* @__PURE__ */ new WeakMap();
593
+ return (arg, ...args) => {
594
+ const val = map.get(arg);
595
+ if (val !== void 0)
596
+ return val;
597
+ const computed = fn(arg, ...args);
598
+ map.set(arg, computed);
599
+ return computed;
600
+ };
601
+ }
602
+
603
+ // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/modular.js
604
+ var _0n2 = BigInt(0);
605
+ var _1n2 = BigInt(1);
606
+ var _2n2 = BigInt(2);
607
+ var _3n = BigInt(3);
608
+ var _4n = BigInt(4);
609
+ var _5n = BigInt(5);
610
+ var _8n = BigInt(8);
611
+ var _9n = BigInt(9);
612
+ var _16n = BigInt(16);
613
+ function mod(a, b) {
614
+ const result = a % b;
615
+ return result >= _0n2 ? result : b + result;
616
+ }
617
+ function pow(num2, power, modulo) {
618
+ if (modulo <= _0n2 || power < _0n2)
619
+ throw new Error("Expected power/modulo > 0");
620
+ if (modulo === _1n2)
621
+ return _0n2;
622
+ let res = _1n2;
623
+ while (power > _0n2) {
624
+ if (power & _1n2)
625
+ res = res * num2 % modulo;
626
+ num2 = num2 * num2 % modulo;
627
+ power >>= _1n2;
628
+ }
629
+ return res;
630
+ }
631
+ function pow2(x, power, modulo) {
632
+ let res = x;
633
+ while (power-- > _0n2) {
634
+ res *= res;
635
+ res %= modulo;
636
+ }
637
+ return res;
638
+ }
639
+ function invert(number, modulo) {
640
+ if (number === _0n2 || modulo <= _0n2) {
641
+ throw new Error(`invert: expected positive integers, got n=${number} mod=${modulo}`);
642
+ }
643
+ let a = mod(number, modulo);
644
+ let b = modulo;
645
+ let x = _0n2, y = _1n2, u = _1n2, v = _0n2;
646
+ while (a !== _0n2) {
647
+ const q = b / a;
648
+ const r = b % a;
649
+ const m = x - u * q;
650
+ const n = y - v * q;
651
+ b = a, a = r, x = u, y = v, u = m, v = n;
652
+ }
653
+ const gcd = b;
654
+ if (gcd !== _1n2)
655
+ throw new Error("invert: does not exist");
656
+ return mod(x, modulo);
657
+ }
658
+ function tonelliShanks(P) {
659
+ const legendreC = (P - _1n2) / _2n2;
660
+ let Q, S, Z;
661
+ for (Q = P - _1n2, S = 0; Q % _2n2 === _0n2; Q /= _2n2, S++)
662
+ ;
663
+ for (Z = _2n2; Z < P && pow(Z, legendreC, P) !== P - _1n2; Z++)
664
+ ;
665
+ if (S === 1) {
666
+ const p1div4 = (P + _1n2) / _4n;
667
+ return function tonelliFast(Fp2, n) {
668
+ const root = Fp2.pow(n, p1div4);
669
+ if (!Fp2.eql(Fp2.sqr(root), n))
670
+ throw new Error("Cannot find square root");
671
+ return root;
672
+ };
673
+ }
674
+ const Q1div2 = (Q + _1n2) / _2n2;
675
+ return function tonelliSlow(Fp2, n) {
676
+ if (Fp2.pow(n, legendreC) === Fp2.neg(Fp2.ONE))
677
+ throw new Error("Cannot find square root");
678
+ let r = S;
679
+ let g = Fp2.pow(Fp2.mul(Fp2.ONE, Z), Q);
680
+ let x = Fp2.pow(n, Q1div2);
681
+ let b = Fp2.pow(n, Q);
682
+ while (!Fp2.eql(b, Fp2.ONE)) {
683
+ if (Fp2.eql(b, Fp2.ZERO))
684
+ return Fp2.ZERO;
685
+ let m = 1;
686
+ for (let t2 = Fp2.sqr(b); m < r; m++) {
687
+ if (Fp2.eql(t2, Fp2.ONE))
688
+ break;
689
+ t2 = Fp2.sqr(t2);
690
+ }
691
+ const ge = Fp2.pow(g, _1n2 << BigInt(r - m - 1));
692
+ g = Fp2.sqr(ge);
693
+ x = Fp2.mul(x, ge);
694
+ b = Fp2.mul(b, g);
695
+ r = m;
696
+ }
697
+ return x;
698
+ };
699
+ }
700
+ function FpSqrt(P) {
701
+ if (P % _4n === _3n) {
702
+ const p1div4 = (P + _1n2) / _4n;
703
+ return function sqrt3mod4(Fp2, n) {
704
+ const root = Fp2.pow(n, p1div4);
705
+ if (!Fp2.eql(Fp2.sqr(root), n))
706
+ throw new Error("Cannot find square root");
707
+ return root;
708
+ };
709
+ }
710
+ if (P % _8n === _5n) {
711
+ const c1 = (P - _5n) / _8n;
712
+ return function sqrt5mod8(Fp2, n) {
713
+ const n2 = Fp2.mul(n, _2n2);
714
+ const v = Fp2.pow(n2, c1);
715
+ const nv = Fp2.mul(n, v);
716
+ const i = Fp2.mul(Fp2.mul(nv, _2n2), v);
717
+ const root = Fp2.mul(nv, Fp2.sub(i, Fp2.ONE));
718
+ if (!Fp2.eql(Fp2.sqr(root), n))
719
+ throw new Error("Cannot find square root");
720
+ return root;
721
+ };
722
+ }
723
+ if (P % _16n === _9n) {
724
+ }
725
+ return tonelliShanks(P);
726
+ }
727
+ var FIELD_FIELDS = [
728
+ "create",
729
+ "isValid",
730
+ "is0",
731
+ "neg",
732
+ "inv",
733
+ "sqrt",
734
+ "sqr",
735
+ "eql",
736
+ "add",
737
+ "sub",
738
+ "mul",
739
+ "pow",
740
+ "div",
741
+ "addN",
742
+ "subN",
743
+ "mulN",
744
+ "sqrN"
745
+ ];
746
+ function validateField(field) {
747
+ const initial = {
748
+ ORDER: "bigint",
749
+ MASK: "bigint",
750
+ BYTES: "isSafeInteger",
751
+ BITS: "isSafeInteger"
752
+ };
753
+ const opts = FIELD_FIELDS.reduce((map, val) => {
754
+ map[val] = "function";
755
+ return map;
756
+ }, initial);
757
+ return validateObject(field, opts);
758
+ }
759
+ function FpPow(f, num2, power) {
760
+ if (power < _0n2)
761
+ throw new Error("Expected power > 0");
762
+ if (power === _0n2)
763
+ return f.ONE;
764
+ if (power === _1n2)
765
+ return num2;
766
+ let p = f.ONE;
767
+ let d = num2;
768
+ while (power > _0n2) {
769
+ if (power & _1n2)
770
+ p = f.mul(p, d);
771
+ d = f.sqr(d);
772
+ power >>= _1n2;
773
+ }
774
+ return p;
775
+ }
776
+ function FpInvertBatch(f, nums) {
777
+ const tmp = new Array(nums.length);
778
+ const lastMultiplied = nums.reduce((acc, num2, i) => {
779
+ if (f.is0(num2))
780
+ return acc;
781
+ tmp[i] = acc;
782
+ return f.mul(acc, num2);
783
+ }, f.ONE);
784
+ const inverted = f.inv(lastMultiplied);
785
+ nums.reduceRight((acc, num2, i) => {
786
+ if (f.is0(num2))
787
+ return acc;
788
+ tmp[i] = f.mul(acc, tmp[i]);
789
+ return f.mul(acc, num2);
790
+ }, inverted);
791
+ return tmp;
792
+ }
793
+ function nLength(n, nBitLength) {
794
+ const _nBitLength = nBitLength !== void 0 ? nBitLength : n.toString(2).length;
795
+ const nByteLength = Math.ceil(_nBitLength / 8);
796
+ return { nBitLength: _nBitLength, nByteLength };
797
+ }
798
+ function Field(ORDER, bitLen2, isLE = false, redef = {}) {
799
+ if (ORDER <= _0n2)
800
+ throw new Error(`Expected Field ORDER > 0, got ${ORDER}`);
801
+ const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
802
+ if (BYTES > 2048)
803
+ throw new Error("Field lengths over 2048 bytes are not supported");
804
+ const sqrtP = FpSqrt(ORDER);
805
+ const f = Object.freeze({
806
+ ORDER,
807
+ BITS,
808
+ BYTES,
809
+ MASK: bitMask(BITS),
810
+ ZERO: _0n2,
811
+ ONE: _1n2,
812
+ create: (num2) => mod(num2, ORDER),
813
+ isValid: (num2) => {
814
+ if (typeof num2 !== "bigint")
815
+ throw new Error(`Invalid field element: expected bigint, got ${typeof num2}`);
816
+ return _0n2 <= num2 && num2 < ORDER;
817
+ },
818
+ is0: (num2) => num2 === _0n2,
819
+ isOdd: (num2) => (num2 & _1n2) === _1n2,
820
+ neg: (num2) => mod(-num2, ORDER),
821
+ eql: (lhs, rhs) => lhs === rhs,
822
+ sqr: (num2) => mod(num2 * num2, ORDER),
823
+ add: (lhs, rhs) => mod(lhs + rhs, ORDER),
824
+ sub: (lhs, rhs) => mod(lhs - rhs, ORDER),
825
+ mul: (lhs, rhs) => mod(lhs * rhs, ORDER),
826
+ pow: (num2, power) => FpPow(f, num2, power),
827
+ div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER),
828
+ // Same as above, but doesn't normalize
829
+ sqrN: (num2) => num2 * num2,
830
+ addN: (lhs, rhs) => lhs + rhs,
831
+ subN: (lhs, rhs) => lhs - rhs,
832
+ mulN: (lhs, rhs) => lhs * rhs,
833
+ inv: (num2) => invert(num2, ORDER),
834
+ sqrt: redef.sqrt || ((n) => sqrtP(f, n)),
835
+ invertBatch: (lst) => FpInvertBatch(f, lst),
836
+ // TODO: do we really need constant cmov?
837
+ // We don't have const-time bigints anyway, so probably will be not very useful
838
+ cmov: (a, b, c) => c ? b : a,
839
+ toBytes: (num2) => isLE ? numberToBytesLE(num2, BYTES) : numberToBytesBE(num2, BYTES),
840
+ fromBytes: (bytes2) => {
841
+ if (bytes2.length !== BYTES)
842
+ throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes2.length}`);
843
+ return isLE ? bytesToNumberLE(bytes2) : bytesToNumberBE(bytes2);
844
+ }
845
+ });
846
+ return Object.freeze(f);
847
+ }
848
+ function getFieldBytesLength(fieldOrder) {
849
+ if (typeof fieldOrder !== "bigint")
850
+ throw new Error("field order must be bigint");
851
+ const bitLength = fieldOrder.toString(2).length;
852
+ return Math.ceil(bitLength / 8);
853
+ }
854
+ function getMinHashLength(fieldOrder) {
855
+ const length = getFieldBytesLength(fieldOrder);
856
+ return length + Math.ceil(length / 2);
857
+ }
858
+ function mapHashToField(key, fieldOrder, isLE = false) {
859
+ const len = key.length;
860
+ const fieldLen = getFieldBytesLength(fieldOrder);
861
+ const minLen = getMinHashLength(fieldOrder);
862
+ if (len < 16 || len < minLen || len > 1024)
863
+ throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
864
+ const num2 = isLE ? bytesToNumberBE(key) : bytesToNumberLE(key);
865
+ const reduced = mod(num2, fieldOrder - _1n2) + _1n2;
866
+ return isLE ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
867
+ }
868
+
869
+ // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/curve.js
870
+ var _0n3 = BigInt(0);
871
+ var _1n3 = BigInt(1);
872
+ var pointPrecomputes = /* @__PURE__ */ new WeakMap();
873
+ var pointWindowSizes = /* @__PURE__ */ new WeakMap();
874
+ function wNAF(c, bits) {
875
+ const constTimeNegate = (condition, item) => {
876
+ const neg = item.negate();
877
+ return condition ? neg : item;
878
+ };
879
+ const validateW = (W) => {
880
+ if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
881
+ throw new Error(`Wrong window size=${W}, should be [1..${bits}]`);
882
+ };
883
+ const opts = (W) => {
884
+ validateW(W);
885
+ const windows = Math.ceil(bits / W) + 1;
886
+ const windowSize = 2 ** (W - 1);
887
+ return { windows, windowSize };
888
+ };
889
+ return {
890
+ constTimeNegate,
891
+ // non-const time multiplication ladder
892
+ unsafeLadder(elm, n) {
893
+ let p = c.ZERO;
894
+ let d = elm;
895
+ while (n > _0n3) {
896
+ if (n & _1n3)
897
+ p = p.add(d);
898
+ d = d.double();
899
+ n >>= _1n3;
900
+ }
901
+ return p;
902
+ },
903
+ /**
904
+ * Creates a wNAF precomputation window. Used for caching.
905
+ * Default window size is set by `utils.precompute()` and is equal to 8.
906
+ * Number of precomputed points depends on the curve size:
907
+ * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
908
+ * - 𝑊 is the window size
909
+ * - 𝑛 is the bitlength of the curve order.
910
+ * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
911
+ * @returns precomputed point tables flattened to a single array
912
+ */
913
+ precomputeWindow(elm, W) {
914
+ const { windows, windowSize } = opts(W);
915
+ const points = [];
916
+ let p = elm;
917
+ let base = p;
918
+ for (let window = 0; window < windows; window++) {
919
+ base = p;
920
+ points.push(base);
921
+ for (let i = 1; i < windowSize; i++) {
922
+ base = base.add(p);
923
+ points.push(base);
924
+ }
925
+ p = base.double();
926
+ }
927
+ return points;
928
+ },
929
+ /**
930
+ * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
931
+ * @param W window size
932
+ * @param precomputes precomputed tables
933
+ * @param n scalar (we don't check here, but should be less than curve order)
934
+ * @returns real and fake (for const-time) points
935
+ */
936
+ wNAF(W, precomputes, n) {
937
+ const { windows, windowSize } = opts(W);
938
+ let p = c.ZERO;
939
+ let f = c.BASE;
940
+ const mask = BigInt(2 ** W - 1);
941
+ const maxNumber = 2 ** W;
942
+ const shiftBy = BigInt(W);
943
+ for (let window = 0; window < windows; window++) {
944
+ const offset = window * windowSize;
945
+ let wbits = Number(n & mask);
946
+ n >>= shiftBy;
947
+ if (wbits > windowSize) {
948
+ wbits -= maxNumber;
949
+ n += _1n3;
950
+ }
951
+ const offset1 = offset;
952
+ const offset2 = offset + Math.abs(wbits) - 1;
953
+ const cond1 = window % 2 !== 0;
954
+ const cond2 = wbits < 0;
955
+ if (wbits === 0) {
956
+ f = f.add(constTimeNegate(cond1, precomputes[offset1]));
957
+ } else {
958
+ p = p.add(constTimeNegate(cond2, precomputes[offset2]));
959
+ }
960
+ }
961
+ return { p, f };
962
+ },
963
+ wNAFCached(P, n, transform) {
964
+ const W = pointWindowSizes.get(P) || 1;
965
+ let comp = pointPrecomputes.get(P);
966
+ if (!comp) {
967
+ comp = this.precomputeWindow(P, W);
968
+ if (W !== 1)
969
+ pointPrecomputes.set(P, transform(comp));
970
+ }
971
+ return this.wNAF(W, comp, n);
972
+ },
973
+ // We calculate precomputes for elliptic curve point multiplication
974
+ // using windowed method. This specifies window size and
975
+ // stores precomputed values. Usually only base point would be precomputed.
976
+ setWindowSize(P, W) {
977
+ validateW(W);
978
+ pointWindowSizes.set(P, W);
979
+ pointPrecomputes.delete(P);
980
+ }
981
+ };
982
+ }
983
+ function pippenger(c, field, points, scalars) {
984
+ if (!Array.isArray(points) || !Array.isArray(scalars) || scalars.length !== points.length)
985
+ throw new Error("arrays of points and scalars must have equal length");
986
+ scalars.forEach((s, i) => {
987
+ if (!field.isValid(s))
988
+ throw new Error(`wrong scalar at index ${i}`);
989
+ });
990
+ points.forEach((p, i) => {
991
+ if (!(p instanceof c))
992
+ throw new Error(`wrong point at index ${i}`);
993
+ });
994
+ const wbits = bitLen(BigInt(points.length));
995
+ const windowSize = wbits > 12 ? wbits - 3 : wbits > 4 ? wbits - 2 : wbits ? 2 : 1;
996
+ const MASK = (1 << windowSize) - 1;
997
+ const buckets = new Array(MASK + 1).fill(c.ZERO);
998
+ const lastBits = Math.floor((field.BITS - 1) / windowSize) * windowSize;
999
+ let sum = c.ZERO;
1000
+ for (let i = lastBits; i >= 0; i -= windowSize) {
1001
+ buckets.fill(c.ZERO);
1002
+ for (let j = 0; j < scalars.length; j++) {
1003
+ const scalar = scalars[j];
1004
+ const wbits2 = Number(scalar >> BigInt(i) & BigInt(MASK));
1005
+ buckets[wbits2] = buckets[wbits2].add(points[j]);
1006
+ }
1007
+ let resI = c.ZERO;
1008
+ for (let j = buckets.length - 1, sumI = c.ZERO; j > 0; j--) {
1009
+ sumI = sumI.add(buckets[j]);
1010
+ resI = resI.add(sumI);
1011
+ }
1012
+ sum = sum.add(resI);
1013
+ if (i !== 0)
1014
+ for (let j = 0; j < windowSize; j++)
1015
+ sum = sum.double();
1016
+ }
1017
+ return sum;
1018
+ }
1019
+ function validateBasic(curve) {
1020
+ validateField(curve.Fp);
1021
+ validateObject(curve, {
1022
+ n: "bigint",
1023
+ h: "bigint",
1024
+ Gx: "field",
1025
+ Gy: "field"
1026
+ }, {
1027
+ nBitLength: "isSafeInteger",
1028
+ nByteLength: "isSafeInteger"
1029
+ });
1030
+ return Object.freeze({
1031
+ ...nLength(curve.n, curve.nBitLength),
1032
+ ...curve,
1033
+ ...{ p: curve.Fp.ORDER }
1034
+ });
1035
+ }
1036
+
1037
+ // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/weierstrass.js
1038
+ function validateSigVerOpts(opts) {
1039
+ if (opts.lowS !== void 0)
1040
+ abool("lowS", opts.lowS);
1041
+ if (opts.prehash !== void 0)
1042
+ abool("prehash", opts.prehash);
1043
+ }
1044
+ function validatePointOpts(curve) {
1045
+ const opts = validateBasic(curve);
1046
+ validateObject(opts, {
1047
+ a: "field",
1048
+ b: "field"
1049
+ }, {
1050
+ allowedPrivateKeyLengths: "array",
1051
+ wrapPrivateKey: "boolean",
1052
+ isTorsionFree: "function",
1053
+ clearCofactor: "function",
1054
+ allowInfinityPoint: "boolean",
1055
+ fromBytes: "function",
1056
+ toBytes: "function"
1057
+ });
1058
+ const { endo, Fp: Fp2, a } = opts;
1059
+ if (endo) {
1060
+ if (!Fp2.eql(a, Fp2.ZERO)) {
1061
+ throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");
1062
+ }
1063
+ if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
1064
+ throw new Error("Expected endomorphism with beta: bigint and splitScalar: function");
1065
+ }
1066
+ }
1067
+ return Object.freeze({ ...opts });
1068
+ }
1069
+ var { bytesToNumberBE: b2n, hexToBytes: h2b } = utils_exports;
1070
+ var DER = {
1071
+ // asn.1 DER encoding utils
1072
+ Err: class DERErr extends Error {
1073
+ constructor(m = "") {
1074
+ super(m);
1075
+ }
1076
+ },
1077
+ // Basic building block is TLV (Tag-Length-Value)
1078
+ _tlv: {
1079
+ encode: (tag, data) => {
1080
+ const { Err: E } = DER;
1081
+ if (tag < 0 || tag > 256)
1082
+ throw new E("tlv.encode: wrong tag");
1083
+ if (data.length & 1)
1084
+ throw new E("tlv.encode: unpadded data");
1085
+ const dataLen = data.length / 2;
1086
+ const len = numberToHexUnpadded(dataLen);
1087
+ if (len.length / 2 & 128)
1088
+ throw new E("tlv.encode: long form length too big");
1089
+ const lenLen = dataLen > 127 ? numberToHexUnpadded(len.length / 2 | 128) : "";
1090
+ return `${numberToHexUnpadded(tag)}${lenLen}${len}${data}`;
1091
+ },
1092
+ // v - value, l - left bytes (unparsed)
1093
+ decode(tag, data) {
1094
+ const { Err: E } = DER;
1095
+ let pos = 0;
1096
+ if (tag < 0 || tag > 256)
1097
+ throw new E("tlv.encode: wrong tag");
1098
+ if (data.length < 2 || data[pos++] !== tag)
1099
+ throw new E("tlv.decode: wrong tlv");
1100
+ const first = data[pos++];
1101
+ const isLong = !!(first & 128);
1102
+ let length = 0;
1103
+ if (!isLong)
1104
+ length = first;
1105
+ else {
1106
+ const lenLen = first & 127;
1107
+ if (!lenLen)
1108
+ throw new E("tlv.decode(long): indefinite length not supported");
1109
+ if (lenLen > 4)
1110
+ throw new E("tlv.decode(long): byte length is too big");
1111
+ const lengthBytes = data.subarray(pos, pos + lenLen);
1112
+ if (lengthBytes.length !== lenLen)
1113
+ throw new E("tlv.decode: length bytes not complete");
1114
+ if (lengthBytes[0] === 0)
1115
+ throw new E("tlv.decode(long): zero leftmost byte");
1116
+ for (const b of lengthBytes)
1117
+ length = length << 8 | b;
1118
+ pos += lenLen;
1119
+ if (length < 128)
1120
+ throw new E("tlv.decode(long): not minimal encoding");
1121
+ }
1122
+ const v = data.subarray(pos, pos + length);
1123
+ if (v.length !== length)
1124
+ throw new E("tlv.decode: wrong value length");
1125
+ return { v, l: data.subarray(pos + length) };
1126
+ }
1127
+ },
1128
+ // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
1129
+ // since we always use positive integers here. It must always be empty:
1130
+ // - add zero byte if exists
1131
+ // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
1132
+ _int: {
1133
+ encode(num2) {
1134
+ const { Err: E } = DER;
1135
+ if (num2 < _0n4)
1136
+ throw new E("integer: negative integers are not allowed");
1137
+ let hex = numberToHexUnpadded(num2);
1138
+ if (Number.parseInt(hex[0], 16) & 8)
1139
+ hex = "00" + hex;
1140
+ if (hex.length & 1)
1141
+ throw new E("unexpected assertion");
1142
+ return hex;
1143
+ },
1144
+ decode(data) {
1145
+ const { Err: E } = DER;
1146
+ if (data[0] & 128)
1147
+ throw new E("Invalid signature integer: negative");
1148
+ if (data[0] === 0 && !(data[1] & 128))
1149
+ throw new E("Invalid signature integer: unnecessary leading zero");
1150
+ return b2n(data);
1151
+ }
1152
+ },
1153
+ toSig(hex) {
1154
+ const { Err: E, _int: int, _tlv: tlv } = DER;
1155
+ const data = typeof hex === "string" ? h2b(hex) : hex;
1156
+ abytes(data);
1157
+ const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
1158
+ if (seqLeftBytes.length)
1159
+ throw new E("Invalid signature: left bytes after parsing");
1160
+ const { v: rBytes, l: rLeftBytes } = tlv.decode(2, seqBytes);
1161
+ const { v: sBytes, l: sLeftBytes } = tlv.decode(2, rLeftBytes);
1162
+ if (sLeftBytes.length)
1163
+ throw new E("Invalid signature: left bytes after parsing");
1164
+ return { r: int.decode(rBytes), s: int.decode(sBytes) };
1165
+ },
1166
+ hexFromSig(sig) {
1167
+ const { _tlv: tlv, _int: int } = DER;
1168
+ const seq = `${tlv.encode(2, int.encode(sig.r))}${tlv.encode(2, int.encode(sig.s))}`;
1169
+ return tlv.encode(48, seq);
1170
+ }
1171
+ };
1172
+ var _0n4 = BigInt(0);
1173
+ var _1n4 = BigInt(1);
1174
+ var _2n3 = BigInt(2);
1175
+ var _3n2 = BigInt(3);
1176
+ var _4n2 = BigInt(4);
1177
+ function weierstrassPoints(opts) {
1178
+ const CURVE = validatePointOpts(opts);
1179
+ const { Fp: Fp2 } = CURVE;
1180
+ const Fn = Field(CURVE.n, CURVE.nBitLength);
1181
+ const toBytes2 = CURVE.toBytes || ((_c, point, _isCompressed) => {
1182
+ const a = point.toAffine();
1183
+ return concatBytes2(Uint8Array.from([4]), Fp2.toBytes(a.x), Fp2.toBytes(a.y));
1184
+ });
1185
+ const fromBytes = CURVE.fromBytes || ((bytes2) => {
1186
+ const tail = bytes2.subarray(1);
1187
+ const x = Fp2.fromBytes(tail.subarray(0, Fp2.BYTES));
1188
+ const y = Fp2.fromBytes(tail.subarray(Fp2.BYTES, 2 * Fp2.BYTES));
1189
+ return { x, y };
1190
+ });
1191
+ function weierstrassEquation(x) {
1192
+ const { a, b } = CURVE;
1193
+ const x2 = Fp2.sqr(x);
1194
+ const x3 = Fp2.mul(x2, x);
1195
+ return Fp2.add(Fp2.add(x3, Fp2.mul(x, a)), b);
1196
+ }
1197
+ if (!Fp2.eql(Fp2.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))
1198
+ throw new Error("bad generator point: equation left != right");
1199
+ function isWithinCurveOrder(num2) {
1200
+ return inRange(num2, _1n4, CURVE.n);
1201
+ }
1202
+ function normPrivateKeyToScalar(key) {
1203
+ const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;
1204
+ if (lengths && typeof key !== "bigint") {
1205
+ if (isBytes(key))
1206
+ key = bytesToHex(key);
1207
+ if (typeof key !== "string" || !lengths.includes(key.length))
1208
+ throw new Error("Invalid key");
1209
+ key = key.padStart(nByteLength * 2, "0");
1210
+ }
1211
+ let num2;
1212
+ try {
1213
+ num2 = typeof key === "bigint" ? key : bytesToNumberBE(ensureBytes("private key", key, nByteLength));
1214
+ } catch (error) {
1215
+ throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
1216
+ }
1217
+ if (wrapPrivateKey)
1218
+ num2 = mod(num2, N);
1219
+ aInRange("private key", num2, _1n4, N);
1220
+ return num2;
1221
+ }
1222
+ function assertPrjPoint(other) {
1223
+ if (!(other instanceof Point2))
1224
+ throw new Error("ProjectivePoint expected");
1225
+ }
1226
+ const toAffineMemo = memoized((p, iz) => {
1227
+ const { px: x, py: y, pz: z } = p;
1228
+ if (Fp2.eql(z, Fp2.ONE))
1229
+ return { x, y };
1230
+ const is0 = p.is0();
1231
+ if (iz == null)
1232
+ iz = is0 ? Fp2.ONE : Fp2.inv(z);
1233
+ const ax = Fp2.mul(x, iz);
1234
+ const ay = Fp2.mul(y, iz);
1235
+ const zz = Fp2.mul(z, iz);
1236
+ if (is0)
1237
+ return { x: Fp2.ZERO, y: Fp2.ZERO };
1238
+ if (!Fp2.eql(zz, Fp2.ONE))
1239
+ throw new Error("invZ was invalid");
1240
+ return { x: ax, y: ay };
1241
+ });
1242
+ const assertValidMemo = memoized((p) => {
1243
+ if (p.is0()) {
1244
+ if (CURVE.allowInfinityPoint && !Fp2.is0(p.py))
1245
+ return;
1246
+ throw new Error("bad point: ZERO");
1247
+ }
1248
+ const { x, y } = p.toAffine();
1249
+ if (!Fp2.isValid(x) || !Fp2.isValid(y))
1250
+ throw new Error("bad point: x or y not FE");
1251
+ const left = Fp2.sqr(y);
1252
+ const right = weierstrassEquation(x);
1253
+ if (!Fp2.eql(left, right))
1254
+ throw new Error("bad point: equation left != right");
1255
+ if (!p.isTorsionFree())
1256
+ throw new Error("bad point: not in prime-order subgroup");
1257
+ return true;
1258
+ });
1259
+ class Point2 {
1260
+ constructor(px, py, pz) {
1261
+ this.px = px;
1262
+ this.py = py;
1263
+ this.pz = pz;
1264
+ if (px == null || !Fp2.isValid(px))
1265
+ throw new Error("x required");
1266
+ if (py == null || !Fp2.isValid(py))
1267
+ throw new Error("y required");
1268
+ if (pz == null || !Fp2.isValid(pz))
1269
+ throw new Error("z required");
1270
+ Object.freeze(this);
1271
+ }
1272
+ // Does not validate if the point is on-curve.
1273
+ // Use fromHex instead, or call assertValidity() later.
1274
+ static fromAffine(p) {
1275
+ const { x, y } = p || {};
1276
+ if (!p || !Fp2.isValid(x) || !Fp2.isValid(y))
1277
+ throw new Error("invalid affine point");
1278
+ if (p instanceof Point2)
1279
+ throw new Error("projective point not allowed");
1280
+ const is0 = (i) => Fp2.eql(i, Fp2.ZERO);
1281
+ if (is0(x) && is0(y))
1282
+ return Point2.ZERO;
1283
+ return new Point2(x, y, Fp2.ONE);
1284
+ }
1285
+ get x() {
1286
+ return this.toAffine().x;
1287
+ }
1288
+ get y() {
1289
+ return this.toAffine().y;
1290
+ }
1291
+ /**
1292
+ * Takes a bunch of Projective Points but executes only one
1293
+ * inversion on all of them. Inversion is very slow operation,
1294
+ * so this improves performance massively.
1295
+ * Optimization: converts a list of projective points to a list of identical points with Z=1.
1296
+ */
1297
+ static normalizeZ(points) {
1298
+ const toInv = Fp2.invertBatch(points.map((p) => p.pz));
1299
+ return points.map((p, i) => p.toAffine(toInv[i])).map(Point2.fromAffine);
1300
+ }
1301
+ /**
1302
+ * Converts hash string or Uint8Array to Point.
1303
+ * @param hex short/long ECDSA hex
1304
+ */
1305
+ static fromHex(hex) {
1306
+ const P = Point2.fromAffine(fromBytes(ensureBytes("pointHex", hex)));
1307
+ P.assertValidity();
1308
+ return P;
1309
+ }
1310
+ // Multiplies generator point by privateKey.
1311
+ static fromPrivateKey(privateKey) {
1312
+ return Point2.BASE.multiply(normPrivateKeyToScalar(privateKey));
1313
+ }
1314
+ // Multiscalar Multiplication
1315
+ static msm(points, scalars) {
1316
+ return pippenger(Point2, Fn, points, scalars);
1317
+ }
1318
+ // "Private method", don't use it directly
1319
+ _setWindowSize(windowSize) {
1320
+ wnaf.setWindowSize(this, windowSize);
1321
+ }
1322
+ // A point on curve is valid if it conforms to equation.
1323
+ assertValidity() {
1324
+ assertValidMemo(this);
1325
+ }
1326
+ hasEvenY() {
1327
+ const { y } = this.toAffine();
1328
+ if (Fp2.isOdd)
1329
+ return !Fp2.isOdd(y);
1330
+ throw new Error("Field doesn't support isOdd");
1331
+ }
1332
+ /**
1333
+ * Compare one point to another.
1334
+ */
1335
+ equals(other) {
1336
+ assertPrjPoint(other);
1337
+ const { px: X1, py: Y1, pz: Z1 } = this;
1338
+ const { px: X2, py: Y2, pz: Z2 } = other;
1339
+ const U1 = Fp2.eql(Fp2.mul(X1, Z2), Fp2.mul(X2, Z1));
1340
+ const U2 = Fp2.eql(Fp2.mul(Y1, Z2), Fp2.mul(Y2, Z1));
1341
+ return U1 && U2;
1342
+ }
1343
+ /**
1344
+ * Flips point to one corresponding to (x, -y) in Affine coordinates.
1345
+ */
1346
+ negate() {
1347
+ return new Point2(this.px, Fp2.neg(this.py), this.pz);
1348
+ }
1349
+ // Renes-Costello-Batina exception-free doubling formula.
1350
+ // There is 30% faster Jacobian formula, but it is not complete.
1351
+ // https://eprint.iacr.org/2015/1060, algorithm 3
1352
+ // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
1353
+ double() {
1354
+ const { a, b } = CURVE;
1355
+ const b3 = Fp2.mul(b, _3n2);
1356
+ const { px: X1, py: Y1, pz: Z1 } = this;
1357
+ let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
1358
+ let t0 = Fp2.mul(X1, X1);
1359
+ let t1 = Fp2.mul(Y1, Y1);
1360
+ let t2 = Fp2.mul(Z1, Z1);
1361
+ let t3 = Fp2.mul(X1, Y1);
1362
+ t3 = Fp2.add(t3, t3);
1363
+ Z3 = Fp2.mul(X1, Z1);
1364
+ Z3 = Fp2.add(Z3, Z3);
1365
+ X3 = Fp2.mul(a, Z3);
1366
+ Y3 = Fp2.mul(b3, t2);
1367
+ Y3 = Fp2.add(X3, Y3);
1368
+ X3 = Fp2.sub(t1, Y3);
1369
+ Y3 = Fp2.add(t1, Y3);
1370
+ Y3 = Fp2.mul(X3, Y3);
1371
+ X3 = Fp2.mul(t3, X3);
1372
+ Z3 = Fp2.mul(b3, Z3);
1373
+ t2 = Fp2.mul(a, t2);
1374
+ t3 = Fp2.sub(t0, t2);
1375
+ t3 = Fp2.mul(a, t3);
1376
+ t3 = Fp2.add(t3, Z3);
1377
+ Z3 = Fp2.add(t0, t0);
1378
+ t0 = Fp2.add(Z3, t0);
1379
+ t0 = Fp2.add(t0, t2);
1380
+ t0 = Fp2.mul(t0, t3);
1381
+ Y3 = Fp2.add(Y3, t0);
1382
+ t2 = Fp2.mul(Y1, Z1);
1383
+ t2 = Fp2.add(t2, t2);
1384
+ t0 = Fp2.mul(t2, t3);
1385
+ X3 = Fp2.sub(X3, t0);
1386
+ Z3 = Fp2.mul(t2, t1);
1387
+ Z3 = Fp2.add(Z3, Z3);
1388
+ Z3 = Fp2.add(Z3, Z3);
1389
+ return new Point2(X3, Y3, Z3);
1390
+ }
1391
+ // Renes-Costello-Batina exception-free addition formula.
1392
+ // There is 30% faster Jacobian formula, but it is not complete.
1393
+ // https://eprint.iacr.org/2015/1060, algorithm 1
1394
+ // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
1395
+ add(other) {
1396
+ assertPrjPoint(other);
1397
+ const { px: X1, py: Y1, pz: Z1 } = this;
1398
+ const { px: X2, py: Y2, pz: Z2 } = other;
1399
+ let X3 = Fp2.ZERO, Y3 = Fp2.ZERO, Z3 = Fp2.ZERO;
1400
+ const a = CURVE.a;
1401
+ const b3 = Fp2.mul(CURVE.b, _3n2);
1402
+ let t0 = Fp2.mul(X1, X2);
1403
+ let t1 = Fp2.mul(Y1, Y2);
1404
+ let t2 = Fp2.mul(Z1, Z2);
1405
+ let t3 = Fp2.add(X1, Y1);
1406
+ let t4 = Fp2.add(X2, Y2);
1407
+ t3 = Fp2.mul(t3, t4);
1408
+ t4 = Fp2.add(t0, t1);
1409
+ t3 = Fp2.sub(t3, t4);
1410
+ t4 = Fp2.add(X1, Z1);
1411
+ let t5 = Fp2.add(X2, Z2);
1412
+ t4 = Fp2.mul(t4, t5);
1413
+ t5 = Fp2.add(t0, t2);
1414
+ t4 = Fp2.sub(t4, t5);
1415
+ t5 = Fp2.add(Y1, Z1);
1416
+ X3 = Fp2.add(Y2, Z2);
1417
+ t5 = Fp2.mul(t5, X3);
1418
+ X3 = Fp2.add(t1, t2);
1419
+ t5 = Fp2.sub(t5, X3);
1420
+ Z3 = Fp2.mul(a, t4);
1421
+ X3 = Fp2.mul(b3, t2);
1422
+ Z3 = Fp2.add(X3, Z3);
1423
+ X3 = Fp2.sub(t1, Z3);
1424
+ Z3 = Fp2.add(t1, Z3);
1425
+ Y3 = Fp2.mul(X3, Z3);
1426
+ t1 = Fp2.add(t0, t0);
1427
+ t1 = Fp2.add(t1, t0);
1428
+ t2 = Fp2.mul(a, t2);
1429
+ t4 = Fp2.mul(b3, t4);
1430
+ t1 = Fp2.add(t1, t2);
1431
+ t2 = Fp2.sub(t0, t2);
1432
+ t2 = Fp2.mul(a, t2);
1433
+ t4 = Fp2.add(t4, t2);
1434
+ t0 = Fp2.mul(t1, t4);
1435
+ Y3 = Fp2.add(Y3, t0);
1436
+ t0 = Fp2.mul(t5, t4);
1437
+ X3 = Fp2.mul(t3, X3);
1438
+ X3 = Fp2.sub(X3, t0);
1439
+ t0 = Fp2.mul(t3, t1);
1440
+ Z3 = Fp2.mul(t5, Z3);
1441
+ Z3 = Fp2.add(Z3, t0);
1442
+ return new Point2(X3, Y3, Z3);
1443
+ }
1444
+ subtract(other) {
1445
+ return this.add(other.negate());
1446
+ }
1447
+ is0() {
1448
+ return this.equals(Point2.ZERO);
1449
+ }
1450
+ wNAF(n) {
1451
+ return wnaf.wNAFCached(this, n, Point2.normalizeZ);
1452
+ }
1453
+ /**
1454
+ * Non-constant-time multiplication. Uses double-and-add algorithm.
1455
+ * It's faster, but should only be used when you don't care about
1456
+ * an exposed private key e.g. sig verification, which works over *public* keys.
1457
+ */
1458
+ multiplyUnsafe(sc) {
1459
+ aInRange("scalar", sc, _0n4, CURVE.n);
1460
+ const I = Point2.ZERO;
1461
+ if (sc === _0n4)
1462
+ return I;
1463
+ if (sc === _1n4)
1464
+ return this;
1465
+ const { endo } = CURVE;
1466
+ if (!endo)
1467
+ return wnaf.unsafeLadder(this, sc);
1468
+ let { k1neg, k1, k2neg, k2 } = endo.splitScalar(sc);
1469
+ let k1p = I;
1470
+ let k2p = I;
1471
+ let d = this;
1472
+ while (k1 > _0n4 || k2 > _0n4) {
1473
+ if (k1 & _1n4)
1474
+ k1p = k1p.add(d);
1475
+ if (k2 & _1n4)
1476
+ k2p = k2p.add(d);
1477
+ d = d.double();
1478
+ k1 >>= _1n4;
1479
+ k2 >>= _1n4;
1480
+ }
1481
+ if (k1neg)
1482
+ k1p = k1p.negate();
1483
+ if (k2neg)
1484
+ k2p = k2p.negate();
1485
+ k2p = new Point2(Fp2.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
1486
+ return k1p.add(k2p);
1487
+ }
1488
+ /**
1489
+ * Constant time multiplication.
1490
+ * Uses wNAF method. Windowed method may be 10% faster,
1491
+ * but takes 2x longer to generate and consumes 2x memory.
1492
+ * Uses precomputes when available.
1493
+ * Uses endomorphism for Koblitz curves.
1494
+ * @param scalar by which the point would be multiplied
1495
+ * @returns New point
1496
+ */
1497
+ multiply(scalar) {
1498
+ const { endo, n: N } = CURVE;
1499
+ aInRange("scalar", scalar, _1n4, N);
1500
+ let point, fake;
1501
+ if (endo) {
1502
+ const { k1neg, k1, k2neg, k2 } = endo.splitScalar(scalar);
1503
+ let { p: k1p, f: f1p } = this.wNAF(k1);
1504
+ let { p: k2p, f: f2p } = this.wNAF(k2);
1505
+ k1p = wnaf.constTimeNegate(k1neg, k1p);
1506
+ k2p = wnaf.constTimeNegate(k2neg, k2p);
1507
+ k2p = new Point2(Fp2.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
1508
+ point = k1p.add(k2p);
1509
+ fake = f1p.add(f2p);
1510
+ } else {
1511
+ const { p, f } = this.wNAF(scalar);
1512
+ point = p;
1513
+ fake = f;
1514
+ }
1515
+ return Point2.normalizeZ([point, fake])[0];
1516
+ }
1517
+ /**
1518
+ * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
1519
+ * Not using Strauss-Shamir trick: precomputation tables are faster.
1520
+ * The trick could be useful if both P and Q are not G (not in our case).
1521
+ * @returns non-zero affine point
1522
+ */
1523
+ multiplyAndAddUnsafe(Q, a, b) {
1524
+ const G = Point2.BASE;
1525
+ const mul = (P, a2) => a2 === _0n4 || a2 === _1n4 || !P.equals(G) ? P.multiplyUnsafe(a2) : P.multiply(a2);
1526
+ const sum = mul(this, a).add(mul(Q, b));
1527
+ return sum.is0() ? void 0 : sum;
1528
+ }
1529
+ // Converts Projective point to affine (x, y) coordinates.
1530
+ // Can accept precomputed Z^-1 - for example, from invertBatch.
1531
+ // (x, y, z) ∋ (x=x/z, y=y/z)
1532
+ toAffine(iz) {
1533
+ return toAffineMemo(this, iz);
1534
+ }
1535
+ isTorsionFree() {
1536
+ const { h: cofactor, isTorsionFree } = CURVE;
1537
+ if (cofactor === _1n4)
1538
+ return true;
1539
+ if (isTorsionFree)
1540
+ return isTorsionFree(Point2, this);
1541
+ throw new Error("isTorsionFree() has not been declared for the elliptic curve");
1542
+ }
1543
+ clearCofactor() {
1544
+ const { h: cofactor, clearCofactor } = CURVE;
1545
+ if (cofactor === _1n4)
1546
+ return this;
1547
+ if (clearCofactor)
1548
+ return clearCofactor(Point2, this);
1549
+ return this.multiplyUnsafe(CURVE.h);
1550
+ }
1551
+ toRawBytes(isCompressed = true) {
1552
+ abool("isCompressed", isCompressed);
1553
+ this.assertValidity();
1554
+ return toBytes2(Point2, this, isCompressed);
1555
+ }
1556
+ toHex(isCompressed = true) {
1557
+ abool("isCompressed", isCompressed);
1558
+ return bytesToHex(this.toRawBytes(isCompressed));
1559
+ }
1560
+ }
1561
+ Point2.BASE = new Point2(CURVE.Gx, CURVE.Gy, Fp2.ONE);
1562
+ Point2.ZERO = new Point2(Fp2.ZERO, Fp2.ONE, Fp2.ZERO);
1563
+ const _bits = CURVE.nBitLength;
1564
+ const wnaf = wNAF(Point2, CURVE.endo ? Math.ceil(_bits / 2) : _bits);
1565
+ return {
1566
+ CURVE,
1567
+ ProjectivePoint: Point2,
1568
+ normPrivateKeyToScalar,
1569
+ weierstrassEquation,
1570
+ isWithinCurveOrder
1571
+ };
1572
+ }
1573
+ function validateOpts(curve) {
1574
+ const opts = validateBasic(curve);
1575
+ validateObject(opts, {
1576
+ hash: "hash",
1577
+ hmac: "function",
1578
+ randomBytes: "function"
1579
+ }, {
1580
+ bits2int: "function",
1581
+ bits2int_modN: "function",
1582
+ lowS: "boolean"
1583
+ });
1584
+ return Object.freeze({ lowS: true, ...opts });
1585
+ }
1586
+ function weierstrass(curveDef) {
1587
+ const CURVE = validateOpts(curveDef);
1588
+ const { Fp: Fp2, n: CURVE_ORDER } = CURVE;
1589
+ const compressedLen = Fp2.BYTES + 1;
1590
+ const uncompressedLen = 2 * Fp2.BYTES + 1;
1591
+ function modN2(a) {
1592
+ return mod(a, CURVE_ORDER);
1593
+ }
1594
+ function invN(a) {
1595
+ return invert(a, CURVE_ORDER);
1596
+ }
1597
+ const { ProjectivePoint: Point2, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
1598
+ ...CURVE,
1599
+ toBytes(_c, point, isCompressed) {
1600
+ const a = point.toAffine();
1601
+ const x = Fp2.toBytes(a.x);
1602
+ const cat = concatBytes2;
1603
+ abool("isCompressed", isCompressed);
1604
+ if (isCompressed) {
1605
+ return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
1606
+ } else {
1607
+ return cat(Uint8Array.from([4]), x, Fp2.toBytes(a.y));
1608
+ }
1609
+ },
1610
+ fromBytes(bytes2) {
1611
+ const len = bytes2.length;
1612
+ const head = bytes2[0];
1613
+ const tail = bytes2.subarray(1);
1614
+ if (len === compressedLen && (head === 2 || head === 3)) {
1615
+ const x = bytesToNumberBE(tail);
1616
+ if (!inRange(x, _1n4, Fp2.ORDER))
1617
+ throw new Error("Point is not on curve");
1618
+ const y2 = weierstrassEquation(x);
1619
+ let y;
1620
+ try {
1621
+ y = Fp2.sqrt(y2);
1622
+ } catch (sqrtError) {
1623
+ const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
1624
+ throw new Error("Point is not on curve" + suffix);
1625
+ }
1626
+ const isYOdd = (y & _1n4) === _1n4;
1627
+ const isHeadOdd = (head & 1) === 1;
1628
+ if (isHeadOdd !== isYOdd)
1629
+ y = Fp2.neg(y);
1630
+ return { x, y };
1631
+ } else if (len === uncompressedLen && head === 4) {
1632
+ const x = Fp2.fromBytes(tail.subarray(0, Fp2.BYTES));
1633
+ const y = Fp2.fromBytes(tail.subarray(Fp2.BYTES, 2 * Fp2.BYTES));
1634
+ return { x, y };
1635
+ } else {
1636
+ throw new Error(`Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes`);
1637
+ }
1638
+ }
1639
+ });
1640
+ const numToNByteStr = (num2) => bytesToHex(numberToBytesBE(num2, CURVE.nByteLength));
1641
+ function isBiggerThanHalfOrder(number) {
1642
+ const HALF = CURVE_ORDER >> _1n4;
1643
+ return number > HALF;
1644
+ }
1645
+ function normalizeS(s) {
1646
+ return isBiggerThanHalfOrder(s) ? modN2(-s) : s;
1647
+ }
1648
+ const slcNum = (b, from, to) => bytesToNumberBE(b.slice(from, to));
1649
+ class Signature {
1650
+ constructor(r, s, recovery) {
1651
+ this.r = r;
1652
+ this.s = s;
1653
+ this.recovery = recovery;
1654
+ this.assertValidity();
1655
+ }
1656
+ // pair (bytes of r, bytes of s)
1657
+ static fromCompact(hex) {
1658
+ const l = CURVE.nByteLength;
1659
+ hex = ensureBytes("compactSignature", hex, l * 2);
1660
+ return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
1661
+ }
1662
+ // DER encoded ECDSA signature
1663
+ // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
1664
+ static fromDER(hex) {
1665
+ const { r, s } = DER.toSig(ensureBytes("DER", hex));
1666
+ return new Signature(r, s);
1667
+ }
1668
+ assertValidity() {
1669
+ aInRange("r", this.r, _1n4, CURVE_ORDER);
1670
+ aInRange("s", this.s, _1n4, CURVE_ORDER);
1671
+ }
1672
+ addRecoveryBit(recovery) {
1673
+ return new Signature(this.r, this.s, recovery);
1674
+ }
1675
+ recoverPublicKey(msgHash) {
1676
+ const { r, s, recovery: rec } = this;
1677
+ const h = bits2int_modN(ensureBytes("msgHash", msgHash));
1678
+ if (rec == null || ![0, 1, 2, 3].includes(rec))
1679
+ throw new Error("recovery id invalid");
1680
+ const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;
1681
+ if (radj >= Fp2.ORDER)
1682
+ throw new Error("recovery id 2 or 3 invalid");
1683
+ const prefix = (rec & 1) === 0 ? "02" : "03";
1684
+ const R = Point2.fromHex(prefix + numToNByteStr(radj));
1685
+ const ir = invN(radj);
1686
+ const u1 = modN2(-h * ir);
1687
+ const u2 = modN2(s * ir);
1688
+ const Q = Point2.BASE.multiplyAndAddUnsafe(R, u1, u2);
1689
+ if (!Q)
1690
+ throw new Error("point at infinify");
1691
+ Q.assertValidity();
1692
+ return Q;
1693
+ }
1694
+ // Signatures should be low-s, to prevent malleability.
1695
+ hasHighS() {
1696
+ return isBiggerThanHalfOrder(this.s);
1697
+ }
1698
+ normalizeS() {
1699
+ return this.hasHighS() ? new Signature(this.r, modN2(-this.s), this.recovery) : this;
1700
+ }
1701
+ // DER-encoded
1702
+ toDERRawBytes() {
1703
+ return hexToBytes(this.toDERHex());
1704
+ }
1705
+ toDERHex() {
1706
+ return DER.hexFromSig({ r: this.r, s: this.s });
1707
+ }
1708
+ // padded bytes of r, then padded bytes of s
1709
+ toCompactRawBytes() {
1710
+ return hexToBytes(this.toCompactHex());
1711
+ }
1712
+ toCompactHex() {
1713
+ return numToNByteStr(this.r) + numToNByteStr(this.s);
1714
+ }
1715
+ }
1716
+ const utils = {
1717
+ isValidPrivateKey(privateKey) {
1718
+ try {
1719
+ normPrivateKeyToScalar(privateKey);
1720
+ return true;
1721
+ } catch (error) {
1722
+ return false;
1723
+ }
1724
+ },
1725
+ normPrivateKeyToScalar,
1726
+ /**
1727
+ * Produces cryptographically secure private key from random of size
1728
+ * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
1729
+ */
1730
+ randomPrivateKey: () => {
1731
+ const length = getMinHashLength(CURVE.n);
1732
+ return mapHashToField(CURVE.randomBytes(length), CURVE.n);
1733
+ },
1734
+ /**
1735
+ * Creates precompute table for an arbitrary EC point. Makes point "cached".
1736
+ * Allows to massively speed-up `point.multiply(scalar)`.
1737
+ * @returns cached point
1738
+ * @example
1739
+ * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
1740
+ * fast.multiply(privKey); // much faster ECDH now
1741
+ */
1742
+ precompute(windowSize = 8, point = Point2.BASE) {
1743
+ point._setWindowSize(windowSize);
1744
+ point.multiply(BigInt(3));
1745
+ return point;
1746
+ }
1747
+ };
1748
+ function getPublicKey(privateKey, isCompressed = true) {
1749
+ return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
1750
+ }
1751
+ function isProbPub(item) {
1752
+ const arr = isBytes(item);
1753
+ const str = typeof item === "string";
1754
+ const len = (arr || str) && item.length;
1755
+ if (arr)
1756
+ return len === compressedLen || len === uncompressedLen;
1757
+ if (str)
1758
+ return len === 2 * compressedLen || len === 2 * uncompressedLen;
1759
+ if (item instanceof Point2)
1760
+ return true;
1761
+ return false;
1762
+ }
1763
+ function getSharedSecret(privateA, publicB, isCompressed = true) {
1764
+ if (isProbPub(privateA))
1765
+ throw new Error("first arg must be private key");
1766
+ if (!isProbPub(publicB))
1767
+ throw new Error("second arg must be public key");
1768
+ const b = Point2.fromHex(publicB);
1769
+ return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
1770
+ }
1771
+ const bits2int = CURVE.bits2int || function(bytes2) {
1772
+ const num2 = bytesToNumberBE(bytes2);
1773
+ const delta = bytes2.length * 8 - CURVE.nBitLength;
1774
+ return delta > 0 ? num2 >> BigInt(delta) : num2;
1775
+ };
1776
+ const bits2int_modN = CURVE.bits2int_modN || function(bytes2) {
1777
+ return modN2(bits2int(bytes2));
1778
+ };
1779
+ const ORDER_MASK = bitMask(CURVE.nBitLength);
1780
+ function int2octets(num2) {
1781
+ aInRange(`num < 2^${CURVE.nBitLength}`, num2, _0n4, ORDER_MASK);
1782
+ return numberToBytesBE(num2, CURVE.nByteLength);
1783
+ }
1784
+ function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
1785
+ if (["recovered", "canonical"].some((k) => k in opts))
1786
+ throw new Error("sign() legacy options not supported");
1787
+ const { hash: hash2, randomBytes: randomBytes2 } = CURVE;
1788
+ let { lowS, prehash, extraEntropy: ent } = opts;
1789
+ if (lowS == null)
1790
+ lowS = true;
1791
+ msgHash = ensureBytes("msgHash", msgHash);
1792
+ validateSigVerOpts(opts);
1793
+ if (prehash)
1794
+ msgHash = ensureBytes("prehashed msgHash", hash2(msgHash));
1795
+ const h1int = bits2int_modN(msgHash);
1796
+ const d = normPrivateKeyToScalar(privateKey);
1797
+ const seedArgs = [int2octets(d), int2octets(h1int)];
1798
+ if (ent != null && ent !== false) {
1799
+ const e = ent === true ? randomBytes2(Fp2.BYTES) : ent;
1800
+ seedArgs.push(ensureBytes("extraEntropy", e));
1801
+ }
1802
+ const seed = concatBytes2(...seedArgs);
1803
+ const m = h1int;
1804
+ function k2sig(kBytes) {
1805
+ const k = bits2int(kBytes);
1806
+ if (!isWithinCurveOrder(k))
1807
+ return;
1808
+ const ik = invN(k);
1809
+ const q = Point2.BASE.multiply(k).toAffine();
1810
+ const r = modN2(q.x);
1811
+ if (r === _0n4)
1812
+ return;
1813
+ const s = modN2(ik * modN2(m + r * d));
1814
+ if (s === _0n4)
1815
+ return;
1816
+ let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n4);
1817
+ let normS = s;
1818
+ if (lowS && isBiggerThanHalfOrder(s)) {
1819
+ normS = normalizeS(s);
1820
+ recovery ^= 1;
1821
+ }
1822
+ return new Signature(r, normS, recovery);
1823
+ }
1824
+ return { seed, k2sig };
1825
+ }
1826
+ const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };
1827
+ const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };
1828
+ function sign(msgHash, privKey, opts = defaultSigOpts) {
1829
+ const { seed, k2sig } = prepSig(msgHash, privKey, opts);
1830
+ const C = CURVE;
1831
+ const drbg = createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac);
1832
+ return drbg(seed, k2sig);
1833
+ }
1834
+ Point2.BASE._setWindowSize(8);
1835
+ function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
1836
+ const sg = signature;
1837
+ msgHash = ensureBytes("msgHash", msgHash);
1838
+ publicKey = ensureBytes("publicKey", publicKey);
1839
+ if ("strict" in opts)
1840
+ throw new Error("options.strict was renamed to lowS");
1841
+ validateSigVerOpts(opts);
1842
+ const { lowS, prehash } = opts;
1843
+ let _sig = void 0;
1844
+ let P;
1845
+ try {
1846
+ if (typeof sg === "string" || isBytes(sg)) {
1847
+ try {
1848
+ _sig = Signature.fromDER(sg);
1849
+ } catch (derError) {
1850
+ if (!(derError instanceof DER.Err))
1851
+ throw derError;
1852
+ _sig = Signature.fromCompact(sg);
1853
+ }
1854
+ } else if (typeof sg === "object" && typeof sg.r === "bigint" && typeof sg.s === "bigint") {
1855
+ const { r: r2, s: s2 } = sg;
1856
+ _sig = new Signature(r2, s2);
1857
+ } else {
1858
+ throw new Error("PARSE");
1859
+ }
1860
+ P = Point2.fromHex(publicKey);
1861
+ } catch (error) {
1862
+ if (error.message === "PARSE")
1863
+ throw new Error(`signature must be Signature instance, Uint8Array or hex string`);
1864
+ return false;
1865
+ }
1866
+ if (lowS && _sig.hasHighS())
1867
+ return false;
1868
+ if (prehash)
1869
+ msgHash = CURVE.hash(msgHash);
1870
+ const { r, s } = _sig;
1871
+ const h = bits2int_modN(msgHash);
1872
+ const is = invN(s);
1873
+ const u1 = modN2(h * is);
1874
+ const u2 = modN2(r * is);
1875
+ const R = Point2.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine();
1876
+ if (!R)
1877
+ return false;
1878
+ const v = modN2(R.x);
1879
+ return v === r;
1880
+ }
1881
+ return {
1882
+ CURVE,
1883
+ getPublicKey,
1884
+ getSharedSecret,
1885
+ sign,
1886
+ verify,
1887
+ ProjectivePoint: Point2,
1888
+ Signature,
1889
+ utils
1890
+ };
1891
+ }
1892
+ function SWUFpSqrtRatio(Fp2, Z) {
1893
+ const q = Fp2.ORDER;
1894
+ let l = _0n4;
1895
+ for (let o = q - _1n4; o % _2n3 === _0n4; o /= _2n3)
1896
+ l += _1n4;
1897
+ const c1 = l;
1898
+ const _2n_pow_c1_1 = _2n3 << c1 - _1n4 - _1n4;
1899
+ const _2n_pow_c1 = _2n_pow_c1_1 * _2n3;
1900
+ const c2 = (q - _1n4) / _2n_pow_c1;
1901
+ const c3 = (c2 - _1n4) / _2n3;
1902
+ const c4 = _2n_pow_c1 - _1n4;
1903
+ const c5 = _2n_pow_c1_1;
1904
+ const c6 = Fp2.pow(Z, c2);
1905
+ const c7 = Fp2.pow(Z, (c2 + _1n4) / _2n3);
1906
+ let sqrtRatio = (u, v) => {
1907
+ let tv1 = c6;
1908
+ let tv2 = Fp2.pow(v, c4);
1909
+ let tv3 = Fp2.sqr(tv2);
1910
+ tv3 = Fp2.mul(tv3, v);
1911
+ let tv5 = Fp2.mul(u, tv3);
1912
+ tv5 = Fp2.pow(tv5, c3);
1913
+ tv5 = Fp2.mul(tv5, tv2);
1914
+ tv2 = Fp2.mul(tv5, v);
1915
+ tv3 = Fp2.mul(tv5, u);
1916
+ let tv4 = Fp2.mul(tv3, tv2);
1917
+ tv5 = Fp2.pow(tv4, c5);
1918
+ let isQR = Fp2.eql(tv5, Fp2.ONE);
1919
+ tv2 = Fp2.mul(tv3, c7);
1920
+ tv5 = Fp2.mul(tv4, tv1);
1921
+ tv3 = Fp2.cmov(tv2, tv3, isQR);
1922
+ tv4 = Fp2.cmov(tv5, tv4, isQR);
1923
+ for (let i = c1; i > _1n4; i--) {
1924
+ let tv52 = i - _2n3;
1925
+ tv52 = _2n3 << tv52 - _1n4;
1926
+ let tvv5 = Fp2.pow(tv4, tv52);
1927
+ const e1 = Fp2.eql(tvv5, Fp2.ONE);
1928
+ tv2 = Fp2.mul(tv3, tv1);
1929
+ tv1 = Fp2.mul(tv1, tv1);
1930
+ tvv5 = Fp2.mul(tv4, tv1);
1931
+ tv3 = Fp2.cmov(tv2, tv3, e1);
1932
+ tv4 = Fp2.cmov(tvv5, tv4, e1);
1933
+ }
1934
+ return { isValid: isQR, value: tv3 };
1935
+ };
1936
+ if (Fp2.ORDER % _4n2 === _3n2) {
1937
+ const c12 = (Fp2.ORDER - _3n2) / _4n2;
1938
+ const c22 = Fp2.sqrt(Fp2.neg(Z));
1939
+ sqrtRatio = (u, v) => {
1940
+ let tv1 = Fp2.sqr(v);
1941
+ const tv2 = Fp2.mul(u, v);
1942
+ tv1 = Fp2.mul(tv1, tv2);
1943
+ let y1 = Fp2.pow(tv1, c12);
1944
+ y1 = Fp2.mul(y1, tv2);
1945
+ const y2 = Fp2.mul(y1, c22);
1946
+ const tv3 = Fp2.mul(Fp2.sqr(y1), v);
1947
+ const isQR = Fp2.eql(tv3, u);
1948
+ let y = Fp2.cmov(y2, y1, isQR);
1949
+ return { isValid: isQR, value: y };
1950
+ };
1951
+ }
1952
+ return sqrtRatio;
1953
+ }
1954
+ function mapToCurveSimpleSWU(Fp2, opts) {
1955
+ validateField(Fp2);
1956
+ if (!Fp2.isValid(opts.A) || !Fp2.isValid(opts.B) || !Fp2.isValid(opts.Z))
1957
+ throw new Error("mapToCurveSimpleSWU: invalid opts");
1958
+ const sqrtRatio = SWUFpSqrtRatio(Fp2, opts.Z);
1959
+ if (!Fp2.isOdd)
1960
+ throw new Error("Fp.isOdd is not implemented!");
1961
+ return (u) => {
1962
+ let tv1, tv2, tv3, tv4, tv5, tv6, x, y;
1963
+ tv1 = Fp2.sqr(u);
1964
+ tv1 = Fp2.mul(tv1, opts.Z);
1965
+ tv2 = Fp2.sqr(tv1);
1966
+ tv2 = Fp2.add(tv2, tv1);
1967
+ tv3 = Fp2.add(tv2, Fp2.ONE);
1968
+ tv3 = Fp2.mul(tv3, opts.B);
1969
+ tv4 = Fp2.cmov(opts.Z, Fp2.neg(tv2), !Fp2.eql(tv2, Fp2.ZERO));
1970
+ tv4 = Fp2.mul(tv4, opts.A);
1971
+ tv2 = Fp2.sqr(tv3);
1972
+ tv6 = Fp2.sqr(tv4);
1973
+ tv5 = Fp2.mul(tv6, opts.A);
1974
+ tv2 = Fp2.add(tv2, tv5);
1975
+ tv2 = Fp2.mul(tv2, tv3);
1976
+ tv6 = Fp2.mul(tv6, tv4);
1977
+ tv5 = Fp2.mul(tv6, opts.B);
1978
+ tv2 = Fp2.add(tv2, tv5);
1979
+ x = Fp2.mul(tv1, tv3);
1980
+ const { isValid, value } = sqrtRatio(tv2, tv6);
1981
+ y = Fp2.mul(tv1, u);
1982
+ y = Fp2.mul(y, value);
1983
+ x = Fp2.cmov(x, tv3, isValid);
1984
+ y = Fp2.cmov(y, value, isValid);
1985
+ const e1 = Fp2.isOdd(u) === Fp2.isOdd(y);
1986
+ y = Fp2.cmov(Fp2.neg(y), y, e1);
1987
+ x = Fp2.div(x, tv4);
1988
+ return { x, y };
1989
+ };
1990
+ }
1991
+
1992
+ // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/_shortw_utils.js
1993
+ function getHash(hash2) {
1994
+ return {
1995
+ hash: hash2,
1996
+ hmac: (key, ...msgs) => hmac(hash2, key, concatBytes(...msgs)),
1997
+ randomBytes
1998
+ };
1999
+ }
2000
+ function createCurve(curveDef, defHash) {
2001
+ const create = (hash2) => weierstrass({ ...curveDef, ...getHash(hash2) });
2002
+ return Object.freeze({ ...create(defHash), create });
2003
+ }
2004
+
2005
+ // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
2006
+ var os2ip = bytesToNumberBE;
2007
+ function i2osp(value, length) {
2008
+ anum(value);
2009
+ anum(length);
2010
+ if (value < 0 || value >= 1 << 8 * length) {
2011
+ throw new Error(`bad I2OSP call: value=${value} length=${length}`);
2012
+ }
2013
+ const res = Array.from({ length }).fill(0);
2014
+ for (let i = length - 1; i >= 0; i--) {
2015
+ res[i] = value & 255;
2016
+ value >>>= 8;
2017
+ }
2018
+ return new Uint8Array(res);
2019
+ }
2020
+ function strxor(a, b) {
2021
+ const arr = new Uint8Array(a.length);
2022
+ for (let i = 0; i < a.length; i++) {
2023
+ arr[i] = a[i] ^ b[i];
2024
+ }
2025
+ return arr;
2026
+ }
2027
+ function anum(item) {
2028
+ if (!Number.isSafeInteger(item))
2029
+ throw new Error("number expected");
2030
+ }
2031
+ function expand_message_xmd(msg, DST, lenInBytes, H) {
2032
+ abytes(msg);
2033
+ abytes(DST);
2034
+ anum(lenInBytes);
2035
+ if (DST.length > 255)
2036
+ DST = H(concatBytes2(utf8ToBytes("H2C-OVERSIZE-DST-"), DST));
2037
+ const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
2038
+ const ell = Math.ceil(lenInBytes / b_in_bytes);
2039
+ if (lenInBytes > 65535 || ell > 255)
2040
+ throw new Error("expand_message_xmd: invalid lenInBytes");
2041
+ const DST_prime = concatBytes2(DST, i2osp(DST.length, 1));
2042
+ const Z_pad = i2osp(0, r_in_bytes);
2043
+ const l_i_b_str = i2osp(lenInBytes, 2);
2044
+ const b = new Array(ell);
2045
+ const b_0 = H(concatBytes2(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
2046
+ b[0] = H(concatBytes2(b_0, i2osp(1, 1), DST_prime));
2047
+ for (let i = 1; i <= ell; i++) {
2048
+ const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];
2049
+ b[i] = H(concatBytes2(...args));
2050
+ }
2051
+ const pseudo_random_bytes = concatBytes2(...b);
2052
+ return pseudo_random_bytes.slice(0, lenInBytes);
2053
+ }
2054
+ function expand_message_xof(msg, DST, lenInBytes, k, H) {
2055
+ abytes(msg);
2056
+ abytes(DST);
2057
+ anum(lenInBytes);
2058
+ if (DST.length > 255) {
2059
+ const dkLen = Math.ceil(2 * k / 8);
2060
+ DST = H.create({ dkLen }).update(utf8ToBytes("H2C-OVERSIZE-DST-")).update(DST).digest();
2061
+ }
2062
+ if (lenInBytes > 65535 || DST.length > 255)
2063
+ throw new Error("expand_message_xof: invalid lenInBytes");
2064
+ return H.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
2065
+ }
2066
+ function hash_to_field(msg, count, options) {
2067
+ validateObject(options, {
2068
+ DST: "stringOrUint8Array",
2069
+ p: "bigint",
2070
+ m: "isSafeInteger",
2071
+ k: "isSafeInteger",
2072
+ hash: "hash"
2073
+ });
2074
+ const { p, k, m, hash: hash2, expand, DST: _DST } = options;
2075
+ abytes(msg);
2076
+ anum(count);
2077
+ const DST = typeof _DST === "string" ? utf8ToBytes(_DST) : _DST;
2078
+ const log2p = p.toString(2).length;
2079
+ const L = Math.ceil((log2p + k) / 8);
2080
+ const len_in_bytes = count * m * L;
2081
+ let prb;
2082
+ if (expand === "xmd") {
2083
+ prb = expand_message_xmd(msg, DST, len_in_bytes, hash2);
2084
+ } else if (expand === "xof") {
2085
+ prb = expand_message_xof(msg, DST, len_in_bytes, k, hash2);
2086
+ } else if (expand === "_internal_pass") {
2087
+ prb = msg;
2088
+ } else {
2089
+ throw new Error('expand must be "xmd" or "xof"');
2090
+ }
2091
+ const u = new Array(count);
2092
+ for (let i = 0; i < count; i++) {
2093
+ const e = new Array(m);
2094
+ for (let j = 0; j < m; j++) {
2095
+ const elm_offset = L * (j + i * m);
2096
+ const tv = prb.subarray(elm_offset, elm_offset + L);
2097
+ e[j] = mod(os2ip(tv), p);
2098
+ }
2099
+ u[i] = e;
2100
+ }
2101
+ return u;
2102
+ }
2103
+ function isogenyMap(field, map) {
2104
+ const COEFF = map.map((i) => Array.from(i).reverse());
2105
+ return (x, y) => {
2106
+ const [xNum, xDen, yNum, yDen] = COEFF.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i)));
2107
+ x = field.div(xNum, xDen);
2108
+ y = field.mul(y, field.div(yNum, yDen));
2109
+ return { x, y };
2110
+ };
2111
+ }
2112
+ function createHasher(Point2, mapToCurve, def) {
2113
+ if (typeof mapToCurve !== "function")
2114
+ throw new Error("mapToCurve() must be defined");
2115
+ return {
2116
+ // Encodes byte string to elliptic curve.
2117
+ // hash_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3
2118
+ hashToCurve(msg, options) {
2119
+ const u = hash_to_field(msg, 2, { ...def, DST: def.DST, ...options });
2120
+ const u0 = Point2.fromAffine(mapToCurve(u[0]));
2121
+ const u1 = Point2.fromAffine(mapToCurve(u[1]));
2122
+ const P = u0.add(u1).clearCofactor();
2123
+ P.assertValidity();
2124
+ return P;
2125
+ },
2126
+ // Encodes byte string to elliptic curve.
2127
+ // encode_to_curve from https://www.rfc-editor.org/rfc/rfc9380#section-3
2128
+ encodeToCurve(msg, options) {
2129
+ const u = hash_to_field(msg, 1, { ...def, DST: def.encodeDST, ...options });
2130
+ const P = Point2.fromAffine(mapToCurve(u[0])).clearCofactor();
2131
+ P.assertValidity();
2132
+ return P;
2133
+ },
2134
+ // Same as encodeToCurve, but without hash
2135
+ mapToCurve(scalars) {
2136
+ if (!Array.isArray(scalars))
2137
+ throw new Error("mapToCurve: expected array of bigints");
2138
+ for (const i of scalars)
2139
+ if (typeof i !== "bigint")
2140
+ throw new Error(`mapToCurve: expected array of bigints, got ${i} in array`);
2141
+ const P = Point2.fromAffine(mapToCurve(scalars)).clearCofactor();
2142
+ P.assertValidity();
2143
+ return P;
2144
+ }
2145
+ };
2146
+ }
2147
+
2148
+ // ../../node_modules/.pnpm/@noble+curves@1.6.0/node_modules/@noble/curves/esm/secp256k1.js
2149
+ var secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
2150
+ var secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
2151
+ var _1n5 = BigInt(1);
2152
+ var _2n4 = BigInt(2);
2153
+ var divNearest = (a, b) => (a + b / _2n4) / b;
2154
+ function sqrtMod(y) {
2155
+ const P = secp256k1P;
2156
+ const _3n3 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
2157
+ const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
2158
+ const b2 = y * y * y % P;
2159
+ const b3 = b2 * b2 * y % P;
2160
+ const b6 = pow2(b3, _3n3, P) * b3 % P;
2161
+ const b9 = pow2(b6, _3n3, P) * b3 % P;
2162
+ const b11 = pow2(b9, _2n4, P) * b2 % P;
2163
+ const b22 = pow2(b11, _11n, P) * b11 % P;
2164
+ const b44 = pow2(b22, _22n, P) * b22 % P;
2165
+ const b88 = pow2(b44, _44n, P) * b44 % P;
2166
+ const b176 = pow2(b88, _88n, P) * b88 % P;
2167
+ const b220 = pow2(b176, _44n, P) * b44 % P;
2168
+ const b223 = pow2(b220, _3n3, P) * b3 % P;
2169
+ const t1 = pow2(b223, _23n, P) * b22 % P;
2170
+ const t2 = pow2(t1, _6n, P) * b2 % P;
2171
+ const root = pow2(t2, _2n4, P);
2172
+ if (!Fp.eql(Fp.sqr(root), y))
2173
+ throw new Error("Cannot find square root");
2174
+ return root;
2175
+ }
2176
+ var Fp = Field(secp256k1P, void 0, void 0, { sqrt: sqrtMod });
2177
+ var secp256k1 = createCurve({
2178
+ a: BigInt(0),
2179
+ // equation params: a, b
2180
+ b: BigInt(7),
2181
+ // Seem to be rigid: bitcointalk.org/index.php?topic=289795.msg3183975#msg3183975
2182
+ Fp,
2183
+ // Field's prime: 2n**256n - 2n**32n - 2n**9n - 2n**8n - 2n**7n - 2n**6n - 2n**4n - 1n
2184
+ n: secp256k1N,
2185
+ // Curve order, total count of valid points in the field
2186
+ // Base point (x, y) aka generator point
2187
+ Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
2188
+ Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
2189
+ h: BigInt(1),
2190
+ // Cofactor
2191
+ lowS: true,
2192
+ // Allow only low-S signatures by default in sign() and verify()
2193
+ /**
2194
+ * secp256k1 belongs to Koblitz curves: it has efficiently computable endomorphism.
2195
+ * Endomorphism uses 2x less RAM, speeds up precomputation by 2x and ECDH / key recovery by 20%.
2196
+ * For precomputed wNAF it trades off 1/2 init time & 1/3 ram for 20% perf hit.
2197
+ * Explanation: https://gist.github.com/paulmillr/eb670806793e84df628a7c434a873066
2198
+ */
2199
+ endo: {
2200
+ beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
2201
+ splitScalar: (k) => {
2202
+ const n = secp256k1N;
2203
+ const a1 = BigInt("0x3086d221a7d46bcde86c90e49284eb15");
2204
+ const b1 = -_1n5 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3");
2205
+ const a2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");
2206
+ const b2 = a1;
2207
+ const POW_2_128 = BigInt("0x100000000000000000000000000000000");
2208
+ const c1 = divNearest(b2 * k, n);
2209
+ const c2 = divNearest(-b1 * k, n);
2210
+ let k1 = mod(k - c1 * a1 - c2 * a2, n);
2211
+ let k2 = mod(-c1 * b1 - c2 * b2, n);
2212
+ const k1neg = k1 > POW_2_128;
2213
+ const k2neg = k2 > POW_2_128;
2214
+ if (k1neg)
2215
+ k1 = n - k1;
2216
+ if (k2neg)
2217
+ k2 = n - k2;
2218
+ if (k1 > POW_2_128 || k2 > POW_2_128) {
2219
+ throw new Error("splitScalar: Endomorphism failed, k=" + k);
2220
+ }
2221
+ return { k1neg, k1, k2neg, k2 };
2222
+ }
2223
+ }
2224
+ }, sha256);
2225
+ var _0n5 = BigInt(0);
2226
+ var TAGGED_HASH_PREFIXES = {};
2227
+ function taggedHash(tag, ...messages) {
2228
+ let tagP = TAGGED_HASH_PREFIXES[tag];
2229
+ if (tagP === void 0) {
2230
+ const tagH = sha256(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
2231
+ tagP = concatBytes2(tagH, tagH);
2232
+ TAGGED_HASH_PREFIXES[tag] = tagP;
2233
+ }
2234
+ return sha256(concatBytes2(tagP, ...messages));
2235
+ }
2236
+ var pointToBytes = (point) => point.toRawBytes(true).slice(1);
2237
+ var numTo32b = (n) => numberToBytesBE(n, 32);
2238
+ var modP = (x) => mod(x, secp256k1P);
2239
+ var modN = (x) => mod(x, secp256k1N);
2240
+ var Point = secp256k1.ProjectivePoint;
2241
+ var GmulAdd = (Q, a, b) => Point.BASE.multiplyAndAddUnsafe(Q, a, b);
2242
+ function schnorrGetExtPubKey(priv) {
2243
+ let d_ = secp256k1.utils.normPrivateKeyToScalar(priv);
2244
+ let p = Point.fromPrivateKey(d_);
2245
+ const scalar = p.hasEvenY() ? d_ : modN(-d_);
2246
+ return { scalar, bytes: pointToBytes(p) };
2247
+ }
2248
+ function lift_x(x) {
2249
+ aInRange("x", x, _1n5, secp256k1P);
2250
+ const xx = modP(x * x);
2251
+ const c = modP(xx * x + BigInt(7));
2252
+ let y = sqrtMod(c);
2253
+ if (y % _2n4 !== _0n5)
2254
+ y = modP(-y);
2255
+ const p = new Point(x, y, _1n5);
2256
+ p.assertValidity();
2257
+ return p;
2258
+ }
2259
+ var num = bytesToNumberBE;
2260
+ function challenge(...args) {
2261
+ return modN(num(taggedHash("BIP0340/challenge", ...args)));
2262
+ }
2263
+ function schnorrGetPublicKey(privateKey) {
2264
+ return schnorrGetExtPubKey(privateKey).bytes;
2265
+ }
2266
+ function schnorrSign(message, privateKey, auxRand = randomBytes(32)) {
2267
+ const m = ensureBytes("message", message);
2268
+ const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey);
2269
+ const a = ensureBytes("auxRand", auxRand, 32);
2270
+ const t = numTo32b(d ^ num(taggedHash("BIP0340/aux", a)));
2271
+ const rand = taggedHash("BIP0340/nonce", t, px, m);
2272
+ const k_ = modN(num(rand));
2273
+ if (k_ === _0n5)
2274
+ throw new Error("sign failed: k is zero");
2275
+ const { bytes: rx, scalar: k } = schnorrGetExtPubKey(k_);
2276
+ const e = challenge(rx, px, m);
2277
+ const sig = new Uint8Array(64);
2278
+ sig.set(rx, 0);
2279
+ sig.set(numTo32b(modN(k + e * d)), 32);
2280
+ if (!schnorrVerify(sig, m, px))
2281
+ throw new Error("sign: Invalid signature produced");
2282
+ return sig;
2283
+ }
2284
+ function schnorrVerify(signature, message, publicKey) {
2285
+ const sig = ensureBytes("signature", signature, 64);
2286
+ const m = ensureBytes("message", message);
2287
+ const pub = ensureBytes("publicKey", publicKey, 32);
2288
+ try {
2289
+ const P = lift_x(num(pub));
2290
+ const r = num(sig.subarray(0, 32));
2291
+ if (!inRange(r, _1n5, secp256k1P))
2292
+ return false;
2293
+ const s = num(sig.subarray(32, 64));
2294
+ if (!inRange(s, _1n5, secp256k1N))
2295
+ return false;
2296
+ const e = challenge(numTo32b(r), pointToBytes(P), m);
2297
+ const R = GmulAdd(P, s, modN(-e));
2298
+ if (!R || !R.hasEvenY() || R.toAffine().x !== r)
2299
+ return false;
2300
+ return true;
2301
+ } catch (error) {
2302
+ return false;
2303
+ }
2304
+ }
2305
+ var schnorr = /* @__PURE__ */ (() => ({
2306
+ getPublicKey: schnorrGetPublicKey,
2307
+ sign: schnorrSign,
2308
+ verify: schnorrVerify,
2309
+ utils: {
2310
+ randomPrivateKey: secp256k1.utils.randomPrivateKey,
2311
+ lift_x,
2312
+ pointToBytes,
2313
+ numberToBytesBE,
2314
+ bytesToNumberBE,
2315
+ taggedHash,
2316
+ mod
2317
+ }
2318
+ }))();
2319
+ var isoMap = /* @__PURE__ */ (() => isogenyMap(Fp, [
2320
+ // xNum
2321
+ [
2322
+ "0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7",
2323
+ "0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581",
2324
+ "0x534c328d23f234e6e2a413deca25caece4506144037c40314ecbd0b53d9dd262",
2325
+ "0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa88c"
2326
+ ],
2327
+ // xDen
2328
+ [
2329
+ "0xd35771193d94918a9ca34ccbb7b640dd86cd409542f8487d9fe6b745781eb49b",
2330
+ "0xedadc6f64383dc1df7c4b2d51b54225406d36b641f5e41bbc52a56612a8c6d14",
2331
+ "0x0000000000000000000000000000000000000000000000000000000000000001"
2332
+ // LAST 1
2333
+ ],
2334
+ // yNum
2335
+ [
2336
+ "0x4bda12f684bda12f684bda12f684bda12f684bda12f684bda12f684b8e38e23c",
2337
+ "0xc75e0c32d5cb7c0fa9d0a54b12a0a6d5647ab046d686da6fdffc90fc201d71a3",
2338
+ "0x29a6194691f91a73715209ef6512e576722830a201be2018a765e85a9ecee931",
2339
+ "0x2f684bda12f684bda12f684bda12f684bda12f684bda12f684bda12f38e38d84"
2340
+ ],
2341
+ // yDen
2342
+ [
2343
+ "0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffff93b",
2344
+ "0x7a06534bb8bdb49fd5e9e6632722c2989467c1bfc8e8d978dfb425d2685c2573",
2345
+ "0x6484aa716545ca2cf3a70c3fa8fe337e0a3d21162f0d6299a7bf8192bfd2a76f",
2346
+ "0x0000000000000000000000000000000000000000000000000000000000000001"
2347
+ // LAST 1
2348
+ ]
2349
+ ].map((i) => i.map((j) => BigInt(j)))))();
2350
+ var mapSWU = /* @__PURE__ */ (() => mapToCurveSimpleSWU(Fp, {
2351
+ A: BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),
2352
+ B: BigInt("1771"),
2353
+ Z: Fp.create(BigInt("-11"))
2354
+ }))();
2355
+ var htf = /* @__PURE__ */ (() => createHasher(secp256k1.ProjectivePoint, (scalars) => {
2356
+ const { x, y } = mapSWU(Fp.create(scalars[0]));
2357
+ return isoMap(x, y);
2358
+ }, {
2359
+ DST: "secp256k1_XMD:SHA-256_SSWU_RO_",
2360
+ encodeDST: "secp256k1_XMD:SHA-256_SSWU_NU_",
2361
+ p: Fp.ORDER,
2362
+ m: 1,
2363
+ k: 128,
2364
+ expand: "xmd",
2365
+ hash: sha256
2366
+ }))();
2367
+ var hashToCurve = /* @__PURE__ */ (() => htf.hashToCurve)();
2368
+ var encodeToCurve = /* @__PURE__ */ (() => htf.encodeToCurve)();
2369
+ export {
2370
+ encodeToCurve,
2371
+ hashToCurve,
2372
+ schnorr,
2373
+ secp256k1
2374
+ };
2375
+ /*! Bundled license information:
2376
+
2377
+ @noble/curves/esm/abstract/utils.js:
2378
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2379
+
2380
+ @noble/curves/esm/abstract/modular.js:
2381
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2382
+
2383
+ @noble/curves/esm/abstract/curve.js:
2384
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2385
+
2386
+ @noble/curves/esm/abstract/weierstrass.js:
2387
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2388
+
2389
+ @noble/curves/esm/_shortw_utils.js:
2390
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2391
+
2392
+ @noble/curves/esm/secp256k1.js:
2393
+ (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
2394
+ */
2395
+ //# sourceMappingURL=secp256k1-XVT662DN.js.map