@strkfarm/sdk 1.0.58 → 1.0.59

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -17,19 +17,20 @@ var __copyProps = (to, from, except, desc) => {
17
17
  }
18
18
  return to;
19
19
  };
20
- var __toESM = (mod2, isNodeMode, target) => (target = mod2 != null ? __create(__getProtoOf(mod2)) : {}, __copyProps(
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
21
  // If the importer is in node compatibility mode or this is not an ESM
22
22
  // file that has been converted to a CommonJS file using a Babel-
23
23
  // compatible transform (i.e. "__esModule" has not been set), then set
24
24
  // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target,
26
- mod2
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
27
  ));
28
- var __toCommonJS = (mod2) => __copyProps(__defProp({}, "__esModule", { value: true }), mod2);
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ AUMTypes: () => AUMTypes,
33
34
  AutoCompounderSTRK: () => AutoCompounderSTRK,
34
35
  AvnuWrapper: () => AvnuWrapper,
35
36
  BaseAdapter: () => BaseAdapter,
@@ -82,7 +83,7 @@ __export(src_exports, {
82
83
  highlightTextWithLinks: () => highlightTextWithLinks,
83
84
  logger: () => logger
84
85
  });
85
- module.exports = __toCommonJS(src_exports);
86
+ module.exports = __toCommonJS(index_exports);
86
87
 
87
88
  // src/modules/pricer.ts
88
89
  var import_axios2 = __toESM(require("axios"));
@@ -2067,2033 +2068,7 @@ var import_core = require("@ericnordelo/strk-merkle-tree/dist/core");
2067
2068
  var import_hashes = require("@ericnordelo/strk-merkle-tree/dist/hashes");
2068
2069
  var import_merkletree = require("@ericnordelo/strk-merkle-tree/dist/merkletree");
2069
2070
  var import_starknet4 = require("starknet");
2070
-
2071
- // ../node_modules/@noble/hashes/esm/_assert.js
2072
- function number(n) {
2073
- if (!Number.isSafeInteger(n) || n < 0)
2074
- throw new Error(`Wrong positive integer: ${n}`);
2075
- }
2076
- function bytes(b, ...lengths) {
2077
- if (!(b instanceof Uint8Array))
2078
- throw new Error("Expected Uint8Array");
2079
- if (lengths.length > 0 && !lengths.includes(b.length))
2080
- throw new Error(`Expected Uint8Array of length ${lengths}, not of length=${b.length}`);
2081
- }
2082
- function hash(hash6) {
2083
- if (typeof hash6 !== "function" || typeof hash6.create !== "function")
2084
- throw new Error("Hash should be wrapped by utils.wrapConstructor");
2085
- number(hash6.outputLen);
2086
- number(hash6.blockLen);
2087
- }
2088
- function exists(instance, checkFinished = true) {
2089
- if (instance.destroyed)
2090
- throw new Error("Hash instance has been destroyed");
2091
- if (checkFinished && instance.finished)
2092
- throw new Error("Hash#digest() has already been called");
2093
- }
2094
- function output(out, instance) {
2095
- bytes(out);
2096
- const min = instance.outputLen;
2097
- if (out.length < min) {
2098
- throw new Error(`digestInto() expects output buffer of length at least ${min}`);
2099
- }
2100
- }
2101
-
2102
- // ../node_modules/@noble/hashes/esm/cryptoNode.js
2103
- var nc = __toESM(require("crypto"), 1);
2104
- var crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : void 0;
2105
-
2106
- // ../node_modules/@noble/hashes/esm/utils.js
2107
- var u8a = (a) => a instanceof Uint8Array;
2108
- var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
2109
- var rotr = (word, shift) => word << 32 - shift | word >>> shift;
2110
- var isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
2111
- if (!isLE)
2112
- throw new Error("Non little-endian hardware is not supported");
2113
- function utf8ToBytes(str) {
2114
- if (typeof str !== "string")
2115
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
2116
- return new Uint8Array(new TextEncoder().encode(str));
2117
- }
2118
- function toBytes(data) {
2119
- if (typeof data === "string")
2120
- data = utf8ToBytes(data);
2121
- if (!u8a(data))
2122
- throw new Error(`expected Uint8Array, got ${typeof data}`);
2123
- return data;
2124
- }
2125
- function concatBytes(...arrays) {
2126
- const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
2127
- let pad = 0;
2128
- arrays.forEach((a) => {
2129
- if (!u8a(a))
2130
- throw new Error("Uint8Array expected");
2131
- r.set(a, pad);
2132
- pad += a.length;
2133
- });
2134
- return r;
2135
- }
2136
- var Hash = class {
2137
- // Safe version that clones internal state
2138
- clone() {
2139
- return this._cloneInto();
2140
- }
2141
- };
2142
- var toStr = {}.toString;
2143
- function wrapConstructor(hashCons) {
2144
- const hashC = (msg) => hashCons().update(toBytes(msg)).digest();
2145
- const tmp = hashCons();
2146
- hashC.outputLen = tmp.outputLen;
2147
- hashC.blockLen = tmp.blockLen;
2148
- hashC.create = () => hashCons();
2149
- return hashC;
2150
- }
2151
- function randomBytes(bytesLength = 32) {
2152
- if (crypto && typeof crypto.getRandomValues === "function") {
2153
- return crypto.getRandomValues(new Uint8Array(bytesLength));
2154
- }
2155
- throw new Error("crypto.getRandomValues must be defined");
2156
- }
2157
-
2158
- // ../node_modules/@noble/hashes/esm/_sha2.js
2159
- function setBigUint64(view, byteOffset, value, isLE2) {
2160
- if (typeof view.setBigUint64 === "function")
2161
- return view.setBigUint64(byteOffset, value, isLE2);
2162
- const _32n = BigInt(32);
2163
- const _u32_max = BigInt(4294967295);
2164
- const wh = Number(value >> _32n & _u32_max);
2165
- const wl = Number(value & _u32_max);
2166
- const h = isLE2 ? 4 : 0;
2167
- const l = isLE2 ? 0 : 4;
2168
- view.setUint32(byteOffset + h, wh, isLE2);
2169
- view.setUint32(byteOffset + l, wl, isLE2);
2170
- }
2171
- var SHA2 = class extends Hash {
2172
- constructor(blockLen, outputLen, padOffset, isLE2) {
2173
- super();
2174
- this.blockLen = blockLen;
2175
- this.outputLen = outputLen;
2176
- this.padOffset = padOffset;
2177
- this.isLE = isLE2;
2178
- this.finished = false;
2179
- this.length = 0;
2180
- this.pos = 0;
2181
- this.destroyed = false;
2182
- this.buffer = new Uint8Array(blockLen);
2183
- this.view = createView(this.buffer);
2184
- }
2185
- update(data) {
2186
- exists(this);
2187
- const { view, buffer, blockLen } = this;
2188
- data = toBytes(data);
2189
- const len = data.length;
2190
- for (let pos = 0; pos < len; ) {
2191
- const take = Math.min(blockLen - this.pos, len - pos);
2192
- if (take === blockLen) {
2193
- const dataView = createView(data);
2194
- for (; blockLen <= len - pos; pos += blockLen)
2195
- this.process(dataView, pos);
2196
- continue;
2197
- }
2198
- buffer.set(data.subarray(pos, pos + take), this.pos);
2199
- this.pos += take;
2200
- pos += take;
2201
- if (this.pos === blockLen) {
2202
- this.process(view, 0);
2203
- this.pos = 0;
2204
- }
2205
- }
2206
- this.length += data.length;
2207
- this.roundClean();
2208
- return this;
2209
- }
2210
- digestInto(out) {
2211
- exists(this);
2212
- output(out, this);
2213
- this.finished = true;
2214
- const { buffer, view, blockLen, isLE: isLE2 } = this;
2215
- let { pos } = this;
2216
- buffer[pos++] = 128;
2217
- this.buffer.subarray(pos).fill(0);
2218
- if (this.padOffset > blockLen - pos) {
2219
- this.process(view, 0);
2220
- pos = 0;
2221
- }
2222
- for (let i = pos; i < blockLen; i++)
2223
- buffer[i] = 0;
2224
- setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE2);
2225
- this.process(view, 0);
2226
- const oview = createView(out);
2227
- const len = this.outputLen;
2228
- if (len % 4)
2229
- throw new Error("_sha2: outputLen should be aligned to 32bit");
2230
- const outLen = len / 4;
2231
- const state = this.get();
2232
- if (outLen > state.length)
2233
- throw new Error("_sha2: outputLen bigger than state");
2234
- for (let i = 0; i < outLen; i++)
2235
- oview.setUint32(4 * i, state[i], isLE2);
2236
- }
2237
- digest() {
2238
- const { buffer, outputLen } = this;
2239
- this.digestInto(buffer);
2240
- const res = buffer.slice(0, outputLen);
2241
- this.destroy();
2242
- return res;
2243
- }
2244
- _cloneInto(to) {
2245
- to || (to = new this.constructor());
2246
- to.set(...this.get());
2247
- const { blockLen, buffer, length, finished, destroyed, pos } = this;
2248
- to.length = length;
2249
- to.pos = pos;
2250
- to.finished = finished;
2251
- to.destroyed = destroyed;
2252
- if (length % blockLen)
2253
- to.buffer.set(buffer);
2254
- return to;
2255
- }
2256
- };
2257
-
2258
- // ../node_modules/@noble/hashes/esm/sha256.js
2259
- var Chi = (a, b, c) => a & b ^ ~a & c;
2260
- var Maj = (a, b, c) => a & b ^ a & c ^ b & c;
2261
- var SHA256_K = /* @__PURE__ */ new Uint32Array([
2262
- 1116352408,
2263
- 1899447441,
2264
- 3049323471,
2265
- 3921009573,
2266
- 961987163,
2267
- 1508970993,
2268
- 2453635748,
2269
- 2870763221,
2270
- 3624381080,
2271
- 310598401,
2272
- 607225278,
2273
- 1426881987,
2274
- 1925078388,
2275
- 2162078206,
2276
- 2614888103,
2277
- 3248222580,
2278
- 3835390401,
2279
- 4022224774,
2280
- 264347078,
2281
- 604807628,
2282
- 770255983,
2283
- 1249150122,
2284
- 1555081692,
2285
- 1996064986,
2286
- 2554220882,
2287
- 2821834349,
2288
- 2952996808,
2289
- 3210313671,
2290
- 3336571891,
2291
- 3584528711,
2292
- 113926993,
2293
- 338241895,
2294
- 666307205,
2295
- 773529912,
2296
- 1294757372,
2297
- 1396182291,
2298
- 1695183700,
2299
- 1986661051,
2300
- 2177026350,
2301
- 2456956037,
2302
- 2730485921,
2303
- 2820302411,
2304
- 3259730800,
2305
- 3345764771,
2306
- 3516065817,
2307
- 3600352804,
2308
- 4094571909,
2309
- 275423344,
2310
- 430227734,
2311
- 506948616,
2312
- 659060556,
2313
- 883997877,
2314
- 958139571,
2315
- 1322822218,
2316
- 1537002063,
2317
- 1747873779,
2318
- 1955562222,
2319
- 2024104815,
2320
- 2227730452,
2321
- 2361852424,
2322
- 2428436474,
2323
- 2756734187,
2324
- 3204031479,
2325
- 3329325298
2326
- ]);
2327
- var IV = /* @__PURE__ */ new Uint32Array([
2328
- 1779033703,
2329
- 3144134277,
2330
- 1013904242,
2331
- 2773480762,
2332
- 1359893119,
2333
- 2600822924,
2334
- 528734635,
2335
- 1541459225
2336
- ]);
2337
- var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
2338
- var SHA256 = class extends SHA2 {
2339
- constructor() {
2340
- super(64, 32, 8, false);
2341
- this.A = IV[0] | 0;
2342
- this.B = IV[1] | 0;
2343
- this.C = IV[2] | 0;
2344
- this.D = IV[3] | 0;
2345
- this.E = IV[4] | 0;
2346
- this.F = IV[5] | 0;
2347
- this.G = IV[6] | 0;
2348
- this.H = IV[7] | 0;
2349
- }
2350
- get() {
2351
- const { A, B, C, D, E, F, G, H } = this;
2352
- return [A, B, C, D, E, F, G, H];
2353
- }
2354
- // prettier-ignore
2355
- set(A, B, C, D, E, F, G, H) {
2356
- this.A = A | 0;
2357
- this.B = B | 0;
2358
- this.C = C | 0;
2359
- this.D = D | 0;
2360
- this.E = E | 0;
2361
- this.F = F | 0;
2362
- this.G = G | 0;
2363
- this.H = H | 0;
2364
- }
2365
- process(view, offset) {
2366
- for (let i = 0; i < 16; i++, offset += 4)
2367
- SHA256_W[i] = view.getUint32(offset, false);
2368
- for (let i = 16; i < 64; i++) {
2369
- const W15 = SHA256_W[i - 15];
2370
- const W2 = SHA256_W[i - 2];
2371
- const s0 = rotr(W15, 7) ^ rotr(W15, 18) ^ W15 >>> 3;
2372
- const s1 = rotr(W2, 17) ^ rotr(W2, 19) ^ W2 >>> 10;
2373
- SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
2374
- }
2375
- let { A, B, C, D, E, F, G, H } = this;
2376
- for (let i = 0; i < 64; i++) {
2377
- const sigma1 = rotr(E, 6) ^ rotr(E, 11) ^ rotr(E, 25);
2378
- const T1 = H + sigma1 + Chi(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
2379
- const sigma0 = rotr(A, 2) ^ rotr(A, 13) ^ rotr(A, 22);
2380
- const T2 = sigma0 + Maj(A, B, C) | 0;
2381
- H = G;
2382
- G = F;
2383
- F = E;
2384
- E = D + T1 | 0;
2385
- D = C;
2386
- C = B;
2387
- B = A;
2388
- A = T1 + T2 | 0;
2389
- }
2390
- A = A + this.A | 0;
2391
- B = B + this.B | 0;
2392
- C = C + this.C | 0;
2393
- D = D + this.D | 0;
2394
- E = E + this.E | 0;
2395
- F = F + this.F | 0;
2396
- G = G + this.G | 0;
2397
- H = H + this.H | 0;
2398
- this.set(A, B, C, D, E, F, G, H);
2399
- }
2400
- roundClean() {
2401
- SHA256_W.fill(0);
2402
- }
2403
- destroy() {
2404
- this.set(0, 0, 0, 0, 0, 0, 0, 0);
2405
- this.buffer.fill(0);
2406
- }
2407
- };
2408
- var sha256 = /* @__PURE__ */ wrapConstructor(() => new SHA256());
2409
-
2410
- // ../node_modules/@noble/curves/esm/abstract/utils.js
2411
- var utils_exports = {};
2412
- __export(utils_exports, {
2413
- bitGet: () => bitGet,
2414
- bitLen: () => bitLen,
2415
- bitMask: () => bitMask,
2416
- bitSet: () => bitSet,
2417
- bytesToHex: () => bytesToHex,
2418
- bytesToNumberBE: () => bytesToNumberBE,
2419
- bytesToNumberLE: () => bytesToNumberLE,
2420
- concatBytes: () => concatBytes2,
2421
- createHmacDrbg: () => createHmacDrbg,
2422
- ensureBytes: () => ensureBytes,
2423
- equalBytes: () => equalBytes,
2424
- hexToBytes: () => hexToBytes,
2425
- hexToNumber: () => hexToNumber,
2426
- numberToBytesBE: () => numberToBytesBE,
2427
- numberToBytesLE: () => numberToBytesLE,
2428
- numberToHexUnpadded: () => numberToHexUnpadded,
2429
- numberToVarBytesBE: () => numberToVarBytesBE,
2430
- utf8ToBytes: () => utf8ToBytes2,
2431
- validateObject: () => validateObject
2432
- });
2433
- var _0n = BigInt(0);
2434
- var _1n = BigInt(1);
2435
- var _2n = BigInt(2);
2436
- var u8a2 = (a) => a instanceof Uint8Array;
2437
- var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
2438
- function bytesToHex(bytes2) {
2439
- if (!u8a2(bytes2))
2440
- throw new Error("Uint8Array expected");
2441
- let hex = "";
2442
- for (let i = 0; i < bytes2.length; i++) {
2443
- hex += hexes[bytes2[i]];
2444
- }
2445
- return hex;
2446
- }
2447
- function numberToHexUnpadded(num11) {
2448
- const hex = num11.toString(16);
2449
- return hex.length & 1 ? `0${hex}` : hex;
2450
- }
2451
- function hexToNumber(hex) {
2452
- if (typeof hex !== "string")
2453
- throw new Error("hex string expected, got " + typeof hex);
2454
- return BigInt(hex === "" ? "0" : `0x${hex}`);
2455
- }
2456
- function hexToBytes(hex) {
2457
- if (typeof hex !== "string")
2458
- throw new Error("hex string expected, got " + typeof hex);
2459
- const len = hex.length;
2460
- if (len % 2)
2461
- throw new Error("padded hex string expected, got unpadded hex of length " + len);
2462
- const array = new Uint8Array(len / 2);
2463
- for (let i = 0; i < array.length; i++) {
2464
- const j = i * 2;
2465
- const hexByte = hex.slice(j, j + 2);
2466
- const byte = Number.parseInt(hexByte, 16);
2467
- if (Number.isNaN(byte) || byte < 0)
2468
- throw new Error("Invalid byte sequence");
2469
- array[i] = byte;
2470
- }
2471
- return array;
2472
- }
2473
- function bytesToNumberBE(bytes2) {
2474
- return hexToNumber(bytesToHex(bytes2));
2475
- }
2476
- function bytesToNumberLE(bytes2) {
2477
- if (!u8a2(bytes2))
2478
- throw new Error("Uint8Array expected");
2479
- return hexToNumber(bytesToHex(Uint8Array.from(bytes2).reverse()));
2480
- }
2481
- function numberToBytesBE(n, len) {
2482
- return hexToBytes(n.toString(16).padStart(len * 2, "0"));
2483
- }
2484
- function numberToBytesLE(n, len) {
2485
- return numberToBytesBE(n, len).reverse();
2486
- }
2487
- function numberToVarBytesBE(n) {
2488
- return hexToBytes(numberToHexUnpadded(n));
2489
- }
2490
- function ensureBytes(title, hex, expectedLength) {
2491
- let res;
2492
- if (typeof hex === "string") {
2493
- try {
2494
- res = hexToBytes(hex);
2495
- } catch (e) {
2496
- throw new Error(`${title} must be valid hex string, got "${hex}". Cause: ${e}`);
2497
- }
2498
- } else if (u8a2(hex)) {
2499
- res = Uint8Array.from(hex);
2500
- } else {
2501
- throw new Error(`${title} must be hex string or Uint8Array`);
2502
- }
2503
- const len = res.length;
2504
- if (typeof expectedLength === "number" && len !== expectedLength)
2505
- throw new Error(`${title} expected ${expectedLength} bytes, got ${len}`);
2506
- return res;
2507
- }
2508
- function concatBytes2(...arrays) {
2509
- const r = new Uint8Array(arrays.reduce((sum, a) => sum + a.length, 0));
2510
- let pad = 0;
2511
- arrays.forEach((a) => {
2512
- if (!u8a2(a))
2513
- throw new Error("Uint8Array expected");
2514
- r.set(a, pad);
2515
- pad += a.length;
2516
- });
2517
- return r;
2518
- }
2519
- function equalBytes(b1, b2) {
2520
- if (b1.length !== b2.length)
2521
- return false;
2522
- for (let i = 0; i < b1.length; i++)
2523
- if (b1[i] !== b2[i])
2524
- return false;
2525
- return true;
2526
- }
2527
- function utf8ToBytes2(str) {
2528
- if (typeof str !== "string")
2529
- throw new Error(`utf8ToBytes expected string, got ${typeof str}`);
2530
- return new Uint8Array(new TextEncoder().encode(str));
2531
- }
2532
- function bitLen(n) {
2533
- let len;
2534
- for (len = 0; n > _0n; n >>= _1n, len += 1)
2535
- ;
2536
- return len;
2537
- }
2538
- function bitGet(n, pos) {
2539
- return n >> BigInt(pos) & _1n;
2540
- }
2541
- var bitSet = (n, pos, value) => {
2542
- return n | (value ? _1n : _0n) << BigInt(pos);
2543
- };
2544
- var bitMask = (n) => (_2n << BigInt(n - 1)) - _1n;
2545
- var u8n = (data) => new Uint8Array(data);
2546
- var u8fr = (arr) => Uint8Array.from(arr);
2547
- function createHmacDrbg(hashLen, qByteLen, hmacFn) {
2548
- if (typeof hashLen !== "number" || hashLen < 2)
2549
- throw new Error("hashLen must be a number");
2550
- if (typeof qByteLen !== "number" || qByteLen < 2)
2551
- throw new Error("qByteLen must be a number");
2552
- if (typeof hmacFn !== "function")
2553
- throw new Error("hmacFn must be a function");
2554
- let v = u8n(hashLen);
2555
- let k = u8n(hashLen);
2556
- let i = 0;
2557
- const reset = () => {
2558
- v.fill(1);
2559
- k.fill(0);
2560
- i = 0;
2561
- };
2562
- const h = (...b) => hmacFn(k, v, ...b);
2563
- const reseed = (seed = u8n()) => {
2564
- k = h(u8fr([0]), seed);
2565
- v = h();
2566
- if (seed.length === 0)
2567
- return;
2568
- k = h(u8fr([1]), seed);
2569
- v = h();
2570
- };
2571
- const gen = () => {
2572
- if (i++ >= 1e3)
2573
- throw new Error("drbg: tried 1000 values");
2574
- let len = 0;
2575
- const out = [];
2576
- while (len < qByteLen) {
2577
- v = h();
2578
- const sl = v.slice();
2579
- out.push(sl);
2580
- len += v.length;
2581
- }
2582
- return concatBytes2(...out);
2583
- };
2584
- const genUntil = (seed, pred) => {
2585
- reset();
2586
- reseed(seed);
2587
- let res = void 0;
2588
- while (!(res = pred(gen())))
2589
- reseed();
2590
- reset();
2591
- return res;
2592
- };
2593
- return genUntil;
2594
- }
2595
- var validatorFns = {
2596
- bigint: (val) => typeof val === "bigint",
2597
- function: (val) => typeof val === "function",
2598
- boolean: (val) => typeof val === "boolean",
2599
- string: (val) => typeof val === "string",
2600
- stringOrUint8Array: (val) => typeof val === "string" || val instanceof Uint8Array,
2601
- isSafeInteger: (val) => Number.isSafeInteger(val),
2602
- array: (val) => Array.isArray(val),
2603
- field: (val, object) => object.Fp.isValid(val),
2604
- hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
2605
- };
2606
- function validateObject(object, validators, optValidators = {}) {
2607
- const checkField = (fieldName, type, isOptional) => {
2608
- const checkVal = validatorFns[type];
2609
- if (typeof checkVal !== "function")
2610
- throw new Error(`Invalid validator "${type}", expected function`);
2611
- const val = object[fieldName];
2612
- if (isOptional && val === void 0)
2613
- return;
2614
- if (!checkVal(val, object)) {
2615
- throw new Error(`Invalid param ${String(fieldName)}=${val} (${typeof val}), expected ${type}`);
2616
- }
2617
- };
2618
- for (const [fieldName, type] of Object.entries(validators))
2619
- checkField(fieldName, type, false);
2620
- for (const [fieldName, type] of Object.entries(optValidators))
2621
- checkField(fieldName, type, true);
2622
- return object;
2623
- }
2624
-
2625
- // ../node_modules/@noble/curves/esm/abstract/modular.js
2626
- var _0n2 = BigInt(0);
2627
- var _1n2 = BigInt(1);
2628
- var _2n2 = BigInt(2);
2629
- var _3n = BigInt(3);
2630
- var _4n = BigInt(4);
2631
- var _5n = BigInt(5);
2632
- var _8n = BigInt(8);
2633
- var _9n = BigInt(9);
2634
- var _16n = BigInt(16);
2635
- function mod(a, b) {
2636
- const result = a % b;
2637
- return result >= _0n2 ? result : b + result;
2638
- }
2639
- function pow(num11, power, modulo) {
2640
- if (modulo <= _0n2 || power < _0n2)
2641
- throw new Error("Expected power/modulo > 0");
2642
- if (modulo === _1n2)
2643
- return _0n2;
2644
- let res = _1n2;
2645
- while (power > _0n2) {
2646
- if (power & _1n2)
2647
- res = res * num11 % modulo;
2648
- num11 = num11 * num11 % modulo;
2649
- power >>= _1n2;
2650
- }
2651
- return res;
2652
- }
2653
- function invert(number2, modulo) {
2654
- if (number2 === _0n2 || modulo <= _0n2) {
2655
- throw new Error(`invert: expected positive integers, got n=${number2} mod=${modulo}`);
2656
- }
2657
- let a = mod(number2, modulo);
2658
- let b = modulo;
2659
- let x = _0n2, y = _1n2, u = _1n2, v = _0n2;
2660
- while (a !== _0n2) {
2661
- const q = b / a;
2662
- const r = b % a;
2663
- const m = x - u * q;
2664
- const n = y - v * q;
2665
- b = a, a = r, x = u, y = v, u = m, v = n;
2666
- }
2667
- const gcd = b;
2668
- if (gcd !== _1n2)
2669
- throw new Error("invert: does not exist");
2670
- return mod(x, modulo);
2671
- }
2672
- function tonelliShanks(P) {
2673
- const legendreC = (P - _1n2) / _2n2;
2674
- let Q, S, Z;
2675
- for (Q = P - _1n2, S = 0; Q % _2n2 === _0n2; Q /= _2n2, S++)
2676
- ;
2677
- for (Z = _2n2; Z < P && pow(Z, legendreC, P) !== P - _1n2; Z++)
2678
- ;
2679
- if (S === 1) {
2680
- const p1div4 = (P + _1n2) / _4n;
2681
- return function tonelliFast(Fp, n) {
2682
- const root = Fp.pow(n, p1div4);
2683
- if (!Fp.eql(Fp.sqr(root), n))
2684
- throw new Error("Cannot find square root");
2685
- return root;
2686
- };
2687
- }
2688
- const Q1div2 = (Q + _1n2) / _2n2;
2689
- return function tonelliSlow(Fp, n) {
2690
- if (Fp.pow(n, legendreC) === Fp.neg(Fp.ONE))
2691
- throw new Error("Cannot find square root");
2692
- let r = S;
2693
- let g = Fp.pow(Fp.mul(Fp.ONE, Z), Q);
2694
- let x = Fp.pow(n, Q1div2);
2695
- let b = Fp.pow(n, Q);
2696
- while (!Fp.eql(b, Fp.ONE)) {
2697
- if (Fp.eql(b, Fp.ZERO))
2698
- return Fp.ZERO;
2699
- let m = 1;
2700
- for (let t2 = Fp.sqr(b); m < r; m++) {
2701
- if (Fp.eql(t2, Fp.ONE))
2702
- break;
2703
- t2 = Fp.sqr(t2);
2704
- }
2705
- const ge = Fp.pow(g, _1n2 << BigInt(r - m - 1));
2706
- g = Fp.sqr(ge);
2707
- x = Fp.mul(x, ge);
2708
- b = Fp.mul(b, g);
2709
- r = m;
2710
- }
2711
- return x;
2712
- };
2713
- }
2714
- function FpSqrt(P) {
2715
- if (P % _4n === _3n) {
2716
- const p1div4 = (P + _1n2) / _4n;
2717
- return function sqrt3mod4(Fp, n) {
2718
- const root = Fp.pow(n, p1div4);
2719
- if (!Fp.eql(Fp.sqr(root), n))
2720
- throw new Error("Cannot find square root");
2721
- return root;
2722
- };
2723
- }
2724
- if (P % _8n === _5n) {
2725
- const c1 = (P - _5n) / _8n;
2726
- return function sqrt5mod8(Fp, n) {
2727
- const n2 = Fp.mul(n, _2n2);
2728
- const v = Fp.pow(n2, c1);
2729
- const nv = Fp.mul(n, v);
2730
- const i = Fp.mul(Fp.mul(nv, _2n2), v);
2731
- const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
2732
- if (!Fp.eql(Fp.sqr(root), n))
2733
- throw new Error("Cannot find square root");
2734
- return root;
2735
- };
2736
- }
2737
- if (P % _16n === _9n) {
2738
- }
2739
- return tonelliShanks(P);
2740
- }
2741
- var FIELD_FIELDS = [
2742
- "create",
2743
- "isValid",
2744
- "is0",
2745
- "neg",
2746
- "inv",
2747
- "sqrt",
2748
- "sqr",
2749
- "eql",
2750
- "add",
2751
- "sub",
2752
- "mul",
2753
- "pow",
2754
- "div",
2755
- "addN",
2756
- "subN",
2757
- "mulN",
2758
- "sqrN"
2759
- ];
2760
- function validateField(field) {
2761
- const initial = {
2762
- ORDER: "bigint",
2763
- MASK: "bigint",
2764
- BYTES: "isSafeInteger",
2765
- BITS: "isSafeInteger"
2766
- };
2767
- const opts = FIELD_FIELDS.reduce((map, val) => {
2768
- map[val] = "function";
2769
- return map;
2770
- }, initial);
2771
- return validateObject(field, opts);
2772
- }
2773
- function FpPow(f, num11, power) {
2774
- if (power < _0n2)
2775
- throw new Error("Expected power > 0");
2776
- if (power === _0n2)
2777
- return f.ONE;
2778
- if (power === _1n2)
2779
- return num11;
2780
- let p = f.ONE;
2781
- let d = num11;
2782
- while (power > _0n2) {
2783
- if (power & _1n2)
2784
- p = f.mul(p, d);
2785
- d = f.sqr(d);
2786
- power >>= _1n2;
2787
- }
2788
- return p;
2789
- }
2790
- function FpInvertBatch(f, nums) {
2791
- const tmp = new Array(nums.length);
2792
- const lastMultiplied = nums.reduce((acc, num11, i) => {
2793
- if (f.is0(num11))
2794
- return acc;
2795
- tmp[i] = acc;
2796
- return f.mul(acc, num11);
2797
- }, f.ONE);
2798
- const inverted = f.inv(lastMultiplied);
2799
- nums.reduceRight((acc, num11, i) => {
2800
- if (f.is0(num11))
2801
- return acc;
2802
- tmp[i] = f.mul(acc, tmp[i]);
2803
- return f.mul(acc, num11);
2804
- }, inverted);
2805
- return tmp;
2806
- }
2807
- function nLength(n, nBitLength2) {
2808
- const _nBitLength = nBitLength2 !== void 0 ? nBitLength2 : n.toString(2).length;
2809
- const nByteLength = Math.ceil(_nBitLength / 8);
2810
- return { nBitLength: _nBitLength, nByteLength };
2811
- }
2812
- function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
2813
- if (ORDER <= _0n2)
2814
- throw new Error(`Expected Field ORDER > 0, got ${ORDER}`);
2815
- const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
2816
- if (BYTES > 2048)
2817
- throw new Error("Field lengths over 2048 bytes are not supported");
2818
- const sqrtP = FpSqrt(ORDER);
2819
- const f = Object.freeze({
2820
- ORDER,
2821
- BITS,
2822
- BYTES,
2823
- MASK: bitMask(BITS),
2824
- ZERO: _0n2,
2825
- ONE: _1n2,
2826
- create: (num11) => mod(num11, ORDER),
2827
- isValid: (num11) => {
2828
- if (typeof num11 !== "bigint")
2829
- throw new Error(`Invalid field element: expected bigint, got ${typeof num11}`);
2830
- return _0n2 <= num11 && num11 < ORDER;
2831
- },
2832
- is0: (num11) => num11 === _0n2,
2833
- isOdd: (num11) => (num11 & _1n2) === _1n2,
2834
- neg: (num11) => mod(-num11, ORDER),
2835
- eql: (lhs, rhs) => lhs === rhs,
2836
- sqr: (num11) => mod(num11 * num11, ORDER),
2837
- add: (lhs, rhs) => mod(lhs + rhs, ORDER),
2838
- sub: (lhs, rhs) => mod(lhs - rhs, ORDER),
2839
- mul: (lhs, rhs) => mod(lhs * rhs, ORDER),
2840
- pow: (num11, power) => FpPow(f, num11, power),
2841
- div: (lhs, rhs) => mod(lhs * invert(rhs, ORDER), ORDER),
2842
- // Same as above, but doesn't normalize
2843
- sqrN: (num11) => num11 * num11,
2844
- addN: (lhs, rhs) => lhs + rhs,
2845
- subN: (lhs, rhs) => lhs - rhs,
2846
- mulN: (lhs, rhs) => lhs * rhs,
2847
- inv: (num11) => invert(num11, ORDER),
2848
- sqrt: redef.sqrt || ((n) => sqrtP(f, n)),
2849
- invertBatch: (lst) => FpInvertBatch(f, lst),
2850
- // TODO: do we really need constant cmov?
2851
- // We don't have const-time bigints anyway, so probably will be not very useful
2852
- cmov: (a, b, c) => c ? b : a,
2853
- toBytes: (num11) => isLE2 ? numberToBytesLE(num11, BYTES) : numberToBytesBE(num11, BYTES),
2854
- fromBytes: (bytes2) => {
2855
- if (bytes2.length !== BYTES)
2856
- throw new Error(`Fp.fromBytes: expected ${BYTES}, got ${bytes2.length}`);
2857
- return isLE2 ? bytesToNumberLE(bytes2) : bytesToNumberBE(bytes2);
2858
- }
2859
- });
2860
- return Object.freeze(f);
2861
- }
2862
- function getFieldBytesLength(fieldOrder) {
2863
- if (typeof fieldOrder !== "bigint")
2864
- throw new Error("field order must be bigint");
2865
- const bitLength = fieldOrder.toString(2).length;
2866
- return Math.ceil(bitLength / 8);
2867
- }
2868
- function getMinHashLength(fieldOrder) {
2869
- const length = getFieldBytesLength(fieldOrder);
2870
- return length + Math.ceil(length / 2);
2871
- }
2872
- function mapHashToField(key, fieldOrder, isLE2 = false) {
2873
- const len = key.length;
2874
- const fieldLen = getFieldBytesLength(fieldOrder);
2875
- const minLen = getMinHashLength(fieldOrder);
2876
- if (len < 16 || len < minLen || len > 1024)
2877
- throw new Error(`expected ${minLen}-1024 bytes of input, got ${len}`);
2878
- const num11 = isLE2 ? bytesToNumberBE(key) : bytesToNumberLE(key);
2879
- const reduced = mod(num11, fieldOrder - _1n2) + _1n2;
2880
- return isLE2 ? numberToBytesLE(reduced, fieldLen) : numberToBytesBE(reduced, fieldLen);
2881
- }
2882
-
2883
- // ../node_modules/@noble/curves/esm/abstract/poseidon.js
2884
- function validateOpts(opts) {
2885
- const { Fp, mds, reversePartialPowIdx: rev, roundConstants: rc } = opts;
2886
- const { roundsFull, roundsPartial, sboxPower, t } = opts;
2887
- validateField(Fp);
2888
- for (const i of ["t", "roundsFull", "roundsPartial"]) {
2889
- if (typeof opts[i] !== "number" || !Number.isSafeInteger(opts[i]))
2890
- throw new Error(`Poseidon: invalid param ${i}=${opts[i]} (${typeof opts[i]})`);
2891
- }
2892
- if (!Array.isArray(mds) || mds.length !== t)
2893
- throw new Error("Poseidon: wrong MDS matrix");
2894
- const _mds = mds.map((mdsRow) => {
2895
- if (!Array.isArray(mdsRow) || mdsRow.length !== t)
2896
- throw new Error(`Poseidon MDS matrix row: ${mdsRow}`);
2897
- return mdsRow.map((i) => {
2898
- if (typeof i !== "bigint")
2899
- throw new Error(`Poseidon MDS matrix value=${i}`);
2900
- return Fp.create(i);
2901
- });
2902
- });
2903
- if (rev !== void 0 && typeof rev !== "boolean")
2904
- throw new Error(`Poseidon: invalid param reversePartialPowIdx=${rev}`);
2905
- if (roundsFull % 2 !== 0)
2906
- throw new Error(`Poseidon roundsFull is not even: ${roundsFull}`);
2907
- const rounds = roundsFull + roundsPartial;
2908
- if (!Array.isArray(rc) || rc.length !== rounds)
2909
- throw new Error("Poseidon: wrong round constants");
2910
- const roundConstants = rc.map((rc2) => {
2911
- if (!Array.isArray(rc2) || rc2.length !== t)
2912
- throw new Error(`Poseidon wrong round constants: ${rc2}`);
2913
- return rc2.map((i) => {
2914
- if (typeof i !== "bigint" || !Fp.isValid(i))
2915
- throw new Error(`Poseidon wrong round constant=${i}`);
2916
- return Fp.create(i);
2917
- });
2918
- });
2919
- if (!sboxPower || ![3, 5, 7].includes(sboxPower))
2920
- throw new Error(`Poseidon wrong sboxPower=${sboxPower}`);
2921
- const _sboxPower = BigInt(sboxPower);
2922
- let sboxFn = (n) => FpPow(Fp, n, _sboxPower);
2923
- if (sboxPower === 3)
2924
- sboxFn = (n) => Fp.mul(Fp.sqrN(n), n);
2925
- else if (sboxPower === 5)
2926
- sboxFn = (n) => Fp.mul(Fp.sqrN(Fp.sqrN(n)), n);
2927
- return Object.freeze({ ...opts, rounds, sboxFn, roundConstants, mds: _mds });
2928
- }
2929
- function poseidon(opts) {
2930
- const _opts = validateOpts(opts);
2931
- const { Fp, mds, roundConstants, rounds, roundsPartial, sboxFn, t } = _opts;
2932
- const halfRoundsFull = _opts.roundsFull / 2;
2933
- const partialIdx = _opts.reversePartialPowIdx ? t - 1 : 0;
2934
- const poseidonRound = (values, isFull, idx) => {
2935
- values = values.map((i, j) => Fp.add(i, roundConstants[idx][j]));
2936
- if (isFull)
2937
- values = values.map((i) => sboxFn(i));
2938
- else
2939
- values[partialIdx] = sboxFn(values[partialIdx]);
2940
- values = mds.map((i) => i.reduce((acc, i2, j) => Fp.add(acc, Fp.mulN(i2, values[j])), Fp.ZERO));
2941
- return values;
2942
- };
2943
- const poseidonHash = function poseidonHash2(values) {
2944
- if (!Array.isArray(values) || values.length !== t)
2945
- throw new Error(`Poseidon: wrong values (expected array of bigints with length ${t})`);
2946
- values = values.map((i) => {
2947
- if (typeof i !== "bigint")
2948
- throw new Error(`Poseidon: wrong value=${i} (${typeof i})`);
2949
- return Fp.create(i);
2950
- });
2951
- let round = 0;
2952
- for (let i = 0; i < halfRoundsFull; i++)
2953
- values = poseidonRound(values, true, round++);
2954
- for (let i = 0; i < roundsPartial; i++)
2955
- values = poseidonRound(values, false, round++);
2956
- for (let i = 0; i < halfRoundsFull; i++)
2957
- values = poseidonRound(values, true, round++);
2958
- if (round !== rounds)
2959
- throw new Error(`Poseidon: wrong number of rounds: last round=${round}, total=${rounds}`);
2960
- return values;
2961
- };
2962
- poseidonHash.roundConstants = roundConstants;
2963
- return poseidonHash;
2964
- }
2965
-
2966
- // ../node_modules/@noble/curves/esm/abstract/curve.js
2967
- var _0n3 = BigInt(0);
2968
- var _1n3 = BigInt(1);
2969
- function wNAF(c, bits) {
2970
- const constTimeNegate = (condition, item) => {
2971
- const neg = item.negate();
2972
- return condition ? neg : item;
2973
- };
2974
- const opts = (W) => {
2975
- const windows = Math.ceil(bits / W) + 1;
2976
- const windowSize = 2 ** (W - 1);
2977
- return { windows, windowSize };
2978
- };
2979
- return {
2980
- constTimeNegate,
2981
- // non-const time multiplication ladder
2982
- unsafeLadder(elm, n) {
2983
- let p = c.ZERO;
2984
- let d = elm;
2985
- while (n > _0n3) {
2986
- if (n & _1n3)
2987
- p = p.add(d);
2988
- d = d.double();
2989
- n >>= _1n3;
2990
- }
2991
- return p;
2992
- },
2993
- /**
2994
- * Creates a wNAF precomputation window. Used for caching.
2995
- * Default window size is set by `utils.precompute()` and is equal to 8.
2996
- * Number of precomputed points depends on the curve size:
2997
- * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
2998
- * - 𝑊 is the window size
2999
- * - 𝑛 is the bitlength of the curve order.
3000
- * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
3001
- * @returns precomputed point tables flattened to a single array
3002
- */
3003
- precomputeWindow(elm, W) {
3004
- const { windows, windowSize } = opts(W);
3005
- const points = [];
3006
- let p = elm;
3007
- let base = p;
3008
- for (let window = 0; window < windows; window++) {
3009
- base = p;
3010
- points.push(base);
3011
- for (let i = 1; i < windowSize; i++) {
3012
- base = base.add(p);
3013
- points.push(base);
3014
- }
3015
- p = base.double();
3016
- }
3017
- return points;
3018
- },
3019
- /**
3020
- * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
3021
- * @param W window size
3022
- * @param precomputes precomputed tables
3023
- * @param n scalar (we don't check here, but should be less than curve order)
3024
- * @returns real and fake (for const-time) points
3025
- */
3026
- wNAF(W, precomputes, n) {
3027
- const { windows, windowSize } = opts(W);
3028
- let p = c.ZERO;
3029
- let f = c.BASE;
3030
- const mask = BigInt(2 ** W - 1);
3031
- const maxNumber = 2 ** W;
3032
- const shiftBy = BigInt(W);
3033
- for (let window = 0; window < windows; window++) {
3034
- const offset = window * windowSize;
3035
- let wbits = Number(n & mask);
3036
- n >>= shiftBy;
3037
- if (wbits > windowSize) {
3038
- wbits -= maxNumber;
3039
- n += _1n3;
3040
- }
3041
- const offset1 = offset;
3042
- const offset2 = offset + Math.abs(wbits) - 1;
3043
- const cond1 = window % 2 !== 0;
3044
- const cond2 = wbits < 0;
3045
- if (wbits === 0) {
3046
- f = f.add(constTimeNegate(cond1, precomputes[offset1]));
3047
- } else {
3048
- p = p.add(constTimeNegate(cond2, precomputes[offset2]));
3049
- }
3050
- }
3051
- return { p, f };
3052
- },
3053
- wNAFCached(P, precomputesMap, n, transform) {
3054
- const W = P._WINDOW_SIZE || 1;
3055
- let comp = precomputesMap.get(P);
3056
- if (!comp) {
3057
- comp = this.precomputeWindow(P, W);
3058
- if (W !== 1) {
3059
- precomputesMap.set(P, transform(comp));
3060
- }
3061
- }
3062
- return this.wNAF(W, comp, n);
3063
- }
3064
- };
3065
- }
3066
- function validateBasic(curve2) {
3067
- validateField(curve2.Fp);
3068
- validateObject(curve2, {
3069
- n: "bigint",
3070
- h: "bigint",
3071
- Gx: "field",
3072
- Gy: "field"
3073
- }, {
3074
- nBitLength: "isSafeInteger",
3075
- nByteLength: "isSafeInteger"
3076
- });
3077
- return Object.freeze({
3078
- ...nLength(curve2.n, curve2.nBitLength),
3079
- ...curve2,
3080
- ...{ p: curve2.Fp.ORDER }
3081
- });
3082
- }
3083
-
3084
- // ../node_modules/@noble/curves/esm/abstract/weierstrass.js
3085
- function validatePointOpts(curve2) {
3086
- const opts = validateBasic(curve2);
3087
- validateObject(opts, {
3088
- a: "field",
3089
- b: "field"
3090
- }, {
3091
- allowedPrivateKeyLengths: "array",
3092
- wrapPrivateKey: "boolean",
3093
- isTorsionFree: "function",
3094
- clearCofactor: "function",
3095
- allowInfinityPoint: "boolean",
3096
- fromBytes: "function",
3097
- toBytes: "function"
3098
- });
3099
- const { endo, Fp, a } = opts;
3100
- if (endo) {
3101
- if (!Fp.eql(a, Fp.ZERO)) {
3102
- throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");
3103
- }
3104
- if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
3105
- throw new Error("Expected endomorphism with beta: bigint and splitScalar: function");
3106
- }
3107
- }
3108
- return Object.freeze({ ...opts });
3109
- }
3110
- var { bytesToNumberBE: b2n, hexToBytes: h2b } = utils_exports;
3111
- var DER = {
3112
- // asn.1 DER encoding utils
3113
- Err: class DERErr extends Error {
3114
- constructor(m = "") {
3115
- super(m);
3116
- }
3117
- },
3118
- _parseInt(data) {
3119
- const { Err: E } = DER;
3120
- if (data.length < 2 || data[0] !== 2)
3121
- throw new E("Invalid signature integer tag");
3122
- const len = data[1];
3123
- const res = data.subarray(2, len + 2);
3124
- if (!len || res.length !== len)
3125
- throw new E("Invalid signature integer: wrong length");
3126
- if (res[0] & 128)
3127
- throw new E("Invalid signature integer: negative");
3128
- if (res[0] === 0 && !(res[1] & 128))
3129
- throw new E("Invalid signature integer: unnecessary leading zero");
3130
- return { d: b2n(res), l: data.subarray(len + 2) };
3131
- },
3132
- toSig(hex) {
3133
- const { Err: E } = DER;
3134
- const data = typeof hex === "string" ? h2b(hex) : hex;
3135
- if (!(data instanceof Uint8Array))
3136
- throw new Error("ui8a expected");
3137
- let l = data.length;
3138
- if (l < 2 || data[0] != 48)
3139
- throw new E("Invalid signature tag");
3140
- if (data[1] !== l - 2)
3141
- throw new E("Invalid signature: incorrect length");
3142
- const { d: r, l: sBytes } = DER._parseInt(data.subarray(2));
3143
- const { d: s, l: rBytesLeft } = DER._parseInt(sBytes);
3144
- if (rBytesLeft.length)
3145
- throw new E("Invalid signature: left bytes after parsing");
3146
- return { r, s };
3147
- },
3148
- hexFromSig(sig) {
3149
- const slice = (s2) => Number.parseInt(s2[0], 16) & 8 ? "00" + s2 : s2;
3150
- const h = (num11) => {
3151
- const hex = num11.toString(16);
3152
- return hex.length & 1 ? `0${hex}` : hex;
3153
- };
3154
- const s = slice(h(sig.s));
3155
- const r = slice(h(sig.r));
3156
- const shl = s.length / 2;
3157
- const rhl = r.length / 2;
3158
- const sl = h(shl);
3159
- const rl = h(rhl);
3160
- return `30${h(rhl + shl + 4)}02${rl}${r}02${sl}${s}`;
3161
- }
3162
- };
3163
- var _0n4 = BigInt(0);
3164
- var _1n4 = BigInt(1);
3165
- var _2n3 = BigInt(2);
3166
- var _3n2 = BigInt(3);
3167
- var _4n2 = BigInt(4);
3168
- function weierstrassPoints(opts) {
3169
- const CURVE2 = validatePointOpts(opts);
3170
- const { Fp } = CURVE2;
3171
- const toBytes2 = CURVE2.toBytes || ((_c, point, _isCompressed) => {
3172
- const a = point.toAffine();
3173
- return concatBytes2(Uint8Array.from([4]), Fp.toBytes(a.x), Fp.toBytes(a.y));
3174
- });
3175
- const fromBytes = CURVE2.fromBytes || ((bytes2) => {
3176
- const tail = bytes2.subarray(1);
3177
- const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
3178
- const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
3179
- return { x, y };
3180
- });
3181
- function weierstrassEquation(x) {
3182
- const { a, b } = CURVE2;
3183
- const x2 = Fp.sqr(x);
3184
- const x3 = Fp.mul(x2, x);
3185
- return Fp.add(Fp.add(x3, Fp.mul(x, a)), b);
3186
- }
3187
- if (!Fp.eql(Fp.sqr(CURVE2.Gy), weierstrassEquation(CURVE2.Gx)))
3188
- throw new Error("bad generator point: equation left != right");
3189
- function isWithinCurveOrder(num11) {
3190
- return typeof num11 === "bigint" && _0n4 < num11 && num11 < CURVE2.n;
3191
- }
3192
- function assertGE(num11) {
3193
- if (!isWithinCurveOrder(num11))
3194
- throw new Error("Expected valid bigint: 0 < bigint < curve.n");
3195
- }
3196
- function normPrivateKeyToScalar(key) {
3197
- const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n } = CURVE2;
3198
- if (lengths && typeof key !== "bigint") {
3199
- if (key instanceof Uint8Array)
3200
- key = bytesToHex(key);
3201
- if (typeof key !== "string" || !lengths.includes(key.length))
3202
- throw new Error("Invalid key");
3203
- key = key.padStart(nByteLength * 2, "0");
3204
- }
3205
- let num11;
3206
- try {
3207
- num11 = typeof key === "bigint" ? key : bytesToNumberBE(ensureBytes("private key", key, nByteLength));
3208
- } catch (error) {
3209
- throw new Error(`private key must be ${nByteLength} bytes, hex or bigint, not ${typeof key}`);
3210
- }
3211
- if (wrapPrivateKey)
3212
- num11 = mod(num11, n);
3213
- assertGE(num11);
3214
- return num11;
3215
- }
3216
- const pointPrecomputes = /* @__PURE__ */ new Map();
3217
- function assertPrjPoint(other) {
3218
- if (!(other instanceof Point))
3219
- throw new Error("ProjectivePoint expected");
3220
- }
3221
- class Point {
3222
- constructor(px, py, pz) {
3223
- this.px = px;
3224
- this.py = py;
3225
- this.pz = pz;
3226
- if (px == null || !Fp.isValid(px))
3227
- throw new Error("x required");
3228
- if (py == null || !Fp.isValid(py))
3229
- throw new Error("y required");
3230
- if (pz == null || !Fp.isValid(pz))
3231
- throw new Error("z required");
3232
- }
3233
- // Does not validate if the point is on-curve.
3234
- // Use fromHex instead, or call assertValidity() later.
3235
- static fromAffine(p) {
3236
- const { x, y } = p || {};
3237
- if (!p || !Fp.isValid(x) || !Fp.isValid(y))
3238
- throw new Error("invalid affine point");
3239
- if (p instanceof Point)
3240
- throw new Error("projective point not allowed");
3241
- const is0 = (i) => Fp.eql(i, Fp.ZERO);
3242
- if (is0(x) && is0(y))
3243
- return Point.ZERO;
3244
- return new Point(x, y, Fp.ONE);
3245
- }
3246
- get x() {
3247
- return this.toAffine().x;
3248
- }
3249
- get y() {
3250
- return this.toAffine().y;
3251
- }
3252
- /**
3253
- * Takes a bunch of Projective Points but executes only one
3254
- * inversion on all of them. Inversion is very slow operation,
3255
- * so this improves performance massively.
3256
- * Optimization: converts a list of projective points to a list of identical points with Z=1.
3257
- */
3258
- static normalizeZ(points) {
3259
- const toInv = Fp.invertBatch(points.map((p) => p.pz));
3260
- return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);
3261
- }
3262
- /**
3263
- * Converts hash string or Uint8Array to Point.
3264
- * @param hex short/long ECDSA hex
3265
- */
3266
- static fromHex(hex) {
3267
- const P = Point.fromAffine(fromBytes(ensureBytes("pointHex", hex)));
3268
- P.assertValidity();
3269
- return P;
3270
- }
3271
- // Multiplies generator point by privateKey.
3272
- static fromPrivateKey(privateKey) {
3273
- return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));
3274
- }
3275
- // "Private method", don't use it directly
3276
- _setWindowSize(windowSize) {
3277
- this._WINDOW_SIZE = windowSize;
3278
- pointPrecomputes.delete(this);
3279
- }
3280
- // A point on curve is valid if it conforms to equation.
3281
- assertValidity() {
3282
- if (this.is0()) {
3283
- if (CURVE2.allowInfinityPoint && !Fp.is0(this.py))
3284
- return;
3285
- throw new Error("bad point: ZERO");
3286
- }
3287
- const { x, y } = this.toAffine();
3288
- if (!Fp.isValid(x) || !Fp.isValid(y))
3289
- throw new Error("bad point: x or y not FE");
3290
- const left = Fp.sqr(y);
3291
- const right = weierstrassEquation(x);
3292
- if (!Fp.eql(left, right))
3293
- throw new Error("bad point: equation left != right");
3294
- if (!this.isTorsionFree())
3295
- throw new Error("bad point: not in prime-order subgroup");
3296
- }
3297
- hasEvenY() {
3298
- const { y } = this.toAffine();
3299
- if (Fp.isOdd)
3300
- return !Fp.isOdd(y);
3301
- throw new Error("Field doesn't support isOdd");
3302
- }
3303
- /**
3304
- * Compare one point to another.
3305
- */
3306
- equals(other) {
3307
- assertPrjPoint(other);
3308
- const { px: X1, py: Y1, pz: Z1 } = this;
3309
- const { px: X2, py: Y2, pz: Z2 } = other;
3310
- const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));
3311
- const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));
3312
- return U1 && U2;
3313
- }
3314
- /**
3315
- * Flips point to one corresponding to (x, -y) in Affine coordinates.
3316
- */
3317
- negate() {
3318
- return new Point(this.px, Fp.neg(this.py), this.pz);
3319
- }
3320
- // Renes-Costello-Batina exception-free doubling formula.
3321
- // There is 30% faster Jacobian formula, but it is not complete.
3322
- // https://eprint.iacr.org/2015/1060, algorithm 3
3323
- // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
3324
- double() {
3325
- const { a, b } = CURVE2;
3326
- const b3 = Fp.mul(b, _3n2);
3327
- const { px: X1, py: Y1, pz: Z1 } = this;
3328
- let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
3329
- let t0 = Fp.mul(X1, X1);
3330
- let t1 = Fp.mul(Y1, Y1);
3331
- let t2 = Fp.mul(Z1, Z1);
3332
- let t3 = Fp.mul(X1, Y1);
3333
- t3 = Fp.add(t3, t3);
3334
- Z3 = Fp.mul(X1, Z1);
3335
- Z3 = Fp.add(Z3, Z3);
3336
- X3 = Fp.mul(a, Z3);
3337
- Y3 = Fp.mul(b3, t2);
3338
- Y3 = Fp.add(X3, Y3);
3339
- X3 = Fp.sub(t1, Y3);
3340
- Y3 = Fp.add(t1, Y3);
3341
- Y3 = Fp.mul(X3, Y3);
3342
- X3 = Fp.mul(t3, X3);
3343
- Z3 = Fp.mul(b3, Z3);
3344
- t2 = Fp.mul(a, t2);
3345
- t3 = Fp.sub(t0, t2);
3346
- t3 = Fp.mul(a, t3);
3347
- t3 = Fp.add(t3, Z3);
3348
- Z3 = Fp.add(t0, t0);
3349
- t0 = Fp.add(Z3, t0);
3350
- t0 = Fp.add(t0, t2);
3351
- t0 = Fp.mul(t0, t3);
3352
- Y3 = Fp.add(Y3, t0);
3353
- t2 = Fp.mul(Y1, Z1);
3354
- t2 = Fp.add(t2, t2);
3355
- t0 = Fp.mul(t2, t3);
3356
- X3 = Fp.sub(X3, t0);
3357
- Z3 = Fp.mul(t2, t1);
3358
- Z3 = Fp.add(Z3, Z3);
3359
- Z3 = Fp.add(Z3, Z3);
3360
- return new Point(X3, Y3, Z3);
3361
- }
3362
- // Renes-Costello-Batina exception-free addition formula.
3363
- // There is 30% faster Jacobian formula, but it is not complete.
3364
- // https://eprint.iacr.org/2015/1060, algorithm 1
3365
- // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
3366
- add(other) {
3367
- assertPrjPoint(other);
3368
- const { px: X1, py: Y1, pz: Z1 } = this;
3369
- const { px: X2, py: Y2, pz: Z2 } = other;
3370
- let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
3371
- const a = CURVE2.a;
3372
- const b3 = Fp.mul(CURVE2.b, _3n2);
3373
- let t0 = Fp.mul(X1, X2);
3374
- let t1 = Fp.mul(Y1, Y2);
3375
- let t2 = Fp.mul(Z1, Z2);
3376
- let t3 = Fp.add(X1, Y1);
3377
- let t4 = Fp.add(X2, Y2);
3378
- t3 = Fp.mul(t3, t4);
3379
- t4 = Fp.add(t0, t1);
3380
- t3 = Fp.sub(t3, t4);
3381
- t4 = Fp.add(X1, Z1);
3382
- let t5 = Fp.add(X2, Z2);
3383
- t4 = Fp.mul(t4, t5);
3384
- t5 = Fp.add(t0, t2);
3385
- t4 = Fp.sub(t4, t5);
3386
- t5 = Fp.add(Y1, Z1);
3387
- X3 = Fp.add(Y2, Z2);
3388
- t5 = Fp.mul(t5, X3);
3389
- X3 = Fp.add(t1, t2);
3390
- t5 = Fp.sub(t5, X3);
3391
- Z3 = Fp.mul(a, t4);
3392
- X3 = Fp.mul(b3, t2);
3393
- Z3 = Fp.add(X3, Z3);
3394
- X3 = Fp.sub(t1, Z3);
3395
- Z3 = Fp.add(t1, Z3);
3396
- Y3 = Fp.mul(X3, Z3);
3397
- t1 = Fp.add(t0, t0);
3398
- t1 = Fp.add(t1, t0);
3399
- t2 = Fp.mul(a, t2);
3400
- t4 = Fp.mul(b3, t4);
3401
- t1 = Fp.add(t1, t2);
3402
- t2 = Fp.sub(t0, t2);
3403
- t2 = Fp.mul(a, t2);
3404
- t4 = Fp.add(t4, t2);
3405
- t0 = Fp.mul(t1, t4);
3406
- Y3 = Fp.add(Y3, t0);
3407
- t0 = Fp.mul(t5, t4);
3408
- X3 = Fp.mul(t3, X3);
3409
- X3 = Fp.sub(X3, t0);
3410
- t0 = Fp.mul(t3, t1);
3411
- Z3 = Fp.mul(t5, Z3);
3412
- Z3 = Fp.add(Z3, t0);
3413
- return new Point(X3, Y3, Z3);
3414
- }
3415
- subtract(other) {
3416
- return this.add(other.negate());
3417
- }
3418
- is0() {
3419
- return this.equals(Point.ZERO);
3420
- }
3421
- wNAF(n) {
3422
- return wnaf.wNAFCached(this, pointPrecomputes, n, (comp) => {
3423
- const toInv = Fp.invertBatch(comp.map((p) => p.pz));
3424
- return comp.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);
3425
- });
3426
- }
3427
- /**
3428
- * Non-constant-time multiplication. Uses double-and-add algorithm.
3429
- * It's faster, but should only be used when you don't care about
3430
- * an exposed private key e.g. sig verification, which works over *public* keys.
3431
- */
3432
- multiplyUnsafe(n) {
3433
- const I = Point.ZERO;
3434
- if (n === _0n4)
3435
- return I;
3436
- assertGE(n);
3437
- if (n === _1n4)
3438
- return this;
3439
- const { endo } = CURVE2;
3440
- if (!endo)
3441
- return wnaf.unsafeLadder(this, n);
3442
- let { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);
3443
- let k1p = I;
3444
- let k2p = I;
3445
- let d = this;
3446
- while (k1 > _0n4 || k2 > _0n4) {
3447
- if (k1 & _1n4)
3448
- k1p = k1p.add(d);
3449
- if (k2 & _1n4)
3450
- k2p = k2p.add(d);
3451
- d = d.double();
3452
- k1 >>= _1n4;
3453
- k2 >>= _1n4;
3454
- }
3455
- if (k1neg)
3456
- k1p = k1p.negate();
3457
- if (k2neg)
3458
- k2p = k2p.negate();
3459
- k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
3460
- return k1p.add(k2p);
3461
- }
3462
- /**
3463
- * Constant time multiplication.
3464
- * Uses wNAF method. Windowed method may be 10% faster,
3465
- * but takes 2x longer to generate and consumes 2x memory.
3466
- * Uses precomputes when available.
3467
- * Uses endomorphism for Koblitz curves.
3468
- * @param scalar by which the point would be multiplied
3469
- * @returns New point
3470
- */
3471
- multiply(scalar) {
3472
- assertGE(scalar);
3473
- let n = scalar;
3474
- let point, fake;
3475
- const { endo } = CURVE2;
3476
- if (endo) {
3477
- const { k1neg, k1, k2neg, k2 } = endo.splitScalar(n);
3478
- let { p: k1p, f: f1p } = this.wNAF(k1);
3479
- let { p: k2p, f: f2p } = this.wNAF(k2);
3480
- k1p = wnaf.constTimeNegate(k1neg, k1p);
3481
- k2p = wnaf.constTimeNegate(k2neg, k2p);
3482
- k2p = new Point(Fp.mul(k2p.px, endo.beta), k2p.py, k2p.pz);
3483
- point = k1p.add(k2p);
3484
- fake = f1p.add(f2p);
3485
- } else {
3486
- const { p, f } = this.wNAF(n);
3487
- point = p;
3488
- fake = f;
3489
- }
3490
- return Point.normalizeZ([point, fake])[0];
3491
- }
3492
- /**
3493
- * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
3494
- * Not using Strauss-Shamir trick: precomputation tables are faster.
3495
- * The trick could be useful if both P and Q are not G (not in our case).
3496
- * @returns non-zero affine point
3497
- */
3498
- multiplyAndAddUnsafe(Q, a, b) {
3499
- const G = Point.BASE;
3500
- const mul = (P, a2) => a2 === _0n4 || a2 === _1n4 || !P.equals(G) ? P.multiplyUnsafe(a2) : P.multiply(a2);
3501
- const sum = mul(this, a).add(mul(Q, b));
3502
- return sum.is0() ? void 0 : sum;
3503
- }
3504
- // Converts Projective point to affine (x, y) coordinates.
3505
- // Can accept precomputed Z^-1 - for example, from invertBatch.
3506
- // (x, y, z) ∋ (x=x/z, y=y/z)
3507
- toAffine(iz) {
3508
- const { px: x, py: y, pz: z } = this;
3509
- const is0 = this.is0();
3510
- if (iz == null)
3511
- iz = is0 ? Fp.ONE : Fp.inv(z);
3512
- const ax = Fp.mul(x, iz);
3513
- const ay = Fp.mul(y, iz);
3514
- const zz = Fp.mul(z, iz);
3515
- if (is0)
3516
- return { x: Fp.ZERO, y: Fp.ZERO };
3517
- if (!Fp.eql(zz, Fp.ONE))
3518
- throw new Error("invZ was invalid");
3519
- return { x: ax, y: ay };
3520
- }
3521
- isTorsionFree() {
3522
- const { h: cofactor, isTorsionFree } = CURVE2;
3523
- if (cofactor === _1n4)
3524
- return true;
3525
- if (isTorsionFree)
3526
- return isTorsionFree(Point, this);
3527
- throw new Error("isTorsionFree() has not been declared for the elliptic curve");
3528
- }
3529
- clearCofactor() {
3530
- const { h: cofactor, clearCofactor } = CURVE2;
3531
- if (cofactor === _1n4)
3532
- return this;
3533
- if (clearCofactor)
3534
- return clearCofactor(Point, this);
3535
- return this.multiplyUnsafe(CURVE2.h);
3536
- }
3537
- toRawBytes(isCompressed = true) {
3538
- this.assertValidity();
3539
- return toBytes2(Point, this, isCompressed);
3540
- }
3541
- toHex(isCompressed = true) {
3542
- return bytesToHex(this.toRawBytes(isCompressed));
3543
- }
3544
- }
3545
- Point.BASE = new Point(CURVE2.Gx, CURVE2.Gy, Fp.ONE);
3546
- Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);
3547
- const _bits = CURVE2.nBitLength;
3548
- const wnaf = wNAF(Point, CURVE2.endo ? Math.ceil(_bits / 2) : _bits);
3549
- return {
3550
- CURVE: CURVE2,
3551
- ProjectivePoint: Point,
3552
- normPrivateKeyToScalar,
3553
- weierstrassEquation,
3554
- isWithinCurveOrder
3555
- };
3556
- }
3557
- function validateOpts2(curve2) {
3558
- const opts = validateBasic(curve2);
3559
- validateObject(opts, {
3560
- hash: "hash",
3561
- hmac: "function",
3562
- randomBytes: "function"
3563
- }, {
3564
- bits2int: "function",
3565
- bits2int_modN: "function",
3566
- lowS: "boolean"
3567
- });
3568
- return Object.freeze({ lowS: true, ...opts });
3569
- }
3570
- function weierstrass(curveDef) {
3571
- const CURVE2 = validateOpts2(curveDef);
3572
- const { Fp, n: CURVE_ORDER2 } = CURVE2;
3573
- const compressedLen = Fp.BYTES + 1;
3574
- const uncompressedLen = 2 * Fp.BYTES + 1;
3575
- function isValidFieldElement(num11) {
3576
- return _0n4 < num11 && num11 < Fp.ORDER;
3577
- }
3578
- function modN(a) {
3579
- return mod(a, CURVE_ORDER2);
3580
- }
3581
- function invN(a) {
3582
- return invert(a, CURVE_ORDER2);
3583
- }
3584
- const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
3585
- ...CURVE2,
3586
- toBytes(_c, point, isCompressed) {
3587
- const a = point.toAffine();
3588
- const x = Fp.toBytes(a.x);
3589
- const cat = concatBytes2;
3590
- if (isCompressed) {
3591
- return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
3592
- } else {
3593
- return cat(Uint8Array.from([4]), x, Fp.toBytes(a.y));
3594
- }
3595
- },
3596
- fromBytes(bytes2) {
3597
- const len = bytes2.length;
3598
- const head = bytes2[0];
3599
- const tail = bytes2.subarray(1);
3600
- if (len === compressedLen && (head === 2 || head === 3)) {
3601
- const x = bytesToNumberBE(tail);
3602
- if (!isValidFieldElement(x))
3603
- throw new Error("Point is not on curve");
3604
- const y2 = weierstrassEquation(x);
3605
- let y = Fp.sqrt(y2);
3606
- const isYOdd = (y & _1n4) === _1n4;
3607
- const isHeadOdd = (head & 1) === 1;
3608
- if (isHeadOdd !== isYOdd)
3609
- y = Fp.neg(y);
3610
- return { x, y };
3611
- } else if (len === uncompressedLen && head === 4) {
3612
- const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
3613
- const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
3614
- return { x, y };
3615
- } else {
3616
- throw new Error(`Point of length ${len} was invalid. Expected ${compressedLen} compressed bytes or ${uncompressedLen} uncompressed bytes`);
3617
- }
3618
- }
3619
- });
3620
- const numToNByteStr = (num11) => bytesToHex(numberToBytesBE(num11, CURVE2.nByteLength));
3621
- function isBiggerThanHalfOrder(number2) {
3622
- const HALF = CURVE_ORDER2 >> _1n4;
3623
- return number2 > HALF;
3624
- }
3625
- function normalizeS(s) {
3626
- return isBiggerThanHalfOrder(s) ? modN(-s) : s;
3627
- }
3628
- const slcNum = (b, from, to) => bytesToNumberBE(b.slice(from, to));
3629
- class Signature2 {
3630
- constructor(r, s, recovery) {
3631
- this.r = r;
3632
- this.s = s;
3633
- this.recovery = recovery;
3634
- this.assertValidity();
3635
- }
3636
- // pair (bytes of r, bytes of s)
3637
- static fromCompact(hex) {
3638
- const l = CURVE2.nByteLength;
3639
- hex = ensureBytes("compactSignature", hex, l * 2);
3640
- return new Signature2(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
3641
- }
3642
- // DER encoded ECDSA signature
3643
- // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
3644
- static fromDER(hex) {
3645
- const { r, s } = DER.toSig(ensureBytes("DER", hex));
3646
- return new Signature2(r, s);
3647
- }
3648
- assertValidity() {
3649
- if (!isWithinCurveOrder(this.r))
3650
- throw new Error("r must be 0 < r < CURVE.n");
3651
- if (!isWithinCurveOrder(this.s))
3652
- throw new Error("s must be 0 < s < CURVE.n");
3653
- }
3654
- addRecoveryBit(recovery) {
3655
- return new Signature2(this.r, this.s, recovery);
3656
- }
3657
- recoverPublicKey(msgHash) {
3658
- const { r, s, recovery: rec } = this;
3659
- const h = bits2int_modN(ensureBytes("msgHash", msgHash));
3660
- if (rec == null || ![0, 1, 2, 3].includes(rec))
3661
- throw new Error("recovery id invalid");
3662
- const radj = rec === 2 || rec === 3 ? r + CURVE2.n : r;
3663
- if (radj >= Fp.ORDER)
3664
- throw new Error("recovery id 2 or 3 invalid");
3665
- const prefix = (rec & 1) === 0 ? "02" : "03";
3666
- const R = Point.fromHex(prefix + numToNByteStr(radj));
3667
- const ir = invN(radj);
3668
- const u1 = modN(-h * ir);
3669
- const u2 = modN(s * ir);
3670
- const Q = Point.BASE.multiplyAndAddUnsafe(R, u1, u2);
3671
- if (!Q)
3672
- throw new Error("point at infinify");
3673
- Q.assertValidity();
3674
- return Q;
3675
- }
3676
- // Signatures should be low-s, to prevent malleability.
3677
- hasHighS() {
3678
- return isBiggerThanHalfOrder(this.s);
3679
- }
3680
- normalizeS() {
3681
- return this.hasHighS() ? new Signature2(this.r, modN(-this.s), this.recovery) : this;
3682
- }
3683
- // DER-encoded
3684
- toDERRawBytes() {
3685
- return hexToBytes(this.toDERHex());
3686
- }
3687
- toDERHex() {
3688
- return DER.hexFromSig({ r: this.r, s: this.s });
3689
- }
3690
- // padded bytes of r, then padded bytes of s
3691
- toCompactRawBytes() {
3692
- return hexToBytes(this.toCompactHex());
3693
- }
3694
- toCompactHex() {
3695
- return numToNByteStr(this.r) + numToNByteStr(this.s);
3696
- }
3697
- }
3698
- const utils2 = {
3699
- isValidPrivateKey(privateKey) {
3700
- try {
3701
- normPrivateKeyToScalar(privateKey);
3702
- return true;
3703
- } catch (error) {
3704
- return false;
3705
- }
3706
- },
3707
- normPrivateKeyToScalar,
3708
- /**
3709
- * Produces cryptographically secure private key from random of size
3710
- * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
3711
- */
3712
- randomPrivateKey: () => {
3713
- const length = getMinHashLength(CURVE2.n);
3714
- return mapHashToField(CURVE2.randomBytes(length), CURVE2.n);
3715
- },
3716
- /**
3717
- * Creates precompute table for an arbitrary EC point. Makes point "cached".
3718
- * Allows to massively speed-up `point.multiply(scalar)`.
3719
- * @returns cached point
3720
- * @example
3721
- * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
3722
- * fast.multiply(privKey); // much faster ECDH now
3723
- */
3724
- precompute(windowSize = 8, point = Point.BASE) {
3725
- point._setWindowSize(windowSize);
3726
- point.multiply(BigInt(3));
3727
- return point;
3728
- }
3729
- };
3730
- function getPublicKey(privateKey, isCompressed = true) {
3731
- return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
3732
- }
3733
- function isProbPub(item) {
3734
- const arr = item instanceof Uint8Array;
3735
- const str = typeof item === "string";
3736
- const len = (arr || str) && item.length;
3737
- if (arr)
3738
- return len === compressedLen || len === uncompressedLen;
3739
- if (str)
3740
- return len === 2 * compressedLen || len === 2 * uncompressedLen;
3741
- if (item instanceof Point)
3742
- return true;
3743
- return false;
3744
- }
3745
- function getSharedSecret(privateA, publicB, isCompressed = true) {
3746
- if (isProbPub(privateA))
3747
- throw new Error("first arg must be private key");
3748
- if (!isProbPub(publicB))
3749
- throw new Error("second arg must be public key");
3750
- const b = Point.fromHex(publicB);
3751
- return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
3752
- }
3753
- const bits2int2 = CURVE2.bits2int || function(bytes2) {
3754
- const num11 = bytesToNumberBE(bytes2);
3755
- const delta = bytes2.length * 8 - CURVE2.nBitLength;
3756
- return delta > 0 ? num11 >> BigInt(delta) : num11;
3757
- };
3758
- const bits2int_modN = CURVE2.bits2int_modN || function(bytes2) {
3759
- return modN(bits2int2(bytes2));
3760
- };
3761
- const ORDER_MASK = bitMask(CURVE2.nBitLength);
3762
- function int2octets(num11) {
3763
- if (typeof num11 !== "bigint")
3764
- throw new Error("bigint expected");
3765
- if (!(_0n4 <= num11 && num11 < ORDER_MASK))
3766
- throw new Error(`bigint expected < 2^${CURVE2.nBitLength}`);
3767
- return numberToBytesBE(num11, CURVE2.nByteLength);
3768
- }
3769
- function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
3770
- if (["recovered", "canonical"].some((k) => k in opts))
3771
- throw new Error("sign() legacy options not supported");
3772
- const { hash: hash6, randomBytes: randomBytes4 } = CURVE2;
3773
- let { lowS, prehash, extraEntropy: ent } = opts;
3774
- if (lowS == null)
3775
- lowS = true;
3776
- msgHash = ensureBytes("msgHash", msgHash);
3777
- if (prehash)
3778
- msgHash = ensureBytes("prehashed msgHash", hash6(msgHash));
3779
- const h1int = bits2int_modN(msgHash);
3780
- const d = normPrivateKeyToScalar(privateKey);
3781
- const seedArgs = [int2octets(d), int2octets(h1int)];
3782
- if (ent != null) {
3783
- const e = ent === true ? randomBytes4(Fp.BYTES) : ent;
3784
- seedArgs.push(ensureBytes("extraEntropy", e));
3785
- }
3786
- const seed = concatBytes2(...seedArgs);
3787
- const m = h1int;
3788
- function k2sig(kBytes) {
3789
- const k = bits2int2(kBytes);
3790
- if (!isWithinCurveOrder(k))
3791
- return;
3792
- const ik = invN(k);
3793
- const q = Point.BASE.multiply(k).toAffine();
3794
- const r = modN(q.x);
3795
- if (r === _0n4)
3796
- return;
3797
- const s = modN(ik * modN(m + r * d));
3798
- if (s === _0n4)
3799
- return;
3800
- let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n4);
3801
- let normS = s;
3802
- if (lowS && isBiggerThanHalfOrder(s)) {
3803
- normS = normalizeS(s);
3804
- recovery ^= 1;
3805
- }
3806
- return new Signature2(r, normS, recovery);
3807
- }
3808
- return { seed, k2sig };
3809
- }
3810
- const defaultSigOpts = { lowS: CURVE2.lowS, prehash: false };
3811
- const defaultVerOpts = { lowS: CURVE2.lowS, prehash: false };
3812
- function sign(msgHash, privKey, opts = defaultSigOpts) {
3813
- const { seed, k2sig } = prepSig(msgHash, privKey, opts);
3814
- const C = CURVE2;
3815
- const drbg = createHmacDrbg(C.hash.outputLen, C.nByteLength, C.hmac);
3816
- return drbg(seed, k2sig);
3817
- }
3818
- Point.BASE._setWindowSize(8);
3819
- function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
3820
- const sg = signature;
3821
- msgHash = ensureBytes("msgHash", msgHash);
3822
- publicKey = ensureBytes("publicKey", publicKey);
3823
- if ("strict" in opts)
3824
- throw new Error("options.strict was renamed to lowS");
3825
- const { lowS, prehash } = opts;
3826
- let _sig = void 0;
3827
- let P;
3828
- try {
3829
- if (typeof sg === "string" || sg instanceof Uint8Array) {
3830
- try {
3831
- _sig = Signature2.fromDER(sg);
3832
- } catch (derError) {
3833
- if (!(derError instanceof DER.Err))
3834
- throw derError;
3835
- _sig = Signature2.fromCompact(sg);
3836
- }
3837
- } else if (typeof sg === "object" && typeof sg.r === "bigint" && typeof sg.s === "bigint") {
3838
- const { r: r2, s: s2 } = sg;
3839
- _sig = new Signature2(r2, s2);
3840
- } else {
3841
- throw new Error("PARSE");
3842
- }
3843
- P = Point.fromHex(publicKey);
3844
- } catch (error) {
3845
- if (error.message === "PARSE")
3846
- throw new Error(`signature must be Signature instance, Uint8Array or hex string`);
3847
- return false;
3848
- }
3849
- if (lowS && _sig.hasHighS())
3850
- return false;
3851
- if (prehash)
3852
- msgHash = CURVE2.hash(msgHash);
3853
- const { r, s } = _sig;
3854
- const h = bits2int_modN(msgHash);
3855
- const is = invN(s);
3856
- const u1 = modN(h * is);
3857
- const u2 = modN(r * is);
3858
- const R = Point.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine();
3859
- if (!R)
3860
- return false;
3861
- const v = modN(R.x);
3862
- return v === r;
3863
- }
3864
- return {
3865
- CURVE: CURVE2,
3866
- getPublicKey,
3867
- getSharedSecret,
3868
- sign,
3869
- verify,
3870
- ProjectivePoint: Point,
3871
- Signature: Signature2,
3872
- utils: utils2
3873
- };
3874
- }
3875
-
3876
- // ../node_modules/@noble/hashes/esm/hmac.js
3877
- var HMAC = class extends Hash {
3878
- constructor(hash6, _key) {
3879
- super();
3880
- this.finished = false;
3881
- this.destroyed = false;
3882
- hash(hash6);
3883
- const key = toBytes(_key);
3884
- this.iHash = hash6.create();
3885
- if (typeof this.iHash.update !== "function")
3886
- throw new Error("Expected instance of class which extends utils.Hash");
3887
- this.blockLen = this.iHash.blockLen;
3888
- this.outputLen = this.iHash.outputLen;
3889
- const blockLen = this.blockLen;
3890
- const pad = new Uint8Array(blockLen);
3891
- pad.set(key.length > blockLen ? hash6.create().update(key).digest() : key);
3892
- for (let i = 0; i < pad.length; i++)
3893
- pad[i] ^= 54;
3894
- this.iHash.update(pad);
3895
- this.oHash = hash6.create();
3896
- for (let i = 0; i < pad.length; i++)
3897
- pad[i] ^= 54 ^ 92;
3898
- this.oHash.update(pad);
3899
- pad.fill(0);
3900
- }
3901
- update(buf) {
3902
- exists(this);
3903
- this.iHash.update(buf);
3904
- return this;
3905
- }
3906
- digestInto(out) {
3907
- exists(this);
3908
- bytes(out, this.outputLen);
3909
- this.finished = true;
3910
- this.iHash.digestInto(out);
3911
- this.oHash.update(out);
3912
- this.oHash.digestInto(out);
3913
- this.destroy();
3914
- }
3915
- digest() {
3916
- const out = new Uint8Array(this.oHash.outputLen);
3917
- this.digestInto(out);
3918
- return out;
3919
- }
3920
- _cloneInto(to) {
3921
- to || (to = Object.create(Object.getPrototypeOf(this), {}));
3922
- const { oHash, iHash, finished, destroyed, blockLen, outputLen } = this;
3923
- to = to;
3924
- to.finished = finished;
3925
- to.destroyed = destroyed;
3926
- to.blockLen = blockLen;
3927
- to.outputLen = outputLen;
3928
- to.oHash = oHash._cloneInto(to.oHash);
3929
- to.iHash = iHash._cloneInto(to.iHash);
3930
- return to;
3931
- }
3932
- destroy() {
3933
- this.destroyed = true;
3934
- this.oHash.destroy();
3935
- this.iHash.destroy();
3936
- }
3937
- };
3938
- var hmac = (hash6, key, message) => new HMAC(hash6, key).update(message).digest();
3939
- hmac.create = (hash6, key) => new HMAC(hash6, key);
3940
-
3941
- // ../node_modules/@noble/curves/esm/_shortw_utils.js
3942
- function getHash(hash6) {
3943
- return {
3944
- hash: hash6,
3945
- hmac: (key, ...msgs) => hmac(hash6, key, concatBytes(...msgs)),
3946
- randomBytes
3947
- };
3948
- }
3949
-
3950
- // ../node_modules/@scure/starknet/lib/esm/index.js
3951
- var CURVE_ORDER = BigInt("3618502788666131213697322783095070105526743751716087489154079457884512865583");
3952
- var MAX_VALUE = BigInt("0x800000000000000000000000000000000000000000000000000000000000000");
3953
- var nBitLength = 252;
3954
- function bits2int(bytes2) {
3955
- while (bytes2[0] === 0)
3956
- bytes2 = bytes2.subarray(1);
3957
- const delta = bytes2.length * 8 - nBitLength;
3958
- const num11 = bytesToNumberBE(bytes2);
3959
- return delta > 0 ? num11 >> BigInt(delta) : num11;
3960
- }
3961
- function hex0xToBytes(hex) {
3962
- if (typeof hex === "string") {
3963
- hex = strip0x(hex);
3964
- if (hex.length & 1)
3965
- hex = "0" + hex;
3966
- }
3967
- return hexToBytes(hex);
3968
- }
3969
- var curve = weierstrass({
3970
- a: BigInt(1),
3971
- b: BigInt("3141592653589793238462643383279502884197169399375105820974944592307816406665"),
3972
- Fp: Field(BigInt("0x800000000000011000000000000000000000000000000000000000000000001")),
3973
- n: CURVE_ORDER,
3974
- nBitLength,
3975
- Gx: BigInt("874739451078007766457464989774322083649278607533249481151382481072868806602"),
3976
- Gy: BigInt("152666792071518830868575557812948353041420400780739481342941381225525861407"),
3977
- h: BigInt(1),
3978
- lowS: false,
3979
- ...getHash(sha256),
3980
- bits2int,
3981
- bits2int_modN: (bytes2) => {
3982
- const hex = bytesToNumberBE(bytes2).toString(16);
3983
- if (hex.length === 63)
3984
- bytes2 = hex0xToBytes(hex + "0");
3985
- return mod(bits2int(bytes2), CURVE_ORDER);
3986
- }
3987
- });
3988
- function ensureBytes2(hex) {
3989
- return ensureBytes("", typeof hex === "string" ? hex0xToBytes(hex) : hex);
3990
- }
3991
- var { CURVE, ProjectivePoint, Signature, utils } = curve;
3992
- function extractX(bytes2) {
3993
- const hex = bytesToHex(bytes2.subarray(1));
3994
- const stripped = hex.replace(/^0+/gm, "");
3995
- return `0x${stripped}`;
3996
- }
3997
- function strip0x(hex) {
3998
- return hex.replace(/^0x/i, "");
3999
- }
4000
- var MASK_31 = 2n ** 31n - 1n;
4001
- var PEDERSEN_POINTS = [
4002
- new ProjectivePoint(2089986280348253421170679821480865132823066470938446095505822317253594081284n, 1713931329540660377023406109199410414810705867260802078187082345529207694986n, 1n),
4003
- new ProjectivePoint(996781205833008774514500082376783249102396023663454813447423147977397232763n, 1668503676786377725805489344771023921079126552019160156920634619255970485781n, 1n),
4004
- new ProjectivePoint(2251563274489750535117886426533222435294046428347329203627021249169616184184n, 1798716007562728905295480679789526322175868328062420237419143593021674992973n, 1n),
4005
- new ProjectivePoint(2138414695194151160943305727036575959195309218611738193261179310511854807447n, 113410276730064486255102093846540133784865286929052426931474106396135072156n, 1n),
4006
- new ProjectivePoint(2379962749567351885752724891227938183011949129833673362440656643086021394946n, 776496453633298175483985398648758586525933812536653089401905292063708816422n, 1n)
4007
- ];
4008
- function pedersenPrecompute(p1, p2) {
4009
- const out = [];
4010
- let p = p1;
4011
- for (let i = 0; i < 248; i++) {
4012
- out.push(p);
4013
- p = p.double();
4014
- }
4015
- p = p2;
4016
- for (let i = 0; i < 4; i++) {
4017
- out.push(p);
4018
- p = p.double();
4019
- }
4020
- return out;
4021
- }
4022
- var PEDERSEN_POINTS1 = pedersenPrecompute(PEDERSEN_POINTS[1], PEDERSEN_POINTS[2]);
4023
- var PEDERSEN_POINTS2 = pedersenPrecompute(PEDERSEN_POINTS[3], PEDERSEN_POINTS[4]);
4024
- function pedersenArg(arg) {
4025
- let value;
4026
- if (typeof arg === "bigint") {
4027
- value = arg;
4028
- } else if (typeof arg === "number") {
4029
- if (!Number.isSafeInteger(arg))
4030
- throw new Error(`Invalid pedersenArg: ${arg}`);
4031
- value = BigInt(arg);
4032
- } else {
4033
- value = bytesToNumberBE(ensureBytes2(arg));
4034
- }
4035
- if (!(0n <= value && value < curve.CURVE.Fp.ORDER))
4036
- throw new Error(`PedersenArg should be 0 <= value < CURVE.P: ${value}`);
4037
- return value;
4038
- }
4039
- function pedersenSingle(point, value, constants3) {
4040
- let x = pedersenArg(value);
4041
- for (let j = 0; j < 252; j++) {
4042
- const pt = constants3[j];
4043
- if (pt.equals(point))
4044
- throw new Error("Same point");
4045
- if ((x & 1n) !== 0n)
4046
- point = point.add(pt);
4047
- x >>= 1n;
4048
- }
4049
- return point;
4050
- }
4051
- function pedersen(x, y) {
4052
- let point = PEDERSEN_POINTS[0];
4053
- point = pedersenSingle(point, x, PEDERSEN_POINTS1);
4054
- point = pedersenSingle(point, y, PEDERSEN_POINTS2);
4055
- return extractX(point.toRawBytes(true));
4056
- }
4057
- var MASK_250 = bitMask(250);
4058
- var Fp251 = Field(BigInt("3618502788666131213697322783095070105623107215331596699973092056135872020481"));
4059
- function poseidonRoundConstant(Fp, name, idx) {
4060
- const val = Fp.fromBytes(sha256(utf8ToBytes(`${name}${idx}`)));
4061
- return Fp.create(val);
4062
- }
4063
- var MDS_SMALL = [
4064
- [3, 1, 1],
4065
- [1, -1, 1],
4066
- [1, 1, -2]
4067
- ].map((i) => i.map(BigInt));
4068
- function poseidonBasic(opts, mds) {
4069
- validateField(opts.Fp);
4070
- if (!Number.isSafeInteger(opts.rate) || !Number.isSafeInteger(opts.capacity))
4071
- throw new Error(`Wrong poseidon opts: ${opts}`);
4072
- const m = opts.rate + opts.capacity;
4073
- const rounds = opts.roundsFull + opts.roundsPartial;
4074
- const roundConstants = [];
4075
- for (let i = 0; i < rounds; i++) {
4076
- const row = [];
4077
- for (let j = 0; j < m; j++)
4078
- row.push(poseidonRoundConstant(opts.Fp, "Hades", m * i + j));
4079
- roundConstants.push(row);
4080
- }
4081
- const res = poseidon({
4082
- ...opts,
4083
- t: m,
4084
- sboxPower: 3,
4085
- reversePartialPowIdx: true,
4086
- mds,
4087
- roundConstants
4088
- });
4089
- res.m = m;
4090
- res.rate = opts.rate;
4091
- res.capacity = opts.capacity;
4092
- return res;
4093
- }
4094
- var poseidonSmall = poseidonBasic({ Fp: Fp251, rate: 2, capacity: 1, roundsFull: 8, roundsPartial: 83 }, MDS_SMALL);
4095
-
4096
- // src/utils/oz-merkle.ts
2071
+ var starknet = __toESM(require("@scure/starknet"));
4097
2072
  function hash_leaf(leaf) {
4098
2073
  if (leaf.data.length < 1) {
4099
2074
  throw new Error("Invalid leaf data");
@@ -4106,7 +2081,7 @@ function hash_leaf(leaf) {
4106
2081
  return `0x${import_starknet4.num.toHexString(value).replace(/^0x/, "").padStart(64, "0")}`;
4107
2082
  }
4108
2083
  function pedersen_hash(a, b) {
4109
- return BigInt(pedersen(a, b).toString());
2084
+ return BigInt(starknet.pedersen(a, b).toString());
4110
2085
  }
4111
2086
  var StandardMerkleTree = class _StandardMerkleTree extends import_merkletree.MerkleTreeImpl {
4112
2087
  constructor(tree, values, leafEncoding) {
@@ -4263,6 +2238,7 @@ function getMainnetConfig(rpcUrl = "https://starknet-mainnet.public.blastapi.io"
4263
2238
  provider: new import_starknet6.RpcProvider({
4264
2239
  nodeUrl: rpcUrl,
4265
2240
  blockIdentifier
2241
+ // specVersion
4266
2242
  }),
4267
2243
  stage: "production",
4268
2244
  network: "mainnet" /* mainnet */
@@ -18014,7 +15990,7 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
18014
15990
  quote.buyAmount.toString(),
18015
15991
  tokenToBuyInfo.decimals
18016
15992
  ).multipliedBy(0.9999);
18017
- const output2 = await this.avnu.getSwapInfo(
15993
+ const output = await this.avnu.getSwapInfo(
18018
15994
  quote,
18019
15995
  this.address.address,
18020
15996
  0,
@@ -18022,9 +15998,9 @@ var EkuboCLVault = class _EkuboCLVault extends BaseStrategy {
18022
15998
  minAmountOut.toWei()
18023
15999
  );
18024
16000
  logger.verbose(
18025
- `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => swap info found: ${JSON.stringify(output2)}`
16001
+ `${_EkuboCLVault.name}: getSwapInfoToHandleUnused => swap info found: ${JSON.stringify(output)}`
18026
16002
  );
18027
- return output2;
16003
+ return output;
18028
16004
  }
18029
16005
  }
18030
16006
  throw new Error("Failed to get swap info");
@@ -22983,13 +20959,13 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
22983
20959
  toBigInt(positionData.length),
22984
20960
  ...positionData
22985
20961
  ];
22986
- const output2 = this.constructSimpleLeafData({
20962
+ const output = this.constructSimpleLeafData({
22987
20963
  id: this.config.id,
22988
20964
  target: this.VESU_SINGLETON,
22989
20965
  method: "modify_position",
22990
20966
  packedArguments
22991
20967
  });
22992
- return { leaf: output2, callConstructor: this.getModifyPositionCall.bind(this) };
20968
+ return { leaf: output, callConstructor: this.getModifyPositionCall.bind(this) };
22993
20969
  };
22994
20970
  this.getModifyPositionCall = (params) => {
22995
20971
  const _collateral = {
@@ -23082,8 +21058,8 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
23082
21058
  if (cacheData) {
23083
21059
  return cacheData;
23084
21060
  }
23085
- const output2 = await this.getVesuSingletonContract(config).call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
23086
- this.setCache(CACHE_KEY, Number(output2.max_ltv) / 1e18, 3e5);
21061
+ const output = await this.getVesuSingletonContract(config).call("ltv_config", [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
21062
+ this.setCache(CACHE_KEY, Number(output.max_ltv) / 1e18, 3e5);
23087
21063
  return this.getCache(CACHE_KEY);
23088
21064
  }
23089
21065
  async getPositions(config) {
@@ -23095,7 +21071,7 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
23095
21071
  if (cacheData) {
23096
21072
  return cacheData;
23097
21073
  }
23098
- const output2 = await this.getVesuSingletonContract(config).call("position_unsafe", [
21074
+ const output = await this.getVesuSingletonContract(config).call("position_unsafe", [
23099
21075
  this.config.poolId.address,
23100
21076
  this.config.collateral.address.address,
23101
21077
  this.config.debt.address.address,
@@ -23103,8 +21079,8 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
23103
21079
  ]);
23104
21080
  const token1Price = await this.pricer.getPrice(this.config.collateral.symbol);
23105
21081
  const token2Price = await this.pricer.getPrice(this.config.debt.symbol);
23106
- const collateralAmount = Web3Number.fromWei(output2["1"].toString(), this.config.collateral.decimals);
23107
- const debtAmount = Web3Number.fromWei(output2["2"].toString(), this.config.debt.decimals);
21082
+ const collateralAmount = Web3Number.fromWei(output["1"].toString(), this.config.collateral.decimals);
21083
+ const debtAmount = Web3Number.fromWei(output["2"].toString(), this.config.debt.decimals);
23108
21084
  const value = [{
23109
21085
  amount: collateralAmount,
23110
21086
  token: this.config.collateral,
@@ -23128,14 +21104,14 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
23128
21104
  if (cacheData) {
23129
21105
  return cacheData;
23130
21106
  }
23131
- const output2 = await this.getVesuSingletonContract(config).call("check_collateralization_unsafe", [
21107
+ const output = await this.getVesuSingletonContract(config).call("check_collateralization_unsafe", [
23132
21108
  this.config.poolId.address,
23133
21109
  this.config.collateral.address.address,
23134
21110
  this.config.debt.address.address,
23135
21111
  this.config.vaultAllocator.address
23136
21112
  ]);
23137
- const collateralAmount = Web3Number.fromWei(output2["1"].toString(), 18);
23138
- const debtAmount = Web3Number.fromWei(output2["2"].toString(), 18);
21113
+ const collateralAmount = Web3Number.fromWei(output["1"].toString(), 18);
21114
+ const debtAmount = Web3Number.fromWei(output["2"].toString(), 18);
23139
21115
  const value = [{
23140
21116
  token: this.config.collateral,
23141
21117
  usdValue: collateralAmount.toNumber(),
@@ -23152,8 +21128,8 @@ var VesuAdapter = class _VesuAdapter extends BaseAdapter {
23152
21128
  const collateralizationProm = this.getCollateralization(this.networkConfig);
23153
21129
  const positionsProm = this.getPositions(this.networkConfig);
23154
21130
  const ltvProm = this.getLTVConfig(this.networkConfig);
23155
- const output2 = await Promise.all([collateralizationProm, positionsProm, ltvProm]);
23156
- const [collateralization, positions, ltv] = output2;
21131
+ const output = await Promise.all([collateralizationProm, positionsProm, ltvProm]);
21132
+ const [collateralization, positions, ltv] = output;
23157
21133
  const collateralTokenAmount = positions[0].amount;
23158
21134
  const collateralUSDAmount = collateralization[0].usdValue;
23159
21135
  const collateralPrice = collateralUSDAmount / collateralTokenAmount.toNumber();
@@ -25421,6 +23397,11 @@ var vault_manager_abi_default = [
25421
23397
  ];
25422
23398
 
25423
23399
  // src/strategies/universal-strategy.ts
23400
+ var AUMTypes = /* @__PURE__ */ ((AUMTypes2) => {
23401
+ AUMTypes2["FINALISED"] = "finalised";
23402
+ AUMTypes2["DEFISPRING"] = "defispring";
23403
+ return AUMTypes2;
23404
+ })(AUMTypes || {});
25424
23405
  var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
25425
23406
  constructor(config, pricer, metadata) {
25426
23407
  super(config);
@@ -25505,6 +23486,19 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
25505
23486
  ]);
25506
23487
  return [call1, call2];
25507
23488
  }
23489
+ async withdrawCall(amountInfo, receiver, owner) {
23490
+ assert(
23491
+ amountInfo.tokenInfo.address.eq(this.asset().address),
23492
+ "Withdraw token mismatch"
23493
+ );
23494
+ const shares = await this.contract.call("convert_to_shares", [import_starknet15.uint256.bnToUint256(amountInfo.amount.toWei())]);
23495
+ const call = this.contract.populate("request_redeem", [
23496
+ import_starknet15.uint256.bnToUint256(shares.toString()),
23497
+ receiver.address,
23498
+ owner.address
23499
+ ]);
23500
+ return [call];
23501
+ }
25508
23502
  /**
25509
23503
  * Calculates the Total Value Locked (TVL) for a specific user.
25510
23504
  * @param user - Address of the user
@@ -25551,14 +23545,24 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
25551
23545
  const collateral2APY = Number(collateralAsset2.supplyApy.value) / 1e18;
25552
23546
  const debt2APY = Number(debtAsset2.borrowApr.value) / 1e18;
25553
23547
  const positions = await this.getVaultPositions();
23548
+ logger.verbose(`${this.metadata.name}::netAPY: positions: ${JSON.stringify(positions)}`);
23549
+ if (positions.every((p) => p.amount.isZero())) {
23550
+ return { net: 0, splits: [{
23551
+ apy: 0,
23552
+ id: "base"
23553
+ }, {
23554
+ apy: 0,
23555
+ id: "defispring"
23556
+ }] };
23557
+ }
25554
23558
  const weights = positions.map((p, index) => p.usdValue * (index % 2 == 0 ? 1 : -1));
25555
23559
  const baseAPYs = [collateral1APY, debt1APY, collateral2APY, debt2APY];
25556
23560
  assert(positions.length == baseAPYs.length, "Positions and APYs length mismatch");
25557
23561
  const rewardAPYs = [Number(collateralAsset1.defiSpringSupplyApr.value) / 1e18, 0, Number(collateralAsset2.defiSpringSupplyApr.value) / 1e18, 0];
25558
23562
  const baseAPY = this.computeAPY(baseAPYs, weights);
25559
23563
  const rewardAPY = this.computeAPY(rewardAPYs, weights);
25560
- const apys = [...baseAPYs, ...rewardAPYs];
25561
23564
  const netAPY = baseAPY + rewardAPY;
23565
+ logger.verbose(`${this.metadata.name}::netAPY: net: ${netAPY}, baseAPY: ${baseAPY}, rewardAPY: ${rewardAPY}`);
25562
23566
  return { net: netAPY, splits: [{
25563
23567
  apy: baseAPY,
25564
23568
  id: "base"
@@ -25593,6 +23597,16 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
25593
23597
  usdValue
25594
23598
  };
25595
23599
  }
23600
+ async getUnusedBalance() {
23601
+ const balance = await new ERC20(this.config).balanceOf(this.asset().address, this.metadata.additionalInfo.vaultAllocator, this.asset().decimals);
23602
+ const price = await this.pricer.getPrice(this.metadata.depositTokens[0].symbol);
23603
+ const usdValue = Number(balance.toFixed(6)) * price.price;
23604
+ return {
23605
+ tokenInfo: this.asset(),
23606
+ amount: balance,
23607
+ usdValue
23608
+ };
23609
+ }
25596
23610
  async getAUM() {
25597
23611
  const currentAUM = await this.contract.call("aum", []);
25598
23612
  const lastReportTime = await this.contract.call("last_report_timestamp", []);
@@ -25600,16 +23614,32 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
25600
23614
  const [vesuAdapter1, vesuAdapter2] = this.getVesuAdapters();
25601
23615
  const leg1AUM = await vesuAdapter1.getPositions(this.config);
25602
23616
  const leg2AUM = await vesuAdapter2.getPositions(this.config);
25603
- const balance = await new ERC20(this.config).balanceOf(this.asset().address, this.metadata.additionalInfo.vaultAllocator, this.asset().decimals);
25604
- logger.verbose(`${this.getTag()} unused balance: ${balance}`);
25605
- const aumToken = leg1AUM[0].amount.plus(leg2AUM[0].usdValue / token1Price.price).minus(leg1AUM[1].usdValue / token1Price.price).minus(leg2AUM[1].amount).plus(balance);
23617
+ const balance = await this.getUnusedBalance();
23618
+ logger.verbose(`${this.getTag()} unused balance: ${balance.amount.toNumber()}`);
23619
+ const vesuAum = leg1AUM[0].amount.plus(leg2AUM[0].usdValue / token1Price.price).minus(leg1AUM[1].usdValue / token1Price.price).minus(leg2AUM[1].amount);
23620
+ const zeroAmt = Web3Number.fromWei("0", this.asset().decimals);
23621
+ const net = {
23622
+ tokenInfo: this.asset(),
23623
+ amount: zeroAmt,
23624
+ usdValue: 0
23625
+ };
23626
+ const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
23627
+ if (vesuAum.isZero()) {
23628
+ return { net, splits: [{
23629
+ aum: zeroAmt,
23630
+ id: "finalised" /* FINALISED */
23631
+ }, {
23632
+ aum: zeroAmt,
23633
+ id: "defispring" /* DEFISPRING */
23634
+ }], prevAum };
23635
+ }
23636
+ const aumToken = vesuAum.plus(balance.amount);
25606
23637
  logger.verbose(`${this.getTag()} Actual AUM: ${aumToken}`);
25607
23638
  const netAPY = await this.netAPY();
25608
23639
  const defispringAPY = netAPY.splits.find((s) => s.id === "defispring")?.apy || 0;
25609
23640
  if (!defispringAPY) throw new Error("DefiSpring APY not found");
25610
23641
  const timeDiff = Math.round(Date.now() / 1e3) - Number(lastReportTime);
25611
23642
  const growthRate = timeDiff * defispringAPY / (365 * 24 * 60 * 60);
25612
- const prevAum = Web3Number.fromWei(currentAUM.toString(), this.asset().decimals);
25613
23643
  const rewardAssets = prevAum.multipliedBy(growthRate);
25614
23644
  logger.verbose(`${this.getTag()} DefiSpring AUM time difference: ${timeDiff}`);
25615
23645
  logger.verbose(`${this.getTag()} Current AUM: ${currentAUM}`);
@@ -25617,16 +23647,13 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
25617
23647
  logger.verbose(`${this.getTag()} rewards AUM: ${rewardAssets}`);
25618
23648
  const newAUM = aumToken.plus(rewardAssets);
25619
23649
  logger.verbose(`${this.getTag()} New AUM: ${newAUM}`);
25620
- const net = {
25621
- tokenInfo: this.asset(),
25622
- amount: newAUM,
25623
- usdValue: newAUM.multipliedBy(token1Price.price).toNumber()
25624
- };
23650
+ net.amount = newAUM;
23651
+ net.usdValue = newAUM.multipliedBy(token1Price.price).toNumber();
25625
23652
  const splits = [{
25626
- id: "finalised",
23653
+ id: "finalised" /* FINALISED */,
25627
23654
  aum: aumToken
25628
23655
  }, {
25629
- id: "defispring",
23656
+ id: "defispring" /* DEFISPRING */,
25630
23657
  aum: rewardAssets
25631
23658
  }];
25632
23659
  return { net, splits, prevAum };
@@ -25677,19 +23704,19 @@ var UniversalStrategy = class _UniversalStrategy extends BaseStrategy {
25677
23704
  debtAmount: params.debtAmount,
25678
23705
  isBorrow: params.isDeposit
25679
23706
  }));
25680
- const output2 = [{
23707
+ const output = [{
25681
23708
  proofs: manage5Info.proofs,
25682
23709
  manageCall: manageCall5,
25683
23710
  step: STEP2_ID
25684
23711
  }];
25685
23712
  if (approveAmount.gt(0)) {
25686
- output2.unshift({
23713
+ output.unshift({
25687
23714
  proofs: manage4Info.proofs,
25688
23715
  manageCall: manageCall4,
25689
23716
  step: STEP1_ID
25690
23717
  });
25691
23718
  }
25692
- return output2;
23719
+ return output;
25693
23720
  }
25694
23721
  getTag() {
25695
23722
  return `${_UniversalStrategy.name}:${this.metadata.name}`;
@@ -25940,6 +23967,36 @@ var wbtcVaultSettings = {
25940
23967
  targetHealthFactor: 1.3,
25941
23968
  minHealthFactor: 1.25
25942
23969
  };
23970
+ var ethVaultSettings = {
23971
+ manager: ContractAddr.from("0x494888b37206616bd09d759dcda61e5118470b9aa7f58fb84f21c778a7b8f97"),
23972
+ vaultAllocator: ContractAddr.from("0x4acc0ad6bea58cb578d60ff7c31f06f44369a7a9a7bbfffe4701f143e427bd"),
23973
+ redeemRequestNFT: ContractAddr.from("0x2e6cd71e5060a254d4db00655e420db7bf89da7755bb0d5f922e2f00c76ac49"),
23974
+ aumOracle: ContractAddr.from("0x4b747f2e75c057bed9aa2ce46fbdc2159dc684c15bd32d4f95983a6ecf39a05"),
23975
+ leafAdapters: [],
23976
+ adapters: [],
23977
+ targetHealthFactor: 1.3,
23978
+ minHealthFactor: 1.25
23979
+ };
23980
+ var strkVaultSettings = {
23981
+ manager: ContractAddr.from("0xcc6a5153ca56293405506eb20826a379d982cd738008ef7e808454d318fb81"),
23982
+ vaultAllocator: ContractAddr.from("0xf29d2f82e896c0ed74c9eff220af34ac148e8b99846d1ace9fbb02c9191d01"),
23983
+ redeemRequestNFT: ContractAddr.from("0x46902423bd632c428376b84fcee9cac5dbe016214e93a8103bcbde6e1de656b"),
23984
+ aumOracle: ContractAddr.from("0x6d7dbfad4bb51715da211468389a623da00c0625f8f6efbea822ee5ac5231f4"),
23985
+ leafAdapters: [],
23986
+ adapters: [],
23987
+ targetHealthFactor: 1.3,
23988
+ minHealthFactor: 1.25
23989
+ };
23990
+ var usdtVaultSettings = {
23991
+ manager: ContractAddr.from("0x39bb9843503799b552b7ed84b31c06e4ff10c0537edcddfbf01fe944b864029"),
23992
+ vaultAllocator: ContractAddr.from("0x56437d18c43727ac971f6c7086031cad7d9d6ccb340f4f3785a74cc791c931a"),
23993
+ redeemRequestNFT: ContractAddr.from("0x5af0c2a657eaa8e23ed78e855dac0c51e4f69e2cf91a18c472041a1f75bb41f"),
23994
+ aumOracle: ContractAddr.from("0x7018f8040c8066a4ab929e6760ae52dd43b6a3a289172f514750a61fcc565cc"),
23995
+ leafAdapters: [],
23996
+ adapters: [],
23997
+ targetHealthFactor: 1.3,
23998
+ minHealthFactor: 1.25
23999
+ };
25943
24000
  var UniversalStrategies = [
25944
24001
  {
25945
24002
  name: "USDC Evergreen",
@@ -25978,6 +24035,63 @@ var UniversalStrategies = [
25978
24035
  contractDetails: [],
25979
24036
  faqs: [],
25980
24037
  investmentSteps: []
24038
+ },
24039
+ {
24040
+ name: "ETH Evergreen",
24041
+ description: "A universal strategy for managing ETH assets",
24042
+ address: ContractAddr.from("0x446c22d4d3f5cb52b4950ba832ba1df99464c6673a37c092b1d9622650dbd8"),
24043
+ launchBlock: 0,
24044
+ type: "ERC4626",
24045
+ depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "ETH")],
24046
+ additionalInfo: getLooperSettings("ETH", "WBTC", ethVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
24047
+ risk: {
24048
+ riskFactor: _riskFactor4,
24049
+ netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
24050
+ notARisks: getNoRiskTags(_riskFactor4)
24051
+ },
24052
+ protocols: [Protocols.VESU],
24053
+ maxTVL: Web3Number.fromWei(0, 18),
24054
+ contractDetails: [],
24055
+ faqs: [],
24056
+ investmentSteps: []
24057
+ },
24058
+ {
24059
+ name: "STRK Evergreen",
24060
+ description: "A universal strategy for managing STRK assets",
24061
+ address: ContractAddr.from("0x55d012f57e58c96e0a5c7ebbe55853989d01e6538b15a95e7178aca4af05c21"),
24062
+ launchBlock: 0,
24063
+ type: "ERC4626",
24064
+ depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "STRK")],
24065
+ additionalInfo: getLooperSettings("STRK", "ETH", strkVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
24066
+ risk: {
24067
+ riskFactor: _riskFactor4,
24068
+ netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
24069
+ notARisks: getNoRiskTags(_riskFactor4)
24070
+ },
24071
+ protocols: [Protocols.VESU],
24072
+ maxTVL: Web3Number.fromWei(0, 18),
24073
+ contractDetails: [],
24074
+ faqs: [],
24075
+ investmentSteps: []
24076
+ },
24077
+ {
24078
+ name: "USDT Evergreen",
24079
+ description: "A universal strategy for managing USDT assets",
24080
+ address: ContractAddr.from("0x1c4933d1880c6778585e597154eaca7b428579d72f3aae425ad2e4d26c6bb3"),
24081
+ launchBlock: 0,
24082
+ type: "ERC4626",
24083
+ depositTokens: [Global.getDefaultTokens().find((token) => token.symbol === "USDT")],
24084
+ additionalInfo: getLooperSettings("USDT", "ETH", usdtVaultSettings, VesuPools.Genesis, VesuPools.Genesis),
24085
+ risk: {
24086
+ riskFactor: _riskFactor4,
24087
+ netRisk: _riskFactor4.reduce((acc, curr) => acc + curr.value * curr.weight, 0) / _riskFactor4.reduce((acc, curr) => acc + curr.weight, 0),
24088
+ notARisks: getNoRiskTags(_riskFactor4)
24089
+ },
24090
+ protocols: [Protocols.VESU],
24091
+ maxTVL: Web3Number.fromWei(0, 6),
24092
+ contractDetails: [],
24093
+ faqs: [],
24094
+ investmentSteps: []
25981
24095
  }
25982
24096
  ];
25983
24097
 
@@ -26083,17 +24197,17 @@ var PricerRedis = class extends Pricer {
26083
24197
  };
26084
24198
 
26085
24199
  // src/node/deployer.ts
26086
- var import_assert3 = __toESM(require("assert"));
24200
+ var import_assert = __toESM(require("assert"));
26087
24201
  var import_starknet17 = require("starknet");
26088
24202
  var import_fs2 = require("fs");
26089
24203
 
26090
24204
  // src/utils/store.ts
26091
24205
  var import_fs = __toESM(require("fs"));
26092
24206
  var import_starknet16 = require("starknet");
26093
- var crypto3 = __toESM(require("crypto"));
24207
+ var crypto2 = __toESM(require("crypto"));
26094
24208
 
26095
24209
  // src/utils/encrypt.ts
26096
- var crypto2 = __toESM(require("crypto"));
24210
+ var crypto = __toESM(require("crypto"));
26097
24211
  var PasswordJsonCryptoUtil = class {
26098
24212
  constructor() {
26099
24213
  this.algorithm = "aes-256-gcm";
@@ -26109,14 +24223,14 @@ var PasswordJsonCryptoUtil = class {
26109
24223
  }
26110
24224
  // Number of iterations for PBKDF2
26111
24225
  deriveKey(password, salt) {
26112
- return crypto2.pbkdf2Sync(password, salt, this.pbkdf2Iterations, this.keyLength, "sha256");
24226
+ return crypto.pbkdf2Sync(password, salt, this.pbkdf2Iterations, this.keyLength, "sha256");
26113
24227
  }
26114
24228
  encrypt(data, password) {
26115
24229
  const jsonString = JSON.stringify(data);
26116
- const salt = crypto2.randomBytes(this.saltLength);
26117
- const iv = crypto2.randomBytes(this.ivLength);
24230
+ const salt = crypto.randomBytes(this.saltLength);
24231
+ const iv = crypto.randomBytes(this.ivLength);
26118
24232
  const key = this.deriveKey(password, salt);
26119
- const cipher = crypto2.createCipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
24233
+ const cipher = crypto.createCipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
26120
24234
  let encrypted = cipher.update(jsonString, "utf8", "hex");
26121
24235
  encrypted += cipher.final("hex");
26122
24236
  const tag = cipher.getAuthTag();
@@ -26129,7 +24243,7 @@ var PasswordJsonCryptoUtil = class {
26129
24243
  const tag = data.subarray(this.saltLength + this.ivLength, this.saltLength + this.ivLength + this.tagLength);
26130
24244
  const encrypted = data.subarray(this.saltLength + this.ivLength + this.tagLength);
26131
24245
  const key = this.deriveKey(password, salt);
26132
- const decipher = crypto2.createDecipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
24246
+ const decipher = crypto.createDecipheriv(this.algorithm, key, iv, { authTagLength: this.tagLength });
26133
24247
  decipher.setAuthTag(tag);
26134
24248
  try {
26135
24249
  let decrypted = decipher.update(encrypted.toString("hex"), "hex", "utf8");
@@ -26150,7 +24264,7 @@ function getDefaultStoreConfig(network) {
26150
24264
  SECRET_FILE_FOLDER: `${process.env.HOME}/.starknet-store`,
26151
24265
  NETWORK: network,
26152
24266
  ACCOUNTS_FILE_NAME: "accounts.json",
26153
- PASSWORD: crypto3.randomBytes(16).toString("hex")
24267
+ PASSWORD: crypto2.randomBytes(16).toString("hex")
26154
24268
  };
26155
24269
  }
26156
24270
  var Store = class _Store {
@@ -26318,7 +24432,7 @@ async function deployContract(contract_name, classHash, constructorData, config,
26318
24432
  classHash,
26319
24433
  constructorCalldata: constructorData
26320
24434
  });
26321
- console.log("Deploy fee", contract_name, Number(fee.suggestedMaxFee) / 10 ** 18, "ETH");
24435
+ console.log("Deploy fee", contract_name, Number(fee.overall_fee) / 10 ** 18, "ETH");
26322
24436
  const tx = await acc.deployContract({
26323
24437
  classHash,
26324
24438
  constructorCalldata: constructorData
@@ -26346,8 +24460,8 @@ async function prepareMultiDeployContracts(contracts, config, acc) {
26346
24460
  classHash,
26347
24461
  constructorCalldata: constructorData
26348
24462
  }, acc.address);
26349
- (0, import_assert3.default)(calls.length == 1, `Expected exactly one call, got ${calls.length}`);
26350
- (0, import_assert3.default)(addresses.length == 1, `Expected exactly one address, got ${addresses.length}`);
24463
+ (0, import_assert.default)(calls.length == 1, `Expected exactly one call, got ${calls.length}`);
24464
+ (0, import_assert.default)(addresses.length == 1, `Expected exactly one address, got ${addresses.length}`);
26351
24465
  result.push({
26352
24466
  contract_name,
26353
24467
  package_name,
@@ -26360,7 +24474,7 @@ async function prepareMultiDeployContracts(contracts, config, acc) {
26360
24474
  }
26361
24475
  async function executeDeployCalls(contractsInfo, acc, provider2) {
26362
24476
  for (let contractInfo of contractsInfo) {
26363
- (0, import_assert3.default)(import_starknet17.num.toHexString(contractInfo.call.contractAddress) == import_starknet17.num.toHexString(import_starknet17.constants.UDC.ADDRESS), "Must be pointed at UDC address");
24477
+ (0, import_assert.default)(import_starknet17.num.toHexString(contractInfo.call.contractAddress) == import_starknet17.num.toHexString(import_starknet17.constants.UDC.ADDRESS), "Must be pointed at UDC address");
26364
24478
  }
26365
24479
  const allCalls = contractsInfo.map((info) => info.call);
26366
24480
  await executeTransactions(allCalls, acc, provider2, `Deploying contracts: ${contractsInfo.map((info) => info.contract_name).join(", ")}`);
@@ -26400,6 +24514,7 @@ var Deployer = {
26400
24514
  var deployer_default = Deployer;
26401
24515
  // Annotate the CommonJS export names for ESM import in node:
26402
24516
  0 && (module.exports = {
24517
+ AUMTypes,
26403
24518
  AutoCompounderSTRK,
26404
24519
  AvnuWrapper,
26405
24520
  BaseAdapter,
@@ -26452,26 +24567,3 @@ var deployer_default = Deployer;
26452
24567
  highlightTextWithLinks,
26453
24568
  logger
26454
24569
  });
26455
- /*! Bundled license information:
26456
-
26457
- @noble/hashes/esm/utils.js:
26458
- (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26459
-
26460
- @noble/curves/esm/abstract/utils.js:
26461
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26462
-
26463
- @noble/curves/esm/abstract/modular.js:
26464
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26465
-
26466
- @noble/curves/esm/abstract/poseidon.js:
26467
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26468
-
26469
- @noble/curves/esm/abstract/curve.js:
26470
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26471
-
26472
- @noble/curves/esm/abstract/weierstrass.js:
26473
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26474
-
26475
- @noble/curves/esm/_shortw_utils.js:
26476
- (*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
26477
- */