@volr/react 0.1.62 → 0.1.64

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
@@ -4556,7 +4556,7 @@ var init_hmac = __esm({
4556
4556
  }
4557
4557
  });
4558
4558
 
4559
- // ../node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js
4559
+ // ../node_modules/@noble/curves/esm/abstract/utils.js
4560
4560
  function isBytes2(a) {
4561
4561
  return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
4562
4562
  }
@@ -4760,7 +4760,7 @@ function memoized(fn) {
4760
4760
  }
4761
4761
  var _0n2, _1n2, hasHexBuiltin, hexes2, asciis, isPosBig, bitMask, u8n, u8fr, validatorFns;
4762
4762
  var init_utils4 = __esm({
4763
- "../node_modules/viem/node_modules/@noble/curves/esm/abstract/utils.js"() {
4763
+ "../node_modules/@noble/curves/esm/abstract/utils.js"() {
4764
4764
  _0n2 = /* @__PURE__ */ BigInt(0);
4765
4765
  _1n2 = /* @__PURE__ */ BigInt(1);
4766
4766
  hasHexBuiltin = // @ts-ignore
@@ -4785,7 +4785,7 @@ var init_utils4 = __esm({
4785
4785
  }
4786
4786
  });
4787
4787
 
4788
- // ../node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js
4788
+ // ../node_modules/@noble/curves/esm/abstract/modular.js
4789
4789
  function mod(a, b) {
4790
4790
  const result = a % b;
4791
4791
  return result >= _0n3 ? result : b + result;
@@ -4955,10 +4955,10 @@ function nLength(n, nBitLength) {
4955
4955
  const nByteLength = Math.ceil(_nBitLength / 8);
4956
4956
  return { nBitLength: _nBitLength, nByteLength };
4957
4957
  }
4958
- function Field(ORDER, bitLen3, isLE2 = false, redef = {}) {
4958
+ function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
4959
4959
  if (ORDER <= _0n3)
4960
4960
  throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
4961
- const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen3);
4961
+ const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
4962
4962
  if (BYTES > 2048)
4963
4963
  throw new Error("invalid field: expected ORDER of <= 2048 bytes");
4964
4964
  let sqrtP;
@@ -5033,7 +5033,7 @@ function mapHashToField(key, fieldOrder, isLE2 = false) {
5033
5033
  }
5034
5034
  var _0n3, _1n3, _2n2, _3n, _4n, _5n, _8n, FIELD_FIELDS;
5035
5035
  var init_modular = __esm({
5036
- "../node_modules/viem/node_modules/@noble/curves/esm/abstract/modular.js"() {
5036
+ "../node_modules/@noble/curves/esm/abstract/modular.js"() {
5037
5037
  init_utils2();
5038
5038
  init_utils4();
5039
5039
  _0n3 = BigInt(0);
@@ -5065,7 +5065,7 @@ var init_modular = __esm({
5065
5065
  }
5066
5066
  });
5067
5067
 
5068
- // ../node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js
5068
+ // ../node_modules/@noble/curves/esm/abstract/curve.js
5069
5069
  function constTimeNegate(condition, item) {
5070
5070
  const neg = item.negate();
5071
5071
  return condition ? neg : item;
@@ -5296,7 +5296,7 @@ function validateBasic(curve) {
5296
5296
  }
5297
5297
  var _0n4, _1n4, pointPrecomputes, pointWindowSizes;
5298
5298
  var init_curve = __esm({
5299
- "../node_modules/viem/node_modules/@noble/curves/esm/abstract/curve.js"() {
5299
+ "../node_modules/@noble/curves/esm/abstract/curve.js"() {
5300
5300
  init_modular();
5301
5301
  init_utils4();
5302
5302
  _0n4 = BigInt(0);
@@ -5306,7 +5306,7 @@ var init_curve = __esm({
5306
5306
  }
5307
5307
  });
5308
5308
 
5309
- // ../node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js
5309
+ // ../node_modules/@noble/curves/esm/abstract/weierstrass.js
5310
5310
  function validateSigVerOpts(opts) {
5311
5311
  if (opts.lowS !== void 0)
5312
5312
  abool("lowS", opts.lowS);
@@ -6183,7 +6183,7 @@ function mapToCurveSimpleSWU(Fp, opts) {
6183
6183
  }
6184
6184
  var DERErr, DER, _0n5, _1n5, _2n3, _3n2, _4n2;
6185
6185
  var init_weierstrass = __esm({
6186
- "../node_modules/viem/node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
6186
+ "../node_modules/@noble/curves/esm/abstract/weierstrass.js"() {
6187
6187
  init_curve();
6188
6188
  init_modular();
6189
6189
  init_utils4();
@@ -6300,7 +6300,7 @@ var init_weierstrass = __esm({
6300
6300
  }
6301
6301
  });
6302
6302
 
6303
- // ../node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js
6303
+ // ../node_modules/@noble/curves/esm/_shortw_utils.js
6304
6304
  function getHash(hash3) {
6305
6305
  return {
6306
6306
  hash: hash3,
@@ -6313,14 +6313,14 @@ function createCurve(curveDef, defHash) {
6313
6313
  return { ...create2(defHash), create: create2 };
6314
6314
  }
6315
6315
  var init_shortw_utils = __esm({
6316
- "../node_modules/viem/node_modules/@noble/curves/esm/_shortw_utils.js"() {
6316
+ "../node_modules/@noble/curves/esm/_shortw_utils.js"() {
6317
6317
  init_hmac();
6318
6318
  init_utils2();
6319
6319
  init_weierstrass();
6320
6320
  }
6321
6321
  });
6322
6322
 
6323
- // ../node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js
6323
+ // ../node_modules/@noble/curves/esm/abstract/hash-to-curve.js
6324
6324
  function i2osp(value, length) {
6325
6325
  anum(value);
6326
6326
  anum(length);
@@ -6468,14 +6468,14 @@ function createHasher2(Point2, mapToCurve, defaults) {
6468
6468
  }
6469
6469
  var os2ip;
6470
6470
  var init_hash_to_curve = __esm({
6471
- "../node_modules/viem/node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
6471
+ "../node_modules/@noble/curves/esm/abstract/hash-to-curve.js"() {
6472
6472
  init_modular();
6473
6473
  init_utils4();
6474
6474
  os2ip = bytesToNumberBE;
6475
6475
  }
6476
6476
  });
6477
6477
 
6478
- // ../node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js
6478
+ // ../node_modules/@noble/curves/esm/secp256k1.js
6479
6479
  var secp256k1_exports = {};
6480
6480
  __export(secp256k1_exports, {
6481
6481
  encodeToCurve: () => encodeToCurve,
@@ -6486,19 +6486,19 @@ __export(secp256k1_exports, {
6486
6486
  });
6487
6487
  function sqrtMod(y) {
6488
6488
  const P = secp256k1P;
6489
- const _3n5 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
6489
+ const _3n3 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
6490
6490
  const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
6491
6491
  const b2 = y * y * y % P;
6492
6492
  const b3 = b2 * b2 * y % P;
6493
- const b6 = pow2(b3, _3n5, P) * b3 % P;
6494
- const b9 = pow2(b6, _3n5, P) * b3 % P;
6493
+ const b6 = pow2(b3, _3n3, P) * b3 % P;
6494
+ const b9 = pow2(b6, _3n3, P) * b3 % P;
6495
6495
  const b11 = pow2(b9, _2n4, P) * b2 % P;
6496
6496
  const b22 = pow2(b11, _11n, P) * b11 % P;
6497
6497
  const b44 = pow2(b22, _22n, P) * b22 % P;
6498
6498
  const b88 = pow2(b44, _44n, P) * b44 % P;
6499
6499
  const b176 = pow2(b88, _88n, P) * b88 % P;
6500
6500
  const b220 = pow2(b176, _44n, P) * b44 % P;
6501
- const b223 = pow2(b220, _3n5, P) * b3 % P;
6501
+ const b223 = pow2(b220, _3n3, P) * b3 % P;
6502
6502
  const t1 = pow2(b223, _23n, P) * b22 % P;
6503
6503
  const t2 = pow2(t1, _6n, P) * b2 % P;
6504
6504
  const root = pow2(t2, _2n4, P);
@@ -6579,7 +6579,7 @@ function schnorrVerify(signature, message, publicKey) {
6579
6579
  }
6580
6580
  var secp256k1P, secp256k1N, _0n6, _1n6, _2n4, divNearest, Fpk1, secp256k1, TAGGED_HASH_PREFIXES, pointToBytes, numTo32b, modP, modN, Point, GmulAdd, num, schnorr, isoMap, mapSWU, secp256k1_hasher, hashToCurve, encodeToCurve;
6581
6581
  var init_secp256k1 = __esm({
6582
- "../node_modules/viem/node_modules/@noble/curves/esm/secp256k1.js"() {
6582
+ "../node_modules/@noble/curves/esm/secp256k1.js"() {
6583
6583
  init_sha2();
6584
6584
  init_utils2();
6585
6585
  init_shortw_utils();
@@ -7178,230 +7178,6 @@ var init_decodeFunctionResult = __esm({
7178
7178
  }
7179
7179
  });
7180
7180
 
7181
- // ../node_modules/ox/node_modules/@noble/curves/esm/abstract/utils.js
7182
- function isBytes3(a) {
7183
- return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
7184
- }
7185
- function abytes3(item) {
7186
- if (!isBytes3(item))
7187
- throw new Error("Uint8Array expected");
7188
- }
7189
- function abool2(title, value) {
7190
- if (typeof value !== "boolean")
7191
- throw new Error(title + " boolean expected, got " + value);
7192
- }
7193
- function numberToHexUnpadded2(num2) {
7194
- const hex = num2.toString(16);
7195
- return hex.length & 1 ? "0" + hex : hex;
7196
- }
7197
- function hexToNumber3(hex) {
7198
- if (typeof hex !== "string")
7199
- throw new Error("hex string expected, got " + typeof hex);
7200
- return hex === "" ? _0n7 : BigInt("0x" + hex);
7201
- }
7202
- function bytesToHex3(bytes) {
7203
- abytes3(bytes);
7204
- if (hasHexBuiltin2)
7205
- return bytes.toHex();
7206
- let hex = "";
7207
- for (let i = 0; i < bytes.length; i++) {
7208
- hex += hexes3[bytes[i]];
7209
- }
7210
- return hex;
7211
- }
7212
- function asciiToBase162(ch) {
7213
- if (ch >= asciis2._0 && ch <= asciis2._9)
7214
- return ch - asciis2._0;
7215
- if (ch >= asciis2.A && ch <= asciis2.F)
7216
- return ch - (asciis2.A - 10);
7217
- if (ch >= asciis2.a && ch <= asciis2.f)
7218
- return ch - (asciis2.a - 10);
7219
- return;
7220
- }
7221
- function hexToBytes3(hex) {
7222
- if (typeof hex !== "string")
7223
- throw new Error("hex string expected, got " + typeof hex);
7224
- if (hasHexBuiltin2)
7225
- return Uint8Array.fromHex(hex);
7226
- const hl = hex.length;
7227
- const al = hl / 2;
7228
- if (hl % 2)
7229
- throw new Error("hex string expected, got unpadded hex of length " + hl);
7230
- const array = new Uint8Array(al);
7231
- for (let ai = 0, hi = 0; ai < al; ai++, hi += 2) {
7232
- const n1 = asciiToBase162(hex.charCodeAt(hi));
7233
- const n2 = asciiToBase162(hex.charCodeAt(hi + 1));
7234
- if (n1 === void 0 || n2 === void 0) {
7235
- const char = hex[hi] + hex[hi + 1];
7236
- throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
7237
- }
7238
- array[ai] = n1 * 16 + n2;
7239
- }
7240
- return array;
7241
- }
7242
- function bytesToNumberBE2(bytes) {
7243
- return hexToNumber3(bytesToHex3(bytes));
7244
- }
7245
- function bytesToNumberLE2(bytes) {
7246
- abytes3(bytes);
7247
- return hexToNumber3(bytesToHex3(Uint8Array.from(bytes).reverse()));
7248
- }
7249
- function numberToBytesBE2(n, len) {
7250
- return hexToBytes3(n.toString(16).padStart(len * 2, "0"));
7251
- }
7252
- function numberToBytesLE2(n, len) {
7253
- return numberToBytesBE2(n, len).reverse();
7254
- }
7255
- function ensureBytes2(title, hex, expectedLength) {
7256
- let res;
7257
- if (typeof hex === "string") {
7258
- try {
7259
- res = hexToBytes3(hex);
7260
- } catch (e) {
7261
- throw new Error(title + " must be hex string or Uint8Array, cause: " + e);
7262
- }
7263
- } else if (isBytes3(hex)) {
7264
- res = Uint8Array.from(hex);
7265
- } else {
7266
- throw new Error(title + " must be hex string or Uint8Array");
7267
- }
7268
- const len = res.length;
7269
- if (typeof expectedLength === "number" && len !== expectedLength)
7270
- throw new Error(title + " of length " + expectedLength + " expected, got " + len);
7271
- return res;
7272
- }
7273
- function concatBytes4(...arrays) {
7274
- let sum = 0;
7275
- for (let i = 0; i < arrays.length; i++) {
7276
- const a = arrays[i];
7277
- abytes3(a);
7278
- sum += a.length;
7279
- }
7280
- const res = new Uint8Array(sum);
7281
- for (let i = 0, pad4 = 0; i < arrays.length; i++) {
7282
- const a = arrays[i];
7283
- res.set(a, pad4);
7284
- pad4 += a.length;
7285
- }
7286
- return res;
7287
- }
7288
- function inRange2(n, min, max) {
7289
- return isPosBig2(n) && isPosBig2(min) && isPosBig2(max) && min <= n && n < max;
7290
- }
7291
- function aInRange2(title, n, min, max) {
7292
- if (!inRange2(n, min, max))
7293
- throw new Error("expected valid " + title + ": " + min + " <= n < " + max + ", got " + n);
7294
- }
7295
- function bitLen2(n) {
7296
- let len;
7297
- for (len = 0; n > _0n7; n >>= _1n7, len += 1)
7298
- ;
7299
- return len;
7300
- }
7301
- function createHmacDrbg2(hashLen, qByteLen, hmacFn) {
7302
- if (typeof hashLen !== "number" || hashLen < 2)
7303
- throw new Error("hashLen must be a number");
7304
- if (typeof qByteLen !== "number" || qByteLen < 2)
7305
- throw new Error("qByteLen must be a number");
7306
- if (typeof hmacFn !== "function")
7307
- throw new Error("hmacFn must be a function");
7308
- let v = u8n2(hashLen);
7309
- let k = u8n2(hashLen);
7310
- let i = 0;
7311
- const reset = () => {
7312
- v.fill(1);
7313
- k.fill(0);
7314
- i = 0;
7315
- };
7316
- const h = (...b) => hmacFn(k, v, ...b);
7317
- const reseed = (seed = u8n2(0)) => {
7318
- k = h(u8fr2([0]), seed);
7319
- v = h();
7320
- if (seed.length === 0)
7321
- return;
7322
- k = h(u8fr2([1]), seed);
7323
- v = h();
7324
- };
7325
- const gen2 = () => {
7326
- if (i++ >= 1e3)
7327
- throw new Error("drbg: tried 1000 values");
7328
- let len = 0;
7329
- const out = [];
7330
- while (len < qByteLen) {
7331
- v = h();
7332
- const sl = v.slice();
7333
- out.push(sl);
7334
- len += v.length;
7335
- }
7336
- return concatBytes4(...out);
7337
- };
7338
- const genUntil = (seed, pred) => {
7339
- reset();
7340
- reseed(seed);
7341
- let res = void 0;
7342
- while (!(res = pred(gen2())))
7343
- reseed();
7344
- reset();
7345
- return res;
7346
- };
7347
- return genUntil;
7348
- }
7349
- function validateObject2(object, validators, optValidators = {}) {
7350
- const checkField = (fieldName, type, isOptional) => {
7351
- const checkVal = validatorFns2[type];
7352
- if (typeof checkVal !== "function")
7353
- throw new Error("invalid validator function");
7354
- const val = object[fieldName];
7355
- if (isOptional && val === void 0)
7356
- return;
7357
- if (!checkVal(val, object)) {
7358
- throw new Error("param " + String(fieldName) + " is invalid. Expected " + type + ", got " + val);
7359
- }
7360
- };
7361
- for (const [fieldName, type] of Object.entries(validators))
7362
- checkField(fieldName, type, false);
7363
- for (const [fieldName, type] of Object.entries(optValidators))
7364
- checkField(fieldName, type, true);
7365
- return object;
7366
- }
7367
- function memoized2(fn) {
7368
- const map = /* @__PURE__ */ new WeakMap();
7369
- return (arg, ...args) => {
7370
- const val = map.get(arg);
7371
- if (val !== void 0)
7372
- return val;
7373
- const computed = fn(arg, ...args);
7374
- map.set(arg, computed);
7375
- return computed;
7376
- };
7377
- }
7378
- var _0n7, _1n7, hasHexBuiltin2, hexes3, asciis2, isPosBig2, bitMask2, u8n2, u8fr2, validatorFns2;
7379
- var init_utils5 = __esm({
7380
- "../node_modules/ox/node_modules/@noble/curves/esm/abstract/utils.js"() {
7381
- _0n7 = /* @__PURE__ */ BigInt(0);
7382
- _1n7 = /* @__PURE__ */ BigInt(1);
7383
- hasHexBuiltin2 = // @ts-ignore
7384
- typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
7385
- hexes3 = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
7386
- asciis2 = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
7387
- isPosBig2 = (n) => typeof n === "bigint" && _0n7 <= n;
7388
- bitMask2 = (n) => (_1n7 << BigInt(n)) - _1n7;
7389
- u8n2 = (len) => new Uint8Array(len);
7390
- u8fr2 = (arr) => Uint8Array.from(arr);
7391
- validatorFns2 = {
7392
- bigint: (val) => typeof val === "bigint",
7393
- function: (val) => typeof val === "function",
7394
- boolean: (val) => typeof val === "boolean",
7395
- string: (val) => typeof val === "string",
7396
- stringOrUint8Array: (val) => typeof val === "string" || isBytes3(val),
7397
- isSafeInteger: (val) => Number.isSafeInteger(val),
7398
- array: (val) => Array.isArray(val),
7399
- field: (val, object) => object.Fp.isValid(val),
7400
- hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
7401
- };
7402
- }
7403
- });
7404
-
7405
7181
  // ../node_modules/ox/_esm/core/version.js
7406
7182
  var version3;
7407
7183
  var init_version3 = __esm({
@@ -7868,7 +7644,7 @@ function fromBoolean(value, options = {}) {
7868
7644
  function fromBytes(value, options = {}) {
7869
7645
  let string = "";
7870
7646
  for (let i = 0; i < value.length; i++)
7871
- string += hexes4[value[i]];
7647
+ string += hexes3[value[i]];
7872
7648
  const hex = `0x${string}`;
7873
7649
  if (typeof options.size === "number") {
7874
7650
  assertSize3(hex, options.size);
@@ -7957,14 +7733,14 @@ function validate2(value, options = {}) {
7957
7733
  return false;
7958
7734
  }
7959
7735
  }
7960
- var encoder4, hexes4, IntegerOutOfRangeError2, InvalidHexTypeError, InvalidHexValueError, SizeOverflowError3, SliceOffsetOutOfBoundsError3, SizeExceedsPaddingSizeError3;
7736
+ var encoder4, hexes3, IntegerOutOfRangeError2, InvalidHexTypeError, InvalidHexValueError, SizeOverflowError3, SliceOffsetOutOfBoundsError3, SizeExceedsPaddingSizeError3;
7961
7737
  var init_Hex = __esm({
7962
7738
  "../node_modules/ox/_esm/core/Hex.js"() {
7963
7739
  init_Errors();
7964
7740
  init_hex();
7965
7741
  init_Json();
7966
7742
  encoder4 = /* @__PURE__ */ new TextEncoder();
7967
- hexes4 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
7743
+ hexes3 = /* @__PURE__ */ Array.from({ length: 256 }, (_v, i) => i.toString(16).padStart(2, "0"));
7968
7744
  IntegerOutOfRangeError2 = class extends BaseError3 {
7969
7745
  constructor({ max, min, signed, size: size5, value }) {
7970
7746
  super(`Number \`${value}\` is not in safe${size5 ? ` ${size5 * 8}-bit` : ""}${signed ? " signed" : " unsigned"} integer range ${max ? `(\`${min}\` to \`${max}\`)` : `(above \`${min}\`)`}`);
@@ -10669,20 +10445,20 @@ init_fromHex();
10669
10445
  init_toHex();
10670
10446
  async function recoverPublicKey({ hash: hash3, signature }) {
10671
10447
  const hashHex = isHex(hash3) ? hash3 : toHex(hash3);
10672
- const { secp256k1: secp256k13 } = await Promise.resolve().then(() => (init_secp256k1(), secp256k1_exports));
10448
+ const { secp256k1: secp256k12 } = await Promise.resolve().then(() => (init_secp256k1(), secp256k1_exports));
10673
10449
  const signature_ = (() => {
10674
10450
  if (typeof signature === "object" && "r" in signature && "s" in signature) {
10675
10451
  const { r, s, v, yParity } = signature;
10676
10452
  const yParityOrV2 = Number(yParity ?? v);
10677
10453
  const recoveryBit2 = toRecoveryBit(yParityOrV2);
10678
- return new secp256k13.Signature(hexToBigInt(r), hexToBigInt(s)).addRecoveryBit(recoveryBit2);
10454
+ return new secp256k12.Signature(hexToBigInt(r), hexToBigInt(s)).addRecoveryBit(recoveryBit2);
10679
10455
  }
10680
10456
  const signatureHex = isHex(signature) ? signature : toHex(signature);
10681
10457
  if (size(signatureHex) !== 65)
10682
10458
  throw new Error("invalid signature length");
10683
10459
  const yParityOrV = hexToNumber(`0x${signatureHex.slice(130)}`);
10684
10460
  const recoveryBit = toRecoveryBit(yParityOrV);
10685
- return secp256k13.Signature.fromCompact(signatureHex.substring(2, 130)).addRecoveryBit(recoveryBit);
10461
+ return secp256k12.Signature.fromCompact(signatureHex.substring(2, 130)).addRecoveryBit(recoveryBit);
10686
10462
  })();
10687
10463
  const publicKey = signature_.recoverPublicKey(hashHex.substring(2)).toHex(false);
10688
10464
  return `0x${publicKey}`;
@@ -15776,1564 +15552,79 @@ function getSizeOfLength2(length) {
15776
15552
  throw new BaseError3("Length is too large.");
15777
15553
  }
15778
15554
 
15779
- // ../node_modules/ox/node_modules/@noble/curves/esm/secp256k1.js
15780
- init_sha2();
15781
-
15782
- // ../node_modules/ox/node_modules/@noble/curves/esm/_shortw_utils.js
15783
- init_hmac();
15784
- init_utils2();
15785
-
15786
- // ../node_modules/ox/node_modules/@noble/curves/esm/abstract/modular.js
15787
- init_utils2();
15788
- init_utils5();
15789
- var _0n8 = BigInt(0);
15790
- var _1n8 = BigInt(1);
15791
- var _2n5 = /* @__PURE__ */ BigInt(2);
15792
- var _3n3 = /* @__PURE__ */ BigInt(3);
15793
- var _4n3 = /* @__PURE__ */ BigInt(4);
15794
- var _5n2 = /* @__PURE__ */ BigInt(5);
15795
- var _8n2 = /* @__PURE__ */ BigInt(8);
15796
- function mod2(a, b) {
15797
- const result = a % b;
15798
- return result >= _0n8 ? result : b + result;
15555
+ // ../node_modules/ox/_esm/core/Signature.js
15556
+ init_Errors();
15557
+ init_Hex();
15558
+ init_Json();
15559
+ function assert5(signature, options = {}) {
15560
+ const { recovered } = options;
15561
+ if (typeof signature.r === "undefined")
15562
+ throw new MissingPropertiesError({ signature });
15563
+ if (typeof signature.s === "undefined")
15564
+ throw new MissingPropertiesError({ signature });
15565
+ if (recovered && typeof signature.yParity === "undefined")
15566
+ throw new MissingPropertiesError({ signature });
15567
+ if (signature.r < 0n || signature.r > maxUint2562)
15568
+ throw new InvalidRError({ value: signature.r });
15569
+ if (signature.s < 0n || signature.s > maxUint2562)
15570
+ throw new InvalidSError({ value: signature.s });
15571
+ if (typeof signature.yParity === "number" && signature.yParity !== 0 && signature.yParity !== 1)
15572
+ throw new InvalidYParityError({ value: signature.yParity });
15799
15573
  }
15800
- function pow22(x, power, modulo) {
15801
- let res = x;
15802
- while (power-- > _0n8) {
15803
- res *= res;
15804
- res %= modulo;
15805
- }
15806
- return res;
15574
+ function fromBytes3(signature) {
15575
+ return fromHex4(fromBytes(signature));
15807
15576
  }
15808
- function invert2(number, modulo) {
15809
- if (number === _0n8)
15810
- throw new Error("invert: expected non-zero number");
15811
- if (modulo <= _0n8)
15812
- throw new Error("invert: expected positive modulus, got " + modulo);
15813
- let a = mod2(number, modulo);
15814
- let b = modulo;
15815
- let x = _0n8, u = _1n8;
15816
- while (a !== _0n8) {
15817
- const q = b / a;
15818
- const r = b % a;
15819
- const m = x - u * q;
15820
- b = a, a = r, x = u, u = m;
15821
- }
15822
- const gcd = b;
15823
- if (gcd !== _1n8)
15824
- throw new Error("invert: does not exist");
15825
- return mod2(x, modulo);
15577
+ function fromHex4(signature) {
15578
+ if (signature.length !== 130 && signature.length !== 132)
15579
+ throw new InvalidSerializedSizeError2({ signature });
15580
+ const r = BigInt(slice3(signature, 0, 32));
15581
+ const s = BigInt(slice3(signature, 32, 64));
15582
+ const yParity = (() => {
15583
+ const yParity2 = Number(`0x${signature.slice(130)}`);
15584
+ if (Number.isNaN(yParity2))
15585
+ return void 0;
15586
+ try {
15587
+ return vToYParity(yParity2);
15588
+ } catch {
15589
+ throw new InvalidYParityError({ value: yParity2 });
15590
+ }
15591
+ })();
15592
+ if (typeof yParity === "undefined")
15593
+ return {
15594
+ r,
15595
+ s
15596
+ };
15597
+ return {
15598
+ r,
15599
+ s,
15600
+ yParity
15601
+ };
15826
15602
  }
15827
- function sqrt3mod42(Fp, n) {
15828
- const p1div4 = (Fp.ORDER + _1n8) / _4n3;
15829
- const root = Fp.pow(n, p1div4);
15830
- if (!Fp.eql(Fp.sqr(root), n))
15831
- throw new Error("Cannot find square root");
15832
- return root;
15603
+ function extract2(value) {
15604
+ if (typeof value.r === "undefined")
15605
+ return void 0;
15606
+ if (typeof value.s === "undefined")
15607
+ return void 0;
15608
+ return from7(value);
15833
15609
  }
15834
- function sqrt5mod82(Fp, n) {
15835
- const p5div8 = (Fp.ORDER - _5n2) / _8n2;
15836
- const n2 = Fp.mul(n, _2n5);
15837
- const v = Fp.pow(n2, p5div8);
15838
- const nv = Fp.mul(n, v);
15839
- const i = Fp.mul(Fp.mul(nv, _2n5), v);
15840
- const root = Fp.mul(nv, Fp.sub(i, Fp.ONE));
15841
- if (!Fp.eql(Fp.sqr(root), n))
15842
- throw new Error("Cannot find square root");
15843
- return root;
15844
- }
15845
- function tonelliShanks2(P) {
15846
- if (P < BigInt(3))
15847
- throw new Error("sqrt is not defined for small field");
15848
- let Q = P - _1n8;
15849
- let S = 0;
15850
- while (Q % _2n5 === _0n8) {
15851
- Q /= _2n5;
15852
- S++;
15853
- }
15854
- let Z = _2n5;
15855
- const _Fp = Field2(P);
15856
- while (FpLegendre2(_Fp, Z) === 1) {
15857
- if (Z++ > 1e3)
15858
- throw new Error("Cannot find square root: probably non-prime P");
15859
- }
15860
- if (S === 1)
15861
- return sqrt3mod42;
15862
- let cc = _Fp.pow(Z, Q);
15863
- const Q1div2 = (Q + _1n8) / _2n5;
15864
- return function tonelliSlow(Fp, n) {
15865
- if (Fp.is0(n))
15866
- return n;
15867
- if (FpLegendre2(Fp, n) !== 1)
15868
- throw new Error("Cannot find square root");
15869
- let M = S;
15870
- let c = Fp.mul(Fp.ONE, cc);
15871
- let t = Fp.pow(n, Q);
15872
- let R = Fp.pow(n, Q1div2);
15873
- while (!Fp.eql(t, Fp.ONE)) {
15874
- if (Fp.is0(t))
15875
- return Fp.ZERO;
15876
- let i = 1;
15877
- let t_tmp = Fp.sqr(t);
15878
- while (!Fp.eql(t_tmp, Fp.ONE)) {
15879
- i++;
15880
- t_tmp = Fp.sqr(t_tmp);
15881
- if (i === M)
15882
- throw new Error("Cannot find square root");
15883
- }
15884
- const exponent = _1n8 << BigInt(M - i - 1);
15885
- const b = Fp.pow(c, exponent);
15886
- M = i;
15887
- c = Fp.sqr(b);
15888
- t = Fp.mul(t, c);
15889
- R = Fp.mul(R, b);
15890
- }
15891
- return R;
15892
- };
15893
- }
15894
- function FpSqrt2(P) {
15895
- if (P % _4n3 === _3n3)
15896
- return sqrt3mod42;
15897
- if (P % _8n2 === _5n2)
15898
- return sqrt5mod82;
15899
- return tonelliShanks2(P);
15900
- }
15901
- var FIELD_FIELDS2 = [
15902
- "create",
15903
- "isValid",
15904
- "is0",
15905
- "neg",
15906
- "inv",
15907
- "sqrt",
15908
- "sqr",
15909
- "eql",
15910
- "add",
15911
- "sub",
15912
- "mul",
15913
- "pow",
15914
- "div",
15915
- "addN",
15916
- "subN",
15917
- "mulN",
15918
- "sqrN"
15919
- ];
15920
- function validateField2(field) {
15921
- const initial = {
15922
- ORDER: "bigint",
15923
- MASK: "bigint",
15924
- BYTES: "isSafeInteger",
15925
- BITS: "isSafeInteger"
15926
- };
15927
- const opts = FIELD_FIELDS2.reduce((map, val) => {
15928
- map[val] = "function";
15929
- return map;
15930
- }, initial);
15931
- return validateObject2(field, opts);
15932
- }
15933
- function FpPow2(Fp, num2, power) {
15934
- if (power < _0n8)
15935
- throw new Error("invalid exponent, negatives unsupported");
15936
- if (power === _0n8)
15937
- return Fp.ONE;
15938
- if (power === _1n8)
15939
- return num2;
15940
- let p = Fp.ONE;
15941
- let d = num2;
15942
- while (power > _0n8) {
15943
- if (power & _1n8)
15944
- p = Fp.mul(p, d);
15945
- d = Fp.sqr(d);
15946
- power >>= _1n8;
15947
- }
15948
- return p;
15949
- }
15950
- function FpInvertBatch2(Fp, nums, passZero = false) {
15951
- const inverted = new Array(nums.length).fill(passZero ? Fp.ZERO : void 0);
15952
- const multipliedAcc = nums.reduce((acc, num2, i) => {
15953
- if (Fp.is0(num2))
15954
- return acc;
15955
- inverted[i] = acc;
15956
- return Fp.mul(acc, num2);
15957
- }, Fp.ONE);
15958
- const invertedAcc = Fp.inv(multipliedAcc);
15959
- nums.reduceRight((acc, num2, i) => {
15960
- if (Fp.is0(num2))
15961
- return acc;
15962
- inverted[i] = Fp.mul(acc, inverted[i]);
15963
- return Fp.mul(acc, num2);
15964
- }, invertedAcc);
15965
- return inverted;
15966
- }
15967
- function FpLegendre2(Fp, n) {
15968
- const p1mod2 = (Fp.ORDER - _1n8) / _2n5;
15969
- const powered = Fp.pow(n, p1mod2);
15970
- const yes = Fp.eql(powered, Fp.ONE);
15971
- const zero = Fp.eql(powered, Fp.ZERO);
15972
- const no = Fp.eql(powered, Fp.neg(Fp.ONE));
15973
- if (!yes && !zero && !no)
15974
- throw new Error("invalid Legendre symbol result");
15975
- return yes ? 1 : zero ? 0 : -1;
15976
- }
15977
- function nLength2(n, nBitLength) {
15978
- if (nBitLength !== void 0)
15979
- anumber(nBitLength);
15980
- const _nBitLength = nBitLength !== void 0 ? nBitLength : n.toString(2).length;
15981
- const nByteLength = Math.ceil(_nBitLength / 8);
15982
- return { nBitLength: _nBitLength, nByteLength };
15983
- }
15984
- function Field2(ORDER, bitLen3, isLE2 = false, redef = {}) {
15985
- if (ORDER <= _0n8)
15986
- throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
15987
- const { nBitLength: BITS, nByteLength: BYTES } = nLength2(ORDER, bitLen3);
15988
- if (BYTES > 2048)
15989
- throw new Error("invalid field: expected ORDER of <= 2048 bytes");
15990
- let sqrtP;
15991
- const f = Object.freeze({
15992
- ORDER,
15993
- isLE: isLE2,
15994
- BITS,
15995
- BYTES,
15996
- MASK: bitMask2(BITS),
15997
- ZERO: _0n8,
15998
- ONE: _1n8,
15999
- create: (num2) => mod2(num2, ORDER),
16000
- isValid: (num2) => {
16001
- if (typeof num2 !== "bigint")
16002
- throw new Error("invalid field element: expected bigint, got " + typeof num2);
16003
- return _0n8 <= num2 && num2 < ORDER;
16004
- },
16005
- is0: (num2) => num2 === _0n8,
16006
- isOdd: (num2) => (num2 & _1n8) === _1n8,
16007
- neg: (num2) => mod2(-num2, ORDER),
16008
- eql: (lhs, rhs) => lhs === rhs,
16009
- sqr: (num2) => mod2(num2 * num2, ORDER),
16010
- add: (lhs, rhs) => mod2(lhs + rhs, ORDER),
16011
- sub: (lhs, rhs) => mod2(lhs - rhs, ORDER),
16012
- mul: (lhs, rhs) => mod2(lhs * rhs, ORDER),
16013
- pow: (num2, power) => FpPow2(f, num2, power),
16014
- div: (lhs, rhs) => mod2(lhs * invert2(rhs, ORDER), ORDER),
16015
- // Same as above, but doesn't normalize
16016
- sqrN: (num2) => num2 * num2,
16017
- addN: (lhs, rhs) => lhs + rhs,
16018
- subN: (lhs, rhs) => lhs - rhs,
16019
- mulN: (lhs, rhs) => lhs * rhs,
16020
- inv: (num2) => invert2(num2, ORDER),
16021
- sqrt: redef.sqrt || ((n) => {
16022
- if (!sqrtP)
16023
- sqrtP = FpSqrt2(ORDER);
16024
- return sqrtP(f, n);
16025
- }),
16026
- toBytes: (num2) => isLE2 ? numberToBytesLE2(num2, BYTES) : numberToBytesBE2(num2, BYTES),
16027
- fromBytes: (bytes) => {
16028
- if (bytes.length !== BYTES)
16029
- throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
16030
- return isLE2 ? bytesToNumberLE2(bytes) : bytesToNumberBE2(bytes);
16031
- },
16032
- // TODO: we don't need it here, move out to separate fn
16033
- invertBatch: (lst) => FpInvertBatch2(f, lst),
16034
- // We can't move this out because Fp6, Fp12 implement it
16035
- // and it's unclear what to return in there.
16036
- cmov: (a, b, c) => c ? b : a
16037
- });
16038
- return Object.freeze(f);
16039
- }
16040
- function getFieldBytesLength2(fieldOrder) {
16041
- if (typeof fieldOrder !== "bigint")
16042
- throw new Error("field order must be bigint");
16043
- const bitLength = fieldOrder.toString(2).length;
16044
- return Math.ceil(bitLength / 8);
16045
- }
16046
- function getMinHashLength2(fieldOrder) {
16047
- const length = getFieldBytesLength2(fieldOrder);
16048
- return length + Math.ceil(length / 2);
16049
- }
16050
- function mapHashToField2(key, fieldOrder, isLE2 = false) {
16051
- const len = key.length;
16052
- const fieldLen = getFieldBytesLength2(fieldOrder);
16053
- const minLen = getMinHashLength2(fieldOrder);
16054
- if (len < 16 || len < minLen || len > 1024)
16055
- throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
16056
- const num2 = isLE2 ? bytesToNumberLE2(key) : bytesToNumberBE2(key);
16057
- const reduced = mod2(num2, fieldOrder - _1n8) + _1n8;
16058
- return isLE2 ? numberToBytesLE2(reduced, fieldLen) : numberToBytesBE2(reduced, fieldLen);
16059
- }
16060
-
16061
- // ../node_modules/ox/node_modules/@noble/curves/esm/abstract/curve.js
16062
- init_utils5();
16063
- var _0n9 = BigInt(0);
16064
- var _1n9 = BigInt(1);
16065
- function constTimeNegate2(condition, item) {
16066
- const neg = item.negate();
16067
- return condition ? neg : item;
16068
- }
16069
- function validateW2(W, bits) {
16070
- if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
16071
- throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W);
16072
- }
16073
- function calcWOpts2(W, scalarBits) {
16074
- validateW2(W, scalarBits);
16075
- const windows = Math.ceil(scalarBits / W) + 1;
16076
- const windowSize = 2 ** (W - 1);
16077
- const maxNumber = 2 ** W;
16078
- const mask = bitMask2(W);
16079
- const shiftBy = BigInt(W);
16080
- return { windows, windowSize, mask, maxNumber, shiftBy };
16081
- }
16082
- function calcOffsets2(n, window2, wOpts) {
16083
- const { windowSize, mask, maxNumber, shiftBy } = wOpts;
16084
- let wbits = Number(n & mask);
16085
- let nextN = n >> shiftBy;
16086
- if (wbits > windowSize) {
16087
- wbits -= maxNumber;
16088
- nextN += _1n9;
16089
- }
16090
- const offsetStart = window2 * windowSize;
16091
- const offset = offsetStart + Math.abs(wbits) - 1;
16092
- const isZero = wbits === 0;
16093
- const isNeg = wbits < 0;
16094
- const isNegF = window2 % 2 !== 0;
16095
- const offsetF = offsetStart;
16096
- return { nextN, offset, isZero, isNeg, isNegF, offsetF };
16097
- }
16098
- function validateMSMPoints2(points, c) {
16099
- if (!Array.isArray(points))
16100
- throw new Error("array expected");
16101
- points.forEach((p, i) => {
16102
- if (!(p instanceof c))
16103
- throw new Error("invalid point at index " + i);
16104
- });
16105
- }
16106
- function validateMSMScalars2(scalars, field) {
16107
- if (!Array.isArray(scalars))
16108
- throw new Error("array of scalars expected");
16109
- scalars.forEach((s, i) => {
16110
- if (!field.isValid(s))
16111
- throw new Error("invalid scalar at index " + i);
16112
- });
16113
- }
16114
- var pointPrecomputes2 = /* @__PURE__ */ new WeakMap();
16115
- var pointWindowSizes2 = /* @__PURE__ */ new WeakMap();
16116
- function getW2(P) {
16117
- return pointWindowSizes2.get(P) || 1;
16118
- }
16119
- function wNAF2(c, bits) {
16120
- return {
16121
- constTimeNegate: constTimeNegate2,
16122
- hasPrecomputes(elm) {
16123
- return getW2(elm) !== 1;
16124
- },
16125
- // non-const time multiplication ladder
16126
- unsafeLadder(elm, n, p = c.ZERO) {
16127
- let d = elm;
16128
- while (n > _0n9) {
16129
- if (n & _1n9)
16130
- p = p.add(d);
16131
- d = d.double();
16132
- n >>= _1n9;
16133
- }
16134
- return p;
16135
- },
16136
- /**
16137
- * Creates a wNAF precomputation window. Used for caching.
16138
- * Default window size is set by `utils.precompute()` and is equal to 8.
16139
- * Number of precomputed points depends on the curve size:
16140
- * 2^(𝑊−1) * (Math.ceil(𝑛 / 𝑊) + 1), where:
16141
- * - 𝑊 is the window size
16142
- * - 𝑛 is the bitlength of the curve order.
16143
- * For a 256-bit curve and window size 8, the number of precomputed points is 128 * 33 = 4224.
16144
- * @param elm Point instance
16145
- * @param W window size
16146
- * @returns precomputed point tables flattened to a single array
16147
- */
16148
- precomputeWindow(elm, W) {
16149
- const { windows, windowSize } = calcWOpts2(W, bits);
16150
- const points = [];
16151
- let p = elm;
16152
- let base = p;
16153
- for (let window2 = 0; window2 < windows; window2++) {
16154
- base = p;
16155
- points.push(base);
16156
- for (let i = 1; i < windowSize; i++) {
16157
- base = base.add(p);
16158
- points.push(base);
16159
- }
16160
- p = base.double();
16161
- }
16162
- return points;
16163
- },
16164
- /**
16165
- * Implements ec multiplication using precomputed tables and w-ary non-adjacent form.
16166
- * @param W window size
16167
- * @param precomputes precomputed tables
16168
- * @param n scalar (we don't check here, but should be less than curve order)
16169
- * @returns real and fake (for const-time) points
16170
- */
16171
- wNAF(W, precomputes, n) {
16172
- let p = c.ZERO;
16173
- let f = c.BASE;
16174
- const wo = calcWOpts2(W, bits);
16175
- for (let window2 = 0; window2 < wo.windows; window2++) {
16176
- const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets2(n, window2, wo);
16177
- n = nextN;
16178
- if (isZero) {
16179
- f = f.add(constTimeNegate2(isNegF, precomputes[offsetF]));
16180
- } else {
16181
- p = p.add(constTimeNegate2(isNeg, precomputes[offset]));
16182
- }
16183
- }
16184
- return { p, f };
16185
- },
16186
- /**
16187
- * Implements ec unsafe (non const-time) multiplication using precomputed tables and w-ary non-adjacent form.
16188
- * @param W window size
16189
- * @param precomputes precomputed tables
16190
- * @param n scalar (we don't check here, but should be less than curve order)
16191
- * @param acc accumulator point to add result of multiplication
16192
- * @returns point
16193
- */
16194
- wNAFUnsafe(W, precomputes, n, acc = c.ZERO) {
16195
- const wo = calcWOpts2(W, bits);
16196
- for (let window2 = 0; window2 < wo.windows; window2++) {
16197
- if (n === _0n9)
16198
- break;
16199
- const { nextN, offset, isZero, isNeg } = calcOffsets2(n, window2, wo);
16200
- n = nextN;
16201
- if (isZero) {
16202
- continue;
16203
- } else {
16204
- const item = precomputes[offset];
16205
- acc = acc.add(isNeg ? item.negate() : item);
16206
- }
16207
- }
16208
- return acc;
16209
- },
16210
- getPrecomputes(W, P, transform) {
16211
- let comp = pointPrecomputes2.get(P);
16212
- if (!comp) {
16213
- comp = this.precomputeWindow(P, W);
16214
- if (W !== 1)
16215
- pointPrecomputes2.set(P, transform(comp));
16216
- }
16217
- return comp;
16218
- },
16219
- wNAFCached(P, n, transform) {
16220
- const W = getW2(P);
16221
- return this.wNAF(W, this.getPrecomputes(W, P, transform), n);
16222
- },
16223
- wNAFCachedUnsafe(P, n, transform, prev) {
16224
- const W = getW2(P);
16225
- if (W === 1)
16226
- return this.unsafeLadder(P, n, prev);
16227
- return this.wNAFUnsafe(W, this.getPrecomputes(W, P, transform), n, prev);
16228
- },
16229
- // We calculate precomputes for elliptic curve point multiplication
16230
- // using windowed method. This specifies window size and
16231
- // stores precomputed values. Usually only base point would be precomputed.
16232
- setWindowSize(P, W) {
16233
- validateW2(W, bits);
16234
- pointWindowSizes2.set(P, W);
16235
- pointPrecomputes2.delete(P);
16236
- }
16237
- };
16238
- }
16239
- function pippenger2(c, fieldN, points, scalars) {
16240
- validateMSMPoints2(points, c);
16241
- validateMSMScalars2(scalars, fieldN);
16242
- const plength = points.length;
16243
- const slength = scalars.length;
16244
- if (plength !== slength)
16245
- throw new Error("arrays of points and scalars must have equal length");
16246
- const zero = c.ZERO;
16247
- const wbits = bitLen2(BigInt(plength));
16248
- let windowSize = 1;
16249
- if (wbits > 12)
16250
- windowSize = wbits - 3;
16251
- else if (wbits > 4)
16252
- windowSize = wbits - 2;
16253
- else if (wbits > 0)
16254
- windowSize = 2;
16255
- const MASK = bitMask2(windowSize);
16256
- const buckets = new Array(Number(MASK) + 1).fill(zero);
16257
- const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
16258
- let sum = zero;
16259
- for (let i = lastBits; i >= 0; i -= windowSize) {
16260
- buckets.fill(zero);
16261
- for (let j = 0; j < slength; j++) {
16262
- const scalar = scalars[j];
16263
- const wbits2 = Number(scalar >> BigInt(i) & MASK);
16264
- buckets[wbits2] = buckets[wbits2].add(points[j]);
16265
- }
16266
- let resI = zero;
16267
- for (let j = buckets.length - 1, sumI = zero; j > 0; j--) {
16268
- sumI = sumI.add(buckets[j]);
16269
- resI = resI.add(sumI);
16270
- }
16271
- sum = sum.add(resI);
16272
- if (i !== 0)
16273
- for (let j = 0; j < windowSize; j++)
16274
- sum = sum.double();
16275
- }
16276
- return sum;
16277
- }
16278
- function validateBasic2(curve) {
16279
- validateField2(curve.Fp);
16280
- validateObject2(curve, {
16281
- n: "bigint",
16282
- h: "bigint",
16283
- Gx: "field",
16284
- Gy: "field"
16285
- }, {
16286
- nBitLength: "isSafeInteger",
16287
- nByteLength: "isSafeInteger"
16288
- });
16289
- return Object.freeze({
16290
- ...nLength2(curve.n, curve.nBitLength),
16291
- ...curve,
16292
- ...{ p: curve.Fp.ORDER }
16293
- });
16294
- }
16295
-
16296
- // ../node_modules/ox/node_modules/@noble/curves/esm/abstract/weierstrass.js
16297
- init_utils5();
16298
- function validateSigVerOpts2(opts) {
16299
- if (opts.lowS !== void 0)
16300
- abool2("lowS", opts.lowS);
16301
- if (opts.prehash !== void 0)
16302
- abool2("prehash", opts.prehash);
16303
- }
16304
- function validatePointOpts2(curve) {
16305
- const opts = validateBasic2(curve);
16306
- validateObject2(opts, {
16307
- a: "field",
16308
- b: "field"
16309
- }, {
16310
- allowInfinityPoint: "boolean",
16311
- allowedPrivateKeyLengths: "array",
16312
- clearCofactor: "function",
16313
- fromBytes: "function",
16314
- isTorsionFree: "function",
16315
- toBytes: "function",
16316
- wrapPrivateKey: "boolean"
16317
- });
16318
- const { endo, Fp, a } = opts;
16319
- if (endo) {
16320
- if (!Fp.eql(a, Fp.ZERO)) {
16321
- throw new Error("invalid endo: CURVE.a must be 0");
16322
- }
16323
- if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
16324
- throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');
16325
- }
16326
- }
16327
- return Object.freeze({ ...opts });
16328
- }
16329
- var DERErr2 = class extends Error {
16330
- constructor(m = "") {
16331
- super(m);
16332
- }
16333
- };
16334
- var DER2 = {
16335
- // asn.1 DER encoding utils
16336
- Err: DERErr2,
16337
- // Basic building block is TLV (Tag-Length-Value)
16338
- _tlv: {
16339
- encode: (tag, data) => {
16340
- const { Err: E } = DER2;
16341
- if (tag < 0 || tag > 256)
16342
- throw new E("tlv.encode: wrong tag");
16343
- if (data.length & 1)
16344
- throw new E("tlv.encode: unpadded data");
16345
- const dataLen = data.length / 2;
16346
- const len = numberToHexUnpadded2(dataLen);
16347
- if (len.length / 2 & 128)
16348
- throw new E("tlv.encode: long form length too big");
16349
- const lenLen = dataLen > 127 ? numberToHexUnpadded2(len.length / 2 | 128) : "";
16350
- const t = numberToHexUnpadded2(tag);
16351
- return t + lenLen + len + data;
16352
- },
16353
- // v - value, l - left bytes (unparsed)
16354
- decode(tag, data) {
16355
- const { Err: E } = DER2;
16356
- let pos = 0;
16357
- if (tag < 0 || tag > 256)
16358
- throw new E("tlv.encode: wrong tag");
16359
- if (data.length < 2 || data[pos++] !== tag)
16360
- throw new E("tlv.decode: wrong tlv");
16361
- const first = data[pos++];
16362
- const isLong = !!(first & 128);
16363
- let length = 0;
16364
- if (!isLong)
16365
- length = first;
16366
- else {
16367
- const lenLen = first & 127;
16368
- if (!lenLen)
16369
- throw new E("tlv.decode(long): indefinite length not supported");
16370
- if (lenLen > 4)
16371
- throw new E("tlv.decode(long): byte length is too big");
16372
- const lengthBytes = data.subarray(pos, pos + lenLen);
16373
- if (lengthBytes.length !== lenLen)
16374
- throw new E("tlv.decode: length bytes not complete");
16375
- if (lengthBytes[0] === 0)
16376
- throw new E("tlv.decode(long): zero leftmost byte");
16377
- for (const b of lengthBytes)
16378
- length = length << 8 | b;
16379
- pos += lenLen;
16380
- if (length < 128)
16381
- throw new E("tlv.decode(long): not minimal encoding");
16382
- }
16383
- const v = data.subarray(pos, pos + length);
16384
- if (v.length !== length)
16385
- throw new E("tlv.decode: wrong value length");
16386
- return { v, l: data.subarray(pos + length) };
16387
- }
16388
- },
16389
- // https://crypto.stackexchange.com/a/57734 Leftmost bit of first byte is 'negative' flag,
16390
- // since we always use positive integers here. It must always be empty:
16391
- // - add zero byte if exists
16392
- // - if next byte doesn't have a flag, leading zero is not allowed (minimal encoding)
16393
- _int: {
16394
- encode(num2) {
16395
- const { Err: E } = DER2;
16396
- if (num2 < _0n10)
16397
- throw new E("integer: negative integers are not allowed");
16398
- let hex = numberToHexUnpadded2(num2);
16399
- if (Number.parseInt(hex[0], 16) & 8)
16400
- hex = "00" + hex;
16401
- if (hex.length & 1)
16402
- throw new E("unexpected DER parsing assertion: unpadded hex");
16403
- return hex;
16404
- },
16405
- decode(data) {
16406
- const { Err: E } = DER2;
16407
- if (data[0] & 128)
16408
- throw new E("invalid signature integer: negative");
16409
- if (data[0] === 0 && !(data[1] & 128))
16410
- throw new E("invalid signature integer: unnecessary leading zero");
16411
- return bytesToNumberBE2(data);
16412
- }
16413
- },
16414
- toSig(hex) {
16415
- const { Err: E, _int: int, _tlv: tlv } = DER2;
16416
- const data = ensureBytes2("signature", hex);
16417
- const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
16418
- if (seqLeftBytes.length)
16419
- throw new E("invalid signature: left bytes after parsing");
16420
- const { v: rBytes, l: rLeftBytes } = tlv.decode(2, seqBytes);
16421
- const { v: sBytes, l: sLeftBytes } = tlv.decode(2, rLeftBytes);
16422
- if (sLeftBytes.length)
16423
- throw new E("invalid signature: left bytes after parsing");
16424
- return { r: int.decode(rBytes), s: int.decode(sBytes) };
16425
- },
16426
- hexFromSig(sig) {
16427
- const { _tlv: tlv, _int: int } = DER2;
16428
- const rs = tlv.encode(2, int.encode(sig.r));
16429
- const ss = tlv.encode(2, int.encode(sig.s));
16430
- const seq = rs + ss;
16431
- return tlv.encode(48, seq);
16432
- }
16433
- };
16434
- function numToSizedHex2(num2, size5) {
16435
- return bytesToHex3(numberToBytesBE2(num2, size5));
16436
- }
16437
- var _0n10 = BigInt(0);
16438
- var _1n10 = BigInt(1);
16439
- BigInt(2);
16440
- var _3n4 = BigInt(3);
16441
- var _4n4 = BigInt(4);
16442
- function weierstrassPoints2(opts) {
16443
- const CURVE = validatePointOpts2(opts);
16444
- const { Fp } = CURVE;
16445
- const Fn = Field2(CURVE.n, CURVE.nBitLength);
16446
- const toBytes4 = CURVE.toBytes || ((_c, point, _isCompressed) => {
16447
- const a = point.toAffine();
16448
- return concatBytes4(Uint8Array.from([4]), Fp.toBytes(a.x), Fp.toBytes(a.y));
16449
- });
16450
- const fromBytes4 = CURVE.fromBytes || ((bytes) => {
16451
- const tail = bytes.subarray(1);
16452
- const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
16453
- const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
16454
- return { x, y };
16455
- });
16456
- function weierstrassEquation(x) {
16457
- const { a, b } = CURVE;
16458
- const x2 = Fp.sqr(x);
16459
- const x3 = Fp.mul(x2, x);
16460
- return Fp.add(Fp.add(x3, Fp.mul(x, a)), b);
16461
- }
16462
- function isValidXY(x, y) {
16463
- const left = Fp.sqr(y);
16464
- const right = weierstrassEquation(x);
16465
- return Fp.eql(left, right);
16466
- }
16467
- if (!isValidXY(CURVE.Gx, CURVE.Gy))
16468
- throw new Error("bad curve params: generator point");
16469
- const _4a3 = Fp.mul(Fp.pow(CURVE.a, _3n4), _4n4);
16470
- const _27b2 = Fp.mul(Fp.sqr(CURVE.b), BigInt(27));
16471
- if (Fp.is0(Fp.add(_4a3, _27b2)))
16472
- throw new Error("bad curve params: a or b");
16473
- function isWithinCurveOrder(num2) {
16474
- return inRange2(num2, _1n10, CURVE.n);
16475
- }
16476
- function normPrivateKeyToScalar(key) {
16477
- const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;
16478
- if (lengths && typeof key !== "bigint") {
16479
- if (isBytes3(key))
16480
- key = bytesToHex3(key);
16481
- if (typeof key !== "string" || !lengths.includes(key.length))
16482
- throw new Error("invalid private key");
16483
- key = key.padStart(nByteLength * 2, "0");
16484
- }
16485
- let num2;
16486
- try {
16487
- num2 = typeof key === "bigint" ? key : bytesToNumberBE2(ensureBytes2("private key", key, nByteLength));
16488
- } catch (error) {
16489
- throw new Error("invalid private key, expected hex or " + nByteLength + " bytes, got " + typeof key);
16490
- }
16491
- if (wrapPrivateKey)
16492
- num2 = mod2(num2, N);
16493
- aInRange2("private key", num2, _1n10, N);
16494
- return num2;
16495
- }
16496
- function aprjpoint(other) {
16497
- if (!(other instanceof Point2))
16498
- throw new Error("ProjectivePoint expected");
16499
- }
16500
- const toAffineMemo = memoized2((p, iz) => {
16501
- const { px: x, py: y, pz: z } = p;
16502
- if (Fp.eql(z, Fp.ONE))
16503
- return { x, y };
16504
- const is0 = p.is0();
16505
- if (iz == null)
16506
- iz = is0 ? Fp.ONE : Fp.inv(z);
16507
- const ax = Fp.mul(x, iz);
16508
- const ay = Fp.mul(y, iz);
16509
- const zz = Fp.mul(z, iz);
16510
- if (is0)
16511
- return { x: Fp.ZERO, y: Fp.ZERO };
16512
- if (!Fp.eql(zz, Fp.ONE))
16513
- throw new Error("invZ was invalid");
16514
- return { x: ax, y: ay };
16515
- });
16516
- const assertValidMemo = memoized2((p) => {
16517
- if (p.is0()) {
16518
- if (CURVE.allowInfinityPoint && !Fp.is0(p.py))
16519
- return;
16520
- throw new Error("bad point: ZERO");
16521
- }
16522
- const { x, y } = p.toAffine();
16523
- if (!Fp.isValid(x) || !Fp.isValid(y))
16524
- throw new Error("bad point: x or y not FE");
16525
- if (!isValidXY(x, y))
16526
- throw new Error("bad point: equation left != right");
16527
- if (!p.isTorsionFree())
16528
- throw new Error("bad point: not in prime-order subgroup");
16529
- return true;
16530
- });
16531
- class Point2 {
16532
- constructor(px, py, pz) {
16533
- if (px == null || !Fp.isValid(px))
16534
- throw new Error("x required");
16535
- if (py == null || !Fp.isValid(py) || Fp.is0(py))
16536
- throw new Error("y required");
16537
- if (pz == null || !Fp.isValid(pz))
16538
- throw new Error("z required");
16539
- this.px = px;
16540
- this.py = py;
16541
- this.pz = pz;
16542
- Object.freeze(this);
16543
- }
16544
- // Does not validate if the point is on-curve.
16545
- // Use fromHex instead, or call assertValidity() later.
16546
- static fromAffine(p) {
16547
- const { x, y } = p || {};
16548
- if (!p || !Fp.isValid(x) || !Fp.isValid(y))
16549
- throw new Error("invalid affine point");
16550
- if (p instanceof Point2)
16551
- throw new Error("projective point not allowed");
16552
- const is0 = (i) => Fp.eql(i, Fp.ZERO);
16553
- if (is0(x) && is0(y))
16554
- return Point2.ZERO;
16555
- return new Point2(x, y, Fp.ONE);
16556
- }
16557
- get x() {
16558
- return this.toAffine().x;
16559
- }
16560
- get y() {
16561
- return this.toAffine().y;
16562
- }
16563
- /**
16564
- * Takes a bunch of Projective Points but executes only one
16565
- * inversion on all of them. Inversion is very slow operation,
16566
- * so this improves performance massively.
16567
- * Optimization: converts a list of projective points to a list of identical points with Z=1.
16568
- */
16569
- static normalizeZ(points) {
16570
- const toInv = FpInvertBatch2(Fp, points.map((p) => p.pz));
16571
- return points.map((p, i) => p.toAffine(toInv[i])).map(Point2.fromAffine);
16572
- }
16573
- /**
16574
- * Converts hash string or Uint8Array to Point.
16575
- * @param hex short/long ECDSA hex
16576
- */
16577
- static fromHex(hex) {
16578
- const P = Point2.fromAffine(fromBytes4(ensureBytes2("pointHex", hex)));
16579
- P.assertValidity();
16580
- return P;
16581
- }
16582
- // Multiplies generator point by privateKey.
16583
- static fromPrivateKey(privateKey) {
16584
- return Point2.BASE.multiply(normPrivateKeyToScalar(privateKey));
16585
- }
16586
- // Multiscalar Multiplication
16587
- static msm(points, scalars) {
16588
- return pippenger2(Point2, Fn, points, scalars);
16589
- }
16590
- // "Private method", don't use it directly
16591
- _setWindowSize(windowSize) {
16592
- wnaf.setWindowSize(this, windowSize);
16593
- }
16594
- // A point on curve is valid if it conforms to equation.
16595
- assertValidity() {
16596
- assertValidMemo(this);
16597
- }
16598
- hasEvenY() {
16599
- const { y } = this.toAffine();
16600
- if (Fp.isOdd)
16601
- return !Fp.isOdd(y);
16602
- throw new Error("Field doesn't support isOdd");
16603
- }
16604
- /**
16605
- * Compare one point to another.
16606
- */
16607
- equals(other) {
16608
- aprjpoint(other);
16609
- const { px: X1, py: Y1, pz: Z1 } = this;
16610
- const { px: X2, py: Y2, pz: Z2 } = other;
16611
- const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));
16612
- const U2 = Fp.eql(Fp.mul(Y1, Z2), Fp.mul(Y2, Z1));
16613
- return U1 && U2;
16614
- }
16615
- /**
16616
- * Flips point to one corresponding to (x, -y) in Affine coordinates.
16617
- */
16618
- negate() {
16619
- return new Point2(this.px, Fp.neg(this.py), this.pz);
16620
- }
16621
- // Renes-Costello-Batina exception-free doubling formula.
16622
- // There is 30% faster Jacobian formula, but it is not complete.
16623
- // https://eprint.iacr.org/2015/1060, algorithm 3
16624
- // Cost: 8M + 3S + 3*a + 2*b3 + 15add.
16625
- double() {
16626
- const { a, b } = CURVE;
16627
- const b3 = Fp.mul(b, _3n4);
16628
- const { px: X1, py: Y1, pz: Z1 } = this;
16629
- let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
16630
- let t0 = Fp.mul(X1, X1);
16631
- let t1 = Fp.mul(Y1, Y1);
16632
- let t2 = Fp.mul(Z1, Z1);
16633
- let t3 = Fp.mul(X1, Y1);
16634
- t3 = Fp.add(t3, t3);
16635
- Z3 = Fp.mul(X1, Z1);
16636
- Z3 = Fp.add(Z3, Z3);
16637
- X3 = Fp.mul(a, Z3);
16638
- Y3 = Fp.mul(b3, t2);
16639
- Y3 = Fp.add(X3, Y3);
16640
- X3 = Fp.sub(t1, Y3);
16641
- Y3 = Fp.add(t1, Y3);
16642
- Y3 = Fp.mul(X3, Y3);
16643
- X3 = Fp.mul(t3, X3);
16644
- Z3 = Fp.mul(b3, Z3);
16645
- t2 = Fp.mul(a, t2);
16646
- t3 = Fp.sub(t0, t2);
16647
- t3 = Fp.mul(a, t3);
16648
- t3 = Fp.add(t3, Z3);
16649
- Z3 = Fp.add(t0, t0);
16650
- t0 = Fp.add(Z3, t0);
16651
- t0 = Fp.add(t0, t2);
16652
- t0 = Fp.mul(t0, t3);
16653
- Y3 = Fp.add(Y3, t0);
16654
- t2 = Fp.mul(Y1, Z1);
16655
- t2 = Fp.add(t2, t2);
16656
- t0 = Fp.mul(t2, t3);
16657
- X3 = Fp.sub(X3, t0);
16658
- Z3 = Fp.mul(t2, t1);
16659
- Z3 = Fp.add(Z3, Z3);
16660
- Z3 = Fp.add(Z3, Z3);
16661
- return new Point2(X3, Y3, Z3);
16662
- }
16663
- // Renes-Costello-Batina exception-free addition formula.
16664
- // There is 30% faster Jacobian formula, but it is not complete.
16665
- // https://eprint.iacr.org/2015/1060, algorithm 1
16666
- // Cost: 12M + 0S + 3*a + 3*b3 + 23add.
16667
- add(other) {
16668
- aprjpoint(other);
16669
- const { px: X1, py: Y1, pz: Z1 } = this;
16670
- const { px: X2, py: Y2, pz: Z2 } = other;
16671
- let X3 = Fp.ZERO, Y3 = Fp.ZERO, Z3 = Fp.ZERO;
16672
- const a = CURVE.a;
16673
- const b3 = Fp.mul(CURVE.b, _3n4);
16674
- let t0 = Fp.mul(X1, X2);
16675
- let t1 = Fp.mul(Y1, Y2);
16676
- let t2 = Fp.mul(Z1, Z2);
16677
- let t3 = Fp.add(X1, Y1);
16678
- let t4 = Fp.add(X2, Y2);
16679
- t3 = Fp.mul(t3, t4);
16680
- t4 = Fp.add(t0, t1);
16681
- t3 = Fp.sub(t3, t4);
16682
- t4 = Fp.add(X1, Z1);
16683
- let t5 = Fp.add(X2, Z2);
16684
- t4 = Fp.mul(t4, t5);
16685
- t5 = Fp.add(t0, t2);
16686
- t4 = Fp.sub(t4, t5);
16687
- t5 = Fp.add(Y1, Z1);
16688
- X3 = Fp.add(Y2, Z2);
16689
- t5 = Fp.mul(t5, X3);
16690
- X3 = Fp.add(t1, t2);
16691
- t5 = Fp.sub(t5, X3);
16692
- Z3 = Fp.mul(a, t4);
16693
- X3 = Fp.mul(b3, t2);
16694
- Z3 = Fp.add(X3, Z3);
16695
- X3 = Fp.sub(t1, Z3);
16696
- Z3 = Fp.add(t1, Z3);
16697
- Y3 = Fp.mul(X3, Z3);
16698
- t1 = Fp.add(t0, t0);
16699
- t1 = Fp.add(t1, t0);
16700
- t2 = Fp.mul(a, t2);
16701
- t4 = Fp.mul(b3, t4);
16702
- t1 = Fp.add(t1, t2);
16703
- t2 = Fp.sub(t0, t2);
16704
- t2 = Fp.mul(a, t2);
16705
- t4 = Fp.add(t4, t2);
16706
- t0 = Fp.mul(t1, t4);
16707
- Y3 = Fp.add(Y3, t0);
16708
- t0 = Fp.mul(t5, t4);
16709
- X3 = Fp.mul(t3, X3);
16710
- X3 = Fp.sub(X3, t0);
16711
- t0 = Fp.mul(t3, t1);
16712
- Z3 = Fp.mul(t5, Z3);
16713
- Z3 = Fp.add(Z3, t0);
16714
- return new Point2(X3, Y3, Z3);
16715
- }
16716
- subtract(other) {
16717
- return this.add(other.negate());
16718
- }
16719
- is0() {
16720
- return this.equals(Point2.ZERO);
16721
- }
16722
- wNAF(n) {
16723
- return wnaf.wNAFCached(this, n, Point2.normalizeZ);
16724
- }
16725
- /**
16726
- * Non-constant-time multiplication. Uses double-and-add algorithm.
16727
- * It's faster, but should only be used when you don't care about
16728
- * an exposed private key e.g. sig verification, which works over *public* keys.
16729
- */
16730
- multiplyUnsafe(sc) {
16731
- const { endo: endo2, n: N } = CURVE;
16732
- aInRange2("scalar", sc, _0n10, N);
16733
- const I = Point2.ZERO;
16734
- if (sc === _0n10)
16735
- return I;
16736
- if (this.is0() || sc === _1n10)
16737
- return this;
16738
- if (!endo2 || wnaf.hasPrecomputes(this))
16739
- return wnaf.wNAFCachedUnsafe(this, sc, Point2.normalizeZ);
16740
- let { k1neg, k1, k2neg, k2 } = endo2.splitScalar(sc);
16741
- let k1p = I;
16742
- let k2p = I;
16743
- let d = this;
16744
- while (k1 > _0n10 || k2 > _0n10) {
16745
- if (k1 & _1n10)
16746
- k1p = k1p.add(d);
16747
- if (k2 & _1n10)
16748
- k2p = k2p.add(d);
16749
- d = d.double();
16750
- k1 >>= _1n10;
16751
- k2 >>= _1n10;
16752
- }
16753
- if (k1neg)
16754
- k1p = k1p.negate();
16755
- if (k2neg)
16756
- k2p = k2p.negate();
16757
- k2p = new Point2(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
16758
- return k1p.add(k2p);
16759
- }
16760
- /**
16761
- * Constant time multiplication.
16762
- * Uses wNAF method. Windowed method may be 10% faster,
16763
- * but takes 2x longer to generate and consumes 2x memory.
16764
- * Uses precomputes when available.
16765
- * Uses endomorphism for Koblitz curves.
16766
- * @param scalar by which the point would be multiplied
16767
- * @returns New point
16768
- */
16769
- multiply(scalar) {
16770
- const { endo: endo2, n: N } = CURVE;
16771
- aInRange2("scalar", scalar, _1n10, N);
16772
- let point, fake;
16773
- if (endo2) {
16774
- const { k1neg, k1, k2neg, k2 } = endo2.splitScalar(scalar);
16775
- let { p: k1p, f: f1p } = this.wNAF(k1);
16776
- let { p: k2p, f: f2p } = this.wNAF(k2);
16777
- k1p = wnaf.constTimeNegate(k1neg, k1p);
16778
- k2p = wnaf.constTimeNegate(k2neg, k2p);
16779
- k2p = new Point2(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
16780
- point = k1p.add(k2p);
16781
- fake = f1p.add(f2p);
16782
- } else {
16783
- const { p, f } = this.wNAF(scalar);
16784
- point = p;
16785
- fake = f;
16786
- }
16787
- return Point2.normalizeZ([point, fake])[0];
16788
- }
16789
- /**
16790
- * Efficiently calculate `aP + bQ`. Unsafe, can expose private key, if used incorrectly.
16791
- * Not using Strauss-Shamir trick: precomputation tables are faster.
16792
- * The trick could be useful if both P and Q are not G (not in our case).
16793
- * @returns non-zero affine point
16794
- */
16795
- multiplyAndAddUnsafe(Q, a, b) {
16796
- const G = Point2.BASE;
16797
- const mul = (P, a2) => a2 === _0n10 || a2 === _1n10 || !P.equals(G) ? P.multiplyUnsafe(a2) : P.multiply(a2);
16798
- const sum = mul(this, a).add(mul(Q, b));
16799
- return sum.is0() ? void 0 : sum;
16800
- }
16801
- // Converts Projective point to affine (x, y) coordinates.
16802
- // Can accept precomputed Z^-1 - for example, from invertBatch.
16803
- // (x, y, z) ∋ (x=x/z, y=y/z)
16804
- toAffine(iz) {
16805
- return toAffineMemo(this, iz);
16806
- }
16807
- isTorsionFree() {
16808
- const { h: cofactor, isTorsionFree } = CURVE;
16809
- if (cofactor === _1n10)
16810
- return true;
16811
- if (isTorsionFree)
16812
- return isTorsionFree(Point2, this);
16813
- throw new Error("isTorsionFree() has not been declared for the elliptic curve");
16814
- }
16815
- clearCofactor() {
16816
- const { h: cofactor, clearCofactor } = CURVE;
16817
- if (cofactor === _1n10)
16818
- return this;
16819
- if (clearCofactor)
16820
- return clearCofactor(Point2, this);
16821
- return this.multiplyUnsafe(CURVE.h);
16822
- }
16823
- toRawBytes(isCompressed = true) {
16824
- abool2("isCompressed", isCompressed);
16825
- this.assertValidity();
16826
- return toBytes4(Point2, this, isCompressed);
16827
- }
16828
- toHex(isCompressed = true) {
16829
- abool2("isCompressed", isCompressed);
16830
- return bytesToHex3(this.toRawBytes(isCompressed));
16831
- }
16832
- }
16833
- Point2.BASE = new Point2(CURVE.Gx, CURVE.Gy, Fp.ONE);
16834
- Point2.ZERO = new Point2(Fp.ZERO, Fp.ONE, Fp.ZERO);
16835
- const { endo, nBitLength } = CURVE;
16836
- const wnaf = wNAF2(Point2, endo ? Math.ceil(nBitLength / 2) : nBitLength);
16837
- return {
16838
- CURVE,
16839
- ProjectivePoint: Point2,
16840
- normPrivateKeyToScalar,
16841
- weierstrassEquation,
16842
- isWithinCurveOrder
16843
- };
16844
- }
16845
- function validateOpts2(curve) {
16846
- const opts = validateBasic2(curve);
16847
- validateObject2(opts, {
16848
- hash: "hash",
16849
- hmac: "function",
16850
- randomBytes: "function"
16851
- }, {
16852
- bits2int: "function",
16853
- bits2int_modN: "function",
16854
- lowS: "boolean"
16855
- });
16856
- return Object.freeze({ lowS: true, ...opts });
16857
- }
16858
- function weierstrass2(curveDef) {
16859
- const CURVE = validateOpts2(curveDef);
16860
- const { Fp, n: CURVE_ORDER, nByteLength, nBitLength } = CURVE;
16861
- const compressedLen = Fp.BYTES + 1;
16862
- const uncompressedLen = 2 * Fp.BYTES + 1;
16863
- function modN2(a) {
16864
- return mod2(a, CURVE_ORDER);
16865
- }
16866
- function invN(a) {
16867
- return invert2(a, CURVE_ORDER);
16868
- }
16869
- const { ProjectivePoint: Point2, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints2({
16870
- ...CURVE,
16871
- toBytes(_c, point, isCompressed) {
16872
- const a = point.toAffine();
16873
- const x = Fp.toBytes(a.x);
16874
- const cat = concatBytes4;
16875
- abool2("isCompressed", isCompressed);
16876
- if (isCompressed) {
16877
- return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
16878
- } else {
16879
- return cat(Uint8Array.from([4]), x, Fp.toBytes(a.y));
16880
- }
16881
- },
16882
- fromBytes(bytes) {
16883
- const len = bytes.length;
16884
- const head = bytes[0];
16885
- const tail = bytes.subarray(1);
16886
- if (len === compressedLen && (head === 2 || head === 3)) {
16887
- const x = bytesToNumberBE2(tail);
16888
- if (!inRange2(x, _1n10, Fp.ORDER))
16889
- throw new Error("Point is not on curve");
16890
- const y2 = weierstrassEquation(x);
16891
- let y;
16892
- try {
16893
- y = Fp.sqrt(y2);
16894
- } catch (sqrtError) {
16895
- const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
16896
- throw new Error("Point is not on curve" + suffix);
16897
- }
16898
- const isYOdd = (y & _1n10) === _1n10;
16899
- const isHeadOdd = (head & 1) === 1;
16900
- if (isHeadOdd !== isYOdd)
16901
- y = Fp.neg(y);
16902
- return { x, y };
16903
- } else if (len === uncompressedLen && head === 4) {
16904
- const x = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
16905
- const y = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
16906
- return { x, y };
16907
- } else {
16908
- const cl = compressedLen;
16909
- const ul = uncompressedLen;
16910
- throw new Error("invalid Point, expected length of " + cl + ", or uncompressed " + ul + ", got " + len);
16911
- }
16912
- }
16913
- });
16914
- function isBiggerThanHalfOrder(number) {
16915
- const HALF = CURVE_ORDER >> _1n10;
16916
- return number > HALF;
16917
- }
16918
- function normalizeS(s) {
16919
- return isBiggerThanHalfOrder(s) ? modN2(-s) : s;
16920
- }
16921
- const slcNum = (b, from14, to) => bytesToNumberBE2(b.slice(from14, to));
16922
- class Signature {
16923
- constructor(r, s, recovery) {
16924
- aInRange2("r", r, _1n10, CURVE_ORDER);
16925
- aInRange2("s", s, _1n10, CURVE_ORDER);
16926
- this.r = r;
16927
- this.s = s;
16928
- if (recovery != null)
16929
- this.recovery = recovery;
16930
- Object.freeze(this);
16931
- }
16932
- // pair (bytes of r, bytes of s)
16933
- static fromCompact(hex) {
16934
- const l = nByteLength;
16935
- hex = ensureBytes2("compactSignature", hex, l * 2);
16936
- return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
16937
- }
16938
- // DER encoded ECDSA signature
16939
- // https://bitcoin.stackexchange.com/questions/57644/what-are-the-parts-of-a-bitcoin-transaction-input-script
16940
- static fromDER(hex) {
16941
- const { r, s } = DER2.toSig(ensureBytes2("DER", hex));
16942
- return new Signature(r, s);
16943
- }
16944
- /**
16945
- * @todo remove
16946
- * @deprecated
16947
- */
16948
- assertValidity() {
16949
- }
16950
- addRecoveryBit(recovery) {
16951
- return new Signature(this.r, this.s, recovery);
16952
- }
16953
- recoverPublicKey(msgHash) {
16954
- const { r, s, recovery: rec } = this;
16955
- const h = bits2int_modN(ensureBytes2("msgHash", msgHash));
16956
- if (rec == null || ![0, 1, 2, 3].includes(rec))
16957
- throw new Error("recovery id invalid");
16958
- const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;
16959
- if (radj >= Fp.ORDER)
16960
- throw new Error("recovery id 2 or 3 invalid");
16961
- const prefix = (rec & 1) === 0 ? "02" : "03";
16962
- const R = Point2.fromHex(prefix + numToSizedHex2(radj, Fp.BYTES));
16963
- const ir = invN(radj);
16964
- const u1 = modN2(-h * ir);
16965
- const u2 = modN2(s * ir);
16966
- const Q = Point2.BASE.multiplyAndAddUnsafe(R, u1, u2);
16967
- if (!Q)
16968
- throw new Error("point at infinify");
16969
- Q.assertValidity();
16970
- return Q;
16971
- }
16972
- // Signatures should be low-s, to prevent malleability.
16973
- hasHighS() {
16974
- return isBiggerThanHalfOrder(this.s);
16975
- }
16976
- normalizeS() {
16977
- return this.hasHighS() ? new Signature(this.r, modN2(-this.s), this.recovery) : this;
16978
- }
16979
- // DER-encoded
16980
- toDERRawBytes() {
16981
- return hexToBytes3(this.toDERHex());
16982
- }
16983
- toDERHex() {
16984
- return DER2.hexFromSig(this);
16985
- }
16986
- // padded bytes of r, then padded bytes of s
16987
- toCompactRawBytes() {
16988
- return hexToBytes3(this.toCompactHex());
16989
- }
16990
- toCompactHex() {
16991
- const l = nByteLength;
16992
- return numToSizedHex2(this.r, l) + numToSizedHex2(this.s, l);
16993
- }
16994
- }
16995
- const utils = {
16996
- isValidPrivateKey(privateKey) {
16997
- try {
16998
- normPrivateKeyToScalar(privateKey);
16999
- return true;
17000
- } catch (error) {
17001
- return false;
17002
- }
17003
- },
17004
- normPrivateKeyToScalar,
17005
- /**
17006
- * Produces cryptographically secure private key from random of size
17007
- * (groupLen + ceil(groupLen / 2)) with modulo bias being negligible.
17008
- */
17009
- randomPrivateKey: () => {
17010
- const length = getMinHashLength2(CURVE.n);
17011
- return mapHashToField2(CURVE.randomBytes(length), CURVE.n);
17012
- },
17013
- /**
17014
- * Creates precompute table for an arbitrary EC point. Makes point "cached".
17015
- * Allows to massively speed-up `point.multiply(scalar)`.
17016
- * @returns cached point
17017
- * @example
17018
- * const fast = utils.precompute(8, ProjectivePoint.fromHex(someonesPubKey));
17019
- * fast.multiply(privKey); // much faster ECDH now
17020
- */
17021
- precompute(windowSize = 8, point = Point2.BASE) {
17022
- point._setWindowSize(windowSize);
17023
- point.multiply(BigInt(3));
17024
- return point;
17025
- }
17026
- };
17027
- function getPublicKey(privateKey, isCompressed = true) {
17028
- return Point2.fromPrivateKey(privateKey).toRawBytes(isCompressed);
17029
- }
17030
- function isProbPub(item) {
17031
- if (typeof item === "bigint")
17032
- return false;
17033
- if (item instanceof Point2)
17034
- return true;
17035
- const arr = ensureBytes2("key", item);
17036
- const len = arr.length;
17037
- const fpl = Fp.BYTES;
17038
- const compLen = fpl + 1;
17039
- const uncompLen = 2 * fpl + 1;
17040
- if (CURVE.allowedPrivateKeyLengths || nByteLength === compLen) {
17041
- return void 0;
17042
- } else {
17043
- return len === compLen || len === uncompLen;
17044
- }
17045
- }
17046
- function getSharedSecret(privateA, publicB, isCompressed = true) {
17047
- if (isProbPub(privateA) === true)
17048
- throw new Error("first arg must be private key");
17049
- if (isProbPub(publicB) === false)
17050
- throw new Error("second arg must be public key");
17051
- const b = Point2.fromHex(publicB);
17052
- return b.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
17053
- }
17054
- const bits2int = CURVE.bits2int || function(bytes) {
17055
- if (bytes.length > 8192)
17056
- throw new Error("input is too large");
17057
- const num2 = bytesToNumberBE2(bytes);
17058
- const delta = bytes.length * 8 - nBitLength;
17059
- return delta > 0 ? num2 >> BigInt(delta) : num2;
17060
- };
17061
- const bits2int_modN = CURVE.bits2int_modN || function(bytes) {
17062
- return modN2(bits2int(bytes));
17063
- };
17064
- const ORDER_MASK = bitMask2(nBitLength);
17065
- function int2octets(num2) {
17066
- aInRange2("num < 2^" + nBitLength, num2, _0n10, ORDER_MASK);
17067
- return numberToBytesBE2(num2, nByteLength);
17068
- }
17069
- function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
17070
- if (["recovered", "canonical"].some((k) => k in opts))
17071
- throw new Error("sign() legacy options not supported");
17072
- const { hash: hash3, randomBytes: randomBytes2 } = CURVE;
17073
- let { lowS, prehash, extraEntropy: ent } = opts;
17074
- if (lowS == null)
17075
- lowS = true;
17076
- msgHash = ensureBytes2("msgHash", msgHash);
17077
- validateSigVerOpts2(opts);
17078
- if (prehash)
17079
- msgHash = ensureBytes2("prehashed msgHash", hash3(msgHash));
17080
- const h1int = bits2int_modN(msgHash);
17081
- const d = normPrivateKeyToScalar(privateKey);
17082
- const seedArgs = [int2octets(d), int2octets(h1int)];
17083
- if (ent != null && ent !== false) {
17084
- const e = ent === true ? randomBytes2(Fp.BYTES) : ent;
17085
- seedArgs.push(ensureBytes2("extraEntropy", e));
17086
- }
17087
- const seed = concatBytes4(...seedArgs);
17088
- const m = h1int;
17089
- function k2sig(kBytes) {
17090
- const k = bits2int(kBytes);
17091
- if (!isWithinCurveOrder(k))
17092
- return;
17093
- const ik = invN(k);
17094
- const q = Point2.BASE.multiply(k).toAffine();
17095
- const r = modN2(q.x);
17096
- if (r === _0n10)
17097
- return;
17098
- const s = modN2(ik * modN2(m + r * d));
17099
- if (s === _0n10)
17100
- return;
17101
- let recovery = (q.x === r ? 0 : 2) | Number(q.y & _1n10);
17102
- let normS = s;
17103
- if (lowS && isBiggerThanHalfOrder(s)) {
17104
- normS = normalizeS(s);
17105
- recovery ^= 1;
17106
- }
17107
- return new Signature(r, normS, recovery);
17108
- }
17109
- return { seed, k2sig };
17110
- }
17111
- const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };
17112
- const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };
17113
- function sign(msgHash, privKey, opts = defaultSigOpts) {
17114
- const { seed, k2sig } = prepSig(msgHash, privKey, opts);
17115
- const C = CURVE;
17116
- const drbg = createHmacDrbg2(C.hash.outputLen, C.nByteLength, C.hmac);
17117
- return drbg(seed, k2sig);
17118
- }
17119
- Point2.BASE._setWindowSize(8);
17120
- function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
17121
- const sg = signature;
17122
- msgHash = ensureBytes2("msgHash", msgHash);
17123
- publicKey = ensureBytes2("publicKey", publicKey);
17124
- const { lowS, prehash, format } = opts;
17125
- validateSigVerOpts2(opts);
17126
- if ("strict" in opts)
17127
- throw new Error("options.strict was renamed to lowS");
17128
- if (format !== void 0 && format !== "compact" && format !== "der")
17129
- throw new Error("format must be compact or der");
17130
- const isHex2 = typeof sg === "string" || isBytes3(sg);
17131
- const isObj = !isHex2 && !format && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
17132
- if (!isHex2 && !isObj)
17133
- throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
17134
- let _sig = void 0;
17135
- let P;
17136
- try {
17137
- if (isObj)
17138
- _sig = new Signature(sg.r, sg.s);
17139
- if (isHex2) {
17140
- try {
17141
- if (format !== "compact")
17142
- _sig = Signature.fromDER(sg);
17143
- } catch (derError) {
17144
- if (!(derError instanceof DER2.Err))
17145
- throw derError;
17146
- }
17147
- if (!_sig && format !== "der")
17148
- _sig = Signature.fromCompact(sg);
17149
- }
17150
- P = Point2.fromHex(publicKey);
17151
- } catch (error) {
17152
- return false;
17153
- }
17154
- if (!_sig)
17155
- return false;
17156
- if (lowS && _sig.hasHighS())
17157
- return false;
17158
- if (prehash)
17159
- msgHash = CURVE.hash(msgHash);
17160
- const { r, s } = _sig;
17161
- const h = bits2int_modN(msgHash);
17162
- const is = invN(s);
17163
- const u1 = modN2(h * is);
17164
- const u2 = modN2(r * is);
17165
- const R = Point2.BASE.multiplyAndAddUnsafe(P, u1, u2)?.toAffine();
17166
- if (!R)
17167
- return false;
17168
- const v = modN2(R.x);
17169
- return v === r;
17170
- }
17171
- return {
17172
- CURVE,
17173
- getPublicKey,
17174
- getSharedSecret,
17175
- sign,
17176
- verify,
17177
- ProjectivePoint: Point2,
17178
- Signature,
17179
- utils
17180
- };
17181
- }
17182
-
17183
- // ../node_modules/ox/node_modules/@noble/curves/esm/_shortw_utils.js
17184
- function getHash2(hash3) {
17185
- return {
17186
- hash: hash3,
17187
- hmac: (key, ...msgs) => hmac(hash3, key, concatBytes(...msgs)),
17188
- randomBytes
17189
- };
17190
- }
17191
- function createCurve2(curveDef, defHash) {
17192
- const create2 = (hash3) => weierstrass2({ ...curveDef, ...getHash2(hash3) });
17193
- return { ...create2(defHash), create: create2 };
17194
- }
17195
-
17196
- // ../node_modules/ox/node_modules/@noble/curves/esm/secp256k1.js
17197
- var secp256k1P2 = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
17198
- var secp256k1N2 = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
17199
- var _0n11 = BigInt(0);
17200
- var _1n11 = BigInt(1);
17201
- var _2n7 = BigInt(2);
17202
- var divNearest2 = (a, b) => (a + b / _2n7) / b;
17203
- function sqrtMod2(y) {
17204
- const P = secp256k1P2;
17205
- const _3n5 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
17206
- const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
17207
- const b2 = y * y * y % P;
17208
- const b3 = b2 * b2 * y % P;
17209
- const b6 = pow22(b3, _3n5, P) * b3 % P;
17210
- const b9 = pow22(b6, _3n5, P) * b3 % P;
17211
- const b11 = pow22(b9, _2n7, P) * b2 % P;
17212
- const b22 = pow22(b11, _11n, P) * b11 % P;
17213
- const b44 = pow22(b22, _22n, P) * b22 % P;
17214
- const b88 = pow22(b44, _44n, P) * b44 % P;
17215
- const b176 = pow22(b88, _88n, P) * b88 % P;
17216
- const b220 = pow22(b176, _44n, P) * b44 % P;
17217
- const b223 = pow22(b220, _3n5, P) * b3 % P;
17218
- const t1 = pow22(b223, _23n, P) * b22 % P;
17219
- const t2 = pow22(t1, _6n, P) * b2 % P;
17220
- const root = pow22(t2, _2n7, P);
17221
- if (!Fpk12.eql(Fpk12.sqr(root), y))
17222
- throw new Error("Cannot find square root");
17223
- return root;
17224
- }
17225
- var Fpk12 = Field2(secp256k1P2, void 0, void 0, { sqrt: sqrtMod2 });
17226
- var secp256k12 = createCurve2({
17227
- a: _0n11,
17228
- b: BigInt(7),
17229
- Fp: Fpk12,
17230
- n: secp256k1N2,
17231
- Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
17232
- Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
17233
- h: BigInt(1),
17234
- lowS: true,
17235
- // Allow only low-S signatures by default in sign() and verify()
17236
- endo: {
17237
- // Endomorphism, see above
17238
- beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
17239
- splitScalar: (k) => {
17240
- const n = secp256k1N2;
17241
- const a1 = BigInt("0x3086d221a7d46bcde86c90e49284eb15");
17242
- const b1 = -_1n11 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3");
17243
- const a2 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");
17244
- const b2 = a1;
17245
- const POW_2_128 = BigInt("0x100000000000000000000000000000000");
17246
- const c1 = divNearest2(b2 * k, n);
17247
- const c2 = divNearest2(-b1 * k, n);
17248
- let k1 = mod2(k - c1 * a1 - c2 * a2, n);
17249
- let k2 = mod2(-c1 * b1 - c2 * b2, n);
17250
- const k1neg = k1 > POW_2_128;
17251
- const k2neg = k2 > POW_2_128;
17252
- if (k1neg)
17253
- k1 = n - k1;
17254
- if (k2neg)
17255
- k2 = n - k2;
17256
- if (k1 > POW_2_128 || k2 > POW_2_128) {
17257
- throw new Error("splitScalar: Endomorphism failed, k=" + k);
17258
- }
17259
- return { k1neg, k1, k2neg, k2 };
17260
- }
17261
- }
17262
- }, sha256);
17263
-
17264
- // ../node_modules/ox/_esm/core/Signature.js
17265
- init_Errors();
17266
- init_Hex();
17267
- init_Json();
17268
- function assert5(signature, options = {}) {
17269
- const { recovered } = options;
17270
- if (typeof signature.r === "undefined")
17271
- throw new MissingPropertiesError({ signature });
17272
- if (typeof signature.s === "undefined")
17273
- throw new MissingPropertiesError({ signature });
17274
- if (recovered && typeof signature.yParity === "undefined")
17275
- throw new MissingPropertiesError({ signature });
17276
- if (signature.r < 0n || signature.r > maxUint2562)
17277
- throw new InvalidRError({ value: signature.r });
17278
- if (signature.s < 0n || signature.s > maxUint2562)
17279
- throw new InvalidSError({ value: signature.s });
17280
- if (typeof signature.yParity === "number" && signature.yParity !== 0 && signature.yParity !== 1)
17281
- throw new InvalidYParityError({ value: signature.yParity });
17282
- }
17283
- function fromBytes3(signature) {
17284
- return fromHex4(fromBytes(signature));
17285
- }
17286
- function fromHex4(signature) {
17287
- if (signature.length !== 130 && signature.length !== 132)
17288
- throw new InvalidSerializedSizeError2({ signature });
17289
- const r = BigInt(slice3(signature, 0, 32));
17290
- const s = BigInt(slice3(signature, 32, 64));
17291
- const yParity = (() => {
17292
- const yParity2 = Number(`0x${signature.slice(130)}`);
17293
- if (Number.isNaN(yParity2))
17294
- return void 0;
17295
- try {
17296
- return vToYParity(yParity2);
17297
- } catch {
17298
- throw new InvalidYParityError({ value: yParity2 });
17299
- }
17300
- })();
17301
- if (typeof yParity === "undefined")
17302
- return {
17303
- r,
17304
- s
17305
- };
17306
- return {
17307
- r,
17308
- s,
17309
- yParity
17310
- };
17311
- }
17312
- function extract2(value) {
17313
- if (typeof value.r === "undefined")
17314
- return void 0;
17315
- if (typeof value.s === "undefined")
17316
- return void 0;
17317
- return from7(value);
17318
- }
17319
- function from7(signature) {
17320
- const signature_ = (() => {
17321
- if (typeof signature === "string")
17322
- return fromHex4(signature);
17323
- if (signature instanceof Uint8Array)
17324
- return fromBytes3(signature);
17325
- if (typeof signature.r === "string")
17326
- return fromRpc2(signature);
17327
- if (signature.v)
17328
- return fromLegacy(signature);
17329
- return {
17330
- r: signature.r,
17331
- s: signature.s,
17332
- ...typeof signature.yParity !== "undefined" ? { yParity: signature.yParity } : {}
17333
- };
17334
- })();
17335
- assert5(signature_);
17336
- return signature_;
15610
+ function from7(signature) {
15611
+ const signature_ = (() => {
15612
+ if (typeof signature === "string")
15613
+ return fromHex4(signature);
15614
+ if (signature instanceof Uint8Array)
15615
+ return fromBytes3(signature);
15616
+ if (typeof signature.r === "string")
15617
+ return fromRpc2(signature);
15618
+ if (signature.v)
15619
+ return fromLegacy(signature);
15620
+ return {
15621
+ r: signature.r,
15622
+ s: signature.s,
15623
+ ...typeof signature.yParity !== "undefined" ? { yParity: signature.yParity } : {}
15624
+ };
15625
+ })();
15626
+ assert5(signature_);
15627
+ return signature_;
17337
15628
  }
17338
15629
  function fromLegacy(signature) {
17339
15630
  return {
@@ -17490,6 +15781,7 @@ init_Errors();
17490
15781
  init_Hex();
17491
15782
 
17492
15783
  // ../node_modules/ox/_esm/core/Secp256k1.js
15784
+ init_secp256k1();
17493
15785
  init_Hex();
17494
15786
  function recoverAddress2(options) {
17495
15787
  return fromPublicKey(recoverPublicKey2(options));
@@ -17497,7 +15789,7 @@ function recoverAddress2(options) {
17497
15789
  function recoverPublicKey2(options) {
17498
15790
  const { payload, signature } = options;
17499
15791
  const { r, s, yParity } = signature;
17500
- const signature_ = new secp256k12.Signature(BigInt(r), BigInt(s)).addRecoveryBit(yParity);
15792
+ const signature_ = new secp256k1.Signature(BigInt(r), BigInt(s)).addRecoveryBit(yParity);
17501
15793
  const point = signature_.recoverPublicKey(from2(payload).substring(2));
17502
15794
  return from3(point);
17503
15795
  }
@@ -21199,12 +19491,6 @@ async function debugTransactionFailure(publicClient, failingWallet, workingWalle
21199
19491
  @noble/hashes/esm/utils.js:
21200
19492
  (*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
21201
19493
 
21202
- @noble/curves/esm/abstract/utils.js:
21203
- @noble/curves/esm/abstract/modular.js:
21204
- @noble/curves/esm/abstract/curve.js:
21205
- @noble/curves/esm/abstract/weierstrass.js:
21206
- @noble/curves/esm/_shortw_utils.js:
21207
- @noble/curves/esm/secp256k1.js:
21208
19494
  @noble/curves/esm/abstract/utils.js:
21209
19495
  @noble/curves/esm/abstract/modular.js:
21210
19496
  @noble/curves/esm/abstract/curve.js: