@settlemint/sdk-cli 2.4.0-prfdc1cdc0 → 2.4.0
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/cli.js +515 -585
- package/dist/cli.js.map +15 -15
- package/package.json +6 -6
package/dist/cli.js
CHANGED
@@ -5149,7 +5149,7 @@ var require_sha2 = __commonJS((exports) => {
|
|
5149
5149
|
exports.sha512_224 = (0, utils_ts_1.createHasher)(() => new SHA512_224);
|
5150
5150
|
});
|
5151
5151
|
|
5152
|
-
// ../../node_modules
|
5152
|
+
// ../../node_modules/@noble/curves/abstract/utils.js
|
5153
5153
|
var require_utils5 = __commonJS((exports) => {
|
5154
5154
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
5155
5155
|
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -5423,7 +5423,7 @@ var require_utils5 = __commonJS((exports) => {
|
|
5423
5423
|
}
|
5424
5424
|
});
|
5425
5425
|
|
5426
|
-
// ../../node_modules
|
5426
|
+
// ../../node_modules/@noble/curves/abstract/modular.js
|
5427
5427
|
var require_modular = __commonJS((exports) => {
|
5428
5428
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5429
5429
|
exports.isNegativeLE = undefined;
|
@@ -5753,7 +5753,7 @@ var require_modular = __commonJS((exports) => {
|
|
5753
5753
|
}
|
5754
5754
|
});
|
5755
5755
|
|
5756
|
-
// ../../node_modules
|
5756
|
+
// ../../node_modules/@noble/curves/abstract/curve.js
|
5757
5757
|
var require_curve = __commonJS((exports) => {
|
5758
5758
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5759
5759
|
exports.wNAF = wNAF;
|
@@ -6002,7 +6002,7 @@ var require_curve = __commonJS((exports) => {
|
|
6002
6002
|
}
|
6003
6003
|
});
|
6004
6004
|
|
6005
|
-
// ../../node_modules
|
6005
|
+
// ../../node_modules/@noble/curves/abstract/edwards.js
|
6006
6006
|
var require_edwards = __commonJS((exports) => {
|
6007
6007
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6008
6008
|
exports.twistedEdwards = twistedEdwards;
|
@@ -6361,7 +6361,7 @@ var require_edwards = __commonJS((exports) => {
|
|
6361
6361
|
}
|
6362
6362
|
});
|
6363
6363
|
|
6364
|
-
// ../../node_modules
|
6364
|
+
// ../../node_modules/@noble/curves/abstract/hash-to-curve.js
|
6365
6365
|
var require_hash_to_curve = __commonJS((exports) => {
|
6366
6366
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6367
6367
|
exports.expand_message_xmd = expand_message_xmd;
|
@@ -6514,7 +6514,7 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6514
6514
|
}
|
6515
6515
|
});
|
6516
6516
|
|
6517
|
-
// ../../node_modules
|
6517
|
+
// ../../node_modules/@noble/curves/abstract/montgomery.js
|
6518
6518
|
var require_montgomery = __commonJS((exports) => {
|
6519
6519
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6520
6520
|
exports.montgomery = montgomery;
|
@@ -6621,7 +6621,7 @@ var require_montgomery = __commonJS((exports) => {
|
|
6621
6621
|
}
|
6622
6622
|
});
|
6623
6623
|
|
6624
|
-
// ../../node_modules
|
6624
|
+
// ../../node_modules/@noble/curves/ed25519.js
|
6625
6625
|
var require_ed25519 = __commonJS((exports) => {
|
6626
6626
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6627
6627
|
exports.hash_to_ristretto255 = exports.hashToRistretto255 = exports.RistrettoPoint = exports.encodeToCurve = exports.hashToCurve = exports.ed25519_hasher = exports.edwardsToMontgomery = exports.x25519 = exports.ed25519ph = exports.ed25519ctx = exports.ed25519 = exports.ED25519_TORSION_SUBGROUP = undefined;
|
@@ -7061,7 +7061,7 @@ var require_hmac = __commonJS((exports) => {
|
|
7061
7061
|
exports.hmac.create = (hash, key) => new HMAC(hash, key);
|
7062
7062
|
});
|
7063
7063
|
|
7064
|
-
// ../../node_modules
|
7064
|
+
// ../../node_modules/@noble/curves/abstract/weierstrass.js
|
7065
7065
|
var require_weierstrass = __commonJS((exports) => {
|
7066
7066
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7067
7067
|
exports.DER = exports.DERErr = undefined;
|
@@ -7980,7 +7980,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7980
7980
|
}
|
7981
7981
|
});
|
7982
7982
|
|
7983
|
-
// ../../node_modules
|
7983
|
+
// ../../node_modules/@noble/curves/_shortw_utils.js
|
7984
7984
|
var require__shortw_utils = __commonJS((exports) => {
|
7985
7985
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7986
7986
|
exports.getHash = getHash;
|
@@ -8002,7 +8002,7 @@ var require__shortw_utils = __commonJS((exports) => {
|
|
8002
8002
|
}
|
8003
8003
|
});
|
8004
8004
|
|
8005
|
-
// ../../node_modules
|
8005
|
+
// ../../node_modules/@noble/curves/secp256k1.js
|
8006
8006
|
var require_secp256k1 = __commonJS((exports) => {
|
8007
8007
|
Object.defineProperty(exports, "__esModule", { value: true });
|
8008
8008
|
exports.encodeToCurve = exports.hashToCurve = exports.secp256k1_hasher = exports.schnorr = exports.secp256k1 = undefined;
|
@@ -231623,7 +231623,7 @@ function size(value4) {
|
|
231623
231623
|
var init_size = () => {};
|
231624
231624
|
|
231625
231625
|
// ../../node_modules/viem/_esm/errors/version.js
|
231626
|
-
var version5 = "2.31.
|
231626
|
+
var version5 = "2.31.1";
|
231627
231627
|
|
231628
231628
|
// ../../node_modules/viem/_esm/errors/base.js
|
231629
231629
|
function walk(err, fn) {
|
@@ -232421,46 +232421,6 @@ function byteSwap32(arr) {
|
|
232421
232421
|
}
|
232422
232422
|
return arr;
|
232423
232423
|
}
|
232424
|
-
function bytesToHex2(bytes) {
|
232425
|
-
abytes(bytes);
|
232426
|
-
if (hasHexBuiltin)
|
232427
|
-
return bytes.toHex();
|
232428
|
-
let hex = "";
|
232429
|
-
for (let i6 = 0;i6 < bytes.length; i6++) {
|
232430
|
-
hex += hexes2[bytes[i6]];
|
232431
|
-
}
|
232432
|
-
return hex;
|
232433
|
-
}
|
232434
|
-
function asciiToBase16(ch) {
|
232435
|
-
if (ch >= asciis._0 && ch <= asciis._9)
|
232436
|
-
return ch - asciis._0;
|
232437
|
-
if (ch >= asciis.A && ch <= asciis.F)
|
232438
|
-
return ch - (asciis.A - 10);
|
232439
|
-
if (ch >= asciis.a && ch <= asciis.f)
|
232440
|
-
return ch - (asciis.a - 10);
|
232441
|
-
return;
|
232442
|
-
}
|
232443
|
-
function hexToBytes2(hex) {
|
232444
|
-
if (typeof hex !== "string")
|
232445
|
-
throw new Error("hex string expected, got " + typeof hex);
|
232446
|
-
if (hasHexBuiltin)
|
232447
|
-
return Uint8Array.fromHex(hex);
|
232448
|
-
const hl = hex.length;
|
232449
|
-
const al = hl / 2;
|
232450
|
-
if (hl % 2)
|
232451
|
-
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
232452
|
-
const array4 = new Uint8Array(al);
|
232453
|
-
for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) {
|
232454
|
-
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
232455
|
-
const n22 = asciiToBase16(hex.charCodeAt(hi + 1));
|
232456
|
-
if (n1 === undefined || n22 === undefined) {
|
232457
|
-
const char = hex[hi] + hex[hi + 1];
|
232458
|
-
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
232459
|
-
}
|
232460
|
-
array4[ai] = n1 * 16 + n22;
|
232461
|
-
}
|
232462
|
-
return array4;
|
232463
|
-
}
|
232464
232424
|
function utf8ToBytes(str) {
|
232465
232425
|
if (typeof str !== "string")
|
232466
232426
|
throw new Error("string expected");
|
@@ -232507,15 +232467,12 @@ function randomBytes(bytesLength = 32) {
|
|
232507
232467
|
}
|
232508
232468
|
throw new Error("crypto.getRandomValues must be defined");
|
232509
232469
|
}
|
232510
|
-
var isLE, swap32IfBE
|
232470
|
+
var isLE, swap32IfBE;
|
232511
232471
|
var init_utils2 = __esm(() => {
|
232512
232472
|
init_cryptoNode();
|
232513
232473
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
232514
232474
|
isLE = /* @__PURE__ */ (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
232515
232475
|
swap32IfBE = isLE ? (u6) => u6 : byteSwap32;
|
232516
|
-
hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
232517
|
-
hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_5, i6) => i6.toString(16).padStart(2, "0"));
|
232518
|
-
asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
232519
232476
|
});
|
232520
232477
|
|
232521
232478
|
// ../../node_modules/@noble/hashes/esm/sha3.js
|
@@ -235181,7 +235138,14 @@ var init_hmac = __esm(() => {
|
|
235181
235138
|
hmac.create = (hash2, key2) => new HMAC(hash2, key2);
|
235182
235139
|
});
|
235183
235140
|
|
235184
|
-
// ../../node_modules/@noble/curves/esm/utils.js
|
235141
|
+
// ../../node_modules/@noble/curves/esm/abstract/utils.js
|
235142
|
+
function isBytes2(a7) {
|
235143
|
+
return a7 instanceof Uint8Array || ArrayBuffer.isView(a7) && a7.constructor.name === "Uint8Array";
|
235144
|
+
}
|
235145
|
+
function abytes2(item) {
|
235146
|
+
if (!isBytes2(item))
|
235147
|
+
throw new Error("Uint8Array expected");
|
235148
|
+
}
|
235185
235149
|
function abool(title, value4) {
|
235186
235150
|
if (typeof value4 !== "boolean")
|
235187
235151
|
throw new Error(title + " boolean expected, got " + value4);
|
@@ -235195,11 +235159,51 @@ function hexToNumber2(hex) {
|
|
235195
235159
|
throw new Error("hex string expected, got " + typeof hex);
|
235196
235160
|
return hex === "" ? _0n2 : BigInt("0x" + hex);
|
235197
235161
|
}
|
235162
|
+
function bytesToHex2(bytes) {
|
235163
|
+
abytes2(bytes);
|
235164
|
+
if (hasHexBuiltin)
|
235165
|
+
return bytes.toHex();
|
235166
|
+
let hex = "";
|
235167
|
+
for (let i6 = 0;i6 < bytes.length; i6++) {
|
235168
|
+
hex += hexes2[bytes[i6]];
|
235169
|
+
}
|
235170
|
+
return hex;
|
235171
|
+
}
|
235172
|
+
function asciiToBase16(ch) {
|
235173
|
+
if (ch >= asciis._0 && ch <= asciis._9)
|
235174
|
+
return ch - asciis._0;
|
235175
|
+
if (ch >= asciis.A && ch <= asciis.F)
|
235176
|
+
return ch - (asciis.A - 10);
|
235177
|
+
if (ch >= asciis.a && ch <= asciis.f)
|
235178
|
+
return ch - (asciis.a - 10);
|
235179
|
+
return;
|
235180
|
+
}
|
235181
|
+
function hexToBytes2(hex) {
|
235182
|
+
if (typeof hex !== "string")
|
235183
|
+
throw new Error("hex string expected, got " + typeof hex);
|
235184
|
+
if (hasHexBuiltin)
|
235185
|
+
return Uint8Array.fromHex(hex);
|
235186
|
+
const hl = hex.length;
|
235187
|
+
const al = hl / 2;
|
235188
|
+
if (hl % 2)
|
235189
|
+
throw new Error("hex string expected, got unpadded hex of length " + hl);
|
235190
|
+
const array4 = new Uint8Array(al);
|
235191
|
+
for (let ai = 0, hi = 0;ai < al; ai++, hi += 2) {
|
235192
|
+
const n1 = asciiToBase16(hex.charCodeAt(hi));
|
235193
|
+
const n22 = asciiToBase16(hex.charCodeAt(hi + 1));
|
235194
|
+
if (n1 === undefined || n22 === undefined) {
|
235195
|
+
const char = hex[hi] + hex[hi + 1];
|
235196
|
+
throw new Error('hex string expected, got non-hex character "' + char + '" at index ' + hi);
|
235197
|
+
}
|
235198
|
+
array4[ai] = n1 * 16 + n22;
|
235199
|
+
}
|
235200
|
+
return array4;
|
235201
|
+
}
|
235198
235202
|
function bytesToNumberBE(bytes) {
|
235199
235203
|
return hexToNumber2(bytesToHex2(bytes));
|
235200
235204
|
}
|
235201
235205
|
function bytesToNumberLE(bytes) {
|
235202
|
-
|
235206
|
+
abytes2(bytes);
|
235203
235207
|
return hexToNumber2(bytesToHex2(Uint8Array.from(bytes).reverse()));
|
235204
235208
|
}
|
235205
235209
|
function numberToBytesBE(n6, len) {
|
@@ -235216,7 +235220,7 @@ function ensureBytes(title, hex, expectedLength) {
|
|
235216
235220
|
} catch (e10) {
|
235217
235221
|
throw new Error(title + " must be hex string or Uint8Array, cause: " + e10);
|
235218
235222
|
}
|
235219
|
-
} else if (
|
235223
|
+
} else if (isBytes2(hex)) {
|
235220
235224
|
res = Uint8Array.from(hex);
|
235221
235225
|
} else {
|
235222
235226
|
throw new Error(title + " must be hex string or Uint8Array");
|
@@ -235226,6 +235230,26 @@ function ensureBytes(title, hex, expectedLength) {
|
|
235226
235230
|
throw new Error(title + " of length " + expectedLength + " expected, got " + len);
|
235227
235231
|
return res;
|
235228
235232
|
}
|
235233
|
+
function concatBytes3(...arrays) {
|
235234
|
+
let sum = 0;
|
235235
|
+
for (let i6 = 0;i6 < arrays.length; i6++) {
|
235236
|
+
const a7 = arrays[i6];
|
235237
|
+
abytes2(a7);
|
235238
|
+
sum += a7.length;
|
235239
|
+
}
|
235240
|
+
const res = new Uint8Array(sum);
|
235241
|
+
for (let i6 = 0, pad2 = 0;i6 < arrays.length; i6++) {
|
235242
|
+
const a7 = arrays[i6];
|
235243
|
+
res.set(a7, pad2);
|
235244
|
+
pad2 += a7.length;
|
235245
|
+
}
|
235246
|
+
return res;
|
235247
|
+
}
|
235248
|
+
function utf8ToBytes2(str) {
|
235249
|
+
if (typeof str !== "string")
|
235250
|
+
throw new Error("string expected");
|
235251
|
+
return new Uint8Array(new TextEncoder().encode(str));
|
235252
|
+
}
|
235229
235253
|
function inRange(n6, min, max) {
|
235230
235254
|
return isPosBig(n6) && isPosBig(min) && isPosBig(max) && min <= n6 && n6 < max;
|
235231
235255
|
}
|
@@ -235246,8 +235270,6 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235246
235270
|
throw new Error("qByteLen must be a number");
|
235247
235271
|
if (typeof hmacFn !== "function")
|
235248
235272
|
throw new Error("hmacFn must be a function");
|
235249
|
-
const u8n = (len) => new Uint8Array(len);
|
235250
|
-
const u8of = (byte) => Uint8Array.of(byte);
|
235251
235273
|
let v6 = u8n(hashLen);
|
235252
235274
|
let k5 = u8n(hashLen);
|
235253
235275
|
let i6 = 0;
|
@@ -235258,11 +235280,11 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235258
235280
|
};
|
235259
235281
|
const h8 = (...b4) => hmacFn(k5, v6, ...b4);
|
235260
235282
|
const reseed = (seed = u8n(0)) => {
|
235261
|
-
k5 = h8(
|
235283
|
+
k5 = h8(u8fr([0]), seed);
|
235262
235284
|
v6 = h8();
|
235263
235285
|
if (seed.length === 0)
|
235264
235286
|
return;
|
235265
|
-
k5 = h8(
|
235287
|
+
k5 = h8(u8fr([1]), seed);
|
235266
235288
|
v6 = h8();
|
235267
235289
|
};
|
235268
235290
|
const gen2 = () => {
|
@@ -235276,7 +235298,7 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235276
235298
|
out.push(sl);
|
235277
235299
|
len += v6.length;
|
235278
235300
|
}
|
235279
|
-
return
|
235301
|
+
return concatBytes3(...out);
|
235280
235302
|
};
|
235281
235303
|
const genUntil = (seed, pred) => {
|
235282
235304
|
reset2();
|
@@ -235289,22 +235311,23 @@ function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
|
235289
235311
|
};
|
235290
235312
|
return genUntil;
|
235291
235313
|
}
|
235292
|
-
function
|
235293
|
-
|
235294
|
-
|
235295
|
-
|
235296
|
-
|
235297
|
-
throw new Error("expected valid options object");
|
235298
|
-
function checkField(fieldName, expectedType, isOpt) {
|
235314
|
+
function validateObject(object4, validators, optValidators = {}) {
|
235315
|
+
const checkField = (fieldName, type4, isOptional) => {
|
235316
|
+
const checkVal = validatorFns[type4];
|
235317
|
+
if (typeof checkVal !== "function")
|
235318
|
+
throw new Error("invalid validator function");
|
235299
235319
|
const val = object4[fieldName];
|
235300
|
-
if (
|
235320
|
+
if (isOptional && val === undefined)
|
235301
235321
|
return;
|
235302
|
-
|
235303
|
-
|
235304
|
-
|
235305
|
-
}
|
235306
|
-
|
235307
|
-
|
235322
|
+
if (!checkVal(val, object4)) {
|
235323
|
+
throw new Error("param " + String(fieldName) + " is invalid. Expected " + type4 + ", got " + val);
|
235324
|
+
}
|
235325
|
+
};
|
235326
|
+
for (const [fieldName, type4] of Object.entries(validators))
|
235327
|
+
checkField(fieldName, type4, false);
|
235328
|
+
for (const [fieldName, type4] of Object.entries(optValidators))
|
235329
|
+
checkField(fieldName, type4, true);
|
235330
|
+
return object4;
|
235308
235331
|
}
|
235309
235332
|
function memoized(fn) {
|
235310
235333
|
const map6 = new WeakMap;
|
@@ -235317,13 +235340,25 @@ function memoized(fn) {
|
|
235317
235340
|
return computed;
|
235318
235341
|
};
|
235319
235342
|
}
|
235320
|
-
var _0n2, _1n2, isPosBig = (n6) => typeof n6 === "bigint" && _0n2 <= n6, bitMask = (n6) => (_1n2 << BigInt(n6)) - _1n2;
|
235343
|
+
var _0n2, _1n2, hasHexBuiltin, hexes2, asciis, isPosBig = (n6) => typeof n6 === "bigint" && _0n2 <= n6, bitMask = (n6) => (_1n2 << BigInt(n6)) - _1n2, u8n = (len) => new Uint8Array(len), u8fr = (arr) => Uint8Array.from(arr), validatorFns;
|
235321
235344
|
var init_utils3 = __esm(() => {
|
235322
|
-
init_utils2();
|
235323
|
-
init_utils2();
|
235324
235345
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
235325
235346
|
_0n2 = /* @__PURE__ */ BigInt(0);
|
235326
235347
|
_1n2 = /* @__PURE__ */ BigInt(1);
|
235348
|
+
hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
|
235349
|
+
hexes2 = /* @__PURE__ */ Array.from({ length: 256 }, (_5, i6) => i6.toString(16).padStart(2, "0"));
|
235350
|
+
asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
235351
|
+
validatorFns = {
|
235352
|
+
bigint: (val) => typeof val === "bigint",
|
235353
|
+
function: (val) => typeof val === "function",
|
235354
|
+
boolean: (val) => typeof val === "boolean",
|
235355
|
+
string: (val) => typeof val === "string",
|
235356
|
+
stringOrUint8Array: (val) => typeof val === "string" || isBytes2(val),
|
235357
|
+
isSafeInteger: (val) => Number.isSafeInteger(val),
|
235358
|
+
array: (val) => Array.isArray(val),
|
235359
|
+
field: (val, object4) => object4.Fp.isValid(val),
|
235360
|
+
hash: (val) => typeof val === "function" && Number.isSafeInteger(val.outputLen)
|
235361
|
+
};
|
235327
235362
|
});
|
235328
235363
|
|
235329
235364
|
// ../../node_modules/@noble/curves/esm/abstract/modular.js
|
@@ -235437,15 +235472,14 @@ function validateField(field2) {
|
|
235437
235472
|
const initial = {
|
235438
235473
|
ORDER: "bigint",
|
235439
235474
|
MASK: "bigint",
|
235440
|
-
BYTES: "
|
235441
|
-
BITS: "
|
235475
|
+
BYTES: "isSafeInteger",
|
235476
|
+
BITS: "isSafeInteger"
|
235442
235477
|
};
|
235443
235478
|
const opts = FIELD_FIELDS.reduce((map6, val) => {
|
235444
235479
|
map6[val] = "function";
|
235445
235480
|
return map6;
|
235446
235481
|
}, initial);
|
235447
|
-
|
235448
|
-
return field2;
|
235482
|
+
return validateObject(field2, opts);
|
235449
235483
|
}
|
235450
235484
|
function FpPow(Fp, num, power) {
|
235451
235485
|
if (power < _0n3)
|
@@ -235498,28 +235532,10 @@ function nLength(n6, nBitLength) {
|
|
235498
235532
|
const nByteLength = Math.ceil(_nBitLength / 8);
|
235499
235533
|
return { nBitLength: _nBitLength, nByteLength };
|
235500
235534
|
}
|
235501
|
-
function Field(ORDER,
|
235535
|
+
function Field(ORDER, bitLen2, isLE2 = false, redef = {}) {
|
235502
235536
|
if (ORDER <= _0n3)
|
235503
235537
|
throw new Error("invalid field: expected ORDER > 0, got " + ORDER);
|
235504
|
-
|
235505
|
-
let _sqrt = undefined;
|
235506
|
-
if (typeof bitLenOrOpts === "object" && bitLenOrOpts != null) {
|
235507
|
-
if (opts.sqrt || isLE2)
|
235508
|
-
throw new Error("cannot specify opts in two arguments");
|
235509
|
-
const _opts = bitLenOrOpts;
|
235510
|
-
if (_opts.BITS)
|
235511
|
-
_nbitLength = _opts.BITS;
|
235512
|
-
if (_opts.sqrt)
|
235513
|
-
_sqrt = _opts.sqrt;
|
235514
|
-
if (typeof _opts.isLE === "boolean")
|
235515
|
-
isLE2 = _opts.isLE;
|
235516
|
-
} else {
|
235517
|
-
if (typeof bitLenOrOpts === "number")
|
235518
|
-
_nbitLength = bitLenOrOpts;
|
235519
|
-
if (opts.sqrt)
|
235520
|
-
_sqrt = opts.sqrt;
|
235521
|
-
}
|
235522
|
-
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, _nbitLength);
|
235538
|
+
const { nBitLength: BITS, nByteLength: BYTES } = nLength(ORDER, bitLen2);
|
235523
235539
|
if (BYTES > 2048)
|
235524
235540
|
throw new Error("invalid field: expected ORDER of <= 2048 bytes");
|
235525
235541
|
let sqrtP;
|
@@ -235538,7 +235554,6 @@ function Field(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
|
|
235538
235554
|
return _0n3 <= num && num < ORDER;
|
235539
235555
|
},
|
235540
235556
|
is0: (num) => num === _0n3,
|
235541
|
-
isValidNot0: (num) => !f5.is0(num) && f5.isValid(num),
|
235542
235557
|
isOdd: (num) => (num & _1n3) === _1n3,
|
235543
235558
|
neg: (num) => mod(-num, ORDER),
|
235544
235559
|
eql: (lhs, rhs) => lhs === rhs,
|
@@ -235553,7 +235568,7 @@ function Field(ORDER, bitLenOrOpts, isLE2 = false, opts = {}) {
|
|
235553
235568
|
subN: (lhs, rhs) => lhs - rhs,
|
235554
235569
|
mulN: (lhs, rhs) => lhs * rhs,
|
235555
235570
|
inv: (num) => invert(num, ORDER),
|
235556
|
-
sqrt:
|
235571
|
+
sqrt: redef.sqrt || ((n6) => {
|
235557
235572
|
if (!sqrtP)
|
235558
235573
|
sqrtP = FpSqrt(ORDER);
|
235559
235574
|
return sqrtP(f5, n6);
|
@@ -235591,6 +235606,7 @@ function mapHashToField(key2, fieldOrder, isLE2 = false) {
|
|
235591
235606
|
}
|
235592
235607
|
var _0n3, _1n3, _2n2, _3n, _4n, _5n, _8n, FIELD_FIELDS;
|
235593
235608
|
var init_modular = __esm(() => {
|
235609
|
+
init_utils2();
|
235594
235610
|
init_utils3();
|
235595
235611
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
235596
235612
|
_0n3 = BigInt(0);
|
@@ -235622,16 +235638,10 @@ var init_modular = __esm(() => {
|
|
235622
235638
|
});
|
235623
235639
|
|
235624
235640
|
// ../../node_modules/@noble/curves/esm/abstract/curve.js
|
235625
|
-
function
|
235641
|
+
function constTimeNegate(condition, item) {
|
235626
235642
|
const neg = item.negate();
|
235627
235643
|
return condition ? neg : item;
|
235628
235644
|
}
|
235629
|
-
function normalizeZ(c3, property, points) {
|
235630
|
-
const getz = property === "pz" ? (p5) => p5.pz : (p5) => p5.ez;
|
235631
|
-
const toInv = FpInvertBatch(c3.Fp, points.map(getz));
|
235632
|
-
const affined = points.map((p5, i6) => p5.toAffine(toInv[i6]));
|
235633
|
-
return affined.map(c3.fromAffine);
|
235634
|
-
}
|
235635
235645
|
function validateW(W5, bits) {
|
235636
235646
|
if (!Number.isSafeInteger(W5) || W5 <= 0 || W5 > bits)
|
235637
235647
|
throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W5);
|
@@ -235680,13 +235690,9 @@ function validateMSMScalars(scalars, field2) {
|
|
235680
235690
|
function getW(P5) {
|
235681
235691
|
return pointWindowSizes.get(P5) || 1;
|
235682
235692
|
}
|
235683
|
-
function assert0(n6) {
|
235684
|
-
if (n6 !== _0n4)
|
235685
|
-
throw new Error("invalid wNAF");
|
235686
|
-
}
|
235687
235693
|
function wNAF(c3, bits) {
|
235688
235694
|
return {
|
235689
|
-
constTimeNegate
|
235695
|
+
constTimeNegate,
|
235690
235696
|
hasPrecomputes(elm) {
|
235691
235697
|
return getW(elm) !== 1;
|
235692
235698
|
},
|
@@ -235724,12 +235730,11 @@ function wNAF(c3, bits) {
|
|
235724
235730
|
const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n6, window2, wo);
|
235725
235731
|
n6 = nextN;
|
235726
235732
|
if (isZero) {
|
235727
|
-
f5 = f5.add(
|
235733
|
+
f5 = f5.add(constTimeNegate(isNegF, precomputes[offsetF]));
|
235728
235734
|
} else {
|
235729
|
-
p5 = p5.add(
|
235735
|
+
p5 = p5.add(constTimeNegate(isNeg, precomputes[offset]));
|
235730
235736
|
}
|
235731
235737
|
}
|
235732
|
-
assert0(n6);
|
235733
235738
|
return { p: p5, f: f5 };
|
235734
235739
|
},
|
235735
235740
|
wNAFUnsafe(W5, precomputes, n6, acc = c3.ZERO) {
|
@@ -235746,18 +235751,14 @@ function wNAF(c3, bits) {
|
|
235746
235751
|
acc = acc.add(isNeg ? item.negate() : item);
|
235747
235752
|
}
|
235748
235753
|
}
|
235749
|
-
assert0(n6);
|
235750
235754
|
return acc;
|
235751
235755
|
},
|
235752
235756
|
getPrecomputes(W5, P5, transform5) {
|
235753
235757
|
let comp = pointPrecomputes.get(P5);
|
235754
235758
|
if (!comp) {
|
235755
235759
|
comp = this.precomputeWindow(P5, W5);
|
235756
|
-
if (W5 !== 1)
|
235757
|
-
|
235758
|
-
comp = transform5(comp);
|
235759
|
-
pointPrecomputes.set(P5, comp);
|
235760
|
-
}
|
235760
|
+
if (W5 !== 1)
|
235761
|
+
pointPrecomputes.set(P5, transform5(comp));
|
235761
235762
|
}
|
235762
235763
|
return comp;
|
235763
235764
|
},
|
@@ -235778,21 +235779,6 @@ function wNAF(c3, bits) {
|
|
235778
235779
|
}
|
235779
235780
|
};
|
235780
235781
|
}
|
235781
|
-
function mulEndoUnsafe(c3, point, k1, k22) {
|
235782
|
-
let acc = point;
|
235783
|
-
let p1 = c3.ZERO;
|
235784
|
-
let p22 = c3.ZERO;
|
235785
|
-
while (k1 > _0n4 || k22 > _0n4) {
|
235786
|
-
if (k1 & _1n4)
|
235787
|
-
p1 = p1.add(acc);
|
235788
|
-
if (k22 & _1n4)
|
235789
|
-
p22 = p22.add(acc);
|
235790
|
-
acc = acc.double();
|
235791
|
-
k1 >>= _1n4;
|
235792
|
-
k22 >>= _1n4;
|
235793
|
-
}
|
235794
|
-
return { p1, p2: p22 };
|
235795
|
-
}
|
235796
235782
|
function pippenger(c3, fieldN, points, scalars) {
|
235797
235783
|
validateMSMPoints(points, c3);
|
235798
235784
|
validateMSMScalars(scalars, fieldN);
|
@@ -235832,38 +235818,27 @@ function pippenger(c3, fieldN, points, scalars) {
|
|
235832
235818
|
}
|
235833
235819
|
return sum;
|
235834
235820
|
}
|
235835
|
-
function
|
235836
|
-
|
235837
|
-
|
235838
|
-
|
235839
|
-
|
235840
|
-
|
235841
|
-
|
235842
|
-
|
235843
|
-
|
235844
|
-
|
235845
|
-
|
235846
|
-
|
235847
|
-
|
235848
|
-
|
235849
|
-
|
235850
|
-
|
235851
|
-
throw new Error(`CURVE.${p5} must be positive bigint`);
|
235852
|
-
}
|
235853
|
-
const Fp = createField(CURVE.p, curveOpts.Fp);
|
235854
|
-
const Fn = createField(CURVE.n, curveOpts.Fn);
|
235855
|
-
const _b = type4 === "weierstrass" ? "b" : "d";
|
235856
|
-
const params = ["Gx", "Gy", "a", _b];
|
235857
|
-
for (const p5 of params) {
|
235858
|
-
if (!Fp.isValid(CURVE[p5]))
|
235859
|
-
throw new Error(`CURVE.${p5} must be valid field element of CURVE.Fp`);
|
235860
|
-
}
|
235861
|
-
return { Fp, Fn };
|
235821
|
+
function validateBasic(curve) {
|
235822
|
+
validateField(curve.Fp);
|
235823
|
+
validateObject(curve, {
|
235824
|
+
n: "bigint",
|
235825
|
+
h: "bigint",
|
235826
|
+
Gx: "field",
|
235827
|
+
Gy: "field"
|
235828
|
+
}, {
|
235829
|
+
nBitLength: "isSafeInteger",
|
235830
|
+
nByteLength: "isSafeInteger"
|
235831
|
+
});
|
235832
|
+
return Object.freeze({
|
235833
|
+
...nLength(curve.n, curve.nBitLength),
|
235834
|
+
...curve,
|
235835
|
+
...{ p: curve.Fp.ORDER }
|
235836
|
+
});
|
235862
235837
|
}
|
235863
235838
|
var _0n4, _1n4, pointPrecomputes, pointWindowSizes;
|
235864
235839
|
var init_curve = __esm(() => {
|
235865
|
-
init_utils3();
|
235866
235840
|
init_modular();
|
235841
|
+
init_utils3();
|
235867
235842
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
235868
235843
|
_0n4 = BigInt(0);
|
235869
235844
|
_1n4 = BigInt(1);
|
@@ -235878,116 +235853,54 @@ function validateSigVerOpts(opts) {
|
|
235878
235853
|
if (opts.prehash !== undefined)
|
235879
235854
|
abool("prehash", opts.prehash);
|
235880
235855
|
}
|
235881
|
-
function
|
235882
|
-
|
235883
|
-
|
235884
|
-
|
235885
|
-
|
235886
|
-
}
|
235887
|
-
return weierstrassEquation;
|
235888
|
-
}
|
235889
|
-
function _legacyHelperNormPriv(Fn, allowedPrivateKeyLengths, wrapPrivateKey) {
|
235890
|
-
const { BYTES: expected } = Fn;
|
235891
|
-
function normPrivateKeyToScalar(key2) {
|
235892
|
-
let num;
|
235893
|
-
if (typeof key2 === "bigint") {
|
235894
|
-
num = key2;
|
235895
|
-
} else {
|
235896
|
-
let bytes = ensureBytes("private key", key2);
|
235897
|
-
if (allowedPrivateKeyLengths) {
|
235898
|
-
if (!allowedPrivateKeyLengths.includes(bytes.length * 2))
|
235899
|
-
throw new Error("invalid private key");
|
235900
|
-
const padded = new Uint8Array(expected);
|
235901
|
-
padded.set(bytes, padded.length - bytes.length);
|
235902
|
-
bytes = padded;
|
235903
|
-
}
|
235904
|
-
try {
|
235905
|
-
num = Fn.fromBytes(bytes);
|
235906
|
-
} catch (error44) {
|
235907
|
-
throw new Error(`invalid private key: expected ui8a of size ${expected}, got ${typeof key2}`);
|
235908
|
-
}
|
235909
|
-
}
|
235910
|
-
if (wrapPrivateKey)
|
235911
|
-
num = Fn.create(num);
|
235912
|
-
if (!Fn.isValidNot0(num))
|
235913
|
-
throw new Error("invalid private key: out of range [1..N-1]");
|
235914
|
-
return num;
|
235915
|
-
}
|
235916
|
-
return normPrivateKeyToScalar;
|
235917
|
-
}
|
235918
|
-
function weierstrassN(CURVE, curveOpts = {}) {
|
235919
|
-
const { Fp, Fn } = _createCurveFields("weierstrass", CURVE, curveOpts);
|
235920
|
-
const { h: cofactor, n: CURVE_ORDER } = CURVE;
|
235921
|
-
_validateObject(curveOpts, {}, {
|
235856
|
+
function validatePointOpts(curve) {
|
235857
|
+
const opts = validateBasic(curve);
|
235858
|
+
validateObject(opts, {
|
235859
|
+
a: "field",
|
235860
|
+
b: "field"
|
235861
|
+
}, {
|
235922
235862
|
allowInfinityPoint: "boolean",
|
235863
|
+
allowedPrivateKeyLengths: "array",
|
235923
235864
|
clearCofactor: "function",
|
235924
|
-
isTorsionFree: "function",
|
235925
235865
|
fromBytes: "function",
|
235866
|
+
isTorsionFree: "function",
|
235926
235867
|
toBytes: "function",
|
235927
|
-
endo: "object",
|
235928
235868
|
wrapPrivateKey: "boolean"
|
235929
235869
|
});
|
235930
|
-
const { endo } =
|
235870
|
+
const { endo, Fp, a: a7 } = opts;
|
235931
235871
|
if (endo) {
|
235932
|
-
if (!Fp.
|
235933
|
-
throw new Error(
|
235872
|
+
if (!Fp.eql(a7, Fp.ZERO)) {
|
235873
|
+
throw new Error("invalid endo: CURVE.a must be 0");
|
235934
235874
|
}
|
235935
|
-
|
235936
|
-
|
235937
|
-
if (!Fp.isOdd)
|
235938
|
-
throw new Error("compression is not supported: Field does not have .isOdd()");
|
235939
|
-
}
|
235940
|
-
function pointToBytes(_c, point, isCompressed) {
|
235941
|
-
const { x: x6, y: y4 } = point.toAffine();
|
235942
|
-
const bx = Fp.toBytes(x6);
|
235943
|
-
abool("isCompressed", isCompressed);
|
235944
|
-
if (isCompressed) {
|
235945
|
-
assertCompressionIsSupported();
|
235946
|
-
const hasEvenY = !Fp.isOdd(y4);
|
235947
|
-
return concatBytes(pprefix(hasEvenY), bx);
|
235948
|
-
} else {
|
235949
|
-
return concatBytes(Uint8Array.of(4), bx, Fp.toBytes(y4));
|
235875
|
+
if (typeof endo !== "object" || typeof endo.beta !== "bigint" || typeof endo.splitScalar !== "function") {
|
235876
|
+
throw new Error('invalid endo: expected "beta": bigint and "splitScalar": function');
|
235950
235877
|
}
|
235951
235878
|
}
|
235952
|
-
|
235953
|
-
|
235954
|
-
|
235955
|
-
|
235956
|
-
|
235957
|
-
|
235958
|
-
|
235879
|
+
return Object.freeze({ ...opts });
|
235880
|
+
}
|
235881
|
+
function numToSizedHex(num, size2) {
|
235882
|
+
return bytesToHex2(numberToBytesBE(num, size2));
|
235883
|
+
}
|
235884
|
+
function weierstrassPoints(opts) {
|
235885
|
+
const CURVE = validatePointOpts(opts);
|
235886
|
+
const { Fp } = CURVE;
|
235887
|
+
const Fn = Field(CURVE.n, CURVE.nBitLength);
|
235888
|
+
const toBytes3 = CURVE.toBytes || ((_c, point, _isCompressed) => {
|
235889
|
+
const a7 = point.toAffine();
|
235890
|
+
return concatBytes3(Uint8Array.from([4]), Fp.toBytes(a7.x), Fp.toBytes(a7.y));
|
235891
|
+
});
|
235892
|
+
const fromBytes = CURVE.fromBytes || ((bytes) => {
|
235959
235893
|
const tail = bytes.subarray(1);
|
235960
|
-
|
235961
|
-
|
235962
|
-
|
235963
|
-
|
235964
|
-
|
235965
|
-
|
235966
|
-
|
235967
|
-
|
235968
|
-
|
235969
|
-
const err = sqrtError instanceof Error ? ": " + sqrtError.message : "";
|
235970
|
-
throw new Error("bad point: is not on curve, sqrt error" + err);
|
235971
|
-
}
|
235972
|
-
assertCompressionIsSupported();
|
235973
|
-
const isYOdd = Fp.isOdd(y4);
|
235974
|
-
const isHeadOdd = (head & 1) === 1;
|
235975
|
-
if (isHeadOdd !== isYOdd)
|
235976
|
-
y4 = Fp.neg(y4);
|
235977
|
-
return { x: x6, y: y4 };
|
235978
|
-
} else if (length === LU && head === 4) {
|
235979
|
-
const x6 = Fp.fromBytes(tail.subarray(L5 * 0, L5 * 1));
|
235980
|
-
const y4 = Fp.fromBytes(tail.subarray(L5 * 1, L5 * 2));
|
235981
|
-
if (!isValidXY(x6, y4))
|
235982
|
-
throw new Error("bad point: is not on curve");
|
235983
|
-
return { x: x6, y: y4 };
|
235984
|
-
} else {
|
235985
|
-
throw new Error(`bad point: got length ${length}, expected compressed=${LC} or uncompressed=${LU}`);
|
235986
|
-
}
|
235894
|
+
const x6 = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
|
235895
|
+
const y4 = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
|
235896
|
+
return { x: x6, y: y4 };
|
235897
|
+
});
|
235898
|
+
function weierstrassEquation(x6) {
|
235899
|
+
const { a: a7, b: b4 } = CURVE;
|
235900
|
+
const x22 = Fp.sqr(x6);
|
235901
|
+
const x32 = Fp.mul(x22, x6);
|
235902
|
+
return Fp.add(Fp.add(x32, Fp.mul(x6, a7)), b4);
|
235987
235903
|
}
|
235988
|
-
const toBytes3 = curveOpts.toBytes || pointToBytes;
|
235989
|
-
const fromBytes = curveOpts.fromBytes || pointFromBytes;
|
235990
|
-
const weierstrassEquation = _legacyHelperEquat(Fp, CURVE.a, CURVE.b);
|
235991
235904
|
function isValidXY(x6, y4) {
|
235992
235905
|
const left = Fp.sqr(y4);
|
235993
235906
|
const right = weierstrassEquation(x6);
|
@@ -235999,10 +235912,28 @@ function weierstrassN(CURVE, curveOpts = {}) {
|
|
235999
235912
|
const _27b2 = Fp.mul(Fp.sqr(CURVE.b), BigInt(27));
|
236000
235913
|
if (Fp.is0(Fp.add(_4a3, _27b2)))
|
236001
235914
|
throw new Error("bad curve params: a or b");
|
236002
|
-
function
|
236003
|
-
|
236004
|
-
|
236005
|
-
|
235915
|
+
function isWithinCurveOrder(num) {
|
235916
|
+
return inRange(num, _1n5, CURVE.n);
|
235917
|
+
}
|
235918
|
+
function normPrivateKeyToScalar(key2) {
|
235919
|
+
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N6 } = CURVE;
|
235920
|
+
if (lengths && typeof key2 !== "bigint") {
|
235921
|
+
if (isBytes2(key2))
|
235922
|
+
key2 = bytesToHex2(key2);
|
235923
|
+
if (typeof key2 !== "string" || !lengths.includes(key2.length))
|
235924
|
+
throw new Error("invalid private key");
|
235925
|
+
key2 = key2.padStart(nByteLength * 2, "0");
|
235926
|
+
}
|
235927
|
+
let num;
|
235928
|
+
try {
|
235929
|
+
num = typeof key2 === "bigint" ? key2 : bytesToNumberBE(ensureBytes("private key", key2, nByteLength));
|
235930
|
+
} catch (error44) {
|
235931
|
+
throw new Error("invalid private key, expected hex or " + nByteLength + " bytes, got " + typeof key2);
|
235932
|
+
}
|
235933
|
+
if (wrapPrivateKey)
|
235934
|
+
num = mod(num, N6);
|
235935
|
+
aInRange("private key", num, _1n5, N6);
|
235936
|
+
return num;
|
236006
235937
|
}
|
236007
235938
|
function aprjpoint(other) {
|
236008
235939
|
if (!(other instanceof Point))
|
@@ -236026,31 +235957,31 @@ function weierstrassN(CURVE, curveOpts = {}) {
|
|
236026
235957
|
});
|
236027
235958
|
const assertValidMemo = memoized((p5) => {
|
236028
235959
|
if (p5.is0()) {
|
236029
|
-
if (
|
235960
|
+
if (CURVE.allowInfinityPoint && !Fp.is0(p5.py))
|
236030
235961
|
return;
|
236031
235962
|
throw new Error("bad point: ZERO");
|
236032
235963
|
}
|
236033
235964
|
const { x: x6, y: y4 } = p5.toAffine();
|
236034
235965
|
if (!Fp.isValid(x6) || !Fp.isValid(y4))
|
236035
|
-
throw new Error("bad point: x or y not
|
235966
|
+
throw new Error("bad point: x or y not FE");
|
236036
235967
|
if (!isValidXY(x6, y4))
|
236037
235968
|
throw new Error("bad point: equation left != right");
|
236038
235969
|
if (!p5.isTorsionFree())
|
236039
235970
|
throw new Error("bad point: not in prime-order subgroup");
|
236040
235971
|
return true;
|
236041
235972
|
});
|
236042
|
-
function finishEndo(endoBeta, k1p, k2p, k1neg, k2neg) {
|
236043
|
-
k2p = new Point(Fp.mul(k2p.px, endoBeta), k2p.py, k2p.pz);
|
236044
|
-
k1p = negateCt(k1neg, k1p);
|
236045
|
-
k2p = negateCt(k2neg, k2p);
|
236046
|
-
return k1p.add(k2p);
|
236047
|
-
}
|
236048
235973
|
|
236049
235974
|
class Point {
|
236050
235975
|
constructor(px, py, pz) {
|
236051
|
-
|
236052
|
-
|
236053
|
-
|
235976
|
+
if (px == null || !Fp.isValid(px))
|
235977
|
+
throw new Error("x required");
|
235978
|
+
if (py == null || !Fp.isValid(py) || Fp.is0(py))
|
235979
|
+
throw new Error("y required");
|
235980
|
+
if (pz == null || !Fp.isValid(pz))
|
235981
|
+
throw new Error("z required");
|
235982
|
+
this.px = px;
|
235983
|
+
this.py = py;
|
235984
|
+
this.pz = pz;
|
236054
235985
|
Object.freeze(this);
|
236055
235986
|
}
|
236056
235987
|
static fromAffine(p5) {
|
@@ -236059,7 +235990,8 @@ function weierstrassN(CURVE, curveOpts = {}) {
|
|
236059
235990
|
throw new Error("invalid affine point");
|
236060
235991
|
if (p5 instanceof Point)
|
236061
235992
|
throw new Error("projective point not allowed");
|
236062
|
-
|
235993
|
+
const is0 = (i6) => Fp.eql(i6, Fp.ZERO);
|
235994
|
+
if (is0(x6) && is0(y4))
|
236063
235995
|
return Point.ZERO;
|
236064
235996
|
return new Point(x6, y4, Fp.ONE);
|
236065
235997
|
}
|
@@ -236070,11 +236002,8 @@ function weierstrassN(CURVE, curveOpts = {}) {
|
|
236070
236002
|
return this.toAffine().y;
|
236071
236003
|
}
|
236072
236004
|
static normalizeZ(points) {
|
236073
|
-
|
236074
|
-
|
236075
|
-
static fromBytes(bytes) {
|
236076
|
-
abytes(bytes);
|
236077
|
-
return Point.fromHex(bytes);
|
236005
|
+
const toInv = FpInvertBatch(Fp, points.map((p5) => p5.pz));
|
236006
|
+
return points.map((p5, i6) => p5.toAffine(toInv[i6])).map(Point.fromAffine);
|
236078
236007
|
}
|
236079
236008
|
static fromHex(hex) {
|
236080
236009
|
const P5 = Point.fromAffine(fromBytes(ensureBytes("pointHex", hex)));
|
@@ -236082,29 +236011,22 @@ function weierstrassN(CURVE, curveOpts = {}) {
|
|
236082
236011
|
return P5;
|
236083
236012
|
}
|
236084
236013
|
static fromPrivateKey(privateKey) {
|
236085
|
-
const normPrivateKeyToScalar = _legacyHelperNormPriv(Fn, curveOpts.allowedPrivateKeyLengths, curveOpts.wrapPrivateKey);
|
236086
236014
|
return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));
|
236087
236015
|
}
|
236088
236016
|
static msm(points, scalars) {
|
236089
236017
|
return pippenger(Point, Fn, points, scalars);
|
236090
236018
|
}
|
236091
|
-
precompute(windowSize = 8, isLazy = true) {
|
236092
|
-
wnaf.setWindowSize(this, windowSize);
|
236093
|
-
if (!isLazy)
|
236094
|
-
this.multiply(_3n2);
|
236095
|
-
return this;
|
236096
|
-
}
|
236097
236019
|
_setWindowSize(windowSize) {
|
236098
|
-
|
236020
|
+
wnaf.setWindowSize(this, windowSize);
|
236099
236021
|
}
|
236100
236022
|
assertValidity() {
|
236101
236023
|
assertValidMemo(this);
|
236102
236024
|
}
|
236103
236025
|
hasEvenY() {
|
236104
236026
|
const { y: y4 } = this.toAffine();
|
236105
|
-
if (
|
236106
|
-
|
236107
|
-
|
236027
|
+
if (Fp.isOdd)
|
236028
|
+
return !Fp.isOdd(y4);
|
236029
|
+
throw new Error("Field doesn't support isOdd");
|
236108
236030
|
}
|
236109
236031
|
equals(other) {
|
236110
236032
|
aprjpoint(other);
|
@@ -236210,121 +236132,188 @@ function weierstrassN(CURVE, curveOpts = {}) {
|
|
236210
236132
|
is0() {
|
236211
236133
|
return this.equals(Point.ZERO);
|
236212
236134
|
}
|
236135
|
+
wNAF(n6) {
|
236136
|
+
return wnaf.wNAFCached(this, n6, Point.normalizeZ);
|
236137
|
+
}
|
236138
|
+
multiplyUnsafe(sc) {
|
236139
|
+
const { endo: endo2, n: N6 } = CURVE;
|
236140
|
+
aInRange("scalar", sc, _0n5, N6);
|
236141
|
+
const I6 = Point.ZERO;
|
236142
|
+
if (sc === _0n5)
|
236143
|
+
return I6;
|
236144
|
+
if (this.is0() || sc === _1n5)
|
236145
|
+
return this;
|
236146
|
+
if (!endo2 || wnaf.hasPrecomputes(this))
|
236147
|
+
return wnaf.wNAFCachedUnsafe(this, sc, Point.normalizeZ);
|
236148
|
+
let { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(sc);
|
236149
|
+
let k1p = I6;
|
236150
|
+
let k2p = I6;
|
236151
|
+
let d6 = this;
|
236152
|
+
while (k1 > _0n5 || k22 > _0n5) {
|
236153
|
+
if (k1 & _1n5)
|
236154
|
+
k1p = k1p.add(d6);
|
236155
|
+
if (k22 & _1n5)
|
236156
|
+
k2p = k2p.add(d6);
|
236157
|
+
d6 = d6.double();
|
236158
|
+
k1 >>= _1n5;
|
236159
|
+
k22 >>= _1n5;
|
236160
|
+
}
|
236161
|
+
if (k1neg)
|
236162
|
+
k1p = k1p.negate();
|
236163
|
+
if (k2neg)
|
236164
|
+
k2p = k2p.negate();
|
236165
|
+
k2p = new Point(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
|
236166
|
+
return k1p.add(k2p);
|
236167
|
+
}
|
236213
236168
|
multiply(scalar) {
|
236214
|
-
const { endo: endo2 } =
|
236215
|
-
|
236216
|
-
throw new Error("invalid scalar: out of range");
|
236169
|
+
const { endo: endo2, n: N6 } = CURVE;
|
236170
|
+
aInRange("scalar", scalar, _1n5, N6);
|
236217
236171
|
let point, fake;
|
236218
|
-
const mul = (n6) => wnaf.wNAFCached(this, n6, Point.normalizeZ);
|
236219
236172
|
if (endo2) {
|
236220
236173
|
const { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(scalar);
|
236221
|
-
|
236222
|
-
|
236223
|
-
|
236224
|
-
|
236174
|
+
let { p: k1p, f: f1p } = this.wNAF(k1);
|
236175
|
+
let { p: k2p, f: f2p } = this.wNAF(k22);
|
236176
|
+
k1p = wnaf.constTimeNegate(k1neg, k1p);
|
236177
|
+
k2p = wnaf.constTimeNegate(k2neg, k2p);
|
236178
|
+
k2p = new Point(Fp.mul(k2p.px, endo2.beta), k2p.py, k2p.pz);
|
236179
|
+
point = k1p.add(k2p);
|
236180
|
+
fake = f1p.add(f2p);
|
236225
236181
|
} else {
|
236226
|
-
const { p: p5, f: f5 } =
|
236182
|
+
const { p: p5, f: f5 } = this.wNAF(scalar);
|
236227
236183
|
point = p5;
|
236228
236184
|
fake = f5;
|
236229
236185
|
}
|
236230
236186
|
return Point.normalizeZ([point, fake])[0];
|
236231
236187
|
}
|
236232
|
-
multiplyUnsafe(sc) {
|
236233
|
-
const { endo: endo2 } = curveOpts;
|
236234
|
-
const p5 = this;
|
236235
|
-
if (!Fn.isValid(sc))
|
236236
|
-
throw new Error("invalid scalar: out of range");
|
236237
|
-
if (sc === _0n5 || p5.is0())
|
236238
|
-
return Point.ZERO;
|
236239
|
-
if (sc === _1n5)
|
236240
|
-
return p5;
|
236241
|
-
if (wnaf.hasPrecomputes(this))
|
236242
|
-
return this.multiply(sc);
|
236243
|
-
if (endo2) {
|
236244
|
-
const { k1neg, k1, k2neg, k2: k22 } = endo2.splitScalar(sc);
|
236245
|
-
const { p1, p2: p22 } = mulEndoUnsafe(Point, p5, k1, k22);
|
236246
|
-
return finishEndo(endo2.beta, p1, p22, k1neg, k2neg);
|
236247
|
-
} else {
|
236248
|
-
return wnaf.wNAFCachedUnsafe(p5, sc);
|
236249
|
-
}
|
236250
|
-
}
|
236251
236188
|
multiplyAndAddUnsafe(Q4, a7, b4) {
|
236252
|
-
const
|
236189
|
+
const G4 = Point.BASE;
|
236190
|
+
const mul = (P5, a8) => a8 === _0n5 || a8 === _1n5 || !P5.equals(G4) ? P5.multiplyUnsafe(a8) : P5.multiply(a8);
|
236191
|
+
const sum = mul(this, a7).add(mul(Q4, b4));
|
236253
236192
|
return sum.is0() ? undefined : sum;
|
236254
236193
|
}
|
236255
|
-
toAffine(
|
236256
|
-
return toAffineMemo(this,
|
236194
|
+
toAffine(iz) {
|
236195
|
+
return toAffineMemo(this, iz);
|
236257
236196
|
}
|
236258
236197
|
isTorsionFree() {
|
236259
|
-
const { isTorsionFree } =
|
236198
|
+
const { h: cofactor, isTorsionFree } = CURVE;
|
236260
236199
|
if (cofactor === _1n5)
|
236261
236200
|
return true;
|
236262
236201
|
if (isTorsionFree)
|
236263
236202
|
return isTorsionFree(Point, this);
|
236264
|
-
|
236203
|
+
throw new Error("isTorsionFree() has not been declared for the elliptic curve");
|
236265
236204
|
}
|
236266
236205
|
clearCofactor() {
|
236267
|
-
const { clearCofactor } =
|
236206
|
+
const { h: cofactor, clearCofactor } = CURVE;
|
236268
236207
|
if (cofactor === _1n5)
|
236269
236208
|
return this;
|
236270
236209
|
if (clearCofactor)
|
236271
236210
|
return clearCofactor(Point, this);
|
236272
|
-
return this.multiplyUnsafe(
|
236211
|
+
return this.multiplyUnsafe(CURVE.h);
|
236273
236212
|
}
|
236274
|
-
|
236213
|
+
toRawBytes(isCompressed = true) {
|
236275
236214
|
abool("isCompressed", isCompressed);
|
236276
236215
|
this.assertValidity();
|
236277
236216
|
return toBytes3(Point, this, isCompressed);
|
236278
236217
|
}
|
236279
|
-
toRawBytes(isCompressed = true) {
|
236280
|
-
return this.toBytes(isCompressed);
|
236281
|
-
}
|
236282
236218
|
toHex(isCompressed = true) {
|
236283
|
-
|
236284
|
-
|
236285
|
-
toString() {
|
236286
|
-
return `<Point ${this.is0() ? "ZERO" : this.toHex()}>`;
|
236219
|
+
abool("isCompressed", isCompressed);
|
236220
|
+
return bytesToHex2(this.toRawBytes(isCompressed));
|
236287
236221
|
}
|
236288
236222
|
}
|
236289
236223
|
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);
|
236290
236224
|
Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);
|
236291
|
-
|
236292
|
-
Point.
|
236293
|
-
|
236294
|
-
|
236295
|
-
|
236296
|
-
|
236297
|
-
|
236298
|
-
|
236225
|
+
const { endo, nBitLength } = CURVE;
|
236226
|
+
const wnaf = wNAF(Point, endo ? Math.ceil(nBitLength / 2) : nBitLength);
|
236227
|
+
return {
|
236228
|
+
CURVE,
|
236229
|
+
ProjectivePoint: Point,
|
236230
|
+
normPrivateKeyToScalar,
|
236231
|
+
weierstrassEquation,
|
236232
|
+
isWithinCurveOrder
|
236233
|
+
};
|
236299
236234
|
}
|
236300
|
-
function
|
236301
|
-
|
236235
|
+
function validateOpts(curve) {
|
236236
|
+
const opts = validateBasic(curve);
|
236237
|
+
validateObject(opts, {
|
236238
|
+
hash: "hash",
|
236302
236239
|
hmac: "function",
|
236303
|
-
|
236304
|
-
|
236240
|
+
randomBytes: "function"
|
236241
|
+
}, {
|
236305
236242
|
bits2int: "function",
|
236306
|
-
bits2int_modN: "function"
|
236243
|
+
bits2int_modN: "function",
|
236244
|
+
lowS: "boolean"
|
236245
|
+
});
|
236246
|
+
return Object.freeze({ lowS: true, ...opts });
|
236247
|
+
}
|
236248
|
+
function weierstrass(curveDef) {
|
236249
|
+
const CURVE = validateOpts(curveDef);
|
236250
|
+
const { Fp, n: CURVE_ORDER, nByteLength, nBitLength } = CURVE;
|
236251
|
+
const compressedLen = Fp.BYTES + 1;
|
236252
|
+
const uncompressedLen = 2 * Fp.BYTES + 1;
|
236253
|
+
function modN(a7) {
|
236254
|
+
return mod(a7, CURVE_ORDER);
|
236255
|
+
}
|
236256
|
+
function invN(a7) {
|
236257
|
+
return invert(a7, CURVE_ORDER);
|
236258
|
+
}
|
236259
|
+
const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
|
236260
|
+
...CURVE,
|
236261
|
+
toBytes(_c, point, isCompressed) {
|
236262
|
+
const a7 = point.toAffine();
|
236263
|
+
const x6 = Fp.toBytes(a7.x);
|
236264
|
+
const cat = concatBytes3;
|
236265
|
+
abool("isCompressed", isCompressed);
|
236266
|
+
if (isCompressed) {
|
236267
|
+
return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x6);
|
236268
|
+
} else {
|
236269
|
+
return cat(Uint8Array.from([4]), x6, Fp.toBytes(a7.y));
|
236270
|
+
}
|
236271
|
+
},
|
236272
|
+
fromBytes(bytes) {
|
236273
|
+
const len = bytes.length;
|
236274
|
+
const head = bytes[0];
|
236275
|
+
const tail = bytes.subarray(1);
|
236276
|
+
if (len === compressedLen && (head === 2 || head === 3)) {
|
236277
|
+
const x6 = bytesToNumberBE(tail);
|
236278
|
+
if (!inRange(x6, _1n5, Fp.ORDER))
|
236279
|
+
throw new Error("Point is not on curve");
|
236280
|
+
const y22 = weierstrassEquation(x6);
|
236281
|
+
let y4;
|
236282
|
+
try {
|
236283
|
+
y4 = Fp.sqrt(y22);
|
236284
|
+
} catch (sqrtError) {
|
236285
|
+
const suffix = sqrtError instanceof Error ? ": " + sqrtError.message : "";
|
236286
|
+
throw new Error("Point is not on curve" + suffix);
|
236287
|
+
}
|
236288
|
+
const isYOdd = (y4 & _1n5) === _1n5;
|
236289
|
+
const isHeadOdd = (head & 1) === 1;
|
236290
|
+
if (isHeadOdd !== isYOdd)
|
236291
|
+
y4 = Fp.neg(y4);
|
236292
|
+
return { x: x6, y: y4 };
|
236293
|
+
} else if (len === uncompressedLen && head === 4) {
|
236294
|
+
const x6 = Fp.fromBytes(tail.subarray(0, Fp.BYTES));
|
236295
|
+
const y4 = Fp.fromBytes(tail.subarray(Fp.BYTES, 2 * Fp.BYTES));
|
236296
|
+
return { x: x6, y: y4 };
|
236297
|
+
} else {
|
236298
|
+
const cl = compressedLen;
|
236299
|
+
const ul = uncompressedLen;
|
236300
|
+
throw new Error("invalid Point, expected length of " + cl + ", or uncompressed " + ul + ", got " + len);
|
236301
|
+
}
|
236302
|
+
}
|
236307
236303
|
});
|
236308
|
-
const randomBytes_ = ecdsaOpts.randomBytes || randomBytes;
|
236309
|
-
const hmac_ = ecdsaOpts.hmac || ((key2, ...msgs) => hmac(ecdsaOpts.hash, key2, concatBytes(...msgs)));
|
236310
|
-
const { Fp, Fn } = Point;
|
236311
|
-
const { ORDER: CURVE_ORDER, BITS: fnBits } = Fn;
|
236312
236304
|
function isBiggerThanHalfOrder(number6) {
|
236313
236305
|
const HALF = CURVE_ORDER >> _1n5;
|
236314
236306
|
return number6 > HALF;
|
236315
236307
|
}
|
236316
236308
|
function normalizeS(s7) {
|
236317
|
-
return isBiggerThanHalfOrder(s7) ?
|
236318
|
-
}
|
236319
|
-
function aValidRS(title, num) {
|
236320
|
-
if (!Fn.isValidNot0(num))
|
236321
|
-
throw new Error(`invalid signature ${title}: out of range 1..CURVE.n`);
|
236309
|
+
return isBiggerThanHalfOrder(s7) ? modN(-s7) : s7;
|
236322
236310
|
}
|
236311
|
+
const slcNum = (b4, from, to) => bytesToNumberBE(b4.slice(from, to));
|
236323
236312
|
|
236324
236313
|
class Signature {
|
236325
236314
|
constructor(r6, s7, recovery) {
|
236326
|
-
|
236327
|
-
|
236315
|
+
aInRange("r", r6, _1n5, CURVE_ORDER);
|
236316
|
+
aInRange("s", s7, _1n5, CURVE_ORDER);
|
236328
236317
|
this.r = r6;
|
236329
236318
|
this.s = s7;
|
236330
236319
|
if (recovery != null)
|
@@ -236332,9 +236321,9 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236332
236321
|
Object.freeze(this);
|
236333
236322
|
}
|
236334
236323
|
static fromCompact(hex) {
|
236335
|
-
const
|
236336
|
-
|
236337
|
-
return new Signature(
|
236324
|
+
const l3 = nByteLength;
|
236325
|
+
hex = ensureBytes("compactSignature", hex, l3 * 2);
|
236326
|
+
return new Signature(slcNum(hex, 0, l3), slcNum(hex, l3, 2 * l3));
|
236338
236327
|
}
|
236339
236328
|
static fromDER(hex) {
|
236340
236329
|
const { r: r6, s: s7 } = DER.toSig(ensureBytes("DER", hex));
|
@@ -236345,24 +236334,20 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236345
236334
|
return new Signature(this.r, this.s, recovery);
|
236346
236335
|
}
|
236347
236336
|
recoverPublicKey(msgHash) {
|
236348
|
-
const FIELD_ORDER = Fp.ORDER;
|
236349
236337
|
const { r: r6, s: s7, recovery: rec } = this;
|
236338
|
+
const h8 = bits2int_modN(ensureBytes("msgHash", msgHash));
|
236350
236339
|
if (rec == null || ![0, 1, 2, 3].includes(rec))
|
236351
236340
|
throw new Error("recovery id invalid");
|
236352
|
-
const
|
236353
|
-
if (
|
236354
|
-
throw new Error("recovery id is ambiguous for h>1 curve");
|
236355
|
-
const radj = rec === 2 || rec === 3 ? r6 + CURVE_ORDER : r6;
|
236356
|
-
if (!Fp.isValid(radj))
|
236341
|
+
const radj = rec === 2 || rec === 3 ? r6 + CURVE.n : r6;
|
236342
|
+
if (radj >= Fp.ORDER)
|
236357
236343
|
throw new Error("recovery id 2 or 3 invalid");
|
236358
|
-
const
|
236359
|
-
const R7 = Point.fromHex(
|
236360
|
-
const ir2 =
|
236361
|
-
const
|
236362
|
-
const
|
236363
|
-
const
|
236364
|
-
|
236365
|
-
if (Q4.is0())
|
236344
|
+
const prefix = (rec & 1) === 0 ? "02" : "03";
|
236345
|
+
const R7 = Point.fromHex(prefix + numToSizedHex(radj, Fp.BYTES));
|
236346
|
+
const ir2 = invN(radj);
|
236347
|
+
const u1 = modN(-h8 * ir2);
|
236348
|
+
const u22 = modN(s7 * ir2);
|
236349
|
+
const Q4 = Point.BASE.multiplyAndAddUnsafe(R7, u1, u22);
|
236350
|
+
if (!Q4)
|
236366
236351
|
throw new Error("point at infinify");
|
236367
236352
|
Q4.assertValidity();
|
236368
236353
|
return Q4;
|
@@ -236371,29 +236356,22 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236371
236356
|
return isBiggerThanHalfOrder(this.s);
|
236372
236357
|
}
|
236373
236358
|
normalizeS() {
|
236374
|
-
return this.hasHighS() ? new Signature(this.r,
|
236375
|
-
}
|
236376
|
-
toBytes(format2) {
|
236377
|
-
if (format2 === "compact")
|
236378
|
-
return concatBytes(Fn.toBytes(this.r), Fn.toBytes(this.s));
|
236379
|
-
if (format2 === "der")
|
236380
|
-
return hexToBytes2(DER.hexFromSig(this));
|
236381
|
-
throw new Error("invalid format");
|
236359
|
+
return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;
|
236382
236360
|
}
|
236383
236361
|
toDERRawBytes() {
|
236384
|
-
return this.
|
236362
|
+
return hexToBytes2(this.toDERHex());
|
236385
236363
|
}
|
236386
236364
|
toDERHex() {
|
236387
|
-
return
|
236365
|
+
return DER.hexFromSig(this);
|
236388
236366
|
}
|
236389
236367
|
toCompactRawBytes() {
|
236390
|
-
return this.
|
236368
|
+
return hexToBytes2(this.toCompactHex());
|
236391
236369
|
}
|
236392
236370
|
toCompactHex() {
|
236393
|
-
|
236371
|
+
const l3 = nByteLength;
|
236372
|
+
return numToSizedHex(this.r, l3) + numToSizedHex(this.s, l3);
|
236394
236373
|
}
|
236395
236374
|
}
|
236396
|
-
const normPrivateKeyToScalar = _legacyHelperNormPriv(Fn, curveOpts.allowedPrivateKeyLengths, curveOpts.wrapPrivateKey);
|
236397
236375
|
const utils = {
|
236398
236376
|
isValidPrivateKey(privateKey) {
|
236399
236377
|
try {
|
@@ -236405,15 +236383,17 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236405
236383
|
},
|
236406
236384
|
normPrivateKeyToScalar,
|
236407
236385
|
randomPrivateKey: () => {
|
236408
|
-
const
|
236409
|
-
return mapHashToField(
|
236386
|
+
const length = getMinHashLength(CURVE.n);
|
236387
|
+
return mapHashToField(CURVE.randomBytes(length), CURVE.n);
|
236410
236388
|
},
|
236411
236389
|
precompute(windowSize = 8, point = Point.BASE) {
|
236412
|
-
|
236390
|
+
point._setWindowSize(windowSize);
|
236391
|
+
point.multiply(BigInt(3));
|
236392
|
+
return point;
|
236413
236393
|
}
|
236414
236394
|
};
|
236415
236395
|
function getPublicKey(privateKey, isCompressed = true) {
|
236416
|
-
return Point.fromPrivateKey(privateKey).
|
236396
|
+
return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
236417
236397
|
}
|
236418
236398
|
function isProbPub(item) {
|
236419
236399
|
if (typeof item === "bigint")
|
@@ -236421,14 +236401,14 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236421
236401
|
if (item instanceof Point)
|
236422
236402
|
return true;
|
236423
236403
|
const arr = ensureBytes("key", item);
|
236424
|
-
const
|
236425
|
-
const
|
236426
|
-
const
|
236427
|
-
const
|
236428
|
-
if (
|
236404
|
+
const len = arr.length;
|
236405
|
+
const fpl = Fp.BYTES;
|
236406
|
+
const compLen = fpl + 1;
|
236407
|
+
const uncompLen = 2 * fpl + 1;
|
236408
|
+
if (CURVE.allowedPrivateKeyLengths || nByteLength === compLen) {
|
236429
236409
|
return;
|
236430
236410
|
} else {
|
236431
|
-
return
|
236411
|
+
return len === compLen || len === uncompLen;
|
236432
236412
|
}
|
236433
236413
|
}
|
236434
236414
|
function getSharedSecret(privateA, publicB, isCompressed = true) {
|
@@ -236437,27 +236417,27 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236437
236417
|
if (isProbPub(publicB) === false)
|
236438
236418
|
throw new Error("second arg must be public key");
|
236439
236419
|
const b4 = Point.fromHex(publicB);
|
236440
|
-
return b4.multiply(normPrivateKeyToScalar(privateA)).
|
236420
|
+
return b4.multiply(normPrivateKeyToScalar(privateA)).toRawBytes(isCompressed);
|
236441
236421
|
}
|
236442
|
-
const bits2int =
|
236422
|
+
const bits2int = CURVE.bits2int || function(bytes) {
|
236443
236423
|
if (bytes.length > 8192)
|
236444
236424
|
throw new Error("input is too large");
|
236445
236425
|
const num = bytesToNumberBE(bytes);
|
236446
|
-
const delta = bytes.length * 8 -
|
236426
|
+
const delta = bytes.length * 8 - nBitLength;
|
236447
236427
|
return delta > 0 ? num >> BigInt(delta) : num;
|
236448
236428
|
};
|
236449
|
-
const bits2int_modN =
|
236450
|
-
return
|
236429
|
+
const bits2int_modN = CURVE.bits2int_modN || function(bytes) {
|
236430
|
+
return modN(bits2int(bytes));
|
236451
236431
|
};
|
236452
|
-
const ORDER_MASK = bitMask(
|
236432
|
+
const ORDER_MASK = bitMask(nBitLength);
|
236453
236433
|
function int2octets(num) {
|
236454
|
-
aInRange("num < 2^" +
|
236455
|
-
return
|
236434
|
+
aInRange("num < 2^" + nBitLength, num, _0n5, ORDER_MASK);
|
236435
|
+
return numberToBytesBE(num, nByteLength);
|
236456
236436
|
}
|
236457
236437
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
236458
236438
|
if (["recovered", "canonical"].some((k5) => (k5 in opts)))
|
236459
236439
|
throw new Error("sign() legacy options not supported");
|
236460
|
-
const { hash: hash2 } =
|
236440
|
+
const { hash: hash2, randomBytes: randomBytes2 } = CURVE;
|
236461
236441
|
let { lowS, prehash, extraEntropy: ent } = opts;
|
236462
236442
|
if (lowS == null)
|
236463
236443
|
lowS = true;
|
@@ -236469,21 +236449,21 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236469
236449
|
const d6 = normPrivateKeyToScalar(privateKey);
|
236470
236450
|
const seedArgs = [int2octets(d6), int2octets(h1int)];
|
236471
236451
|
if (ent != null && ent !== false) {
|
236472
|
-
const e10 = ent === true ?
|
236452
|
+
const e10 = ent === true ? randomBytes2(Fp.BYTES) : ent;
|
236473
236453
|
seedArgs.push(ensureBytes("extraEntropy", e10));
|
236474
236454
|
}
|
236475
|
-
const seed =
|
236455
|
+
const seed = concatBytes3(...seedArgs);
|
236476
236456
|
const m7 = h1int;
|
236477
236457
|
function k2sig(kBytes) {
|
236478
236458
|
const k5 = bits2int(kBytes);
|
236479
|
-
if (!
|
236459
|
+
if (!isWithinCurveOrder(k5))
|
236480
236460
|
return;
|
236481
|
-
const ik =
|
236461
|
+
const ik = invN(k5);
|
236482
236462
|
const q6 = Point.BASE.multiply(k5).toAffine();
|
236483
|
-
const r6 =
|
236463
|
+
const r6 = modN(q6.x);
|
236484
236464
|
if (r6 === _0n5)
|
236485
236465
|
return;
|
236486
|
-
const s7 =
|
236466
|
+
const s7 = modN(ik * modN(m7 + r6 * d6));
|
236487
236467
|
if (s7 === _0n5)
|
236488
236468
|
return;
|
236489
236469
|
let recovery = (q6.x === r6 ? 0 : 2) | Number(q6.y & _1n5);
|
@@ -236496,38 +236476,34 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236496
236476
|
}
|
236497
236477
|
return { seed, k2sig };
|
236498
236478
|
}
|
236499
|
-
const defaultSigOpts = { lowS:
|
236500
|
-
const defaultVerOpts = { lowS:
|
236479
|
+
const defaultSigOpts = { lowS: CURVE.lowS, prehash: false };
|
236480
|
+
const defaultVerOpts = { lowS: CURVE.lowS, prehash: false };
|
236501
236481
|
function sign(msgHash, privKey, opts = defaultSigOpts) {
|
236502
236482
|
const { seed, k2sig } = prepSig(msgHash, privKey, opts);
|
236503
|
-
const
|
236483
|
+
const C4 = CURVE;
|
236484
|
+
const drbg = createHmacDrbg(C4.hash.outputLen, C4.nByteLength, C4.hmac);
|
236504
236485
|
return drbg(seed, k2sig);
|
236505
236486
|
}
|
236506
|
-
Point.BASE.
|
236487
|
+
Point.BASE._setWindowSize(8);
|
236507
236488
|
function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
|
236508
236489
|
const sg = signature;
|
236509
236490
|
msgHash = ensureBytes("msgHash", msgHash);
|
236510
236491
|
publicKey = ensureBytes("publicKey", publicKey);
|
236511
|
-
validateSigVerOpts(opts);
|
236512
236492
|
const { lowS, prehash, format: format2 } = opts;
|
236493
|
+
validateSigVerOpts(opts);
|
236513
236494
|
if ("strict" in opts)
|
236514
236495
|
throw new Error("options.strict was renamed to lowS");
|
236515
|
-
if (format2 !== undefined &&
|
236516
|
-
throw new Error(
|
236517
|
-
const isHex2 = typeof sg === "string" ||
|
236496
|
+
if (format2 !== undefined && format2 !== "compact" && format2 !== "der")
|
236497
|
+
throw new Error("format must be compact or der");
|
236498
|
+
const isHex2 = typeof sg === "string" || isBytes2(sg);
|
236518
236499
|
const isObj = !isHex2 && !format2 && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
|
236519
236500
|
if (!isHex2 && !isObj)
|
236520
236501
|
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
236521
236502
|
let _sig = undefined;
|
236522
236503
|
let P5;
|
236523
236504
|
try {
|
236524
|
-
if (isObj)
|
236525
|
-
|
236526
|
-
_sig = new Signature(sg.r, sg.s);
|
236527
|
-
} else {
|
236528
|
-
throw new Error("invalid format");
|
236529
|
-
}
|
236530
|
-
}
|
236505
|
+
if (isObj)
|
236506
|
+
_sig = new Signature(sg.r, sg.s);
|
236531
236507
|
if (isHex2) {
|
236532
236508
|
try {
|
236533
236509
|
if (format2 !== "compact")
|
@@ -236548,77 +236524,28 @@ function ecdsa(Point, ecdsaOpts, curveOpts = {}) {
|
|
236548
236524
|
if (lowS && _sig.hasHighS())
|
236549
236525
|
return false;
|
236550
236526
|
if (prehash)
|
236551
|
-
msgHash =
|
236527
|
+
msgHash = CURVE.hash(msgHash);
|
236552
236528
|
const { r: r6, s: s7 } = _sig;
|
236553
236529
|
const h8 = bits2int_modN(msgHash);
|
236554
|
-
const is =
|
236555
|
-
const u1 =
|
236556
|
-
const u22 =
|
236557
|
-
const R7 = Point.BASE.
|
236558
|
-
if (R7
|
236530
|
+
const is = invN(s7);
|
236531
|
+
const u1 = modN(h8 * is);
|
236532
|
+
const u22 = modN(r6 * is);
|
236533
|
+
const R7 = Point.BASE.multiplyAndAddUnsafe(P5, u1, u22)?.toAffine();
|
236534
|
+
if (!R7)
|
236559
236535
|
return false;
|
236560
|
-
const v6 =
|
236536
|
+
const v6 = modN(R7.x);
|
236561
236537
|
return v6 === r6;
|
236562
236538
|
}
|
236563
|
-
return
|
236539
|
+
return {
|
236540
|
+
CURVE,
|
236564
236541
|
getPublicKey,
|
236565
236542
|
getSharedSecret,
|
236566
236543
|
sign,
|
236567
236544
|
verify,
|
236568
|
-
|
236569
|
-
|
236570
|
-
|
236571
|
-
}
|
236572
|
-
}
|
236573
|
-
function _weierstrass_legacy_opts_to_new(c3) {
|
236574
|
-
const CURVE = {
|
236575
|
-
a: c3.a,
|
236576
|
-
b: c3.b,
|
236577
|
-
p: c3.Fp.ORDER,
|
236578
|
-
n: c3.n,
|
236579
|
-
h: c3.h,
|
236580
|
-
Gx: c3.Gx,
|
236581
|
-
Gy: c3.Gy
|
236582
|
-
};
|
236583
|
-
const Fp = c3.Fp;
|
236584
|
-
const Fn = Field(CURVE.n, c3.nBitLength);
|
236585
|
-
const curveOpts = {
|
236586
|
-
Fp,
|
236587
|
-
Fn,
|
236588
|
-
allowedPrivateKeyLengths: c3.allowedPrivateKeyLengths,
|
236589
|
-
allowInfinityPoint: c3.allowInfinityPoint,
|
236590
|
-
endo: c3.endo,
|
236591
|
-
wrapPrivateKey: c3.wrapPrivateKey,
|
236592
|
-
isTorsionFree: c3.isTorsionFree,
|
236593
|
-
clearCofactor: c3.clearCofactor,
|
236594
|
-
fromBytes: c3.fromBytes,
|
236595
|
-
toBytes: c3.toBytes
|
236596
|
-
};
|
236597
|
-
return { CURVE, curveOpts };
|
236598
|
-
}
|
236599
|
-
function _ecdsa_legacy_opts_to_new(c3) {
|
236600
|
-
const { CURVE, curveOpts } = _weierstrass_legacy_opts_to_new(c3);
|
236601
|
-
const ecdsaOpts = {
|
236602
|
-
hash: c3.hash,
|
236603
|
-
hmac: c3.hmac,
|
236604
|
-
randomBytes: c3.randomBytes,
|
236605
|
-
lowS: c3.lowS,
|
236606
|
-
bits2int: c3.bits2int,
|
236607
|
-
bits2int_modN: c3.bits2int_modN
|
236608
|
-
};
|
236609
|
-
return { CURVE, curveOpts, ecdsaOpts };
|
236610
|
-
}
|
236611
|
-
function _ecdsa_new_output_to_legacy(c3, ecdsa2) {
|
236612
|
-
return Object.assign({}, ecdsa2, {
|
236613
|
-
ProjectivePoint: ecdsa2.Point,
|
236614
|
-
CURVE: c3
|
236615
|
-
});
|
236616
|
-
}
|
236617
|
-
function weierstrass(c3) {
|
236618
|
-
const { CURVE, curveOpts, ecdsaOpts } = _ecdsa_legacy_opts_to_new(c3);
|
236619
|
-
const Point = weierstrassN(CURVE, curveOpts);
|
236620
|
-
const signs = ecdsa(Point, ecdsaOpts, curveOpts);
|
236621
|
-
return _ecdsa_new_output_to_legacy(c3, signs);
|
236545
|
+
ProjectivePoint: Point,
|
236546
|
+
Signature,
|
236547
|
+
utils
|
236548
|
+
};
|
236622
236549
|
}
|
236623
236550
|
function SWUFpSqrtRatio(Fp, Z4) {
|
236624
236551
|
const q6 = Fp.ORDER;
|
@@ -236684,29 +236611,28 @@ function SWUFpSqrtRatio(Fp, Z4) {
|
|
236684
236611
|
}
|
236685
236612
|
function mapToCurveSimpleSWU(Fp, opts) {
|
236686
236613
|
validateField(Fp);
|
236687
|
-
|
236688
|
-
if (!Fp.isValid(A5) || !Fp.isValid(B4) || !Fp.isValid(Z4))
|
236614
|
+
if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))
|
236689
236615
|
throw new Error("mapToCurveSimpleSWU: invalid opts");
|
236690
|
-
const sqrtRatio = SWUFpSqrtRatio(Fp,
|
236616
|
+
const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);
|
236691
236617
|
if (!Fp.isOdd)
|
236692
|
-
throw new Error("
|
236618
|
+
throw new Error("Fp.isOdd is not implemented!");
|
236693
236619
|
return (u6) => {
|
236694
236620
|
let tv1, tv2, tv3, tv4, tv5, tv6, x6, y4;
|
236695
236621
|
tv1 = Fp.sqr(u6);
|
236696
|
-
tv1 = Fp.mul(tv1,
|
236622
|
+
tv1 = Fp.mul(tv1, opts.Z);
|
236697
236623
|
tv2 = Fp.sqr(tv1);
|
236698
236624
|
tv2 = Fp.add(tv2, tv1);
|
236699
236625
|
tv3 = Fp.add(tv2, Fp.ONE);
|
236700
|
-
tv3 = Fp.mul(tv3,
|
236701
|
-
tv4 = Fp.cmov(
|
236702
|
-
tv4 = Fp.mul(tv4,
|
236626
|
+
tv3 = Fp.mul(tv3, opts.B);
|
236627
|
+
tv4 = Fp.cmov(opts.Z, Fp.neg(tv2), !Fp.eql(tv2, Fp.ZERO));
|
236628
|
+
tv4 = Fp.mul(tv4, opts.A);
|
236703
236629
|
tv2 = Fp.sqr(tv3);
|
236704
236630
|
tv6 = Fp.sqr(tv4);
|
236705
|
-
tv5 = Fp.mul(tv6,
|
236631
|
+
tv5 = Fp.mul(tv6, opts.A);
|
236706
236632
|
tv2 = Fp.add(tv2, tv5);
|
236707
236633
|
tv2 = Fp.mul(tv2, tv3);
|
236708
236634
|
tv6 = Fp.mul(tv6, tv4);
|
236709
|
-
tv5 = Fp.mul(tv6,
|
236635
|
+
tv5 = Fp.mul(tv6, opts.B);
|
236710
236636
|
tv2 = Fp.add(tv2, tv5);
|
236711
236637
|
x6 = Fp.mul(tv1, tv3);
|
236712
236638
|
const { isValid, value: value4 } = sqrtRatio(tv2, tv6);
|
@@ -236723,10 +236649,9 @@ function mapToCurveSimpleSWU(Fp, opts) {
|
|
236723
236649
|
}
|
236724
236650
|
var DERErr, DER, _0n5, _1n5, _2n3, _3n2, _4n2;
|
236725
236651
|
var init_weierstrass = __esm(() => {
|
236726
|
-
init_hmac();
|
236727
|
-
init_utils3();
|
236728
236652
|
init_curve();
|
236729
236653
|
init_modular();
|
236654
|
+
init_utils3();
|
236730
236655
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
236731
236656
|
DERErr = class DERErr extends Error {
|
236732
236657
|
constructor(m7 = "") {
|
@@ -236834,11 +236759,20 @@ var init_weierstrass = __esm(() => {
|
|
236834
236759
|
});
|
236835
236760
|
|
236836
236761
|
// ../../node_modules/@noble/curves/esm/_shortw_utils.js
|
236762
|
+
function getHash(hash2) {
|
236763
|
+
return {
|
236764
|
+
hash: hash2,
|
236765
|
+
hmac: (key2, ...msgs) => hmac(hash2, key2, concatBytes(...msgs)),
|
236766
|
+
randomBytes
|
236767
|
+
};
|
236768
|
+
}
|
236837
236769
|
function createCurve(curveDef, defHash) {
|
236838
|
-
const create2 = (hash2) => weierstrass({ ...curveDef,
|
236770
|
+
const create2 = (hash2) => weierstrass({ ...curveDef, ...getHash(hash2) });
|
236839
236771
|
return { ...create2(defHash), create: create2 };
|
236840
236772
|
}
|
236841
236773
|
var init__shortw_utils = __esm(() => {
|
236774
|
+
init_hmac();
|
236775
|
+
init_utils2();
|
236842
236776
|
init_weierstrass();
|
236843
236777
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
236844
236778
|
});
|
@@ -236868,55 +236802,52 @@ function anum(item) {
|
|
236868
236802
|
throw new Error("number expected");
|
236869
236803
|
}
|
236870
236804
|
function expand_message_xmd(msg, DST, lenInBytes, H4) {
|
236871
|
-
|
236872
|
-
|
236805
|
+
abytes2(msg);
|
236806
|
+
abytes2(DST);
|
236873
236807
|
anum(lenInBytes);
|
236874
236808
|
if (DST.length > 255)
|
236875
|
-
DST = H4(
|
236809
|
+
DST = H4(concatBytes3(utf8ToBytes2("H2C-OVERSIZE-DST-"), DST));
|
236876
236810
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H4;
|
236877
236811
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
236878
236812
|
if (lenInBytes > 65535 || ell > 255)
|
236879
236813
|
throw new Error("expand_message_xmd: invalid lenInBytes");
|
236880
|
-
const DST_prime =
|
236814
|
+
const DST_prime = concatBytes3(DST, i2osp(DST.length, 1));
|
236881
236815
|
const Z_pad = i2osp(0, r_in_bytes);
|
236882
236816
|
const l_i_b_str = i2osp(lenInBytes, 2);
|
236883
236817
|
const b4 = new Array(ell);
|
236884
|
-
const b_0 = H4(
|
236885
|
-
b4[0] = H4(
|
236818
|
+
const b_0 = H4(concatBytes3(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
|
236819
|
+
b4[0] = H4(concatBytes3(b_0, i2osp(1, 1), DST_prime));
|
236886
236820
|
for (let i6 = 1;i6 <= ell; i6++) {
|
236887
236821
|
const args = [strxor(b_0, b4[i6 - 1]), i2osp(i6 + 1, 1), DST_prime];
|
236888
|
-
b4[i6] = H4(
|
236822
|
+
b4[i6] = H4(concatBytes3(...args));
|
236889
236823
|
}
|
236890
|
-
const pseudo_random_bytes =
|
236824
|
+
const pseudo_random_bytes = concatBytes3(...b4);
|
236891
236825
|
return pseudo_random_bytes.slice(0, lenInBytes);
|
236892
236826
|
}
|
236893
236827
|
function expand_message_xof(msg, DST, lenInBytes, k5, H4) {
|
236894
|
-
|
236895
|
-
|
236828
|
+
abytes2(msg);
|
236829
|
+
abytes2(DST);
|
236896
236830
|
anum(lenInBytes);
|
236897
236831
|
if (DST.length > 255) {
|
236898
236832
|
const dkLen = Math.ceil(2 * k5 / 8);
|
236899
|
-
DST = H4.create({ dkLen }).update(
|
236833
|
+
DST = H4.create({ dkLen }).update(utf8ToBytes2("H2C-OVERSIZE-DST-")).update(DST).digest();
|
236900
236834
|
}
|
236901
236835
|
if (lenInBytes > 65535 || DST.length > 255)
|
236902
236836
|
throw new Error("expand_message_xof: invalid lenInBytes");
|
236903
236837
|
return H4.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
|
236904
236838
|
}
|
236905
236839
|
function hash_to_field(msg, count, options) {
|
236906
|
-
|
236840
|
+
validateObject(options, {
|
236841
|
+
DST: "stringOrUint8Array",
|
236907
236842
|
p: "bigint",
|
236908
|
-
m: "
|
236909
|
-
k: "
|
236910
|
-
hash: "
|
236843
|
+
m: "isSafeInteger",
|
236844
|
+
k: "isSafeInteger",
|
236845
|
+
hash: "hash"
|
236911
236846
|
});
|
236912
236847
|
const { p: p5, k: k5, m: m7, hash: hash2, expand, DST: _DST } = options;
|
236913
|
-
|
236914
|
-
throw new Error("DST must be string or uint8array");
|
236915
|
-
if (!isHash(options.hash))
|
236916
|
-
throw new Error("expected valid hash");
|
236917
|
-
abytes(msg);
|
236848
|
+
abytes2(msg);
|
236918
236849
|
anum(count);
|
236919
|
-
const DST = typeof _DST === "string" ?
|
236850
|
+
const DST = typeof _DST === "string" ? utf8ToBytes2(_DST) : _DST;
|
236920
236851
|
const log2p = p5.toString(2).length;
|
236921
236852
|
const L5 = Math.ceil((log2p + k5) / 8);
|
236922
236853
|
const len_in_bytes = count * m7 * L5;
|
@@ -236968,17 +236899,13 @@ function createHasher2(Point, mapToCurve, defaults4) {
|
|
236968
236899
|
return {
|
236969
236900
|
defaults: defaults4,
|
236970
236901
|
hashToCurve(msg, options) {
|
236971
|
-
const
|
236972
|
-
const opts = Object.assign({}, defaults4, dst, options);
|
236973
|
-
const u6 = hash_to_field(msg, 2, opts);
|
236902
|
+
const u6 = hash_to_field(msg, 2, { ...defaults4, DST: defaults4.DST, ...options });
|
236974
236903
|
const u0 = map6(u6[0]);
|
236975
236904
|
const u1 = map6(u6[1]);
|
236976
236905
|
return clear(u0.add(u1));
|
236977
236906
|
},
|
236978
236907
|
encodeToCurve(msg, options) {
|
236979
|
-
const
|
236980
|
-
const opts = Object.assign({}, defaults4, dst, options);
|
236981
|
-
const u6 = hash_to_field(msg, 1, opts);
|
236908
|
+
const u6 = hash_to_field(msg, 1, { ...defaults4, DST: defaults4.encodeDST, ...options });
|
236982
236909
|
return clear(map6(u6[0]));
|
236983
236910
|
},
|
236984
236911
|
mapToCurve(scalars) {
|
@@ -236993,8 +236920,8 @@ function createHasher2(Point, mapToCurve, defaults4) {
|
|
236993
236920
|
}
|
236994
236921
|
var os2ip;
|
236995
236922
|
var init_hash_to_curve = __esm(() => {
|
236996
|
-
init_utils3();
|
236997
236923
|
init_modular();
|
236924
|
+
init_utils3();
|
236998
236925
|
os2ip = bytesToNumberBE;
|
236999
236926
|
});
|
237000
236927
|
|
@@ -237008,7 +236935,7 @@ __export(exports_secp256k1, {
|
|
237008
236935
|
encodeToCurve: () => encodeToCurve
|
237009
236936
|
});
|
237010
236937
|
function sqrtMod(y4) {
|
237011
|
-
const P5 =
|
236938
|
+
const P5 = secp256k1P;
|
237012
236939
|
const _3n3 = BigInt(3), _6n = BigInt(6), _11n = BigInt(11), _22n = BigInt(22);
|
237013
236940
|
const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
|
237014
236941
|
const b22 = y4 * y4 * y4 % P5;
|
@@ -237033,25 +236960,25 @@ function taggedHash(tag, ...messages) {
|
|
237033
236960
|
let tagP = TAGGED_HASH_PREFIXES[tag];
|
237034
236961
|
if (tagP === undefined) {
|
237035
236962
|
const tagH = sha256(Uint8Array.from(tag, (c3) => c3.charCodeAt(0)));
|
237036
|
-
tagP =
|
236963
|
+
tagP = concatBytes3(tagH, tagH);
|
237037
236964
|
TAGGED_HASH_PREFIXES[tag] = tagP;
|
237038
236965
|
}
|
237039
|
-
return sha256(
|
236966
|
+
return sha256(concatBytes3(tagP, ...messages));
|
237040
236967
|
}
|
237041
236968
|
function schnorrGetExtPubKey(priv) {
|
237042
236969
|
let d_ = secp256k1.utils.normPrivateKeyToScalar(priv);
|
237043
236970
|
let p5 = Point.fromPrivateKey(d_);
|
237044
|
-
const scalar =
|
236971
|
+
const scalar = p5.hasEvenY() ? d_ : modN(-d_);
|
237045
236972
|
return { scalar, bytes: pointToBytes(p5) };
|
237046
236973
|
}
|
237047
236974
|
function lift_x(x6) {
|
237048
|
-
aInRange("x", x6, _1n6,
|
236975
|
+
aInRange("x", x6, _1n6, secp256k1P);
|
237049
236976
|
const xx = modP(x6 * x6);
|
237050
236977
|
const c3 = modP(xx * x6 + BigInt(7));
|
237051
236978
|
let y4 = sqrtMod(c3);
|
237052
|
-
if (
|
236979
|
+
if (y4 % _2n4 !== _0n6)
|
237053
236980
|
y4 = modP(-y4);
|
237054
|
-
const p5 = Point
|
236981
|
+
const p5 = new Point(x6, y4, _1n6);
|
237055
236982
|
p5.assertValidity();
|
237056
236983
|
return p5;
|
237057
236984
|
}
|
@@ -237086,52 +237013,49 @@ function schnorrVerify(signature, message, publicKey) {
|
|
237086
237013
|
try {
|
237087
237014
|
const P5 = lift_x(num(pub));
|
237088
237015
|
const r6 = num(sig.subarray(0, 32));
|
237089
|
-
if (!inRange(r6, _1n6,
|
237016
|
+
if (!inRange(r6, _1n6, secp256k1P))
|
237090
237017
|
return false;
|
237091
237018
|
const s7 = num(sig.subarray(32, 64));
|
237092
|
-
if (!inRange(s7, _1n6,
|
237019
|
+
if (!inRange(s7, _1n6, secp256k1N))
|
237093
237020
|
return false;
|
237094
237021
|
const e10 = challenge(numTo32b(r6), pointToBytes(P5), m7);
|
237095
|
-
const R7 =
|
237096
|
-
|
237097
|
-
if (R7.is0() || !hasEven(y4) || x6 !== r6)
|
237022
|
+
const R7 = GmulAdd(P5, s7, modN(-e10));
|
237023
|
+
if (!R7 || !R7.hasEvenY() || R7.toAffine().x !== r6)
|
237098
237024
|
return false;
|
237099
237025
|
return true;
|
237100
237026
|
} catch (error44) {
|
237101
237027
|
return false;
|
237102
237028
|
}
|
237103
237029
|
}
|
237104
|
-
var
|
237030
|
+
var secp256k1P, secp256k1N, _0n6, _1n6, _2n4, divNearest = (a7, b4) => (a7 + b4 / _2n4) / b4, Fpk1, secp256k1, TAGGED_HASH_PREFIXES, pointToBytes = (point) => point.toRawBytes(true).slice(1), numTo32b = (n6) => numberToBytesBE(n6, 32), modP = (x6) => mod(x6, secp256k1P), modN = (x6) => mod(x6, secp256k1N), Point, GmulAdd = (Q4, a7, b4) => Point.BASE.multiplyAndAddUnsafe(Q4, a7, b4), num, schnorr, isoMap, mapSWU, secp256k1_hasher, hashToCurve, encodeToCurve;
|
237105
237031
|
var init_secp256k1 = __esm(() => {
|
237106
237032
|
init_sha2();
|
237107
237033
|
init_utils2();
|
237108
237034
|
init__shortw_utils();
|
237109
237035
|
init_hash_to_curve();
|
237110
237036
|
init_modular();
|
237111
|
-
init_weierstrass();
|
237112
237037
|
init_utils3();
|
237038
|
+
init_weierstrass();
|
237113
237039
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
237114
|
-
|
237115
|
-
|
237116
|
-
n: BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),
|
237117
|
-
h: BigInt(1),
|
237118
|
-
a: BigInt(0),
|
237119
|
-
b: BigInt(7),
|
237120
|
-
Gx: BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),
|
237121
|
-
Gy: BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")
|
237122
|
-
};
|
237040
|
+
secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
|
237041
|
+
secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
237123
237042
|
_0n6 = BigInt(0);
|
237124
237043
|
_1n6 = BigInt(1);
|
237125
237044
|
_2n4 = BigInt(2);
|
237126
|
-
Fpk1 = Field(
|
237045
|
+
Fpk1 = Field(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
|
237127
237046
|
secp256k1 = createCurve({
|
237128
|
-
|
237047
|
+
a: _0n6,
|
237048
|
+
b: BigInt(7),
|
237129
237049
|
Fp: Fpk1,
|
237050
|
+
n: secp256k1N,
|
237051
|
+
Gx: BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),
|
237052
|
+
Gy: BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),
|
237053
|
+
h: BigInt(1),
|
237130
237054
|
lowS: true,
|
237131
237055
|
endo: {
|
237132
237056
|
beta: BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),
|
237133
237057
|
splitScalar: (k5) => {
|
237134
|
-
const n6 =
|
237058
|
+
const n6 = secp256k1N;
|
237135
237059
|
const a1 = BigInt("0x3086d221a7d46bcde86c90e49284eb15");
|
237136
237060
|
const b1 = -_1n6 * BigInt("0xe4437ed6010e88286f547fa90abfe4c3");
|
237137
237061
|
const a22 = BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8");
|
@@ -237155,7 +237079,7 @@ var init_secp256k1 = __esm(() => {
|
|
237155
237079
|
}
|
237156
237080
|
}, sha256);
|
237157
237081
|
TAGGED_HASH_PREFIXES = {};
|
237158
|
-
Point = /* @__PURE__ */ (() => secp256k1.
|
237082
|
+
Point = /* @__PURE__ */ (() => secp256k1.ProjectivePoint)();
|
237159
237083
|
num = bytesToNumberBE;
|
237160
237084
|
schnorr = /* @__PURE__ */ (() => ({
|
237161
237085
|
getPublicKey: schnorrGetPublicKey,
|
@@ -237201,7 +237125,7 @@ var init_secp256k1 = __esm(() => {
|
|
237201
237125
|
B: BigInt("1771"),
|
237202
237126
|
Z: Fpk1.create(BigInt("-11"))
|
237203
237127
|
}))();
|
237204
|
-
secp256k1_hasher = /* @__PURE__ */ (() => createHasher2(secp256k1.
|
237128
|
+
secp256k1_hasher = /* @__PURE__ */ (() => createHasher2(secp256k1.ProjectivePoint, (scalars) => {
|
237205
237129
|
const { x: x6, y: y4 } = mapSWU(Fpk1.create(scalars[0]));
|
237206
237130
|
return isoMap(x6, y4);
|
237207
237131
|
}, {
|
@@ -263840,7 +263764,7 @@ function pruneCurrentEnv(currentEnv, env2) {
|
|
263840
263764
|
var package_default = {
|
263841
263765
|
name: "@settlemint/sdk-cli",
|
263842
263766
|
description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
|
263843
|
-
version: "2.4.0
|
263767
|
+
version: "2.4.0",
|
263844
263768
|
type: "module",
|
263845
263769
|
private: false,
|
263846
263770
|
license: "FSL-1.1-MIT",
|
@@ -263889,10 +263813,10 @@ var package_default = {
|
|
263889
263813
|
"@inquirer/input": "4.1.12",
|
263890
263814
|
"@inquirer/password": "4.0.15",
|
263891
263815
|
"@inquirer/select": "4.2.3",
|
263892
|
-
"@settlemint/sdk-js": "2.4.0
|
263893
|
-
"@settlemint/sdk-utils": "2.4.0
|
263894
|
-
"@settlemint/sdk-viem": "2.4.0
|
263895
|
-
"@types/node": "24.0.
|
263816
|
+
"@settlemint/sdk-js": "2.4.0",
|
263817
|
+
"@settlemint/sdk-utils": "2.4.0",
|
263818
|
+
"@settlemint/sdk-viem": "2.4.0",
|
263819
|
+
"@types/node": "24.0.1",
|
263896
263820
|
"@types/semver": "7.7.0",
|
263897
263821
|
"@types/which": "3.0.4",
|
263898
263822
|
"get-tsconfig": "4.10.1",
|
@@ -263900,7 +263824,7 @@ var package_default = {
|
|
263900
263824
|
"is-in-ci": "1.0.0",
|
263901
263825
|
semver: "7.7.2",
|
263902
263826
|
slugify: "1.6.6",
|
263903
|
-
viem: "2.31.
|
263827
|
+
viem: "2.31.1",
|
263904
263828
|
which: "5.0.0",
|
263905
263829
|
yaml: "2.8.0",
|
263906
263830
|
yoctocolors: "2.1.1"
|
@@ -305011,11 +304935,8 @@ function observe(observerId, callbacks, fn) {
|
|
305011
304935
|
if (!listeners2.some((cb) => cb.id === callbackId))
|
305012
304936
|
return;
|
305013
304937
|
const cleanup2 = cleanupCache.get(observerId);
|
305014
|
-
if (listeners2.length === 1 && cleanup2)
|
305015
|
-
|
305016
|
-
if (p5 instanceof Promise)
|
305017
|
-
p5.catch(() => {});
|
305018
|
-
}
|
304938
|
+
if (listeners2.length === 1 && cleanup2)
|
304939
|
+
cleanup2();
|
305019
304940
|
unsubscribe();
|
305020
304941
|
};
|
305021
304942
|
const listeners = getListeners();
|
@@ -307194,7 +307115,7 @@ async function simulateBlocks(client, parameters) {
|
|
307194
307115
|
return;
|
307195
307116
|
return getContractError(error45, {
|
307196
307117
|
abi: abi2 ?? [],
|
307197
|
-
address: to
|
307118
|
+
address: to,
|
307198
307119
|
args,
|
307199
307120
|
functionName: functionName ?? "<unknown>"
|
307200
307121
|
});
|
@@ -308136,6 +308057,14 @@ async function simulateCalls(client, parameters) {
|
|
308136
308057
|
});
|
308137
308058
|
return accessList.map(({ address, storageKeys }) => storageKeys.length > 0 ? address : null);
|
308138
308059
|
})).then((x6) => x6.flat().filter(Boolean)) : [];
|
308060
|
+
const resultsStateOverrides = stateOverrides?.map((override) => {
|
308061
|
+
if (override.address === account?.address)
|
308062
|
+
return {
|
308063
|
+
...override,
|
308064
|
+
nonce: 0
|
308065
|
+
};
|
308066
|
+
return override;
|
308067
|
+
});
|
308139
308068
|
const blocks = await simulateBlocks(client, {
|
308140
308069
|
blockNumber,
|
308141
308070
|
blockTag,
|
@@ -308165,11 +308094,12 @@ async function simulateCalls(client, parameters) {
|
|
308165
308094
|
}
|
308166
308095
|
] : [],
|
308167
308096
|
{
|
308168
|
-
calls: [...calls, {}].map((call2) => ({
|
308097
|
+
calls: [...calls, {}].map((call2, index2) => ({
|
308169
308098
|
...call2,
|
308170
|
-
from: account?.address
|
308099
|
+
from: account?.address,
|
308100
|
+
nonce: index2
|
308171
308101
|
})),
|
308172
|
-
stateOverrides
|
308102
|
+
stateOverrides: resultsStateOverrides
|
308173
308103
|
},
|
308174
308104
|
...traceAssetChanges ? [
|
308175
308105
|
{
|
@@ -308708,7 +308638,7 @@ function watchBlocks(client, { blockTag = "latest", emitMissed = false, emitOnBe
|
|
308708
308638
|
if (!active)
|
308709
308639
|
return;
|
308710
308640
|
const block = await getAction(client, getBlock, "getBlock")({
|
308711
|
-
blockNumber: data.
|
308641
|
+
blockNumber: data.blockNumber,
|
308712
308642
|
includeTransactions
|
308713
308643
|
}).catch(() => {});
|
308714
308644
|
if (!active)
|
@@ -330089,4 +330019,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
330089
330019
|
// src/cli.ts
|
330090
330020
|
sdkCliCommand();
|
330091
330021
|
|
330092
|
-
//# debugId=
|
330022
|
+
//# debugId=C10D93033A91B39964756E2164756E21
|