@settlemint/sdk-cli 2.1.4-pr6b1dbf80 → 2.1.4-pr6d9b7c01
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 +930 -783
- package/dist/cli.js.map +57 -56
- package/package.json +5 -5
package/dist/cli.js
CHANGED
@@ -837,7 +837,7 @@ var require_dist2 = __commonJS((exports) => {
|
|
837
837
|
// ../../node_modules/@dotenvx/dotenvx/package.json
|
838
838
|
var require_package = __commonJS((exports, module) => {
|
839
839
|
module.exports = {
|
840
|
-
version: "1.
|
840
|
+
version: "1.41.0",
|
841
841
|
name: "@dotenvx/dotenvx",
|
842
842
|
description: "a better dotenv–from the creator of `dotenv`",
|
843
843
|
author: "@motdotla",
|
@@ -1086,7 +1086,7 @@ var require_logger = __commonJS((exports, module) => {
|
|
1086
1086
|
// ../../node_modules/fdir/dist/utils.js
|
1087
1087
|
var require_utils = __commonJS((exports) => {
|
1088
1088
|
Object.defineProperty(exports, "__esModule", { value: true });
|
1089
|
-
exports.normalizePath = exports.convertSlashes = exports.cleanPath = undefined;
|
1089
|
+
exports.normalizePath = exports.isRootDirectory = exports.convertSlashes = exports.cleanPath = undefined;
|
1090
1090
|
var path_1 = __require("path");
|
1091
1091
|
function cleanPath(path) {
|
1092
1092
|
let normalized = (0, path_1.normalize)(path);
|
@@ -1100,6 +1100,10 @@ var require_utils = __commonJS((exports) => {
|
|
1100
1100
|
return path.replace(SLASHES_REGEX, separator);
|
1101
1101
|
}
|
1102
1102
|
exports.convertSlashes = convertSlashes;
|
1103
|
+
function isRootDirectory(path) {
|
1104
|
+
return path === "/" || /^[a-z]:\\$/i.test(path);
|
1105
|
+
}
|
1106
|
+
exports.isRootDirectory = isRootDirectory;
|
1103
1107
|
function normalizePath(path, options) {
|
1104
1108
|
const { resolvePaths, normalizePath: normalizePath2, pathSeparator } = options;
|
1105
1109
|
const pathNeedsCleaning = process.platform === "win32" && path.includes("/") || path.startsWith(".");
|
@@ -1523,7 +1527,7 @@ var require_walker = __commonJS((exports) => {
|
|
1523
1527
|
this.callbackInvoker = invokeCallback.build(options, this.isSynchronous);
|
1524
1528
|
this.root = (0, utils_1.normalizePath)(root, options);
|
1525
1529
|
this.state = {
|
1526
|
-
root: this.root.slice(0, -1),
|
1530
|
+
root: (0, utils_1.isRootDirectory)(this.root) ? this.root : this.root.slice(0, -1),
|
1527
1531
|
paths: [""].slice(0, 0),
|
1528
1532
|
groups: [],
|
1529
1533
|
counts: new counter_1.Counter,
|
@@ -3705,23 +3709,51 @@ var require_decrypt = __commonJS((exports, module) => {
|
|
3705
3709
|
module.exports = decrypt;
|
3706
3710
|
});
|
3707
3711
|
|
3708
|
-
// ../../node_modules/@noble/ciphers/
|
3709
|
-
var
|
3712
|
+
// ../../node_modules/@noble/ciphers/utils.js
|
3713
|
+
var require_utils3 = __commonJS((exports) => {
|
3714
|
+
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
3710
3715
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3716
|
+
exports.wrapCipher = exports.Hash = exports.nextTick = exports.isLE = undefined;
|
3717
|
+
exports.isBytes = isBytes;
|
3711
3718
|
exports.abool = abool;
|
3719
|
+
exports.anumber = anumber;
|
3712
3720
|
exports.abytes = abytes;
|
3713
|
-
exports.aexists = aexists;
|
3714
3721
|
exports.ahash = ahash;
|
3715
|
-
exports.
|
3722
|
+
exports.aexists = aexists;
|
3716
3723
|
exports.aoutput = aoutput;
|
3717
|
-
exports.
|
3724
|
+
exports.u8 = u8;
|
3725
|
+
exports.u32 = u32;
|
3726
|
+
exports.clean = clean;
|
3727
|
+
exports.createView = createView;
|
3728
|
+
exports.bytesToHex = bytesToHex;
|
3729
|
+
exports.hexToBytes = hexToBytes;
|
3730
|
+
exports.hexToNumber = hexToNumber;
|
3731
|
+
exports.bytesToNumberBE = bytesToNumberBE;
|
3732
|
+
exports.numberToBytesBE = numberToBytesBE;
|
3733
|
+
exports.utf8ToBytes = utf8ToBytes;
|
3734
|
+
exports.bytesToUtf8 = bytesToUtf8;
|
3735
|
+
exports.toBytes = toBytes;
|
3736
|
+
exports.overlapBytes = overlapBytes;
|
3737
|
+
exports.complexOverlapBytes = complexOverlapBytes;
|
3738
|
+
exports.concatBytes = concatBytes;
|
3739
|
+
exports.checkOpts = checkOpts;
|
3740
|
+
exports.equalBytes = equalBytes;
|
3741
|
+
exports.getOutput = getOutput;
|
3742
|
+
exports.setBigUint64 = setBigUint64;
|
3743
|
+
exports.u64Lengths = u64Lengths;
|
3744
|
+
exports.isAligned32 = isAligned32;
|
3745
|
+
exports.copyBytes = copyBytes;
|
3746
|
+
function isBytes(a) {
|
3747
|
+
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
3748
|
+
}
|
3749
|
+
function abool(b) {
|
3750
|
+
if (typeof b !== "boolean")
|
3751
|
+
throw new Error(`boolean expected, not ${b}`);
|
3752
|
+
}
|
3718
3753
|
function anumber(n) {
|
3719
3754
|
if (!Number.isSafeInteger(n) || n < 0)
|
3720
3755
|
throw new Error("positive integer expected, got " + n);
|
3721
3756
|
}
|
3722
|
-
function isBytes(a) {
|
3723
|
-
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
3724
|
-
}
|
3725
3757
|
function abytes(b, ...lengths) {
|
3726
3758
|
if (!isBytes(b))
|
3727
3759
|
throw new Error("Uint8Array expected");
|
@@ -3730,7 +3762,7 @@ var require__assert = __commonJS((exports) => {
|
|
3730
3762
|
}
|
3731
3763
|
function ahash(h) {
|
3732
3764
|
if (typeof h !== "function" || typeof h.create !== "function")
|
3733
|
-
throw new Error("Hash should be wrapped by utils.
|
3765
|
+
throw new Error("Hash should be wrapped by utils.createHasher");
|
3734
3766
|
anumber(h.outputLen);
|
3735
3767
|
anumber(h.blockLen);
|
3736
3768
|
}
|
@@ -3747,49 +3779,27 @@ var require__assert = __commonJS((exports) => {
|
|
3747
3779
|
throw new Error("digestInto() expects output buffer of length at least " + min);
|
3748
3780
|
}
|
3749
3781
|
}
|
3750
|
-
function
|
3751
|
-
|
3752
|
-
throw new Error(`boolean expected, not ${b}`);
|
3782
|
+
function u8(arr) {
|
3783
|
+
return new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
3753
3784
|
}
|
3754
|
-
|
3755
|
-
|
3756
|
-
|
3757
|
-
|
3758
|
-
|
3759
|
-
|
3760
|
-
|
3761
|
-
|
3762
|
-
|
3763
|
-
|
3764
|
-
|
3765
|
-
exports.
|
3766
|
-
|
3767
|
-
exports.toBytes = toBytes;
|
3768
|
-
exports.overlapBytes = overlapBytes;
|
3769
|
-
exports.complexOverlapBytes = complexOverlapBytes;
|
3770
|
-
exports.concatBytes = concatBytes;
|
3771
|
-
exports.checkOpts = checkOpts;
|
3772
|
-
exports.equalBytes = equalBytes;
|
3773
|
-
exports.getOutput = getOutput;
|
3774
|
-
exports.setBigUint64 = setBigUint64;
|
3775
|
-
exports.u64Lengths = u64Lengths;
|
3776
|
-
exports.isAligned32 = isAligned32;
|
3777
|
-
exports.copyBytes = copyBytes;
|
3778
|
-
exports.clean = clean;
|
3779
|
-
/*! noble-ciphers - MIT License (c) 2023 Paul Miller (paulmillr.com) */
|
3780
|
-
var _assert_js_1 = require__assert();
|
3781
|
-
var u8 = (arr) => new Uint8Array(arr.buffer, arr.byteOffset, arr.byteLength);
|
3782
|
-
exports.u8 = u8;
|
3783
|
-
var u32 = (arr) => new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
3784
|
-
exports.u32 = u32;
|
3785
|
-
var createView = (arr) => new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
3786
|
-
exports.createView = createView;
|
3787
|
-
exports.isLE = new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68;
|
3788
|
-
if (!exports.isLE)
|
3789
|
-
throw new Error("Non little-endian hardware is not supported");
|
3785
|
+
function u32(arr) {
|
3786
|
+
return new Uint32Array(arr.buffer, arr.byteOffset, Math.floor(arr.byteLength / 4));
|
3787
|
+
}
|
3788
|
+
function clean(...arrays) {
|
3789
|
+
for (let i = 0;i < arrays.length; i++) {
|
3790
|
+
arrays[i].fill(0);
|
3791
|
+
}
|
3792
|
+
}
|
3793
|
+
function createView(arr) {
|
3794
|
+
return new DataView(arr.buffer, arr.byteOffset, arr.byteLength);
|
3795
|
+
}
|
3796
|
+
exports.isLE = (() => new Uint8Array(new Uint32Array([287454020]).buffer)[0] === 68)();
|
3797
|
+
var hasHexBuiltin = /* @__PURE__ */ (() => typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function")();
|
3790
3798
|
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
3791
3799
|
function bytesToHex(bytes) {
|
3792
|
-
|
3800
|
+
abytes(bytes);
|
3801
|
+
if (hasHexBuiltin)
|
3802
|
+
return bytes.toHex();
|
3793
3803
|
let hex = "";
|
3794
3804
|
for (let i = 0;i < bytes.length; i++) {
|
3795
3805
|
hex += hexes[bytes[i]];
|
@@ -3809,6 +3819,8 @@ var require_utils3 = __commonJS((exports) => {
|
|
3809
3819
|
function hexToBytes(hex) {
|
3810
3820
|
if (typeof hex !== "string")
|
3811
3821
|
throw new Error("hex string expected, got " + typeof hex);
|
3822
|
+
if (hasHexBuiltin)
|
3823
|
+
return Uint8Array.fromHex(hex);
|
3812
3824
|
const hl = hex.length;
|
3813
3825
|
const al = hl / 2;
|
3814
3826
|
if (hl % 2)
|
@@ -3849,7 +3861,7 @@ var require_utils3 = __commonJS((exports) => {
|
|
3849
3861
|
function toBytes(data) {
|
3850
3862
|
if (typeof data === "string")
|
3851
3863
|
data = utf8ToBytes(data);
|
3852
|
-
else if (
|
3864
|
+
else if (isBytes(data))
|
3853
3865
|
data = copyBytes(data);
|
3854
3866
|
else
|
3855
3867
|
throw new Error("Uint8Array expected, got " + typeof data);
|
@@ -3866,7 +3878,7 @@ var require_utils3 = __commonJS((exports) => {
|
|
3866
3878
|
let sum = 0;
|
3867
3879
|
for (let i = 0;i < arrays.length; i++) {
|
3868
3880
|
const a = arrays[i];
|
3869
|
-
|
3881
|
+
abytes(a);
|
3870
3882
|
sum += a.length;
|
3871
3883
|
}
|
3872
3884
|
const res = new Uint8Array(sum);
|
@@ -3897,26 +3909,28 @@ var require_utils3 = __commonJS((exports) => {
|
|
3897
3909
|
exports.Hash = Hash;
|
3898
3910
|
var wrapCipher = (params, constructor) => {
|
3899
3911
|
function wrappedCipher(key, ...args) {
|
3900
|
-
|
3912
|
+
abytes(key);
|
3913
|
+
if (!exports.isLE)
|
3914
|
+
throw new Error("Non little-endian hardware is not yet supported");
|
3901
3915
|
if (params.nonceLength !== undefined) {
|
3902
3916
|
const nonce = args[0];
|
3903
3917
|
if (!nonce)
|
3904
3918
|
throw new Error("nonce / iv required");
|
3905
3919
|
if (params.varSizeNonce)
|
3906
|
-
|
3920
|
+
abytes(nonce);
|
3907
3921
|
else
|
3908
|
-
|
3922
|
+
abytes(nonce, params.nonceLength);
|
3909
3923
|
}
|
3910
3924
|
const tagl = params.tagLength;
|
3911
3925
|
if (tagl && args[1] !== undefined) {
|
3912
|
-
|
3926
|
+
abytes(args[1]);
|
3913
3927
|
}
|
3914
3928
|
const cipher = constructor(key, ...args);
|
3915
3929
|
const checkOutput = (fnLength, output) => {
|
3916
3930
|
if (output !== undefined) {
|
3917
3931
|
if (fnLength !== 2)
|
3918
3932
|
throw new Error("cipher output not supported");
|
3919
|
-
|
3933
|
+
abytes(output);
|
3920
3934
|
}
|
3921
3935
|
};
|
3922
3936
|
let called = false;
|
@@ -3925,12 +3939,12 @@ var require_utils3 = __commonJS((exports) => {
|
|
3925
3939
|
if (called)
|
3926
3940
|
throw new Error("cannot encrypt() twice with same key + nonce");
|
3927
3941
|
called = true;
|
3928
|
-
|
3942
|
+
abytes(data);
|
3929
3943
|
checkOutput(cipher.encrypt.length, output);
|
3930
3944
|
return cipher.encrypt(data, output);
|
3931
3945
|
},
|
3932
3946
|
decrypt(data, output) {
|
3933
|
-
|
3947
|
+
abytes(data);
|
3934
3948
|
if (tagl && data.length < tagl)
|
3935
3949
|
throw new Error("invalid ciphertext length: smaller than tagLength=" + tagl);
|
3936
3950
|
checkOutput(cipher.decrypt.length, output);
|
@@ -3964,11 +3978,12 @@ var require_utils3 = __commonJS((exports) => {
|
|
3964
3978
|
view.setUint32(byteOffset + h, wh, isLE);
|
3965
3979
|
view.setUint32(byteOffset + l, wl, isLE);
|
3966
3980
|
}
|
3967
|
-
function u64Lengths(
|
3981
|
+
function u64Lengths(dataLength, aadLength, isLE) {
|
3982
|
+
abool(isLE);
|
3968
3983
|
const num = new Uint8Array(16);
|
3969
|
-
const view =
|
3970
|
-
setBigUint64(view, 0, BigInt(
|
3971
|
-
setBigUint64(view, 8, BigInt(
|
3984
|
+
const view = createView(num);
|
3985
|
+
setBigUint64(view, 0, BigInt(aadLength), isLE);
|
3986
|
+
setBigUint64(view, 8, BigInt(dataLength), isLE);
|
3972
3987
|
return num;
|
3973
3988
|
}
|
3974
3989
|
function isAligned32(bytes) {
|
@@ -3977,11 +3992,6 @@ var require_utils3 = __commonJS((exports) => {
|
|
3977
3992
|
function copyBytes(bytes) {
|
3978
3993
|
return Uint8Array.from(bytes);
|
3979
3994
|
}
|
3980
|
-
function clean(...arrays) {
|
3981
|
-
for (let i = 0;i < arrays.length; i++) {
|
3982
|
-
arrays[i].fill(0);
|
3983
|
-
}
|
3984
|
-
}
|
3985
3995
|
});
|
3986
3996
|
|
3987
3997
|
// ../../node_modules/eciesjs/dist/consts.js
|
@@ -4064,14 +4074,13 @@ var require_webcrypto = __commonJS((exports) => {
|
|
4064
4074
|
exports.getWebcryptoSubtle = getWebcryptoSubtle;
|
4065
4075
|
exports.managedNonce = managedNonce;
|
4066
4076
|
var crypto_1 = require_cryptoNode();
|
4067
|
-
var
|
4068
|
-
var utils_js_1 = require_utils3();
|
4077
|
+
var utils_ts_1 = require_utils3();
|
4069
4078
|
function randomBytes(bytesLength = 32) {
|
4070
4079
|
if (crypto_1.crypto && typeof crypto_1.crypto.getRandomValues === "function") {
|
4071
4080
|
return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
|
4072
4081
|
}
|
4073
4082
|
if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") {
|
4074
|
-
return crypto_1.crypto.randomBytes(bytesLength);
|
4083
|
+
return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
|
4075
4084
|
}
|
4076
4085
|
throw new Error("crypto.getRandomValues must be defined");
|
4077
4086
|
}
|
@@ -4082,12 +4091,12 @@ var require_webcrypto = __commonJS((exports) => {
|
|
4082
4091
|
}
|
4083
4092
|
function managedNonce(fn) {
|
4084
4093
|
const { nonceLength } = fn;
|
4085
|
-
(0,
|
4094
|
+
(0, utils_ts_1.anumber)(nonceLength);
|
4086
4095
|
return (key, ...args) => ({
|
4087
4096
|
encrypt(plaintext, ...argsEnc) {
|
4088
4097
|
const nonce = randomBytes(nonceLength);
|
4089
4098
|
const ciphertext = fn(key, nonce, ...args).encrypt(plaintext, ...argsEnc);
|
4090
|
-
const out = (0,
|
4099
|
+
const out = (0, utils_ts_1.concatBytes)(nonce, ciphertext);
|
4091
4100
|
ciphertext.fill(0);
|
4092
4101
|
return out;
|
4093
4102
|
},
|
@@ -4132,21 +4141,21 @@ var require_webcrypto = __commonJS((exports) => {
|
|
4132
4141
|
}
|
4133
4142
|
function generate(algo) {
|
4134
4143
|
return (key, nonce, AAD) => {
|
4135
|
-
(0,
|
4136
|
-
(0,
|
4144
|
+
(0, utils_ts_1.abytes)(key);
|
4145
|
+
(0, utils_ts_1.abytes)(nonce);
|
4137
4146
|
const keyParams = { name: algo, length: key.length * 8 };
|
4138
4147
|
const cryptParams = getCryptParams(algo, nonce, AAD);
|
4139
4148
|
let consumed = false;
|
4140
4149
|
return {
|
4141
4150
|
encrypt(plaintext) {
|
4142
|
-
(0,
|
4151
|
+
(0, utils_ts_1.abytes)(plaintext);
|
4143
4152
|
if (consumed)
|
4144
4153
|
throw new Error("Cannot encrypt() twice with same key / nonce");
|
4145
4154
|
consumed = true;
|
4146
4155
|
return exports.utils.encrypt(key, keyParams, cryptParams, plaintext);
|
4147
4156
|
},
|
4148
4157
|
decrypt(ciphertext) {
|
4149
|
-
(0,
|
4158
|
+
(0, utils_ts_1.abytes)(ciphertext);
|
4150
4159
|
return exports.utils.decrypt(key, keyParams, cryptParams, ciphertext);
|
4151
4160
|
}
|
4152
4161
|
};
|
@@ -4157,8 +4166,8 @@ var require_webcrypto = __commonJS((exports) => {
|
|
4157
4166
|
exports.gcm = /* @__PURE__ */ (() => generate(mode.GCM))();
|
4158
4167
|
});
|
4159
4168
|
|
4160
|
-
// ../../node_modules
|
4161
|
-
var
|
4169
|
+
// ../../node_modules/@noble/hashes/_assert.js
|
4170
|
+
var require__assert = __commonJS((exports) => {
|
4162
4171
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4163
4172
|
exports.anumber = anumber;
|
4164
4173
|
exports.abytes = abytes;
|
@@ -4199,7 +4208,7 @@ var require__assert2 = __commonJS((exports) => {
|
|
4199
4208
|
}
|
4200
4209
|
});
|
4201
4210
|
|
4202
|
-
// ../../node_modules
|
4211
|
+
// ../../node_modules/@noble/hashes/cryptoNode.js
|
4203
4212
|
var require_cryptoNode2 = __commonJS((exports) => {
|
4204
4213
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4205
4214
|
exports.crypto = undefined;
|
@@ -4207,7 +4216,7 @@ var require_cryptoNode2 = __commonJS((exports) => {
|
|
4207
4216
|
exports.crypto = nc && typeof nc === "object" && "webcrypto" in nc ? nc.webcrypto : nc && typeof nc === "object" && ("randomBytes" in nc) ? nc : undefined;
|
4208
4217
|
});
|
4209
4218
|
|
4210
|
-
// ../../node_modules
|
4219
|
+
// ../../node_modules/@noble/hashes/utils.js
|
4211
4220
|
var require_utils4 = __commonJS((exports) => {
|
4212
4221
|
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
4213
4222
|
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -4232,7 +4241,7 @@ var require_utils4 = __commonJS((exports) => {
|
|
4232
4241
|
exports.wrapXOFConstructorWithOpts = wrapXOFConstructorWithOpts;
|
4233
4242
|
exports.randomBytes = randomBytes;
|
4234
4243
|
var crypto_1 = require_cryptoNode2();
|
4235
|
-
var
|
4244
|
+
var _assert_ts_1 = require__assert();
|
4236
4245
|
function isBytes(a) {
|
4237
4246
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
4238
4247
|
}
|
@@ -4261,9 +4270,12 @@ var require_utils4 = __commonJS((exports) => {
|
|
4261
4270
|
arr[i] = byteSwap(arr[i]);
|
4262
4271
|
}
|
4263
4272
|
}
|
4273
|
+
var hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
|
4264
4274
|
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
4265
4275
|
function bytesToHex(bytes) {
|
4266
|
-
(0,
|
4276
|
+
(0, _assert_ts_1.abytes)(bytes);
|
4277
|
+
if (hasHexBuiltin)
|
4278
|
+
return bytes.toHex();
|
4267
4279
|
let hex = "";
|
4268
4280
|
for (let i = 0;i < bytes.length; i++) {
|
4269
4281
|
hex += hexes[bytes[i]];
|
@@ -4283,6 +4295,8 @@ var require_utils4 = __commonJS((exports) => {
|
|
4283
4295
|
function hexToBytes(hex) {
|
4284
4296
|
if (typeof hex !== "string")
|
4285
4297
|
throw new Error("hex string expected, got " + typeof hex);
|
4298
|
+
if (hasHexBuiltin)
|
4299
|
+
return Uint8Array.fromHex(hex);
|
4286
4300
|
const hl = hex.length;
|
4287
4301
|
const al = hl / 2;
|
4288
4302
|
if (hl % 2)
|
@@ -4320,14 +4334,14 @@ var require_utils4 = __commonJS((exports) => {
|
|
4320
4334
|
function toBytes(data) {
|
4321
4335
|
if (typeof data === "string")
|
4322
4336
|
data = utf8ToBytes(data);
|
4323
|
-
(0,
|
4337
|
+
(0, _assert_ts_1.abytes)(data);
|
4324
4338
|
return data;
|
4325
4339
|
}
|
4326
4340
|
function concatBytes(...arrays) {
|
4327
4341
|
let sum = 0;
|
4328
4342
|
for (let i = 0;i < arrays.length; i++) {
|
4329
4343
|
const a = arrays[i];
|
4330
|
-
(0,
|
4344
|
+
(0, _assert_ts_1.abytes)(a);
|
4331
4345
|
sum += a.length;
|
4332
4346
|
}
|
4333
4347
|
const res = new Uint8Array(sum);
|
@@ -4380,21 +4394,21 @@ var require_utils4 = __commonJS((exports) => {
|
|
4380
4394
|
return crypto_1.crypto.getRandomValues(new Uint8Array(bytesLength));
|
4381
4395
|
}
|
4382
4396
|
if (crypto_1.crypto && typeof crypto_1.crypto.randomBytes === "function") {
|
4383
|
-
return crypto_1.crypto.randomBytes(bytesLength);
|
4397
|
+
return Uint8Array.from(crypto_1.crypto.randomBytes(bytesLength));
|
4384
4398
|
}
|
4385
4399
|
throw new Error("crypto.getRandomValues must be defined");
|
4386
4400
|
}
|
4387
4401
|
});
|
4388
4402
|
|
4389
|
-
// ../../node_modules
|
4403
|
+
// ../../node_modules/@noble/hashes/_md.js
|
4390
4404
|
var require__md = __commonJS((exports) => {
|
4391
4405
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4392
4406
|
exports.HashMD = undefined;
|
4393
4407
|
exports.setBigUint64 = setBigUint64;
|
4394
4408
|
exports.Chi = Chi;
|
4395
4409
|
exports.Maj = Maj;
|
4396
|
-
var
|
4397
|
-
var
|
4410
|
+
var _assert_ts_1 = require__assert();
|
4411
|
+
var utils_ts_1 = require_utils4();
|
4398
4412
|
function setBigUint64(view, byteOffset, value, isLE) {
|
4399
4413
|
if (typeof view.setBigUint64 === "function")
|
4400
4414
|
return view.setBigUint64(byteOffset, value, isLE);
|
@@ -4414,29 +4428,29 @@ var require__md = __commonJS((exports) => {
|
|
4414
4428
|
return a & b ^ a & c ^ b & c;
|
4415
4429
|
}
|
4416
4430
|
|
4417
|
-
class HashMD extends
|
4431
|
+
class HashMD extends utils_ts_1.Hash {
|
4418
4432
|
constructor(blockLen, outputLen, padOffset, isLE) {
|
4419
4433
|
super();
|
4420
|
-
this.blockLen = blockLen;
|
4421
|
-
this.outputLen = outputLen;
|
4422
|
-
this.padOffset = padOffset;
|
4423
|
-
this.isLE = isLE;
|
4424
4434
|
this.finished = false;
|
4425
4435
|
this.length = 0;
|
4426
4436
|
this.pos = 0;
|
4427
4437
|
this.destroyed = false;
|
4438
|
+
this.blockLen = blockLen;
|
4439
|
+
this.outputLen = outputLen;
|
4440
|
+
this.padOffset = padOffset;
|
4441
|
+
this.isLE = isLE;
|
4428
4442
|
this.buffer = new Uint8Array(blockLen);
|
4429
|
-
this.view = (0,
|
4443
|
+
this.view = (0, utils_ts_1.createView)(this.buffer);
|
4430
4444
|
}
|
4431
4445
|
update(data) {
|
4432
|
-
(0,
|
4446
|
+
(0, _assert_ts_1.aexists)(this);
|
4433
4447
|
const { view, buffer, blockLen } = this;
|
4434
|
-
data = (0,
|
4448
|
+
data = (0, utils_ts_1.toBytes)(data);
|
4435
4449
|
const len = data.length;
|
4436
4450
|
for (let pos = 0;pos < len; ) {
|
4437
4451
|
const take = Math.min(blockLen - this.pos, len - pos);
|
4438
4452
|
if (take === blockLen) {
|
4439
|
-
const dataView = (0,
|
4453
|
+
const dataView = (0, utils_ts_1.createView)(data);
|
4440
4454
|
for (;blockLen <= len - pos; pos += blockLen)
|
4441
4455
|
this.process(dataView, pos);
|
4442
4456
|
continue;
|
@@ -4454,8 +4468,8 @@ var require__md = __commonJS((exports) => {
|
|
4454
4468
|
return this;
|
4455
4469
|
}
|
4456
4470
|
digestInto(out) {
|
4457
|
-
(0,
|
4458
|
-
(0,
|
4471
|
+
(0, _assert_ts_1.aexists)(this);
|
4472
|
+
(0, _assert_ts_1.aoutput)(out, this);
|
4459
4473
|
this.finished = true;
|
4460
4474
|
const { buffer, view, blockLen, isLE } = this;
|
4461
4475
|
let { pos } = this;
|
@@ -4469,7 +4483,7 @@ var require__md = __commonJS((exports) => {
|
|
4469
4483
|
buffer[i] = 0;
|
4470
4484
|
setBigUint64(view, blockLen - 8, BigInt(this.length * 8), isLE);
|
4471
4485
|
this.process(view, 0);
|
4472
|
-
const oview = (0,
|
4486
|
+
const oview = (0, utils_ts_1.createView)(out);
|
4473
4487
|
const len = this.outputLen;
|
4474
4488
|
if (len % 4)
|
4475
4489
|
throw new Error("_sha2: outputLen should be aligned to 32bit");
|
@@ -4503,7 +4517,179 @@ var require__md = __commonJS((exports) => {
|
|
4503
4517
|
exports.HashMD = HashMD;
|
4504
4518
|
});
|
4505
4519
|
|
4506
|
-
// ../../node_modules
|
4520
|
+
// ../../node_modules/@noble/hashes/sha256.js
|
4521
|
+
var require_sha256 = __commonJS((exports) => {
|
4522
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
4523
|
+
exports.sha224 = exports.sha256 = exports.SHA256 = undefined;
|
4524
|
+
var _md_ts_1 = require__md();
|
4525
|
+
var utils_ts_1 = require_utils4();
|
4526
|
+
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
4527
|
+
1116352408,
|
4528
|
+
1899447441,
|
4529
|
+
3049323471,
|
4530
|
+
3921009573,
|
4531
|
+
961987163,
|
4532
|
+
1508970993,
|
4533
|
+
2453635748,
|
4534
|
+
2870763221,
|
4535
|
+
3624381080,
|
4536
|
+
310598401,
|
4537
|
+
607225278,
|
4538
|
+
1426881987,
|
4539
|
+
1925078388,
|
4540
|
+
2162078206,
|
4541
|
+
2614888103,
|
4542
|
+
3248222580,
|
4543
|
+
3835390401,
|
4544
|
+
4022224774,
|
4545
|
+
264347078,
|
4546
|
+
604807628,
|
4547
|
+
770255983,
|
4548
|
+
1249150122,
|
4549
|
+
1555081692,
|
4550
|
+
1996064986,
|
4551
|
+
2554220882,
|
4552
|
+
2821834349,
|
4553
|
+
2952996808,
|
4554
|
+
3210313671,
|
4555
|
+
3336571891,
|
4556
|
+
3584528711,
|
4557
|
+
113926993,
|
4558
|
+
338241895,
|
4559
|
+
666307205,
|
4560
|
+
773529912,
|
4561
|
+
1294757372,
|
4562
|
+
1396182291,
|
4563
|
+
1695183700,
|
4564
|
+
1986661051,
|
4565
|
+
2177026350,
|
4566
|
+
2456956037,
|
4567
|
+
2730485921,
|
4568
|
+
2820302411,
|
4569
|
+
3259730800,
|
4570
|
+
3345764771,
|
4571
|
+
3516065817,
|
4572
|
+
3600352804,
|
4573
|
+
4094571909,
|
4574
|
+
275423344,
|
4575
|
+
430227734,
|
4576
|
+
506948616,
|
4577
|
+
659060556,
|
4578
|
+
883997877,
|
4579
|
+
958139571,
|
4580
|
+
1322822218,
|
4581
|
+
1537002063,
|
4582
|
+
1747873779,
|
4583
|
+
1955562222,
|
4584
|
+
2024104815,
|
4585
|
+
2227730452,
|
4586
|
+
2361852424,
|
4587
|
+
2428436474,
|
4588
|
+
2756734187,
|
4589
|
+
3204031479,
|
4590
|
+
3329325298
|
4591
|
+
]);
|
4592
|
+
var SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
4593
|
+
1779033703,
|
4594
|
+
3144134277,
|
4595
|
+
1013904242,
|
4596
|
+
2773480762,
|
4597
|
+
1359893119,
|
4598
|
+
2600822924,
|
4599
|
+
528734635,
|
4600
|
+
1541459225
|
4601
|
+
]);
|
4602
|
+
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
4603
|
+
|
4604
|
+
class SHA256 extends _md_ts_1.HashMD {
|
4605
|
+
constructor(outputLen = 32) {
|
4606
|
+
super(64, outputLen, 8, false);
|
4607
|
+
this.A = SHA256_IV[0] | 0;
|
4608
|
+
this.B = SHA256_IV[1] | 0;
|
4609
|
+
this.C = SHA256_IV[2] | 0;
|
4610
|
+
this.D = SHA256_IV[3] | 0;
|
4611
|
+
this.E = SHA256_IV[4] | 0;
|
4612
|
+
this.F = SHA256_IV[5] | 0;
|
4613
|
+
this.G = SHA256_IV[6] | 0;
|
4614
|
+
this.H = SHA256_IV[7] | 0;
|
4615
|
+
}
|
4616
|
+
get() {
|
4617
|
+
const { A, B, C, D, E, F, G, H } = this;
|
4618
|
+
return [A, B, C, D, E, F, G, H];
|
4619
|
+
}
|
4620
|
+
set(A, B, C, D, E, F, G, H) {
|
4621
|
+
this.A = A | 0;
|
4622
|
+
this.B = B | 0;
|
4623
|
+
this.C = C | 0;
|
4624
|
+
this.D = D | 0;
|
4625
|
+
this.E = E | 0;
|
4626
|
+
this.F = F | 0;
|
4627
|
+
this.G = G | 0;
|
4628
|
+
this.H = H | 0;
|
4629
|
+
}
|
4630
|
+
process(view, offset) {
|
4631
|
+
for (let i = 0;i < 16; i++, offset += 4)
|
4632
|
+
SHA256_W[i] = view.getUint32(offset, false);
|
4633
|
+
for (let i = 16;i < 64; i++) {
|
4634
|
+
const W15 = SHA256_W[i - 15];
|
4635
|
+
const W2 = SHA256_W[i - 2];
|
4636
|
+
const s0 = (0, utils_ts_1.rotr)(W15, 7) ^ (0, utils_ts_1.rotr)(W15, 18) ^ W15 >>> 3;
|
4637
|
+
const s1 = (0, utils_ts_1.rotr)(W2, 17) ^ (0, utils_ts_1.rotr)(W2, 19) ^ W2 >>> 10;
|
4638
|
+
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
4639
|
+
}
|
4640
|
+
let { A, B, C, D, E, F, G, H } = this;
|
4641
|
+
for (let i = 0;i < 64; i++) {
|
4642
|
+
const sigma1 = (0, utils_ts_1.rotr)(E, 6) ^ (0, utils_ts_1.rotr)(E, 11) ^ (0, utils_ts_1.rotr)(E, 25);
|
4643
|
+
const T1 = H + sigma1 + (0, _md_ts_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
4644
|
+
const sigma0 = (0, utils_ts_1.rotr)(A, 2) ^ (0, utils_ts_1.rotr)(A, 13) ^ (0, utils_ts_1.rotr)(A, 22);
|
4645
|
+
const T2 = sigma0 + (0, _md_ts_1.Maj)(A, B, C) | 0;
|
4646
|
+
H = G;
|
4647
|
+
G = F;
|
4648
|
+
F = E;
|
4649
|
+
E = D + T1 | 0;
|
4650
|
+
D = C;
|
4651
|
+
C = B;
|
4652
|
+
B = A;
|
4653
|
+
A = T1 + T2 | 0;
|
4654
|
+
}
|
4655
|
+
A = A + this.A | 0;
|
4656
|
+
B = B + this.B | 0;
|
4657
|
+
C = C + this.C | 0;
|
4658
|
+
D = D + this.D | 0;
|
4659
|
+
E = E + this.E | 0;
|
4660
|
+
F = F + this.F | 0;
|
4661
|
+
G = G + this.G | 0;
|
4662
|
+
H = H + this.H | 0;
|
4663
|
+
this.set(A, B, C, D, E, F, G, H);
|
4664
|
+
}
|
4665
|
+
roundClean() {
|
4666
|
+
SHA256_W.fill(0);
|
4667
|
+
}
|
4668
|
+
destroy() {
|
4669
|
+
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
4670
|
+
this.buffer.fill(0);
|
4671
|
+
}
|
4672
|
+
}
|
4673
|
+
exports.SHA256 = SHA256;
|
4674
|
+
|
4675
|
+
class SHA224 extends SHA256 {
|
4676
|
+
constructor() {
|
4677
|
+
super(28);
|
4678
|
+
this.A = 3238371032 | 0;
|
4679
|
+
this.B = 914150663 | 0;
|
4680
|
+
this.C = 812702999 | 0;
|
4681
|
+
this.D = 4144912697 | 0;
|
4682
|
+
this.E = 4290775857 | 0;
|
4683
|
+
this.F = 1750603025 | 0;
|
4684
|
+
this.G = 1694076839 | 0;
|
4685
|
+
this.H = 3204075428 | 0;
|
4686
|
+
}
|
4687
|
+
}
|
4688
|
+
exports.sha256 = (0, utils_ts_1.wrapConstructor)(() => new SHA256);
|
4689
|
+
exports.sha224 = (0, utils_ts_1.wrapConstructor)(() => new SHA224);
|
4690
|
+
});
|
4691
|
+
|
4692
|
+
// ../../node_modules/@noble/hashes/_u64.js
|
4507
4693
|
var require__u64 = __commonJS((exports) => {
|
4508
4694
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4509
4695
|
exports.add5L = exports.add5H = exports.add4H = exports.add4L = exports.add3H = exports.add3L = exports.rotlBL = exports.rotlBH = exports.rotlSL = exports.rotlSH = exports.rotr32L = exports.rotr32H = exports.rotrBL = exports.rotrBH = exports.rotrSL = exports.rotrSH = exports.shrSL = exports.shrSH = exports.toBig = undefined;
|
@@ -4595,14 +4781,14 @@ var require__u64 = __commonJS((exports) => {
|
|
4595
4781
|
exports.default = u64;
|
4596
4782
|
});
|
4597
4783
|
|
4598
|
-
// ../../node_modules
|
4784
|
+
// ../../node_modules/@noble/hashes/sha512.js
|
4599
4785
|
var require_sha512 = __commonJS((exports) => {
|
4600
4786
|
Object.defineProperty(exports, "__esModule", { value: true });
|
4601
4787
|
exports.sha384 = exports.sha512_256 = exports.sha512_224 = exports.sha512 = exports.SHA384 = exports.SHA512_256 = exports.SHA512_224 = exports.SHA512 = undefined;
|
4602
|
-
var
|
4603
|
-
var
|
4604
|
-
var
|
4605
|
-
var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() =>
|
4788
|
+
var _md_ts_1 = require__md();
|
4789
|
+
var _u64_ts_1 = require__u64();
|
4790
|
+
var utils_ts_1 = require_utils4();
|
4791
|
+
var [SHA512_Kh, SHA512_Kl] = /* @__PURE__ */ (() => _u64_ts_1.default.split([
|
4606
4792
|
"0x428a2f98d728ae22",
|
4607
4793
|
"0x7137449123ef65cd",
|
4608
4794
|
"0xb5c0fbcfec4d3b2f",
|
@@ -4687,9 +4873,9 @@ var require_sha512 = __commonJS((exports) => {
|
|
4687
4873
|
var SHA512_W_H = /* @__PURE__ */ new Uint32Array(80);
|
4688
4874
|
var SHA512_W_L = /* @__PURE__ */ new Uint32Array(80);
|
4689
4875
|
|
4690
|
-
class SHA512 extends
|
4691
|
-
constructor() {
|
4692
|
-
super(128,
|
4876
|
+
class SHA512 extends _md_ts_1.HashMD {
|
4877
|
+
constructor(outputLen = 64) {
|
4878
|
+
super(128, outputLen, 16, false);
|
4693
4879
|
this.Ah = 1779033703 | 0;
|
4694
4880
|
this.Al = 4089235720 | 0;
|
4695
4881
|
this.Bh = 3144134277 | 0;
|
@@ -4737,28 +4923,28 @@ var require_sha512 = __commonJS((exports) => {
|
|
4737
4923
|
for (let i = 16;i < 80; i++) {
|
4738
4924
|
const W15h = SHA512_W_H[i - 15] | 0;
|
4739
4925
|
const W15l = SHA512_W_L[i - 15] | 0;
|
4740
|
-
const s0h =
|
4741
|
-
const s0l =
|
4926
|
+
const s0h = _u64_ts_1.default.rotrSH(W15h, W15l, 1) ^ _u64_ts_1.default.rotrSH(W15h, W15l, 8) ^ _u64_ts_1.default.shrSH(W15h, W15l, 7);
|
4927
|
+
const s0l = _u64_ts_1.default.rotrSL(W15h, W15l, 1) ^ _u64_ts_1.default.rotrSL(W15h, W15l, 8) ^ _u64_ts_1.default.shrSL(W15h, W15l, 7);
|
4742
4928
|
const W2h = SHA512_W_H[i - 2] | 0;
|
4743
4929
|
const W2l = SHA512_W_L[i - 2] | 0;
|
4744
|
-
const s1h =
|
4745
|
-
const s1l =
|
4746
|
-
const SUMl =
|
4747
|
-
const SUMh =
|
4930
|
+
const s1h = _u64_ts_1.default.rotrSH(W2h, W2l, 19) ^ _u64_ts_1.default.rotrBH(W2h, W2l, 61) ^ _u64_ts_1.default.shrSH(W2h, W2l, 6);
|
4931
|
+
const s1l = _u64_ts_1.default.rotrSL(W2h, W2l, 19) ^ _u64_ts_1.default.rotrBL(W2h, W2l, 61) ^ _u64_ts_1.default.shrSL(W2h, W2l, 6);
|
4932
|
+
const SUMl = _u64_ts_1.default.add4L(s0l, s1l, SHA512_W_L[i - 7], SHA512_W_L[i - 16]);
|
4933
|
+
const SUMh = _u64_ts_1.default.add4H(SUMl, s0h, s1h, SHA512_W_H[i - 7], SHA512_W_H[i - 16]);
|
4748
4934
|
SHA512_W_H[i] = SUMh | 0;
|
4749
4935
|
SHA512_W_L[i] = SUMl | 0;
|
4750
4936
|
}
|
4751
4937
|
let { Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl } = this;
|
4752
4938
|
for (let i = 0;i < 80; i++) {
|
4753
|
-
const sigma1h =
|
4754
|
-
const sigma1l =
|
4939
|
+
const sigma1h = _u64_ts_1.default.rotrSH(Eh, El, 14) ^ _u64_ts_1.default.rotrSH(Eh, El, 18) ^ _u64_ts_1.default.rotrBH(Eh, El, 41);
|
4940
|
+
const sigma1l = _u64_ts_1.default.rotrSL(Eh, El, 14) ^ _u64_ts_1.default.rotrSL(Eh, El, 18) ^ _u64_ts_1.default.rotrBL(Eh, El, 41);
|
4755
4941
|
const CHIh = Eh & Fh ^ ~Eh & Gh;
|
4756
4942
|
const CHIl = El & Fl ^ ~El & Gl;
|
4757
|
-
const T1ll =
|
4758
|
-
const T1h =
|
4943
|
+
const T1ll = _u64_ts_1.default.add5L(Hl, sigma1l, CHIl, SHA512_Kl[i], SHA512_W_L[i]);
|
4944
|
+
const T1h = _u64_ts_1.default.add5H(T1ll, Hh, sigma1h, CHIh, SHA512_Kh[i], SHA512_W_H[i]);
|
4759
4945
|
const T1l = T1ll | 0;
|
4760
|
-
const sigma0h =
|
4761
|
-
const sigma0l =
|
4946
|
+
const sigma0h = _u64_ts_1.default.rotrSH(Ah, Al, 28) ^ _u64_ts_1.default.rotrBH(Ah, Al, 34) ^ _u64_ts_1.default.rotrBH(Ah, Al, 39);
|
4947
|
+
const sigma0l = _u64_ts_1.default.rotrSL(Ah, Al, 28) ^ _u64_ts_1.default.rotrBL(Ah, Al, 34) ^ _u64_ts_1.default.rotrBL(Ah, Al, 39);
|
4762
4948
|
const MAJh = Ah & Bh ^ Ah & Ch ^ Bh & Ch;
|
4763
4949
|
const MAJl = Al & Bl ^ Al & Cl ^ Bl & Cl;
|
4764
4950
|
Hh = Gh | 0;
|
@@ -4767,25 +4953,25 @@ var require_sha512 = __commonJS((exports) => {
|
|
4767
4953
|
Gl = Fl | 0;
|
4768
4954
|
Fh = Eh | 0;
|
4769
4955
|
Fl = El | 0;
|
4770
|
-
({ h: Eh, l: El } =
|
4956
|
+
({ h: Eh, l: El } = _u64_ts_1.default.add(Dh | 0, Dl | 0, T1h | 0, T1l | 0));
|
4771
4957
|
Dh = Ch | 0;
|
4772
4958
|
Dl = Cl | 0;
|
4773
4959
|
Ch = Bh | 0;
|
4774
4960
|
Cl = Bl | 0;
|
4775
4961
|
Bh = Ah | 0;
|
4776
4962
|
Bl = Al | 0;
|
4777
|
-
const All =
|
4778
|
-
Ah =
|
4963
|
+
const All = _u64_ts_1.default.add3L(T1l, sigma0l, MAJl);
|
4964
|
+
Ah = _u64_ts_1.default.add3H(All, T1h, sigma0h, MAJh);
|
4779
4965
|
Al = All | 0;
|
4780
4966
|
}
|
4781
|
-
({ h: Ah, l: Al } =
|
4782
|
-
({ h: Bh, l: Bl } =
|
4783
|
-
({ h: Ch, l: Cl } =
|
4784
|
-
({ h: Dh, l: Dl } =
|
4785
|
-
({ h: Eh, l: El } =
|
4786
|
-
({ h: Fh, l: Fl } =
|
4787
|
-
({ h: Gh, l: Gl } =
|
4788
|
-
({ h: Hh, l: Hl } =
|
4967
|
+
({ h: Ah, l: Al } = _u64_ts_1.default.add(this.Ah | 0, this.Al | 0, Ah | 0, Al | 0));
|
4968
|
+
({ h: Bh, l: Bl } = _u64_ts_1.default.add(this.Bh | 0, this.Bl | 0, Bh | 0, Bl | 0));
|
4969
|
+
({ h: Ch, l: Cl } = _u64_ts_1.default.add(this.Ch | 0, this.Cl | 0, Ch | 0, Cl | 0));
|
4970
|
+
({ h: Dh, l: Dl } = _u64_ts_1.default.add(this.Dh | 0, this.Dl | 0, Dh | 0, Dl | 0));
|
4971
|
+
({ h: Eh, l: El } = _u64_ts_1.default.add(this.Eh | 0, this.El | 0, Eh | 0, El | 0));
|
4972
|
+
({ h: Fh, l: Fl } = _u64_ts_1.default.add(this.Fh | 0, this.Fl | 0, Fh | 0, Fl | 0));
|
4973
|
+
({ h: Gh, l: Gl } = _u64_ts_1.default.add(this.Gh | 0, this.Gl | 0, Gh | 0, Gl | 0));
|
4974
|
+
({ h: Hh, l: Hl } = _u64_ts_1.default.add(this.Hh | 0, this.Hl | 0, Hh | 0, Hl | 0));
|
4789
4975
|
this.set(Ah, Al, Bh, Bl, Ch, Cl, Dh, Dl, Eh, El, Fh, Fl, Gh, Gl, Hh, Hl);
|
4790
4976
|
}
|
4791
4977
|
roundClean() {
|
@@ -4801,7 +4987,7 @@ var require_sha512 = __commonJS((exports) => {
|
|
4801
4987
|
|
4802
4988
|
class SHA512_224 extends SHA512 {
|
4803
4989
|
constructor() {
|
4804
|
-
super();
|
4990
|
+
super(28);
|
4805
4991
|
this.Ah = 2352822216 | 0;
|
4806
4992
|
this.Al = 424955298 | 0;
|
4807
4993
|
this.Bh = 1944164710 | 0;
|
@@ -4818,14 +5004,13 @@ var require_sha512 = __commonJS((exports) => {
|
|
4818
5004
|
this.Gl = 1780299464 | 0;
|
4819
5005
|
this.Hh = 286451373 | 0;
|
4820
5006
|
this.Hl = 2446758561 | 0;
|
4821
|
-
this.outputLen = 28;
|
4822
5007
|
}
|
4823
5008
|
}
|
4824
5009
|
exports.SHA512_224 = SHA512_224;
|
4825
5010
|
|
4826
5011
|
class SHA512_256 extends SHA512 {
|
4827
5012
|
constructor() {
|
4828
|
-
super();
|
5013
|
+
super(32);
|
4829
5014
|
this.Ah = 573645204 | 0;
|
4830
5015
|
this.Al = 4230739756 | 0;
|
4831
5016
|
this.Bh = 2673172387 | 0;
|
@@ -4842,14 +5027,13 @@ var require_sha512 = __commonJS((exports) => {
|
|
4842
5027
|
this.Gl = 746961066 | 0;
|
4843
5028
|
this.Hh = 246885852 | 0;
|
4844
5029
|
this.Hl = 2177182882 | 0;
|
4845
|
-
this.outputLen = 32;
|
4846
5030
|
}
|
4847
5031
|
}
|
4848
5032
|
exports.SHA512_256 = SHA512_256;
|
4849
5033
|
|
4850
5034
|
class SHA384 extends SHA512 {
|
4851
5035
|
constructor() {
|
4852
|
-
super();
|
5036
|
+
super(48);
|
4853
5037
|
this.Ah = 3418070365 | 0;
|
4854
5038
|
this.Al = 3238371032 | 0;
|
4855
5039
|
this.Bh = 1654270250 | 0;
|
@@ -4866,17 +5050,42 @@ var require_sha512 = __commonJS((exports) => {
|
|
4866
5050
|
this.Gl = 1694076839 | 0;
|
4867
5051
|
this.Hh = 1203062813 | 0;
|
4868
5052
|
this.Hl = 3204075428 | 0;
|
4869
|
-
this.outputLen = 48;
|
4870
5053
|
}
|
4871
5054
|
}
|
4872
5055
|
exports.SHA384 = SHA384;
|
4873
|
-
exports.sha512 = (0,
|
4874
|
-
exports.sha512_224 = (0,
|
4875
|
-
exports.sha512_256 = (0,
|
4876
|
-
exports.sha384 = (0,
|
5056
|
+
exports.sha512 = (0, utils_ts_1.wrapConstructor)(() => new SHA512);
|
5057
|
+
exports.sha512_224 = (0, utils_ts_1.wrapConstructor)(() => new SHA512_224);
|
5058
|
+
exports.sha512_256 = (0, utils_ts_1.wrapConstructor)(() => new SHA512_256);
|
5059
|
+
exports.sha384 = (0, utils_ts_1.wrapConstructor)(() => new SHA384);
|
5060
|
+
});
|
5061
|
+
|
5062
|
+
// ../../node_modules/@noble/hashes/sha2.js
|
5063
|
+
var require_sha2 = __commonJS((exports) => {
|
5064
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5065
|
+
exports.sha512_256 = exports.sha512_224 = exports.sha512 = exports.sha384 = exports.sha256 = exports.sha224 = undefined;
|
5066
|
+
var sha256_ts_1 = require_sha256();
|
5067
|
+
Object.defineProperty(exports, "sha224", { enumerable: true, get: function() {
|
5068
|
+
return sha256_ts_1.sha224;
|
5069
|
+
} });
|
5070
|
+
Object.defineProperty(exports, "sha256", { enumerable: true, get: function() {
|
5071
|
+
return sha256_ts_1.sha256;
|
5072
|
+
} });
|
5073
|
+
var sha512_ts_1 = require_sha512();
|
5074
|
+
Object.defineProperty(exports, "sha384", { enumerable: true, get: function() {
|
5075
|
+
return sha512_ts_1.sha384;
|
5076
|
+
} });
|
5077
|
+
Object.defineProperty(exports, "sha512", { enumerable: true, get: function() {
|
5078
|
+
return sha512_ts_1.sha512;
|
5079
|
+
} });
|
5080
|
+
Object.defineProperty(exports, "sha512_224", { enumerable: true, get: function() {
|
5081
|
+
return sha512_ts_1.sha512_224;
|
5082
|
+
} });
|
5083
|
+
Object.defineProperty(exports, "sha512_256", { enumerable: true, get: function() {
|
5084
|
+
return sha512_ts_1.sha512_256;
|
5085
|
+
} });
|
4877
5086
|
});
|
4878
5087
|
|
4879
|
-
// ../../node_modules
|
5088
|
+
// ../../node_modules/@noble/curves/abstract/utils.js
|
4880
5089
|
var require_utils5 = __commonJS((exports) => {
|
4881
5090
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
4882
5091
|
Object.defineProperty(exports, "__esModule", { value: true });
|
@@ -4884,9 +5093,9 @@ var require_utils5 = __commonJS((exports) => {
|
|
4884
5093
|
exports.isBytes = isBytes;
|
4885
5094
|
exports.abytes = abytes;
|
4886
5095
|
exports.abool = abool;
|
4887
|
-
exports.bytesToHex = bytesToHex;
|
4888
5096
|
exports.numberToHexUnpadded = numberToHexUnpadded;
|
4889
5097
|
exports.hexToNumber = hexToNumber;
|
5098
|
+
exports.bytesToHex = bytesToHex;
|
4890
5099
|
exports.hexToBytes = hexToBytes;
|
4891
5100
|
exports.bytesToNumberBE = bytesToNumberBE;
|
4892
5101
|
exports.bytesToNumberLE = bytesToNumberLE;
|
@@ -4907,7 +5116,6 @@ var require_utils5 = __commonJS((exports) => {
|
|
4907
5116
|
exports.memoized = memoized;
|
4908
5117
|
var _0n = /* @__PURE__ */ BigInt(0);
|
4909
5118
|
var _1n = /* @__PURE__ */ BigInt(1);
|
4910
|
-
var _2n = /* @__PURE__ */ BigInt(2);
|
4911
5119
|
function isBytes(a) {
|
4912
5120
|
return a instanceof Uint8Array || ArrayBuffer.isView(a) && a.constructor.name === "Uint8Array";
|
4913
5121
|
}
|
@@ -4919,15 +5127,6 @@ var require_utils5 = __commonJS((exports) => {
|
|
4919
5127
|
if (typeof value !== "boolean")
|
4920
5128
|
throw new Error(title + " boolean expected, got " + value);
|
4921
5129
|
}
|
4922
|
-
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
4923
|
-
function bytesToHex(bytes) {
|
4924
|
-
abytes(bytes);
|
4925
|
-
let hex = "";
|
4926
|
-
for (let i = 0;i < bytes.length; i++) {
|
4927
|
-
hex += hexes[bytes[i]];
|
4928
|
-
}
|
4929
|
-
return hex;
|
4930
|
-
}
|
4931
5130
|
function numberToHexUnpadded(num) {
|
4932
5131
|
const hex = num.toString(16);
|
4933
5132
|
return hex.length & 1 ? "0" + hex : hex;
|
@@ -4937,6 +5136,18 @@ var require_utils5 = __commonJS((exports) => {
|
|
4937
5136
|
throw new Error("hex string expected, got " + typeof hex);
|
4938
5137
|
return hex === "" ? _0n : BigInt("0x" + hex);
|
4939
5138
|
}
|
5139
|
+
var hasHexBuiltin = typeof Uint8Array.from([]).toHex === "function" && typeof Uint8Array.fromHex === "function";
|
5140
|
+
var hexes = /* @__PURE__ */ Array.from({ length: 256 }, (_, i) => i.toString(16).padStart(2, "0"));
|
5141
|
+
function bytesToHex(bytes) {
|
5142
|
+
abytes(bytes);
|
5143
|
+
if (hasHexBuiltin)
|
5144
|
+
return bytes.toHex();
|
5145
|
+
let hex = "";
|
5146
|
+
for (let i = 0;i < bytes.length; i++) {
|
5147
|
+
hex += hexes[bytes[i]];
|
5148
|
+
}
|
5149
|
+
return hex;
|
5150
|
+
}
|
4940
5151
|
var asciis = { _0: 48, _9: 57, A: 65, F: 70, a: 97, f: 102 };
|
4941
5152
|
function asciiToBase16(ch) {
|
4942
5153
|
if (ch >= asciis._0 && ch <= asciis._9)
|
@@ -4950,6 +5161,8 @@ var require_utils5 = __commonJS((exports) => {
|
|
4950
5161
|
function hexToBytes(hex) {
|
4951
5162
|
if (typeof hex !== "string")
|
4952
5163
|
throw new Error("hex string expected, got " + typeof hex);
|
5164
|
+
if (hasHexBuiltin)
|
5165
|
+
return Uint8Array.fromHex(hex);
|
4953
5166
|
const hl = hex.length;
|
4954
5167
|
const al = hl / 2;
|
4955
5168
|
if (hl % 2)
|
@@ -5048,9 +5261,9 @@ var require_utils5 = __commonJS((exports) => {
|
|
5048
5261
|
function bitSet(n, pos, value) {
|
5049
5262
|
return n | (value ? _1n : _0n) << BigInt(pos);
|
5050
5263
|
}
|
5051
|
-
var bitMask = (n) => (
|
5264
|
+
var bitMask = (n) => (_1n << BigInt(n)) - _1n;
|
5052
5265
|
exports.bitMask = bitMask;
|
5053
|
-
var u8n = (
|
5266
|
+
var u8n = (len) => new Uint8Array(len);
|
5054
5267
|
var u8fr = (arr) => Uint8Array.from(arr);
|
5055
5268
|
function createHmacDrbg(hashLen, qByteLen, hmacFn) {
|
5056
5269
|
if (typeof hashLen !== "number" || hashLen < 2)
|
@@ -5068,7 +5281,7 @@ var require_utils5 = __commonJS((exports) => {
|
|
5068
5281
|
i = 0;
|
5069
5282
|
};
|
5070
5283
|
const h = (...b) => hmacFn(k, v, ...b);
|
5071
|
-
const reseed = (seed = u8n()) => {
|
5284
|
+
const reseed = (seed = u8n(0)) => {
|
5072
5285
|
k = h(u8fr([0]), seed);
|
5073
5286
|
v = h();
|
5074
5287
|
if (seed.length === 0)
|
@@ -5146,7 +5359,7 @@ var require_utils5 = __commonJS((exports) => {
|
|
5146
5359
|
}
|
5147
5360
|
});
|
5148
5361
|
|
5149
|
-
// ../../node_modules
|
5362
|
+
// ../../node_modules/@noble/curves/abstract/modular.js
|
5150
5363
|
var require_modular = __commonJS((exports) => {
|
5151
5364
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5152
5365
|
exports.isNegativeLE = undefined;
|
@@ -5171,7 +5384,7 @@ var require_modular = __commonJS((exports) => {
|
|
5171
5384
|
exports.getMinHashLength = getMinHashLength;
|
5172
5385
|
exports.mapHashToField = mapHashToField;
|
5173
5386
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
5174
|
-
var
|
5387
|
+
var utils_ts_1 = require_utils5();
|
5175
5388
|
var _0n = BigInt(0);
|
5176
5389
|
var _1n = BigInt(1);
|
5177
5390
|
var _2n = /* @__PURE__ */ BigInt(2);
|
@@ -5331,7 +5544,7 @@ var require_modular = __commonJS((exports) => {
|
|
5331
5544
|
map[val] = "function";
|
5332
5545
|
return map;
|
5333
5546
|
}, initial);
|
5334
|
-
return (0,
|
5547
|
+
return (0, utils_ts_1.validateObject)(field, opts);
|
5335
5548
|
}
|
5336
5549
|
function FpPow(f, num, power) {
|
5337
5550
|
if (power < _0n)
|
@@ -5398,7 +5611,7 @@ var require_modular = __commonJS((exports) => {
|
|
5398
5611
|
isLE,
|
5399
5612
|
BITS,
|
5400
5613
|
BYTES,
|
5401
|
-
MASK: (0,
|
5614
|
+
MASK: (0, utils_ts_1.bitMask)(BITS),
|
5402
5615
|
ZERO: _0n,
|
5403
5616
|
ONE: _1n,
|
5404
5617
|
create: (num) => mod(num, ORDER),
|
@@ -5429,11 +5642,11 @@ var require_modular = __commonJS((exports) => {
|
|
5429
5642
|
}),
|
5430
5643
|
invertBatch: (lst) => FpInvertBatch(f, lst),
|
5431
5644
|
cmov: (a, b, c) => c ? b : a,
|
5432
|
-
toBytes: (num) => isLE ? (0,
|
5645
|
+
toBytes: (num) => isLE ? (0, utils_ts_1.numberToBytesLE)(num, BYTES) : (0, utils_ts_1.numberToBytesBE)(num, BYTES),
|
5433
5646
|
fromBytes: (bytes) => {
|
5434
5647
|
if (bytes.length !== BYTES)
|
5435
5648
|
throw new Error("Field.fromBytes: expected " + BYTES + " bytes, got " + bytes.length);
|
5436
|
-
return isLE ? (0,
|
5649
|
+
return isLE ? (0, utils_ts_1.bytesToNumberLE)(bytes) : (0, utils_ts_1.bytesToNumberBE)(bytes);
|
5437
5650
|
}
|
5438
5651
|
});
|
5439
5652
|
return Object.freeze(f);
|
@@ -5451,12 +5664,12 @@ var require_modular = __commonJS((exports) => {
|
|
5451
5664
|
return Fp.isOdd(root) ? Fp.neg(root) : root;
|
5452
5665
|
}
|
5453
5666
|
function hashToPrivateScalar(hash, groupOrder, isLE = false) {
|
5454
|
-
hash = (0,
|
5667
|
+
hash = (0, utils_ts_1.ensureBytes)("privateHash", hash);
|
5455
5668
|
const hashLen = hash.length;
|
5456
5669
|
const minLen = nLength(groupOrder).nByteLength + 8;
|
5457
5670
|
if (minLen < 24 || hashLen < minLen || hashLen > 1024)
|
5458
5671
|
throw new Error("hashToPrivateScalar: expected " + minLen + "-1024 bytes of input, got " + hashLen);
|
5459
|
-
const num = isLE ? (0,
|
5672
|
+
const num = isLE ? (0, utils_ts_1.bytesToNumberLE)(hash) : (0, utils_ts_1.bytesToNumberBE)(hash);
|
5460
5673
|
return mod(num, groupOrder - _1n) + _1n;
|
5461
5674
|
}
|
5462
5675
|
function getFieldBytesLength(fieldOrder) {
|
@@ -5475,13 +5688,13 @@ var require_modular = __commonJS((exports) => {
|
|
5475
5688
|
const minLen = getMinHashLength(fieldOrder);
|
5476
5689
|
if (len < 16 || len < minLen || len > 1024)
|
5477
5690
|
throw new Error("expected " + minLen + "-1024 bytes of input, got " + len);
|
5478
|
-
const num = isLE ? (0,
|
5691
|
+
const num = isLE ? (0, utils_ts_1.bytesToNumberLE)(key) : (0, utils_ts_1.bytesToNumberBE)(key);
|
5479
5692
|
const reduced = mod(num, fieldOrder - _1n) + _1n;
|
5480
|
-
return isLE ? (0,
|
5693
|
+
return isLE ? (0, utils_ts_1.numberToBytesLE)(reduced, fieldLen) : (0, utils_ts_1.numberToBytesBE)(reduced, fieldLen);
|
5481
5694
|
}
|
5482
5695
|
});
|
5483
5696
|
|
5484
|
-
// ../../node_modules
|
5697
|
+
// ../../node_modules/@noble/curves/abstract/curve.js
|
5485
5698
|
var require_curve = __commonJS((exports) => {
|
5486
5699
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5487
5700
|
exports.wNAF = wNAF;
|
@@ -5489,8 +5702,8 @@ var require_curve = __commonJS((exports) => {
|
|
5489
5702
|
exports.precomputeMSMUnsafe = precomputeMSMUnsafe;
|
5490
5703
|
exports.validateBasic = validateBasic;
|
5491
5704
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
5492
|
-
var
|
5493
|
-
var
|
5705
|
+
var modular_ts_1 = require_modular();
|
5706
|
+
var utils_ts_1 = require_utils5();
|
5494
5707
|
var _0n = BigInt(0);
|
5495
5708
|
var _1n = BigInt(1);
|
5496
5709
|
function constTimeNegate(condition, item) {
|
@@ -5501,11 +5714,30 @@ var require_curve = __commonJS((exports) => {
|
|
5501
5714
|
if (!Number.isSafeInteger(W) || W <= 0 || W > bits)
|
5502
5715
|
throw new Error("invalid window size, expected [1.." + bits + "], got W=" + W);
|
5503
5716
|
}
|
5504
|
-
function calcWOpts(W,
|
5505
|
-
validateW(W,
|
5506
|
-
const windows = Math.ceil(
|
5717
|
+
function calcWOpts(W, scalarBits) {
|
5718
|
+
validateW(W, scalarBits);
|
5719
|
+
const windows = Math.ceil(scalarBits / W) + 1;
|
5507
5720
|
const windowSize = 2 ** (W - 1);
|
5508
|
-
|
5721
|
+
const maxNumber = 2 ** W;
|
5722
|
+
const mask = (0, utils_ts_1.bitMask)(W);
|
5723
|
+
const shiftBy = BigInt(W);
|
5724
|
+
return { windows, windowSize, mask, maxNumber, shiftBy };
|
5725
|
+
}
|
5726
|
+
function calcOffsets(n, window2, wOpts) {
|
5727
|
+
const { windowSize, mask, maxNumber, shiftBy } = wOpts;
|
5728
|
+
let wbits = Number(n & mask);
|
5729
|
+
let nextN = n >> shiftBy;
|
5730
|
+
if (wbits > windowSize) {
|
5731
|
+
wbits -= maxNumber;
|
5732
|
+
nextN += _1n;
|
5733
|
+
}
|
5734
|
+
const offsetStart = window2 * windowSize;
|
5735
|
+
const offset = offsetStart + Math.abs(wbits) - 1;
|
5736
|
+
const isZero = wbits === 0;
|
5737
|
+
const isNeg = wbits < 0;
|
5738
|
+
const isNegF = window2 % 2 !== 0;
|
5739
|
+
const offsetF = offsetStart;
|
5740
|
+
return { nextN, offset, isZero, isNeg, isNegF, offsetF };
|
5509
5741
|
}
|
5510
5742
|
function validateMSMPoints(points, c) {
|
5511
5743
|
if (!Array.isArray(points))
|
@@ -5561,53 +5793,33 @@ var require_curve = __commonJS((exports) => {
|
|
5561
5793
|
return points;
|
5562
5794
|
},
|
5563
5795
|
wNAF(W, precomputes, n) {
|
5564
|
-
const { windows, windowSize } = calcWOpts(W, bits);
|
5565
5796
|
let p = c.ZERO;
|
5566
5797
|
let f = c.BASE;
|
5567
|
-
const
|
5568
|
-
|
5569
|
-
|
5570
|
-
|
5571
|
-
|
5572
|
-
|
5573
|
-
n >>= shiftBy;
|
5574
|
-
if (wbits > windowSize) {
|
5575
|
-
wbits -= maxNumber;
|
5576
|
-
n += _1n;
|
5577
|
-
}
|
5578
|
-
const offset1 = offset;
|
5579
|
-
const offset2 = offset + Math.abs(wbits) - 1;
|
5580
|
-
const cond1 = window2 % 2 !== 0;
|
5581
|
-
const cond2 = wbits < 0;
|
5582
|
-
if (wbits === 0) {
|
5583
|
-
f = f.add(constTimeNegate(cond1, precomputes[offset1]));
|
5798
|
+
const wo = calcWOpts(W, bits);
|
5799
|
+
for (let window2 = 0;window2 < wo.windows; window2++) {
|
5800
|
+
const { nextN, offset, isZero, isNeg, isNegF, offsetF } = calcOffsets(n, window2, wo);
|
5801
|
+
n = nextN;
|
5802
|
+
if (isZero) {
|
5803
|
+
f = f.add(constTimeNegate(isNegF, precomputes[offsetF]));
|
5584
5804
|
} else {
|
5585
|
-
p = p.add(constTimeNegate(
|
5805
|
+
p = p.add(constTimeNegate(isNeg, precomputes[offset]));
|
5586
5806
|
}
|
5587
5807
|
}
|
5588
5808
|
return { p, f };
|
5589
5809
|
},
|
5590
5810
|
wNAFUnsafe(W, precomputes, n, acc = c.ZERO) {
|
5591
|
-
const
|
5592
|
-
|
5593
|
-
const maxNumber = 2 ** W;
|
5594
|
-
const shiftBy = BigInt(W);
|
5595
|
-
for (let window2 = 0;window2 < windows; window2++) {
|
5596
|
-
const offset = window2 * windowSize;
|
5811
|
+
const wo = calcWOpts(W, bits);
|
5812
|
+
for (let window2 = 0;window2 < wo.windows; window2++) {
|
5597
5813
|
if (n === _0n)
|
5598
5814
|
break;
|
5599
|
-
|
5600
|
-
n
|
5601
|
-
if (
|
5602
|
-
wbits -= maxNumber;
|
5603
|
-
n += _1n;
|
5604
|
-
}
|
5605
|
-
if (wbits === 0)
|
5815
|
+
const { nextN, offset, isZero, isNeg } = calcOffsets(n, window2, wo);
|
5816
|
+
n = nextN;
|
5817
|
+
if (isZero) {
|
5606
5818
|
continue;
|
5607
|
-
|
5608
|
-
|
5609
|
-
|
5610
|
-
|
5819
|
+
} else {
|
5820
|
+
const item = precomputes[offset];
|
5821
|
+
acc = acc.add(isNeg ? item.negate() : item);
|
5822
|
+
}
|
5611
5823
|
}
|
5612
5824
|
return acc;
|
5613
5825
|
},
|
@@ -5643,17 +5855,17 @@ var require_curve = __commonJS((exports) => {
|
|
5643
5855
|
if (points.length !== scalars.length)
|
5644
5856
|
throw new Error("arrays of points and scalars must have equal length");
|
5645
5857
|
const zero = c.ZERO;
|
5646
|
-
const wbits = (0,
|
5858
|
+
const wbits = (0, utils_ts_1.bitLen)(BigInt(points.length));
|
5647
5859
|
const windowSize = wbits > 12 ? wbits - 3 : wbits > 4 ? wbits - 2 : wbits ? 2 : 1;
|
5648
|
-
const MASK = (
|
5649
|
-
const buckets = new Array(MASK + 1).fill(zero);
|
5860
|
+
const MASK = (0, utils_ts_1.bitMask)(windowSize);
|
5861
|
+
const buckets = new Array(Number(MASK) + 1).fill(zero);
|
5650
5862
|
const lastBits = Math.floor((fieldN.BITS - 1) / windowSize) * windowSize;
|
5651
5863
|
let sum = zero;
|
5652
5864
|
for (let i = lastBits;i >= 0; i -= windowSize) {
|
5653
5865
|
buckets.fill(zero);
|
5654
5866
|
for (let j = 0;j < scalars.length; j++) {
|
5655
5867
|
const scalar = scalars[j];
|
5656
|
-
const wbits2 = Number(scalar >> BigInt(i) &
|
5868
|
+
const wbits2 = Number(scalar >> BigInt(i) & MASK);
|
5657
5869
|
buckets[wbits2] = buckets[wbits2].add(points[j]);
|
5658
5870
|
}
|
5659
5871
|
let resI = zero;
|
@@ -5674,7 +5886,7 @@ var require_curve = __commonJS((exports) => {
|
|
5674
5886
|
const zero = c.ZERO;
|
5675
5887
|
const tableSize = 2 ** windowSize - 1;
|
5676
5888
|
const chunks = Math.ceil(fieldN.BITS / windowSize);
|
5677
|
-
const MASK =
|
5889
|
+
const MASK = (0, utils_ts_1.bitMask)(windowSize);
|
5678
5890
|
const tables = points.map((p) => {
|
5679
5891
|
const res = [];
|
5680
5892
|
for (let i = 0, acc = p;i < tableSize; i++) {
|
@@ -5705,8 +5917,8 @@ var require_curve = __commonJS((exports) => {
|
|
5705
5917
|
};
|
5706
5918
|
}
|
5707
5919
|
function validateBasic(curve) {
|
5708
|
-
(0,
|
5709
|
-
(0,
|
5920
|
+
(0, modular_ts_1.validateField)(curve.Fp);
|
5921
|
+
(0, utils_ts_1.validateObject)(curve, {
|
5710
5922
|
n: "bigint",
|
5711
5923
|
h: "bigint",
|
5712
5924
|
Gx: "field",
|
@@ -5716,30 +5928,29 @@ var require_curve = __commonJS((exports) => {
|
|
5716
5928
|
nByteLength: "isSafeInteger"
|
5717
5929
|
});
|
5718
5930
|
return Object.freeze({
|
5719
|
-
...(0,
|
5931
|
+
...(0, modular_ts_1.nLength)(curve.n, curve.nBitLength),
|
5720
5932
|
...curve,
|
5721
5933
|
...{ p: curve.Fp.ORDER }
|
5722
5934
|
});
|
5723
5935
|
}
|
5724
5936
|
});
|
5725
5937
|
|
5726
|
-
// ../../node_modules
|
5938
|
+
// ../../node_modules/@noble/curves/abstract/edwards.js
|
5727
5939
|
var require_edwards = __commonJS((exports) => {
|
5728
5940
|
Object.defineProperty(exports, "__esModule", { value: true });
|
5729
5941
|
exports.twistedEdwards = twistedEdwards;
|
5730
5942
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
5731
|
-
var
|
5732
|
-
var
|
5733
|
-
var
|
5734
|
-
var utils_js_1 = require_utils5();
|
5943
|
+
var curve_ts_1 = require_curve();
|
5944
|
+
var modular_ts_1 = require_modular();
|
5945
|
+
var utils_ts_1 = require_utils5();
|
5735
5946
|
var _0n = BigInt(0);
|
5736
5947
|
var _1n = BigInt(1);
|
5737
5948
|
var _2n = BigInt(2);
|
5738
5949
|
var _8n = BigInt(8);
|
5739
5950
|
var VERIFY_DEFAULT = { zip215: true };
|
5740
5951
|
function validateOpts(curve) {
|
5741
|
-
const opts = (0,
|
5742
|
-
|
5952
|
+
const opts = (0, curve_ts_1.validateBasic)(curve);
|
5953
|
+
(0, utils_ts_1.validateObject)(curve, {
|
5743
5954
|
hash: "function",
|
5744
5955
|
a: "bigint",
|
5745
5956
|
d: "bigint",
|
@@ -5757,7 +5968,7 @@ var require_edwards = __commonJS((exports) => {
|
|
5757
5968
|
const { Fp, n: CURVE_ORDER, prehash, hash: cHash, randomBytes, nByteLength, h: cofactor } = CURVE;
|
5758
5969
|
const MASK = _2n << BigInt(nByteLength * 8) - _1n;
|
5759
5970
|
const modP = Fp.create;
|
5760
|
-
const Fn = (0,
|
5971
|
+
const Fn = (0, modular_ts_1.Field)(CURVE.n, CURVE.nBitLength);
|
5761
5972
|
const uvRatio = CURVE.uvRatio || ((u, v) => {
|
5762
5973
|
try {
|
5763
5974
|
return { isValid: true, value: Fp.sqrt(u * Fp.inv(v)) };
|
@@ -5767,19 +5978,20 @@ var require_edwards = __commonJS((exports) => {
|
|
5767
5978
|
});
|
5768
5979
|
const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes);
|
5769
5980
|
const domain = CURVE.domain || ((data, ctx, phflag) => {
|
5770
|
-
(0,
|
5981
|
+
(0, utils_ts_1.abool)("phflag", phflag);
|
5771
5982
|
if (ctx.length || phflag)
|
5772
5983
|
throw new Error("Contexts/pre-hash are not supported");
|
5773
5984
|
return data;
|
5774
5985
|
});
|
5775
|
-
function aCoordinate(title, n) {
|
5776
|
-
|
5986
|
+
function aCoordinate(title, n, banZero = false) {
|
5987
|
+
const min = banZero ? _1n : _0n;
|
5988
|
+
(0, utils_ts_1.aInRange)("coordinate " + title, n, min, MASK);
|
5777
5989
|
}
|
5778
|
-
function
|
5990
|
+
function aextpoint(other) {
|
5779
5991
|
if (!(other instanceof Point))
|
5780
5992
|
throw new Error("ExtendedPoint expected");
|
5781
5993
|
}
|
5782
|
-
const toAffineMemo = (0,
|
5994
|
+
const toAffineMemo = (0, utils_ts_1.memoized)((p, iz) => {
|
5783
5995
|
const { ex: x, ey: y, ez: z2 } = p;
|
5784
5996
|
const is0 = p.is0();
|
5785
5997
|
if (iz == null)
|
@@ -5793,7 +6005,7 @@ var require_edwards = __commonJS((exports) => {
|
|
5793
6005
|
throw new Error("invZ was invalid");
|
5794
6006
|
return { x: ax, y: ay };
|
5795
6007
|
});
|
5796
|
-
const assertValidMemo = (0,
|
6008
|
+
const assertValidMemo = (0, utils_ts_1.memoized)((p) => {
|
5797
6009
|
const { a, d } = CURVE;
|
5798
6010
|
if (p.is0())
|
5799
6011
|
throw new Error("bad point: ZERO");
|
@@ -5816,14 +6028,14 @@ var require_edwards = __commonJS((exports) => {
|
|
5816
6028
|
|
5817
6029
|
class Point {
|
5818
6030
|
constructor(ex, ey, ez, et) {
|
6031
|
+
aCoordinate("x", ex);
|
6032
|
+
aCoordinate("y", ey);
|
6033
|
+
aCoordinate("z", ez, true);
|
6034
|
+
aCoordinate("t", et);
|
5819
6035
|
this.ex = ex;
|
5820
6036
|
this.ey = ey;
|
5821
6037
|
this.ez = ez;
|
5822
6038
|
this.et = et;
|
5823
|
-
aCoordinate("x", ex);
|
5824
|
-
aCoordinate("y", ey);
|
5825
|
-
aCoordinate("z", ez);
|
5826
|
-
aCoordinate("t", et);
|
5827
6039
|
Object.freeze(this);
|
5828
6040
|
}
|
5829
6041
|
get x() {
|
@@ -5845,7 +6057,7 @@ var require_edwards = __commonJS((exports) => {
|
|
5845
6057
|
return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);
|
5846
6058
|
}
|
5847
6059
|
static msm(points, scalars) {
|
5848
|
-
return (0,
|
6060
|
+
return (0, curve_ts_1.pippenger)(Point, Fn, points, scalars);
|
5849
6061
|
}
|
5850
6062
|
_setWindowSize(windowSize) {
|
5851
6063
|
wnaf.setWindowSize(this, windowSize);
|
@@ -5854,7 +6066,7 @@ var require_edwards = __commonJS((exports) => {
|
|
5854
6066
|
assertValidMemo(this);
|
5855
6067
|
}
|
5856
6068
|
equals(other) {
|
5857
|
-
|
6069
|
+
aextpoint(other);
|
5858
6070
|
const { ex: X1, ey: Y1, ez: Z1 } = this;
|
5859
6071
|
const { ex: X2, ey: Y2, ez: Z2 } = other;
|
5860
6072
|
const X1Z2 = modP(X1 * Z2);
|
@@ -5888,27 +6100,10 @@ var require_edwards = __commonJS((exports) => {
|
|
5888
6100
|
return new Point(X3, Y3, Z3, T3);
|
5889
6101
|
}
|
5890
6102
|
add(other) {
|
5891
|
-
|
6103
|
+
aextpoint(other);
|
5892
6104
|
const { a, d } = CURVE;
|
5893
6105
|
const { ex: X1, ey: Y1, ez: Z1, et: T1 } = this;
|
5894
6106
|
const { ex: X2, ey: Y2, ez: Z2, et: T2 } = other;
|
5895
|
-
if (a === BigInt(-1)) {
|
5896
|
-
const A2 = modP((Y1 - X1) * (Y2 + X2));
|
5897
|
-
const B2 = modP((Y1 + X1) * (Y2 - X2));
|
5898
|
-
const F2 = modP(B2 - A2);
|
5899
|
-
if (F2 === _0n)
|
5900
|
-
return this.double();
|
5901
|
-
const C2 = modP(Z1 * _2n * T2);
|
5902
|
-
const D2 = modP(T1 * _2n * Z2);
|
5903
|
-
const E2 = D2 + C2;
|
5904
|
-
const G3 = B2 + A2;
|
5905
|
-
const H2 = D2 - C2;
|
5906
|
-
const X32 = modP(E2 * F2);
|
5907
|
-
const Y32 = modP(G3 * H2);
|
5908
|
-
const T32 = modP(E2 * H2);
|
5909
|
-
const Z32 = modP(F2 * G3);
|
5910
|
-
return new Point(X32, Y32, Z32, T32);
|
5911
|
-
}
|
5912
6107
|
const A = modP(X1 * X2);
|
5913
6108
|
const B = modP(Y1 * Y2);
|
5914
6109
|
const C = modP(T1 * d * T2);
|
@@ -5931,13 +6126,13 @@ var require_edwards = __commonJS((exports) => {
|
|
5931
6126
|
}
|
5932
6127
|
multiply(scalar) {
|
5933
6128
|
const n = scalar;
|
5934
|
-
|
6129
|
+
(0, utils_ts_1.aInRange)("scalar", n, _1n, CURVE_ORDER);
|
5935
6130
|
const { p, f } = this.wNAF(n);
|
5936
6131
|
return Point.normalizeZ([p, f])[0];
|
5937
6132
|
}
|
5938
6133
|
multiplyUnsafe(scalar, acc = Point.ZERO) {
|
5939
6134
|
const n = scalar;
|
5940
|
-
|
6135
|
+
(0, utils_ts_1.aInRange)("scalar", n, _0n, CURVE_ORDER);
|
5941
6136
|
if (n === _0n)
|
5942
6137
|
return I;
|
5943
6138
|
if (this.is0() || n === _1n)
|
@@ -5962,14 +6157,14 @@ var require_edwards = __commonJS((exports) => {
|
|
5962
6157
|
static fromHex(hex, zip215 = false) {
|
5963
6158
|
const { d, a } = CURVE;
|
5964
6159
|
const len = Fp.BYTES;
|
5965
|
-
hex = (0,
|
5966
|
-
(0,
|
6160
|
+
hex = (0, utils_ts_1.ensureBytes)("pointHex", hex, len);
|
6161
|
+
(0, utils_ts_1.abool)("zip215", zip215);
|
5967
6162
|
const normed = hex.slice();
|
5968
6163
|
const lastByte = hex[len - 1];
|
5969
6164
|
normed[len - 1] = lastByte & ~128;
|
5970
|
-
const y =
|
6165
|
+
const y = (0, utils_ts_1.bytesToNumberLE)(normed);
|
5971
6166
|
const max = zip215 ? MASK : Fp.ORDER;
|
5972
|
-
|
6167
|
+
(0, utils_ts_1.aInRange)("pointHex.y", y, _0n, max);
|
5973
6168
|
const y2 = modP(y * y);
|
5974
6169
|
const u = modP(y2 - _1n);
|
5975
6170
|
const v = modP(d * y2 - a);
|
@@ -5985,35 +6180,40 @@ var require_edwards = __commonJS((exports) => {
|
|
5985
6180
|
return Point.fromAffine({ x, y });
|
5986
6181
|
}
|
5987
6182
|
static fromPrivateKey(privKey) {
|
5988
|
-
|
6183
|
+
const { scalar } = getPrivateScalar(privKey);
|
6184
|
+
return G.multiply(scalar);
|
5989
6185
|
}
|
5990
6186
|
toRawBytes() {
|
5991
6187
|
const { x, y } = this.toAffine();
|
5992
|
-
const bytes =
|
6188
|
+
const bytes = (0, utils_ts_1.numberToBytesLE)(y, Fp.BYTES);
|
5993
6189
|
bytes[bytes.length - 1] |= x & _1n ? 128 : 0;
|
5994
6190
|
return bytes;
|
5995
6191
|
}
|
5996
6192
|
toHex() {
|
5997
|
-
return
|
6193
|
+
return (0, utils_ts_1.bytesToHex)(this.toRawBytes());
|
5998
6194
|
}
|
5999
6195
|
}
|
6000
6196
|
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, _1n, modP(CURVE.Gx * CURVE.Gy));
|
6001
6197
|
Point.ZERO = new Point(_0n, _1n, _1n, _0n);
|
6002
6198
|
const { BASE: G, ZERO: I } = Point;
|
6003
|
-
const wnaf = (0,
|
6199
|
+
const wnaf = (0, curve_ts_1.wNAF)(Point, nByteLength * 8);
|
6004
6200
|
function modN(a) {
|
6005
|
-
return (0,
|
6201
|
+
return (0, modular_ts_1.mod)(a, CURVE_ORDER);
|
6006
6202
|
}
|
6007
6203
|
function modN_LE(hash) {
|
6008
|
-
return modN(
|
6204
|
+
return modN((0, utils_ts_1.bytesToNumberLE)(hash));
|
6009
6205
|
}
|
6010
|
-
function
|
6206
|
+
function getPrivateScalar(key) {
|
6011
6207
|
const len = Fp.BYTES;
|
6012
|
-
key = (0,
|
6013
|
-
const hashed = (0,
|
6208
|
+
key = (0, utils_ts_1.ensureBytes)("private key", key, len);
|
6209
|
+
const hashed = (0, utils_ts_1.ensureBytes)("hashed private key", cHash(key), 2 * len);
|
6014
6210
|
const head = adjustScalarBytes(hashed.slice(0, len));
|
6015
6211
|
const prefix = hashed.slice(len, 2 * len);
|
6016
6212
|
const scalar = modN_LE(head);
|
6213
|
+
return { head, prefix, scalar };
|
6214
|
+
}
|
6215
|
+
function getExtendedPublicKey(key) {
|
6216
|
+
const { head, prefix, scalar } = getPrivateScalar(key);
|
6017
6217
|
const point = G.multiply(scalar);
|
6018
6218
|
const pointBytes = point.toRawBytes();
|
6019
6219
|
return { head, prefix, scalar, point, pointBytes };
|
@@ -6022,11 +6222,11 @@ var require_edwards = __commonJS((exports) => {
|
|
6022
6222
|
return getExtendedPublicKey(privKey).pointBytes;
|
6023
6223
|
}
|
6024
6224
|
function hashDomainToScalar(context = new Uint8Array, ...msgs) {
|
6025
|
-
const msg =
|
6026
|
-
return modN_LE(cHash(domain(msg, (0,
|
6225
|
+
const msg = (0, utils_ts_1.concatBytes)(...msgs);
|
6226
|
+
return modN_LE(cHash(domain(msg, (0, utils_ts_1.ensureBytes)("context", context), !!prehash)));
|
6027
6227
|
}
|
6028
6228
|
function sign(msg, privKey, options = {}) {
|
6029
|
-
msg = (0,
|
6229
|
+
msg = (0, utils_ts_1.ensureBytes)("message", msg);
|
6030
6230
|
if (prehash)
|
6031
6231
|
msg = prehash(msg);
|
6032
6232
|
const { prefix, scalar, pointBytes } = getExtendedPublicKey(privKey);
|
@@ -6034,22 +6234,22 @@ var require_edwards = __commonJS((exports) => {
|
|
6034
6234
|
const R = G.multiply(r).toRawBytes();
|
6035
6235
|
const k = hashDomainToScalar(options.context, R, pointBytes, msg);
|
6036
6236
|
const s = modN(r + k * scalar);
|
6037
|
-
|
6038
|
-
const res =
|
6039
|
-
return (0,
|
6237
|
+
(0, utils_ts_1.aInRange)("signature.s", s, _0n, CURVE_ORDER);
|
6238
|
+
const res = (0, utils_ts_1.concatBytes)(R, (0, utils_ts_1.numberToBytesLE)(s, Fp.BYTES));
|
6239
|
+
return (0, utils_ts_1.ensureBytes)("result", res, Fp.BYTES * 2);
|
6040
6240
|
}
|
6041
6241
|
const verifyOpts = VERIFY_DEFAULT;
|
6042
6242
|
function verify(sig, msg, publicKey, options = verifyOpts) {
|
6043
6243
|
const { context, zip215 } = options;
|
6044
6244
|
const len = Fp.BYTES;
|
6045
|
-
sig = (0,
|
6046
|
-
msg = (0,
|
6047
|
-
publicKey = (0,
|
6245
|
+
sig = (0, utils_ts_1.ensureBytes)("signature", sig, 2 * len);
|
6246
|
+
msg = (0, utils_ts_1.ensureBytes)("message", msg);
|
6247
|
+
publicKey = (0, utils_ts_1.ensureBytes)("publicKey", publicKey, len);
|
6048
6248
|
if (zip215 !== undefined)
|
6049
|
-
(0,
|
6249
|
+
(0, utils_ts_1.abool)("zip215", zip215);
|
6050
6250
|
if (prehash)
|
6051
6251
|
msg = prehash(msg);
|
6052
|
-
const s =
|
6252
|
+
const s = (0, utils_ts_1.bytesToNumberLE)(sig.slice(len, 2 * len));
|
6053
6253
|
let A, R, SB;
|
6054
6254
|
try {
|
6055
6255
|
A = Point.fromHex(publicKey, zip215);
|
@@ -6085,7 +6285,7 @@ var require_edwards = __commonJS((exports) => {
|
|
6085
6285
|
}
|
6086
6286
|
});
|
6087
6287
|
|
6088
|
-
// ../../node_modules
|
6288
|
+
// ../../node_modules/@noble/curves/abstract/hash-to-curve.js
|
6089
6289
|
var require_hash_to_curve = __commonJS((exports) => {
|
6090
6290
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6091
6291
|
exports.expand_message_xmd = expand_message_xmd;
|
@@ -6093,9 +6293,9 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6093
6293
|
exports.hash_to_field = hash_to_field;
|
6094
6294
|
exports.isogenyMap = isogenyMap;
|
6095
6295
|
exports.createHasher = createHasher;
|
6096
|
-
var
|
6097
|
-
var
|
6098
|
-
var os2ip =
|
6296
|
+
var modular_ts_1 = require_modular();
|
6297
|
+
var utils_ts_1 = require_utils5();
|
6298
|
+
var os2ip = utils_ts_1.bytesToNumberBE;
|
6099
6299
|
function i2osp(value, length) {
|
6100
6300
|
anum(value);
|
6101
6301
|
anum(length);
|
@@ -6120,42 +6320,42 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6120
6320
|
throw new Error("number expected");
|
6121
6321
|
}
|
6122
6322
|
function expand_message_xmd(msg, DST, lenInBytes, H) {
|
6123
|
-
(0,
|
6124
|
-
(0,
|
6323
|
+
(0, utils_ts_1.abytes)(msg);
|
6324
|
+
(0, utils_ts_1.abytes)(DST);
|
6125
6325
|
anum(lenInBytes);
|
6126
6326
|
if (DST.length > 255)
|
6127
|
-
DST = H((0,
|
6327
|
+
DST = H((0, utils_ts_1.concatBytes)((0, utils_ts_1.utf8ToBytes)("H2C-OVERSIZE-DST-"), DST));
|
6128
6328
|
const { outputLen: b_in_bytes, blockLen: r_in_bytes } = H;
|
6129
6329
|
const ell = Math.ceil(lenInBytes / b_in_bytes);
|
6130
6330
|
if (lenInBytes > 65535 || ell > 255)
|
6131
6331
|
throw new Error("expand_message_xmd: invalid lenInBytes");
|
6132
|
-
const DST_prime = (0,
|
6332
|
+
const DST_prime = (0, utils_ts_1.concatBytes)(DST, i2osp(DST.length, 1));
|
6133
6333
|
const Z_pad = i2osp(0, r_in_bytes);
|
6134
6334
|
const l_i_b_str = i2osp(lenInBytes, 2);
|
6135
6335
|
const b = new Array(ell);
|
6136
|
-
const b_0 = H((0,
|
6137
|
-
b[0] = H((0,
|
6336
|
+
const b_0 = H((0, utils_ts_1.concatBytes)(Z_pad, msg, l_i_b_str, i2osp(0, 1), DST_prime));
|
6337
|
+
b[0] = H((0, utils_ts_1.concatBytes)(b_0, i2osp(1, 1), DST_prime));
|
6138
6338
|
for (let i = 1;i <= ell; i++) {
|
6139
6339
|
const args = [strxor(b_0, b[i - 1]), i2osp(i + 1, 1), DST_prime];
|
6140
|
-
b[i] = H((0,
|
6340
|
+
b[i] = H((0, utils_ts_1.concatBytes)(...args));
|
6141
6341
|
}
|
6142
|
-
const pseudo_random_bytes = (0,
|
6342
|
+
const pseudo_random_bytes = (0, utils_ts_1.concatBytes)(...b);
|
6143
6343
|
return pseudo_random_bytes.slice(0, lenInBytes);
|
6144
6344
|
}
|
6145
6345
|
function expand_message_xof(msg, DST, lenInBytes, k, H) {
|
6146
|
-
(0,
|
6147
|
-
(0,
|
6346
|
+
(0, utils_ts_1.abytes)(msg);
|
6347
|
+
(0, utils_ts_1.abytes)(DST);
|
6148
6348
|
anum(lenInBytes);
|
6149
6349
|
if (DST.length > 255) {
|
6150
6350
|
const dkLen = Math.ceil(2 * k / 8);
|
6151
|
-
DST = H.create({ dkLen }).update((0,
|
6351
|
+
DST = H.create({ dkLen }).update((0, utils_ts_1.utf8ToBytes)("H2C-OVERSIZE-DST-")).update(DST).digest();
|
6152
6352
|
}
|
6153
6353
|
if (lenInBytes > 65535 || DST.length > 255)
|
6154
6354
|
throw new Error("expand_message_xof: invalid lenInBytes");
|
6155
6355
|
return H.create({ dkLen: lenInBytes }).update(msg).update(i2osp(lenInBytes, 2)).update(DST).update(i2osp(DST.length, 1)).digest();
|
6156
6356
|
}
|
6157
6357
|
function hash_to_field(msg, count, options) {
|
6158
|
-
(0,
|
6358
|
+
(0, utils_ts_1.validateObject)(options, {
|
6159
6359
|
DST: "stringOrUint8Array",
|
6160
6360
|
p: "bigint",
|
6161
6361
|
m: "isSafeInteger",
|
@@ -6163,9 +6363,9 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6163
6363
|
hash: "hash"
|
6164
6364
|
});
|
6165
6365
|
const { p, k, m, hash, expand, DST: _DST } = options;
|
6166
|
-
(0,
|
6366
|
+
(0, utils_ts_1.abytes)(msg);
|
6167
6367
|
anum(count);
|
6168
|
-
const DST = typeof _DST === "string" ? (0,
|
6368
|
+
const DST = typeof _DST === "string" ? (0, utils_ts_1.utf8ToBytes)(_DST) : _DST;
|
6169
6369
|
const log2p = p.toString(2).length;
|
6170
6370
|
const L = Math.ceil((log2p + k) / 8);
|
6171
6371
|
const len_in_bytes = count * m * L;
|
@@ -6185,7 +6385,7 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6185
6385
|
for (let j = 0;j < m; j++) {
|
6186
6386
|
const elm_offset = L * (j + i * m);
|
6187
6387
|
const tv = prb.subarray(elm_offset, elm_offset + L);
|
6188
|
-
e[j] = (0,
|
6388
|
+
e[j] = (0, modular_ts_1.mod)(os2ip(tv), p);
|
6189
6389
|
}
|
6190
6390
|
u[i] = e;
|
6191
6391
|
}
|
@@ -6195,6 +6395,8 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6195
6395
|
const COEFF = map.map((i) => Array.from(i).reverse());
|
6196
6396
|
return (x, y) => {
|
6197
6397
|
const [xNum, xDen, yNum, yDen] = COEFF.map((val) => val.reduce((acc, i) => field.add(field.mul(acc, x), i)));
|
6398
|
+
if (field.is0(xDen) || field.is0(yDen))
|
6399
|
+
throw new Error("bad point: ZERO");
|
6198
6400
|
x = field.div(xNum, xDen);
|
6199
6401
|
y = field.mul(y, field.div(yNum, yDen));
|
6200
6402
|
return { x, y };
|
@@ -6232,17 +6434,17 @@ var require_hash_to_curve = __commonJS((exports) => {
|
|
6232
6434
|
}
|
6233
6435
|
});
|
6234
6436
|
|
6235
|
-
// ../../node_modules
|
6437
|
+
// ../../node_modules/@noble/curves/abstract/montgomery.js
|
6236
6438
|
var require_montgomery = __commonJS((exports) => {
|
6237
6439
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6238
6440
|
exports.montgomery = montgomery;
|
6239
6441
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
6240
|
-
var
|
6241
|
-
var
|
6442
|
+
var modular_ts_1 = require_modular();
|
6443
|
+
var utils_ts_1 = require_utils5();
|
6242
6444
|
var _0n = BigInt(0);
|
6243
6445
|
var _1n = BigInt(1);
|
6244
6446
|
function validateOpts(curve) {
|
6245
|
-
(0,
|
6447
|
+
(0, utils_ts_1.validateObject)(curve, {
|
6246
6448
|
a: "bigint"
|
6247
6449
|
}, {
|
6248
6450
|
montgomeryBits: "isSafeInteger",
|
@@ -6257,12 +6459,12 @@ var require_montgomery = __commonJS((exports) => {
|
|
6257
6459
|
function montgomery(curveDef) {
|
6258
6460
|
const CURVE = validateOpts(curveDef);
|
6259
6461
|
const { P } = CURVE;
|
6260
|
-
const modP = (n) => (0,
|
6462
|
+
const modP = (n) => (0, modular_ts_1.mod)(n, P);
|
6261
6463
|
const montgomeryBits = CURVE.montgomeryBits;
|
6262
6464
|
const montgomeryBytes = Math.ceil(montgomeryBits / 8);
|
6263
6465
|
const fieldLen = CURVE.nByteLength;
|
6264
6466
|
const adjustScalarBytes = CURVE.adjustScalarBytes || ((bytes) => bytes);
|
6265
|
-
const powPminus2 = CURVE.powPminus2 || ((x) => (0,
|
6467
|
+
const powPminus2 = CURVE.powPminus2 || ((x) => (0, modular_ts_1.pow)(x, P - BigInt(2), P));
|
6266
6468
|
function cswap(swap, x_2, x_3) {
|
6267
6469
|
const dummy = modP(swap * (x_2 - x_3));
|
6268
6470
|
x_2 = modP(x_2 - dummy);
|
@@ -6271,8 +6473,8 @@ var require_montgomery = __commonJS((exports) => {
|
|
6271
6473
|
}
|
6272
6474
|
const a24 = (CURVE.a - BigInt(2)) / BigInt(4);
|
6273
6475
|
function montgomeryLadder(u, scalar) {
|
6274
|
-
(0,
|
6275
|
-
(0,
|
6476
|
+
(0, utils_ts_1.aInRange)("u", u, _0n, P);
|
6477
|
+
(0, utils_ts_1.aInRange)("scalar", scalar, _0n, P);
|
6276
6478
|
const k = scalar;
|
6277
6479
|
const x_1 = u;
|
6278
6480
|
let x_2 = _1n;
|
@@ -6317,22 +6519,22 @@ var require_montgomery = __commonJS((exports) => {
|
|
6317
6519
|
return modP(x_2 * z2);
|
6318
6520
|
}
|
6319
6521
|
function encodeUCoordinate(u) {
|
6320
|
-
return (0,
|
6522
|
+
return (0, utils_ts_1.numberToBytesLE)(modP(u), montgomeryBytes);
|
6321
6523
|
}
|
6322
6524
|
function decodeUCoordinate(uEnc) {
|
6323
|
-
const u = (0,
|
6525
|
+
const u = (0, utils_ts_1.ensureBytes)("u coordinate", uEnc, montgomeryBytes);
|
6324
6526
|
if (fieldLen === 32)
|
6325
6527
|
u[31] &= 127;
|
6326
|
-
return (0,
|
6528
|
+
return (0, utils_ts_1.bytesToNumberLE)(u);
|
6327
6529
|
}
|
6328
6530
|
function decodeScalar(n) {
|
6329
|
-
const bytes = (0,
|
6531
|
+
const bytes = (0, utils_ts_1.ensureBytes)("scalar", n);
|
6330
6532
|
const len = bytes.length;
|
6331
6533
|
if (len !== montgomeryBytes && len !== fieldLen) {
|
6332
6534
|
let valid = "" + montgomeryBytes + " or " + fieldLen;
|
6333
6535
|
throw new Error("invalid scalar, expected " + valid + " bytes, got " + len);
|
6334
6536
|
}
|
6335
|
-
return (0,
|
6537
|
+
return (0, utils_ts_1.bytesToNumberLE)(adjustScalarBytes(bytes));
|
6336
6538
|
}
|
6337
6539
|
function scalarMult(scalar, u) {
|
6338
6540
|
const pointU = decodeUCoordinate(u);
|
@@ -6357,21 +6559,21 @@ var require_montgomery = __commonJS((exports) => {
|
|
6357
6559
|
}
|
6358
6560
|
});
|
6359
6561
|
|
6360
|
-
// ../../node_modules
|
6562
|
+
// ../../node_modules/@noble/curves/ed25519.js
|
6361
6563
|
var require_ed25519 = __commonJS((exports) => {
|
6362
6564
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6363
6565
|
exports.hash_to_ristretto255 = exports.hashToRistretto255 = exports.RistrettoPoint = exports.encodeToCurve = exports.hashToCurve = exports.edwardsToMontgomery = exports.x25519 = exports.ed25519ph = exports.ed25519ctx = exports.ed25519 = exports.ED25519_TORSION_SUBGROUP = undefined;
|
6364
6566
|
exports.edwardsToMontgomeryPub = edwardsToMontgomeryPub;
|
6365
6567
|
exports.edwardsToMontgomeryPriv = edwardsToMontgomeryPriv;
|
6366
6568
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
6367
|
-
var
|
6569
|
+
var sha2_1 = require_sha2();
|
6368
6570
|
var utils_1 = require_utils4();
|
6369
|
-
var
|
6370
|
-
var
|
6371
|
-
var
|
6372
|
-
var
|
6373
|
-
var
|
6374
|
-
var
|
6571
|
+
var curve_ts_1 = require_curve();
|
6572
|
+
var edwards_ts_1 = require_edwards();
|
6573
|
+
var hash_to_curve_ts_1 = require_hash_to_curve();
|
6574
|
+
var modular_ts_1 = require_modular();
|
6575
|
+
var montgomery_ts_1 = require_montgomery();
|
6576
|
+
var utils_ts_1 = require_utils5();
|
6375
6577
|
var ED25519_P = BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");
|
6376
6578
|
var ED25519_SQRT_M1 = /* @__PURE__ */ BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");
|
6377
6579
|
var _0n = BigInt(0);
|
@@ -6385,16 +6587,16 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6385
6587
|
const P = ED25519_P;
|
6386
6588
|
const x2 = x * x % P;
|
6387
6589
|
const b2 = x2 * x % P;
|
6388
|
-
const b4 = (0,
|
6389
|
-
const b5 = (0,
|
6390
|
-
const b10 = (0,
|
6391
|
-
const b20 = (0,
|
6392
|
-
const b40 = (0,
|
6393
|
-
const b80 = (0,
|
6394
|
-
const b160 = (0,
|
6395
|
-
const b240 = (0,
|
6396
|
-
const b250 = (0,
|
6397
|
-
const pow_p_5_8 = (0,
|
6590
|
+
const b4 = (0, modular_ts_1.pow2)(b2, _2n, P) * b2 % P;
|
6591
|
+
const b5 = (0, modular_ts_1.pow2)(b4, _1n, P) * x % P;
|
6592
|
+
const b10 = (0, modular_ts_1.pow2)(b5, _5n, P) * b5 % P;
|
6593
|
+
const b20 = (0, modular_ts_1.pow2)(b10, _10n, P) * b10 % P;
|
6594
|
+
const b40 = (0, modular_ts_1.pow2)(b20, _20n, P) * b20 % P;
|
6595
|
+
const b80 = (0, modular_ts_1.pow2)(b40, _40n, P) * b40 % P;
|
6596
|
+
const b160 = (0, modular_ts_1.pow2)(b80, _80n, P) * b80 % P;
|
6597
|
+
const b240 = (0, modular_ts_1.pow2)(b160, _80n, P) * b80 % P;
|
6598
|
+
const b250 = (0, modular_ts_1.pow2)(b240, _10n, P) * b10 % P;
|
6599
|
+
const pow_p_5_8 = (0, modular_ts_1.pow2)(b250, _2n, P) * x % P;
|
6398
6600
|
return { pow_p_5_8, b2 };
|
6399
6601
|
}
|
6400
6602
|
function adjustScalarBytes(bytes) {
|
@@ -6405,22 +6607,22 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6405
6607
|
}
|
6406
6608
|
function uvRatio(u, v) {
|
6407
6609
|
const P = ED25519_P;
|
6408
|
-
const v3 = (0,
|
6409
|
-
const v7 = (0,
|
6610
|
+
const v3 = (0, modular_ts_1.mod)(v * v * v, P);
|
6611
|
+
const v7 = (0, modular_ts_1.mod)(v3 * v3 * v, P);
|
6410
6612
|
const pow = ed25519_pow_2_252_3(u * v7).pow_p_5_8;
|
6411
|
-
let x = (0,
|
6412
|
-
const vx2 = (0,
|
6613
|
+
let x = (0, modular_ts_1.mod)(u * v3 * pow, P);
|
6614
|
+
const vx2 = (0, modular_ts_1.mod)(v * x * x, P);
|
6413
6615
|
const root1 = x;
|
6414
|
-
const root2 = (0,
|
6616
|
+
const root2 = (0, modular_ts_1.mod)(x * ED25519_SQRT_M1, P);
|
6415
6617
|
const useRoot1 = vx2 === u;
|
6416
|
-
const useRoot2 = vx2 === (0,
|
6417
|
-
const noRoot = vx2 === (0,
|
6618
|
+
const useRoot2 = vx2 === (0, modular_ts_1.mod)(-u, P);
|
6619
|
+
const noRoot = vx2 === (0, modular_ts_1.mod)(-u * ED25519_SQRT_M1, P);
|
6418
6620
|
if (useRoot1)
|
6419
6621
|
x = root1;
|
6420
6622
|
if (useRoot2 || noRoot)
|
6421
6623
|
x = root2;
|
6422
|
-
if ((0,
|
6423
|
-
x = (0,
|
6624
|
+
if ((0, modular_ts_1.isNegativeLE)(x, P))
|
6625
|
+
x = (0, modular_ts_1.mod)(-x, P);
|
6424
6626
|
return { isValid: useRoot1 || useRoot2, value: x };
|
6425
6627
|
}
|
6426
6628
|
exports.ED25519_TORSION_SUBGROUP = [
|
@@ -6433,35 +6635,35 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6433
6635
|
"0000000000000000000000000000000000000000000000000000000000000000",
|
6434
6636
|
"c7176a703d4dd84fba3c0b760d10670f2a2053fa2c39ccc64ec7fd7792ac03fa"
|
6435
6637
|
];
|
6436
|
-
var Fp = /* @__PURE__ */ (() => (0,
|
6638
|
+
var Fp = /* @__PURE__ */ (() => (0, modular_ts_1.Field)(ED25519_P, undefined, true))();
|
6437
6639
|
var ed25519Defaults = /* @__PURE__ */ (() => ({
|
6438
|
-
a: BigInt(-1),
|
6640
|
+
a: Fp.create(BigInt(-1)),
|
6439
6641
|
d: BigInt("37095705934669439343138083508754565189542113879843219016388785533085940283555"),
|
6440
6642
|
Fp,
|
6441
6643
|
n: BigInt("7237005577332262213973186563042994240857116359379907606001950938285454250989"),
|
6442
6644
|
h: _8n,
|
6443
6645
|
Gx: BigInt("15112221349535400772501151409588531511454012693041857206046113283949847762202"),
|
6444
6646
|
Gy: BigInt("46316835694926478169428394003475163141307993866256225615783033603165251855960"),
|
6445
|
-
hash:
|
6647
|
+
hash: sha2_1.sha512,
|
6446
6648
|
randomBytes: utils_1.randomBytes,
|
6447
6649
|
adjustScalarBytes,
|
6448
6650
|
uvRatio
|
6449
6651
|
}))();
|
6450
|
-
exports.ed25519 = (() => (0,
|
6652
|
+
exports.ed25519 = (() => (0, edwards_ts_1.twistedEdwards)(ed25519Defaults))();
|
6451
6653
|
function ed25519_domain(data, ctx, phflag) {
|
6452
6654
|
if (ctx.length > 255)
|
6453
6655
|
throw new Error("Context is too big");
|
6454
6656
|
return (0, utils_1.concatBytes)((0, utils_1.utf8ToBytes)("SigEd25519 no Ed25519 collisions"), new Uint8Array([phflag ? 1 : 0, ctx.length]), ctx, data);
|
6455
6657
|
}
|
6456
|
-
exports.ed25519ctx = (() => (0,
|
6658
|
+
exports.ed25519ctx = (() => (0, edwards_ts_1.twistedEdwards)({
|
6457
6659
|
...ed25519Defaults,
|
6458
6660
|
domain: ed25519_domain
|
6459
6661
|
}))();
|
6460
|
-
exports.ed25519ph = (() => (0,
|
6662
|
+
exports.ed25519ph = (() => (0, edwards_ts_1.twistedEdwards)(Object.assign({}, ed25519Defaults, {
|
6461
6663
|
domain: ed25519_domain,
|
6462
|
-
prehash:
|
6664
|
+
prehash: sha2_1.sha512
|
6463
6665
|
})))();
|
6464
|
-
exports.x25519 = (() => (0,
|
6666
|
+
exports.x25519 = (() => (0, montgomery_ts_1.montgomery)({
|
6465
6667
|
P: ED25519_P,
|
6466
6668
|
a: BigInt(486662),
|
6467
6669
|
montgomeryBits: 255,
|
@@ -6470,7 +6672,7 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6470
6672
|
powPminus2: (x) => {
|
6471
6673
|
const P = ED25519_P;
|
6472
6674
|
const { pow_p_5_8, b2 } = ed25519_pow_2_252_3(x);
|
6473
|
-
return (0,
|
6675
|
+
return (0, modular_ts_1.mod)((0, modular_ts_1.pow2)(pow_p_5_8, _3n, P) * b2, P);
|
6474
6676
|
},
|
6475
6677
|
adjustScalarBytes,
|
6476
6678
|
randomBytes: utils_1.randomBytes
|
@@ -6531,7 +6733,7 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6531
6733
|
y = Fp.cmov(y, Fp.neg(y), e3 !== e4);
|
6532
6734
|
return { xMn: xn, xMd: xd, yMn: y, yMd: _1n };
|
6533
6735
|
}
|
6534
|
-
var ELL2_C1_EDWARDS = /* @__PURE__ */ (() => (0,
|
6736
|
+
var ELL2_C1_EDWARDS = /* @__PURE__ */ (() => (0, modular_ts_1.FpSqrtEven)(Fp, Fp.neg(BigInt(486664))))();
|
6535
6737
|
function map_to_curve_elligator2_edwards25519(u) {
|
6536
6738
|
const { xMn, xMd, yMn, yMd } = map_to_curve_elligator2_curve25519(u);
|
6537
6739
|
let xn = Fp.mul(xMn, yMd);
|
@@ -6548,18 +6750,18 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6548
6750
|
const inv = Fp.invertBatch([xd, yd]);
|
6549
6751
|
return { x: Fp.mul(xn, inv[0]), y: Fp.mul(yn, inv[1]) };
|
6550
6752
|
}
|
6551
|
-
var htf = /* @__PURE__ */ (() => (0,
|
6753
|
+
var htf = /* @__PURE__ */ (() => (0, hash_to_curve_ts_1.createHasher)(exports.ed25519.ExtendedPoint, (scalars) => map_to_curve_elligator2_edwards25519(scalars[0]), {
|
6552
6754
|
DST: "edwards25519_XMD:SHA-512_ELL2_RO_",
|
6553
6755
|
encodeDST: "edwards25519_XMD:SHA-512_ELL2_NU_",
|
6554
6756
|
p: Fp.ORDER,
|
6555
6757
|
m: 1,
|
6556
6758
|
k: 128,
|
6557
6759
|
expand: "xmd",
|
6558
|
-
hash:
|
6760
|
+
hash: sha2_1.sha512
|
6559
6761
|
}))();
|
6560
6762
|
exports.hashToCurve = (() => htf.hashToCurve)();
|
6561
6763
|
exports.encodeToCurve = (() => htf.encodeToCurve)();
|
6562
|
-
function
|
6764
|
+
function aristp(other) {
|
6563
6765
|
if (!(other instanceof RistPoint))
|
6564
6766
|
throw new Error("RistrettoPoint expected");
|
6565
6767
|
}
|
@@ -6570,7 +6772,7 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6570
6772
|
var D_MINUS_ONE_SQ = /* @__PURE__ */ BigInt("40440834346308536858101042469323190826248399146238708352240133220865137265952");
|
6571
6773
|
var invertSqrt = (number) => uvRatio(_1n, number);
|
6572
6774
|
var MAX_255B = /* @__PURE__ */ BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");
|
6573
|
-
var bytes255ToNumberLE = (bytes) => exports.ed25519.CURVE.Fp.create((0,
|
6775
|
+
var bytes255ToNumberLE = (bytes) => exports.ed25519.CURVE.Fp.create((0, utils_ts_1.bytesToNumberLE)(bytes) & MAX_255B);
|
6574
6776
|
function calcElligatorRistrettoMap(r0) {
|
6575
6777
|
const { d } = exports.ed25519.CURVE;
|
6576
6778
|
const P = exports.ed25519.CURVE.Fp.ORDER;
|
@@ -6581,7 +6783,7 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6581
6783
|
const D = mod((c - d * r) * mod(r + d));
|
6582
6784
|
let { isValid: Ns_D_is_sq, value: s } = uvRatio(Ns, D);
|
6583
6785
|
let s_ = mod(s * r0);
|
6584
|
-
if (!(0,
|
6786
|
+
if (!(0, modular_ts_1.isNegativeLE)(s_, P))
|
6585
6787
|
s_ = mod(-s_);
|
6586
6788
|
if (!Ns_D_is_sq)
|
6587
6789
|
s = s_;
|
@@ -6604,7 +6806,7 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6604
6806
|
return new RistPoint(exports.ed25519.ExtendedPoint.fromAffine(ap));
|
6605
6807
|
}
|
6606
6808
|
static hashToCurve(hex) {
|
6607
|
-
hex = (0,
|
6809
|
+
hex = (0, utils_ts_1.ensureBytes)("ristrettoHash", hex, 64);
|
6608
6810
|
const r1 = bytes255ToNumberLE(hex.slice(0, 32));
|
6609
6811
|
const R1 = calcElligatorRistrettoMap(r1);
|
6610
6812
|
const r2 = bytes255ToNumberLE(hex.slice(32, 64));
|
@@ -6612,13 +6814,13 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6612
6814
|
return new RistPoint(R1.add(R2));
|
6613
6815
|
}
|
6614
6816
|
static fromHex(hex) {
|
6615
|
-
hex = (0,
|
6817
|
+
hex = (0, utils_ts_1.ensureBytes)("ristrettoHex", hex, 32);
|
6616
6818
|
const { a, d } = exports.ed25519.CURVE;
|
6617
6819
|
const P = exports.ed25519.CURVE.Fp.ORDER;
|
6618
6820
|
const mod = exports.ed25519.CURVE.Fp.create;
|
6619
6821
|
const emsg = "RistrettoPoint.fromHex: the hex is not valid encoding of RistrettoPoint";
|
6620
6822
|
const s = bytes255ToNumberLE(hex);
|
6621
|
-
if (!(0,
|
6823
|
+
if (!(0, utils_ts_1.equalBytes)((0, utils_ts_1.numberToBytesLE)(s, 32), hex) || (0, modular_ts_1.isNegativeLE)(s, P))
|
6622
6824
|
throw new Error(emsg);
|
6623
6825
|
const s2 = mod(s * s);
|
6624
6826
|
const u1 = mod(_1n + a * s2);
|
@@ -6630,17 +6832,17 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6630
6832
|
const Dx = mod(I * u2);
|
6631
6833
|
const Dy = mod(I * Dx * v);
|
6632
6834
|
let x = mod((s + s) * Dx);
|
6633
|
-
if ((0,
|
6835
|
+
if ((0, modular_ts_1.isNegativeLE)(x, P))
|
6634
6836
|
x = mod(-x);
|
6635
6837
|
const y = mod(u1 * Dy);
|
6636
6838
|
const t = mod(x * y);
|
6637
|
-
if (!isValid2 || (0,
|
6839
|
+
if (!isValid2 || (0, modular_ts_1.isNegativeLE)(t, P) || y === _0n)
|
6638
6840
|
throw new Error(emsg);
|
6639
6841
|
return new RistPoint(new exports.ed25519.ExtendedPoint(x, y, _1n, t));
|
6640
6842
|
}
|
6641
6843
|
static msm(points, scalars) {
|
6642
|
-
const Fn = (0,
|
6643
|
-
return (0,
|
6844
|
+
const Fn = (0, modular_ts_1.Field)(exports.ed25519.CURVE.n, exports.ed25519.CURVE.nBitLength);
|
6845
|
+
return (0, curve_ts_1.pippenger)(RistPoint, Fn, points, scalars);
|
6644
6846
|
}
|
6645
6847
|
toRawBytes() {
|
6646
6848
|
let { ex: x, ey: y, ez: z2, et: t } = this.ep;
|
@@ -6654,7 +6856,7 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6654
6856
|
const D2 = mod(invsqrt * u2);
|
6655
6857
|
const zInv = mod(D1 * D2 * t);
|
6656
6858
|
let D;
|
6657
|
-
if ((0,
|
6859
|
+
if ((0, modular_ts_1.isNegativeLE)(t * zInv, P)) {
|
6658
6860
|
let _x = mod(y * SQRT_M1);
|
6659
6861
|
let _y = mod(x * SQRT_M1);
|
6660
6862
|
x = _x;
|
@@ -6663,21 +6865,21 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6663
6865
|
} else {
|
6664
6866
|
D = D2;
|
6665
6867
|
}
|
6666
|
-
if ((0,
|
6868
|
+
if ((0, modular_ts_1.isNegativeLE)(x * zInv, P))
|
6667
6869
|
y = mod(-y);
|
6668
6870
|
let s = mod((z2 - y) * D);
|
6669
|
-
if ((0,
|
6871
|
+
if ((0, modular_ts_1.isNegativeLE)(s, P))
|
6670
6872
|
s = mod(-s);
|
6671
|
-
return (0,
|
6873
|
+
return (0, utils_ts_1.numberToBytesLE)(s, 32);
|
6672
6874
|
}
|
6673
6875
|
toHex() {
|
6674
|
-
return (0,
|
6876
|
+
return (0, utils_ts_1.bytesToHex)(this.toRawBytes());
|
6675
6877
|
}
|
6676
6878
|
toString() {
|
6677
6879
|
return this.toHex();
|
6678
6880
|
}
|
6679
6881
|
equals(other) {
|
6680
|
-
|
6882
|
+
aristp(other);
|
6681
6883
|
const { ex: X1, ey: Y1 } = this.ep;
|
6682
6884
|
const { ex: X2, ey: Y2 } = other.ep;
|
6683
6885
|
const mod = exports.ed25519.CURVE.Fp.create;
|
@@ -6686,11 +6888,11 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6686
6888
|
return one || two;
|
6687
6889
|
}
|
6688
6890
|
add(other) {
|
6689
|
-
|
6891
|
+
aristp(other);
|
6690
6892
|
return new RistPoint(this.ep.add(other.ep));
|
6691
6893
|
}
|
6692
6894
|
subtract(other) {
|
6693
|
-
|
6895
|
+
aristp(other);
|
6694
6896
|
return new RistPoint(this.ep.subtract(other.ep));
|
6695
6897
|
}
|
6696
6898
|
multiply(scalar) {
|
@@ -6716,7 +6918,7 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6716
6918
|
var hashToRistretto255 = (msg, options) => {
|
6717
6919
|
const d = options.DST;
|
6718
6920
|
const DST = typeof d === "string" ? (0, utils_1.utf8ToBytes)(d) : d;
|
6719
|
-
const uniform_bytes = (0,
|
6921
|
+
const uniform_bytes = (0, hash_to_curve_ts_1.expand_message_xmd)(msg, DST, 64, sha2_1.sha512);
|
6720
6922
|
const P = RistPoint.hashToCurve(uniform_bytes);
|
6721
6923
|
return P;
|
6722
6924
|
};
|
@@ -6724,193 +6926,20 @@ var require_ed25519 = __commonJS((exports) => {
|
|
6724
6926
|
exports.hash_to_ristretto255 = exports.hashToRistretto255;
|
6725
6927
|
});
|
6726
6928
|
|
6727
|
-
// ../../node_modules
|
6728
|
-
var require_sha256 = __commonJS((exports) => {
|
6729
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
6730
|
-
exports.sha224 = exports.sha256 = exports.SHA256 = undefined;
|
6731
|
-
var _md_js_1 = require__md();
|
6732
|
-
var utils_js_1 = require_utils4();
|
6733
|
-
var SHA256_K = /* @__PURE__ */ new Uint32Array([
|
6734
|
-
1116352408,
|
6735
|
-
1899447441,
|
6736
|
-
3049323471,
|
6737
|
-
3921009573,
|
6738
|
-
961987163,
|
6739
|
-
1508970993,
|
6740
|
-
2453635748,
|
6741
|
-
2870763221,
|
6742
|
-
3624381080,
|
6743
|
-
310598401,
|
6744
|
-
607225278,
|
6745
|
-
1426881987,
|
6746
|
-
1925078388,
|
6747
|
-
2162078206,
|
6748
|
-
2614888103,
|
6749
|
-
3248222580,
|
6750
|
-
3835390401,
|
6751
|
-
4022224774,
|
6752
|
-
264347078,
|
6753
|
-
604807628,
|
6754
|
-
770255983,
|
6755
|
-
1249150122,
|
6756
|
-
1555081692,
|
6757
|
-
1996064986,
|
6758
|
-
2554220882,
|
6759
|
-
2821834349,
|
6760
|
-
2952996808,
|
6761
|
-
3210313671,
|
6762
|
-
3336571891,
|
6763
|
-
3584528711,
|
6764
|
-
113926993,
|
6765
|
-
338241895,
|
6766
|
-
666307205,
|
6767
|
-
773529912,
|
6768
|
-
1294757372,
|
6769
|
-
1396182291,
|
6770
|
-
1695183700,
|
6771
|
-
1986661051,
|
6772
|
-
2177026350,
|
6773
|
-
2456956037,
|
6774
|
-
2730485921,
|
6775
|
-
2820302411,
|
6776
|
-
3259730800,
|
6777
|
-
3345764771,
|
6778
|
-
3516065817,
|
6779
|
-
3600352804,
|
6780
|
-
4094571909,
|
6781
|
-
275423344,
|
6782
|
-
430227734,
|
6783
|
-
506948616,
|
6784
|
-
659060556,
|
6785
|
-
883997877,
|
6786
|
-
958139571,
|
6787
|
-
1322822218,
|
6788
|
-
1537002063,
|
6789
|
-
1747873779,
|
6790
|
-
1955562222,
|
6791
|
-
2024104815,
|
6792
|
-
2227730452,
|
6793
|
-
2361852424,
|
6794
|
-
2428436474,
|
6795
|
-
2756734187,
|
6796
|
-
3204031479,
|
6797
|
-
3329325298
|
6798
|
-
]);
|
6799
|
-
var SHA256_IV = /* @__PURE__ */ new Uint32Array([
|
6800
|
-
1779033703,
|
6801
|
-
3144134277,
|
6802
|
-
1013904242,
|
6803
|
-
2773480762,
|
6804
|
-
1359893119,
|
6805
|
-
2600822924,
|
6806
|
-
528734635,
|
6807
|
-
1541459225
|
6808
|
-
]);
|
6809
|
-
var SHA256_W = /* @__PURE__ */ new Uint32Array(64);
|
6810
|
-
|
6811
|
-
class SHA256 extends _md_js_1.HashMD {
|
6812
|
-
constructor() {
|
6813
|
-
super(64, 32, 8, false);
|
6814
|
-
this.A = SHA256_IV[0] | 0;
|
6815
|
-
this.B = SHA256_IV[1] | 0;
|
6816
|
-
this.C = SHA256_IV[2] | 0;
|
6817
|
-
this.D = SHA256_IV[3] | 0;
|
6818
|
-
this.E = SHA256_IV[4] | 0;
|
6819
|
-
this.F = SHA256_IV[5] | 0;
|
6820
|
-
this.G = SHA256_IV[6] | 0;
|
6821
|
-
this.H = SHA256_IV[7] | 0;
|
6822
|
-
}
|
6823
|
-
get() {
|
6824
|
-
const { A, B, C, D, E, F, G, H } = this;
|
6825
|
-
return [A, B, C, D, E, F, G, H];
|
6826
|
-
}
|
6827
|
-
set(A, B, C, D, E, F, G, H) {
|
6828
|
-
this.A = A | 0;
|
6829
|
-
this.B = B | 0;
|
6830
|
-
this.C = C | 0;
|
6831
|
-
this.D = D | 0;
|
6832
|
-
this.E = E | 0;
|
6833
|
-
this.F = F | 0;
|
6834
|
-
this.G = G | 0;
|
6835
|
-
this.H = H | 0;
|
6836
|
-
}
|
6837
|
-
process(view, offset) {
|
6838
|
-
for (let i = 0;i < 16; i++, offset += 4)
|
6839
|
-
SHA256_W[i] = view.getUint32(offset, false);
|
6840
|
-
for (let i = 16;i < 64; i++) {
|
6841
|
-
const W15 = SHA256_W[i - 15];
|
6842
|
-
const W2 = SHA256_W[i - 2];
|
6843
|
-
const s0 = (0, utils_js_1.rotr)(W15, 7) ^ (0, utils_js_1.rotr)(W15, 18) ^ W15 >>> 3;
|
6844
|
-
const s1 = (0, utils_js_1.rotr)(W2, 17) ^ (0, utils_js_1.rotr)(W2, 19) ^ W2 >>> 10;
|
6845
|
-
SHA256_W[i] = s1 + SHA256_W[i - 7] + s0 + SHA256_W[i - 16] | 0;
|
6846
|
-
}
|
6847
|
-
let { A, B, C, D, E, F, G, H } = this;
|
6848
|
-
for (let i = 0;i < 64; i++) {
|
6849
|
-
const sigma1 = (0, utils_js_1.rotr)(E, 6) ^ (0, utils_js_1.rotr)(E, 11) ^ (0, utils_js_1.rotr)(E, 25);
|
6850
|
-
const T1 = H + sigma1 + (0, _md_js_1.Chi)(E, F, G) + SHA256_K[i] + SHA256_W[i] | 0;
|
6851
|
-
const sigma0 = (0, utils_js_1.rotr)(A, 2) ^ (0, utils_js_1.rotr)(A, 13) ^ (0, utils_js_1.rotr)(A, 22);
|
6852
|
-
const T2 = sigma0 + (0, _md_js_1.Maj)(A, B, C) | 0;
|
6853
|
-
H = G;
|
6854
|
-
G = F;
|
6855
|
-
F = E;
|
6856
|
-
E = D + T1 | 0;
|
6857
|
-
D = C;
|
6858
|
-
C = B;
|
6859
|
-
B = A;
|
6860
|
-
A = T1 + T2 | 0;
|
6861
|
-
}
|
6862
|
-
A = A + this.A | 0;
|
6863
|
-
B = B + this.B | 0;
|
6864
|
-
C = C + this.C | 0;
|
6865
|
-
D = D + this.D | 0;
|
6866
|
-
E = E + this.E | 0;
|
6867
|
-
F = F + this.F | 0;
|
6868
|
-
G = G + this.G | 0;
|
6869
|
-
H = H + this.H | 0;
|
6870
|
-
this.set(A, B, C, D, E, F, G, H);
|
6871
|
-
}
|
6872
|
-
roundClean() {
|
6873
|
-
SHA256_W.fill(0);
|
6874
|
-
}
|
6875
|
-
destroy() {
|
6876
|
-
this.set(0, 0, 0, 0, 0, 0, 0, 0);
|
6877
|
-
this.buffer.fill(0);
|
6878
|
-
}
|
6879
|
-
}
|
6880
|
-
exports.SHA256 = SHA256;
|
6881
|
-
|
6882
|
-
class SHA224 extends SHA256 {
|
6883
|
-
constructor() {
|
6884
|
-
super();
|
6885
|
-
this.A = 3238371032 | 0;
|
6886
|
-
this.B = 914150663 | 0;
|
6887
|
-
this.C = 812702999 | 0;
|
6888
|
-
this.D = 4144912697 | 0;
|
6889
|
-
this.E = 4290775857 | 0;
|
6890
|
-
this.F = 1750603025 | 0;
|
6891
|
-
this.G = 1694076839 | 0;
|
6892
|
-
this.H = 3204075428 | 0;
|
6893
|
-
this.outputLen = 28;
|
6894
|
-
}
|
6895
|
-
}
|
6896
|
-
exports.sha256 = (0, utils_js_1.wrapConstructor)(() => new SHA256);
|
6897
|
-
exports.sha224 = (0, utils_js_1.wrapConstructor)(() => new SHA224);
|
6898
|
-
});
|
6899
|
-
|
6900
|
-
// ../../node_modules/eciesjs/node_modules/@noble/hashes/hmac.js
|
6929
|
+
// ../../node_modules/@noble/hashes/hmac.js
|
6901
6930
|
var require_hmac = __commonJS((exports) => {
|
6902
6931
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6903
6932
|
exports.hmac = exports.HMAC = undefined;
|
6904
|
-
var
|
6905
|
-
var
|
6933
|
+
var _assert_ts_1 = require__assert();
|
6934
|
+
var utils_ts_1 = require_utils4();
|
6906
6935
|
|
6907
|
-
class HMAC extends
|
6936
|
+
class HMAC extends utils_ts_1.Hash {
|
6908
6937
|
constructor(hash, _key) {
|
6909
6938
|
super();
|
6910
6939
|
this.finished = false;
|
6911
6940
|
this.destroyed = false;
|
6912
|
-
(0,
|
6913
|
-
const key = (0,
|
6941
|
+
(0, _assert_ts_1.ahash)(hash);
|
6942
|
+
const key = (0, utils_ts_1.toBytes)(_key);
|
6914
6943
|
this.iHash = hash.create();
|
6915
6944
|
if (typeof this.iHash.update !== "function")
|
6916
6945
|
throw new Error("Expected instance of class which extends utils.Hash");
|
@@ -6929,13 +6958,13 @@ var require_hmac = __commonJS((exports) => {
|
|
6929
6958
|
pad.fill(0);
|
6930
6959
|
}
|
6931
6960
|
update(buf) {
|
6932
|
-
(0,
|
6961
|
+
(0, _assert_ts_1.aexists)(this);
|
6933
6962
|
this.iHash.update(buf);
|
6934
6963
|
return this;
|
6935
6964
|
}
|
6936
6965
|
digestInto(out) {
|
6937
|
-
(0,
|
6938
|
-
(0,
|
6966
|
+
(0, _assert_ts_1.aexists)(this);
|
6967
|
+
(0, _assert_ts_1.abytes)(out, this.outputLen);
|
6939
6968
|
this.finished = true;
|
6940
6969
|
this.iHash.digestInto(out);
|
6941
6970
|
this.oHash.update(out);
|
@@ -6971,7 +7000,7 @@ var require_hmac = __commonJS((exports) => {
|
|
6971
7000
|
exports.hmac.create = (hash, key) => new HMAC(hash, key);
|
6972
7001
|
});
|
6973
7002
|
|
6974
|
-
// ../../node_modules
|
7003
|
+
// ../../node_modules/@noble/curves/abstract/weierstrass.js
|
6975
7004
|
var require_weierstrass = __commonJS((exports) => {
|
6976
7005
|
Object.defineProperty(exports, "__esModule", { value: true });
|
6977
7006
|
exports.DER = exports.DERErr = undefined;
|
@@ -6980,19 +7009,18 @@ var require_weierstrass = __commonJS((exports) => {
|
|
6980
7009
|
exports.SWUFpSqrtRatio = SWUFpSqrtRatio;
|
6981
7010
|
exports.mapToCurveSimpleSWU = mapToCurveSimpleSWU;
|
6982
7011
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
6983
|
-
var
|
6984
|
-
var
|
6985
|
-
var
|
6986
|
-
var utils_js_1 = require_utils5();
|
7012
|
+
var curve_ts_1 = require_curve();
|
7013
|
+
var modular_ts_1 = require_modular();
|
7014
|
+
var utils_ts_1 = require_utils5();
|
6987
7015
|
function validateSigVerOpts(opts) {
|
6988
7016
|
if (opts.lowS !== undefined)
|
6989
|
-
(0,
|
7017
|
+
(0, utils_ts_1.abool)("lowS", opts.lowS);
|
6990
7018
|
if (opts.prehash !== undefined)
|
6991
|
-
(0,
|
7019
|
+
(0, utils_ts_1.abool)("prehash", opts.prehash);
|
6992
7020
|
}
|
6993
7021
|
function validatePointOpts(curve) {
|
6994
|
-
const opts = (0,
|
6995
|
-
|
7022
|
+
const opts = (0, curve_ts_1.validateBasic)(curve);
|
7023
|
+
(0, utils_ts_1.validateObject)(opts, {
|
6996
7024
|
a: "field",
|
6997
7025
|
b: "field"
|
6998
7026
|
}, {
|
@@ -7015,7 +7043,6 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7015
7043
|
}
|
7016
7044
|
return Object.freeze({ ...opts });
|
7017
7045
|
}
|
7018
|
-
var { bytesToNumberBE: b2n, hexToBytes: h2b } = ut;
|
7019
7046
|
|
7020
7047
|
class DERErr extends Error {
|
7021
7048
|
constructor(m = "") {
|
@@ -7033,11 +7060,11 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7033
7060
|
if (data.length & 1)
|
7034
7061
|
throw new E("tlv.encode: unpadded data");
|
7035
7062
|
const dataLen = data.length / 2;
|
7036
|
-
const len =
|
7063
|
+
const len = (0, utils_ts_1.numberToHexUnpadded)(dataLen);
|
7037
7064
|
if (len.length / 2 & 128)
|
7038
7065
|
throw new E("tlv.encode: long form length too big");
|
7039
|
-
const lenLen = dataLen > 127 ?
|
7040
|
-
const t =
|
7066
|
+
const lenLen = dataLen > 127 ? (0, utils_ts_1.numberToHexUnpadded)(len.length / 2 | 128) : "";
|
7067
|
+
const t = (0, utils_ts_1.numberToHexUnpadded)(tag);
|
7041
7068
|
return t + lenLen + len + data;
|
7042
7069
|
},
|
7043
7070
|
decode(tag, data) {
|
@@ -7080,7 +7107,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7080
7107
|
const { Err: E } = exports.DER;
|
7081
7108
|
if (num < _0n)
|
7082
7109
|
throw new E("integer: negative integers are not allowed");
|
7083
|
-
let hex =
|
7110
|
+
let hex = (0, utils_ts_1.numberToHexUnpadded)(num);
|
7084
7111
|
if (Number.parseInt(hex[0], 16) & 8)
|
7085
7112
|
hex = "00" + hex;
|
7086
7113
|
if (hex.length & 1)
|
@@ -7093,13 +7120,12 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7093
7120
|
throw new E("invalid signature integer: negative");
|
7094
7121
|
if (data[0] === 0 && !(data[1] & 128))
|
7095
7122
|
throw new E("invalid signature integer: unnecessary leading zero");
|
7096
|
-
return
|
7123
|
+
return (0, utils_ts_1.bytesToNumberBE)(data);
|
7097
7124
|
}
|
7098
7125
|
},
|
7099
7126
|
toSig(hex) {
|
7100
7127
|
const { Err: E, _int: int, _tlv: tlv } = exports.DER;
|
7101
|
-
const data =
|
7102
|
-
ut.abytes(data);
|
7128
|
+
const data = (0, utils_ts_1.ensureBytes)("signature", hex);
|
7103
7129
|
const { v: seqBytes, l: seqLeftBytes } = tlv.decode(48, data);
|
7104
7130
|
if (seqLeftBytes.length)
|
7105
7131
|
throw new E("invalid signature: left bytes after parsing");
|
@@ -7125,10 +7151,10 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7125
7151
|
function weierstrassPoints(opts) {
|
7126
7152
|
const CURVE = validatePointOpts(opts);
|
7127
7153
|
const { Fp } = CURVE;
|
7128
|
-
const Fn = (0,
|
7154
|
+
const Fn = (0, modular_ts_1.Field)(CURVE.n, CURVE.nBitLength);
|
7129
7155
|
const toBytes = CURVE.toBytes || ((_c, point, _isCompressed) => {
|
7130
7156
|
const a = point.toAffine();
|
7131
|
-
return
|
7157
|
+
return (0, utils_ts_1.concatBytes)(Uint8Array.from([4]), Fp.toBytes(a.x), Fp.toBytes(a.y));
|
7132
7158
|
});
|
7133
7159
|
const fromBytes = CURVE.fromBytes || ((bytes) => {
|
7134
7160
|
const tail = bytes.subarray(1);
|
@@ -7145,33 +7171,33 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7145
7171
|
if (!Fp.eql(Fp.sqr(CURVE.Gy), weierstrassEquation(CURVE.Gx)))
|
7146
7172
|
throw new Error("bad generator point: equation left != right");
|
7147
7173
|
function isWithinCurveOrder(num) {
|
7148
|
-
return
|
7174
|
+
return (0, utils_ts_1.inRange)(num, _1n, CURVE.n);
|
7149
7175
|
}
|
7150
7176
|
function normPrivateKeyToScalar(key) {
|
7151
7177
|
const { allowedPrivateKeyLengths: lengths, nByteLength, wrapPrivateKey, n: N } = CURVE;
|
7152
7178
|
if (lengths && typeof key !== "bigint") {
|
7153
|
-
if (
|
7154
|
-
key =
|
7179
|
+
if ((0, utils_ts_1.isBytes)(key))
|
7180
|
+
key = (0, utils_ts_1.bytesToHex)(key);
|
7155
7181
|
if (typeof key !== "string" || !lengths.includes(key.length))
|
7156
7182
|
throw new Error("invalid private key");
|
7157
7183
|
key = key.padStart(nByteLength * 2, "0");
|
7158
7184
|
}
|
7159
7185
|
let num;
|
7160
7186
|
try {
|
7161
|
-
num = typeof key === "bigint" ? key :
|
7187
|
+
num = typeof key === "bigint" ? key : (0, utils_ts_1.bytesToNumberBE)((0, utils_ts_1.ensureBytes)("private key", key, nByteLength));
|
7162
7188
|
} catch (error) {
|
7163
7189
|
throw new Error("invalid private key, expected hex or " + nByteLength + " bytes, got " + typeof key);
|
7164
7190
|
}
|
7165
7191
|
if (wrapPrivateKey)
|
7166
|
-
num = (0,
|
7167
|
-
|
7192
|
+
num = (0, modular_ts_1.mod)(num, N);
|
7193
|
+
(0, utils_ts_1.aInRange)("private key", num, _1n, N);
|
7168
7194
|
return num;
|
7169
7195
|
}
|
7170
|
-
function
|
7196
|
+
function aprjpoint(other) {
|
7171
7197
|
if (!(other instanceof Point))
|
7172
7198
|
throw new Error("ProjectivePoint expected");
|
7173
7199
|
}
|
7174
|
-
const toAffineMemo = (0,
|
7200
|
+
const toAffineMemo = (0, utils_ts_1.memoized)((p, iz) => {
|
7175
7201
|
const { px: x, py: y, pz: z2 } = p;
|
7176
7202
|
if (Fp.eql(z2, Fp.ONE))
|
7177
7203
|
return { x, y };
|
@@ -7187,7 +7213,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7187
7213
|
throw new Error("invZ was invalid");
|
7188
7214
|
return { x: ax, y: ay };
|
7189
7215
|
});
|
7190
|
-
const assertValidMemo = (0,
|
7216
|
+
const assertValidMemo = (0, utils_ts_1.memoized)((p) => {
|
7191
7217
|
if (p.is0()) {
|
7192
7218
|
if (CURVE.allowInfinityPoint && !Fp.is0(p.py))
|
7193
7219
|
return;
|
@@ -7207,15 +7233,15 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7207
7233
|
|
7208
7234
|
class Point {
|
7209
7235
|
constructor(px, py, pz) {
|
7210
|
-
this.px = px;
|
7211
|
-
this.py = py;
|
7212
|
-
this.pz = pz;
|
7213
7236
|
if (px == null || !Fp.isValid(px))
|
7214
7237
|
throw new Error("x required");
|
7215
7238
|
if (py == null || !Fp.isValid(py))
|
7216
7239
|
throw new Error("y required");
|
7217
7240
|
if (pz == null || !Fp.isValid(pz))
|
7218
7241
|
throw new Error("z required");
|
7242
|
+
this.px = px;
|
7243
|
+
this.py = py;
|
7244
|
+
this.pz = pz;
|
7219
7245
|
Object.freeze(this);
|
7220
7246
|
}
|
7221
7247
|
static fromAffine(p) {
|
@@ -7240,7 +7266,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7240
7266
|
return points.map((p, i) => p.toAffine(toInv[i])).map(Point.fromAffine);
|
7241
7267
|
}
|
7242
7268
|
static fromHex(hex) {
|
7243
|
-
const P = Point.fromAffine(fromBytes((0,
|
7269
|
+
const P = Point.fromAffine(fromBytes((0, utils_ts_1.ensureBytes)("pointHex", hex)));
|
7244
7270
|
P.assertValidity();
|
7245
7271
|
return P;
|
7246
7272
|
}
|
@@ -7248,7 +7274,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7248
7274
|
return Point.BASE.multiply(normPrivateKeyToScalar(privateKey));
|
7249
7275
|
}
|
7250
7276
|
static msm(points, scalars) {
|
7251
|
-
return (0,
|
7277
|
+
return (0, curve_ts_1.pippenger)(Point, Fn, points, scalars);
|
7252
7278
|
}
|
7253
7279
|
_setWindowSize(windowSize) {
|
7254
7280
|
wnaf.setWindowSize(this, windowSize);
|
@@ -7263,7 +7289,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7263
7289
|
throw new Error("Field doesn't support isOdd");
|
7264
7290
|
}
|
7265
7291
|
equals(other) {
|
7266
|
-
|
7292
|
+
aprjpoint(other);
|
7267
7293
|
const { px: X1, py: Y1, pz: Z1 } = this;
|
7268
7294
|
const { px: X2, py: Y2, pz: Z2 } = other;
|
7269
7295
|
const U1 = Fp.eql(Fp.mul(X1, Z2), Fp.mul(X2, Z1));
|
@@ -7312,7 +7338,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7312
7338
|
return new Point(X3, Y3, Z3);
|
7313
7339
|
}
|
7314
7340
|
add(other) {
|
7315
|
-
|
7341
|
+
aprjpoint(other);
|
7316
7342
|
const { px: X1, py: Y1, pz: Z1 } = this;
|
7317
7343
|
const { px: X2, py: Y2, pz: Z2 } = other;
|
7318
7344
|
let { ZERO: X3, ZERO: Y3, ZERO: Z3 } = Fp;
|
@@ -7371,7 +7397,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7371
7397
|
}
|
7372
7398
|
multiplyUnsafe(sc) {
|
7373
7399
|
const { endo, n: N } = CURVE;
|
7374
|
-
|
7400
|
+
(0, utils_ts_1.aInRange)("scalar", sc, _0n, N);
|
7375
7401
|
const I = Point.ZERO;
|
7376
7402
|
if (sc === _0n)
|
7377
7403
|
return I;
|
@@ -7401,7 +7427,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7401
7427
|
}
|
7402
7428
|
multiply(scalar) {
|
7403
7429
|
const { endo, n: N } = CURVE;
|
7404
|
-
|
7430
|
+
(0, utils_ts_1.aInRange)("scalar", scalar, _1n, N);
|
7405
7431
|
let point, fake;
|
7406
7432
|
if (endo) {
|
7407
7433
|
const { k1neg, k1, k2neg, k2 } = endo.splitScalar(scalar);
|
@@ -7445,19 +7471,19 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7445
7471
|
return this.multiplyUnsafe(CURVE.h);
|
7446
7472
|
}
|
7447
7473
|
toRawBytes(isCompressed = true) {
|
7448
|
-
(0,
|
7474
|
+
(0, utils_ts_1.abool)("isCompressed", isCompressed);
|
7449
7475
|
this.assertValidity();
|
7450
7476
|
return toBytes(Point, this, isCompressed);
|
7451
7477
|
}
|
7452
7478
|
toHex(isCompressed = true) {
|
7453
|
-
(0,
|
7454
|
-
return
|
7479
|
+
(0, utils_ts_1.abool)("isCompressed", isCompressed);
|
7480
|
+
return (0, utils_ts_1.bytesToHex)(this.toRawBytes(isCompressed));
|
7455
7481
|
}
|
7456
7482
|
}
|
7457
7483
|
Point.BASE = new Point(CURVE.Gx, CURVE.Gy, Fp.ONE);
|
7458
7484
|
Point.ZERO = new Point(Fp.ZERO, Fp.ONE, Fp.ZERO);
|
7459
7485
|
const _bits = CURVE.nBitLength;
|
7460
|
-
const wnaf = (0,
|
7486
|
+
const wnaf = (0, curve_ts_1.wNAF)(Point, CURVE.endo ? Math.ceil(_bits / 2) : _bits);
|
7461
7487
|
return {
|
7462
7488
|
CURVE,
|
7463
7489
|
ProjectivePoint: Point,
|
@@ -7467,8 +7493,8 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7467
7493
|
};
|
7468
7494
|
}
|
7469
7495
|
function validateOpts(curve) {
|
7470
|
-
const opts = (0,
|
7471
|
-
|
7496
|
+
const opts = (0, curve_ts_1.validateBasic)(curve);
|
7497
|
+
(0, utils_ts_1.validateObject)(opts, {
|
7472
7498
|
hash: "hash",
|
7473
7499
|
hmac: "function",
|
7474
7500
|
randomBytes: "function"
|
@@ -7485,18 +7511,18 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7485
7511
|
const compressedLen = Fp.BYTES + 1;
|
7486
7512
|
const uncompressedLen = 2 * Fp.BYTES + 1;
|
7487
7513
|
function modN(a) {
|
7488
|
-
return (0,
|
7514
|
+
return (0, modular_ts_1.mod)(a, CURVE_ORDER);
|
7489
7515
|
}
|
7490
7516
|
function invN(a) {
|
7491
|
-
return (0,
|
7517
|
+
return (0, modular_ts_1.invert)(a, CURVE_ORDER);
|
7492
7518
|
}
|
7493
7519
|
const { ProjectivePoint: Point, normPrivateKeyToScalar, weierstrassEquation, isWithinCurveOrder } = weierstrassPoints({
|
7494
7520
|
...CURVE,
|
7495
7521
|
toBytes(_c, point, isCompressed) {
|
7496
7522
|
const a = point.toAffine();
|
7497
7523
|
const x = Fp.toBytes(a.x);
|
7498
|
-
const cat =
|
7499
|
-
(0,
|
7524
|
+
const cat = utils_ts_1.concatBytes;
|
7525
|
+
(0, utils_ts_1.abool)("isCompressed", isCompressed);
|
7500
7526
|
if (isCompressed) {
|
7501
7527
|
return cat(Uint8Array.from([point.hasEvenY() ? 2 : 3]), x);
|
7502
7528
|
} else {
|
@@ -7508,8 +7534,8 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7508
7534
|
const head = bytes[0];
|
7509
7535
|
const tail = bytes.subarray(1);
|
7510
7536
|
if (len === compressedLen && (head === 2 || head === 3)) {
|
7511
|
-
const x =
|
7512
|
-
if (!
|
7537
|
+
const x = (0, utils_ts_1.bytesToNumberBE)(tail);
|
7538
|
+
if (!(0, utils_ts_1.inRange)(x, _1n, Fp.ORDER))
|
7513
7539
|
throw new Error("Point is not on curve");
|
7514
7540
|
const y2 = weierstrassEquation(x);
|
7515
7541
|
let y;
|
@@ -7535,7 +7561,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7535
7561
|
}
|
7536
7562
|
}
|
7537
7563
|
});
|
7538
|
-
const
|
7564
|
+
const numToNByteHex = (num) => (0, utils_ts_1.bytesToHex)((0, utils_ts_1.numberToBytesBE)(num, CURVE.nByteLength));
|
7539
7565
|
function isBiggerThanHalfOrder(number) {
|
7540
7566
|
const HALF = CURVE_ORDER >> _1n;
|
7541
7567
|
return number > HALF;
|
@@ -7543,41 +7569,41 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7543
7569
|
function normalizeS(s) {
|
7544
7570
|
return isBiggerThanHalfOrder(s) ? modN(-s) : s;
|
7545
7571
|
}
|
7546
|
-
const slcNum = (b, from, to) =>
|
7572
|
+
const slcNum = (b, from, to) => (0, utils_ts_1.bytesToNumberBE)(b.slice(from, to));
|
7547
7573
|
|
7548
7574
|
class Signature {
|
7549
7575
|
constructor(r, s, recovery) {
|
7576
|
+
(0, utils_ts_1.aInRange)("r", r, _1n, CURVE_ORDER);
|
7577
|
+
(0, utils_ts_1.aInRange)("s", s, _1n, CURVE_ORDER);
|
7550
7578
|
this.r = r;
|
7551
7579
|
this.s = s;
|
7552
|
-
|
7553
|
-
|
7580
|
+
if (recovery != null)
|
7581
|
+
this.recovery = recovery;
|
7582
|
+
Object.freeze(this);
|
7554
7583
|
}
|
7555
7584
|
static fromCompact(hex) {
|
7556
7585
|
const l = CURVE.nByteLength;
|
7557
|
-
hex = (0,
|
7586
|
+
hex = (0, utils_ts_1.ensureBytes)("compactSignature", hex, l * 2);
|
7558
7587
|
return new Signature(slcNum(hex, 0, l), slcNum(hex, l, 2 * l));
|
7559
7588
|
}
|
7560
7589
|
static fromDER(hex) {
|
7561
|
-
const { r, s } = exports.DER.toSig((0,
|
7590
|
+
const { r, s } = exports.DER.toSig((0, utils_ts_1.ensureBytes)("DER", hex));
|
7562
7591
|
return new Signature(r, s);
|
7563
7592
|
}
|
7564
|
-
assertValidity() {
|
7565
|
-
ut.aInRange("r", this.r, _1n, CURVE_ORDER);
|
7566
|
-
ut.aInRange("s", this.s, _1n, CURVE_ORDER);
|
7567
|
-
}
|
7593
|
+
assertValidity() {}
|
7568
7594
|
addRecoveryBit(recovery) {
|
7569
7595
|
return new Signature(this.r, this.s, recovery);
|
7570
7596
|
}
|
7571
7597
|
recoverPublicKey(msgHash) {
|
7572
7598
|
const { r, s, recovery: rec } = this;
|
7573
|
-
const h = bits2int_modN((0,
|
7599
|
+
const h = bits2int_modN((0, utils_ts_1.ensureBytes)("msgHash", msgHash));
|
7574
7600
|
if (rec == null || ![0, 1, 2, 3].includes(rec))
|
7575
7601
|
throw new Error("recovery id invalid");
|
7576
7602
|
const radj = rec === 2 || rec === 3 ? r + CURVE.n : r;
|
7577
7603
|
if (radj >= Fp.ORDER)
|
7578
7604
|
throw new Error("recovery id 2 or 3 invalid");
|
7579
7605
|
const prefix = (rec & 1) === 0 ? "02" : "03";
|
7580
|
-
const R = Point.fromHex(prefix +
|
7606
|
+
const R = Point.fromHex(prefix + numToNByteHex(radj));
|
7581
7607
|
const ir = invN(radj);
|
7582
7608
|
const u1 = modN(-h * ir);
|
7583
7609
|
const u2 = modN(s * ir);
|
@@ -7594,16 +7620,16 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7594
7620
|
return this.hasHighS() ? new Signature(this.r, modN(-this.s), this.recovery) : this;
|
7595
7621
|
}
|
7596
7622
|
toDERRawBytes() {
|
7597
|
-
return
|
7623
|
+
return (0, utils_ts_1.hexToBytes)(this.toDERHex());
|
7598
7624
|
}
|
7599
7625
|
toDERHex() {
|
7600
7626
|
return exports.DER.hexFromSig({ r: this.r, s: this.s });
|
7601
7627
|
}
|
7602
7628
|
toCompactRawBytes() {
|
7603
|
-
return
|
7629
|
+
return (0, utils_ts_1.hexToBytes)(this.toCompactHex());
|
7604
7630
|
}
|
7605
7631
|
toCompactHex() {
|
7606
|
-
return
|
7632
|
+
return numToNByteHex(this.r) + numToNByteHex(this.s);
|
7607
7633
|
}
|
7608
7634
|
}
|
7609
7635
|
const utils = {
|
@@ -7617,8 +7643,8 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7617
7643
|
},
|
7618
7644
|
normPrivateKeyToScalar,
|
7619
7645
|
randomPrivateKey: () => {
|
7620
|
-
const length = (0,
|
7621
|
-
return (0,
|
7646
|
+
const length = (0, modular_ts_1.getMinHashLength)(CURVE.n);
|
7647
|
+
return (0, modular_ts_1.mapHashToField)(CURVE.randomBytes(length), CURVE.n);
|
7622
7648
|
},
|
7623
7649
|
precompute(windowSize = 8, point = Point.BASE) {
|
7624
7650
|
point._setWindowSize(windowSize);
|
@@ -7630,7 +7656,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7630
7656
|
return Point.fromPrivateKey(privateKey).toRawBytes(isCompressed);
|
7631
7657
|
}
|
7632
7658
|
function isProbPub(item) {
|
7633
|
-
const arr =
|
7659
|
+
const arr = (0, utils_ts_1.isBytes)(item);
|
7634
7660
|
const str = typeof item === "string";
|
7635
7661
|
const len = (arr || str) && item.length;
|
7636
7662
|
if (arr)
|
@@ -7652,17 +7678,17 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7652
7678
|
const bits2int = CURVE.bits2int || function(bytes) {
|
7653
7679
|
if (bytes.length > 8192)
|
7654
7680
|
throw new Error("input is too large");
|
7655
|
-
const num =
|
7681
|
+
const num = (0, utils_ts_1.bytesToNumberBE)(bytes);
|
7656
7682
|
const delta = bytes.length * 8 - CURVE.nBitLength;
|
7657
7683
|
return delta > 0 ? num >> BigInt(delta) : num;
|
7658
7684
|
};
|
7659
7685
|
const bits2int_modN = CURVE.bits2int_modN || function(bytes) {
|
7660
7686
|
return modN(bits2int(bytes));
|
7661
7687
|
};
|
7662
|
-
const ORDER_MASK =
|
7688
|
+
const ORDER_MASK = (0, utils_ts_1.bitMask)(CURVE.nBitLength);
|
7663
7689
|
function int2octets(num) {
|
7664
|
-
|
7665
|
-
return
|
7690
|
+
(0, utils_ts_1.aInRange)("num < 2^" + CURVE.nBitLength, num, _0n, ORDER_MASK);
|
7691
|
+
return (0, utils_ts_1.numberToBytesBE)(num, CURVE.nByteLength);
|
7666
7692
|
}
|
7667
7693
|
function prepSig(msgHash, privateKey, opts = defaultSigOpts) {
|
7668
7694
|
if (["recovered", "canonical"].some((k) => (k in opts)))
|
@@ -7671,18 +7697,18 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7671
7697
|
let { lowS, prehash, extraEntropy: ent } = opts;
|
7672
7698
|
if (lowS == null)
|
7673
7699
|
lowS = true;
|
7674
|
-
msgHash = (0,
|
7700
|
+
msgHash = (0, utils_ts_1.ensureBytes)("msgHash", msgHash);
|
7675
7701
|
validateSigVerOpts(opts);
|
7676
7702
|
if (prehash)
|
7677
|
-
msgHash = (0,
|
7703
|
+
msgHash = (0, utils_ts_1.ensureBytes)("prehashed msgHash", hash(msgHash));
|
7678
7704
|
const h1int = bits2int_modN(msgHash);
|
7679
7705
|
const d = normPrivateKeyToScalar(privateKey);
|
7680
7706
|
const seedArgs = [int2octets(d), int2octets(h1int)];
|
7681
7707
|
if (ent != null && ent !== false) {
|
7682
7708
|
const e = ent === true ? randomBytes(Fp.BYTES) : ent;
|
7683
|
-
seedArgs.push((0,
|
7709
|
+
seedArgs.push((0, utils_ts_1.ensureBytes)("extraEntropy", e));
|
7684
7710
|
}
|
7685
|
-
const seed =
|
7711
|
+
const seed = (0, utils_ts_1.concatBytes)(...seedArgs);
|
7686
7712
|
const m = h1int;
|
7687
7713
|
function k2sig(kBytes) {
|
7688
7714
|
const k = bits2int(kBytes);
|
@@ -7711,21 +7737,21 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7711
7737
|
function sign(msgHash, privKey, opts = defaultSigOpts) {
|
7712
7738
|
const { seed, k2sig } = prepSig(msgHash, privKey, opts);
|
7713
7739
|
const C = CURVE;
|
7714
|
-
const drbg =
|
7740
|
+
const drbg = (0, utils_ts_1.createHmacDrbg)(C.hash.outputLen, C.nByteLength, C.hmac);
|
7715
7741
|
return drbg(seed, k2sig);
|
7716
7742
|
}
|
7717
7743
|
Point.BASE._setWindowSize(8);
|
7718
7744
|
function verify(signature, msgHash, publicKey, opts = defaultVerOpts) {
|
7719
7745
|
const sg = signature;
|
7720
|
-
msgHash = (0,
|
7721
|
-
publicKey = (0,
|
7746
|
+
msgHash = (0, utils_ts_1.ensureBytes)("msgHash", msgHash);
|
7747
|
+
publicKey = (0, utils_ts_1.ensureBytes)("publicKey", publicKey);
|
7722
7748
|
const { lowS, prehash, format: format2 } = opts;
|
7723
7749
|
validateSigVerOpts(opts);
|
7724
7750
|
if ("strict" in opts)
|
7725
7751
|
throw new Error("options.strict was renamed to lowS");
|
7726
7752
|
if (format2 !== undefined && format2 !== "compact" && format2 !== "der")
|
7727
7753
|
throw new Error("format must be compact or der");
|
7728
|
-
const isHex = typeof sg === "string" ||
|
7754
|
+
const isHex = typeof sg === "string" || (0, utils_ts_1.isBytes)(sg);
|
7729
7755
|
const isObj = !isHex && !format2 && typeof sg === "object" && sg !== null && typeof sg.r === "bigint" && typeof sg.s === "bigint";
|
7730
7756
|
if (!isHex && !isObj)
|
7731
7757
|
throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");
|
@@ -7840,7 +7866,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7840
7866
|
return sqrtRatio;
|
7841
7867
|
}
|
7842
7868
|
function mapToCurveSimpleSWU(Fp, opts) {
|
7843
|
-
(0,
|
7869
|
+
(0, modular_ts_1.validateField)(Fp);
|
7844
7870
|
if (!Fp.isValid(opts.A) || !Fp.isValid(opts.B) || !Fp.isValid(opts.Z))
|
7845
7871
|
throw new Error("mapToCurveSimpleSWU: invalid opts");
|
7846
7872
|
const sqrtRatio = SWUFpSqrtRatio(Fp, opts.Z);
|
@@ -7878,7 +7904,7 @@ var require_weierstrass = __commonJS((exports) => {
|
|
7878
7904
|
}
|
7879
7905
|
});
|
7880
7906
|
|
7881
|
-
// ../../node_modules
|
7907
|
+
// ../../node_modules/@noble/curves/_shortw_utils.js
|
7882
7908
|
var require__shortw_utils = __commonJS((exports) => {
|
7883
7909
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7884
7910
|
exports.getHash = getHash;
|
@@ -7886,7 +7912,7 @@ var require__shortw_utils = __commonJS((exports) => {
|
|
7886
7912
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
7887
7913
|
var hmac_1 = require_hmac();
|
7888
7914
|
var utils_1 = require_utils4();
|
7889
|
-
var
|
7915
|
+
var weierstrass_ts_1 = require_weierstrass();
|
7890
7916
|
function getHash(hash) {
|
7891
7917
|
return {
|
7892
7918
|
hash,
|
@@ -7895,23 +7921,23 @@ var require__shortw_utils = __commonJS((exports) => {
|
|
7895
7921
|
};
|
7896
7922
|
}
|
7897
7923
|
function createCurve(curveDef, defHash) {
|
7898
|
-
const create = (hash) => (0,
|
7924
|
+
const create = (hash) => (0, weierstrass_ts_1.weierstrass)({ ...curveDef, ...getHash(hash) });
|
7899
7925
|
return { ...create(defHash), create };
|
7900
7926
|
}
|
7901
7927
|
});
|
7902
7928
|
|
7903
|
-
// ../../node_modules
|
7929
|
+
// ../../node_modules/@noble/curves/secp256k1.js
|
7904
7930
|
var require_secp256k1 = __commonJS((exports) => {
|
7905
7931
|
Object.defineProperty(exports, "__esModule", { value: true });
|
7906
7932
|
exports.encodeToCurve = exports.hashToCurve = exports.schnorr = exports.secp256k1 = undefined;
|
7907
7933
|
/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
7908
|
-
var
|
7934
|
+
var sha2_1 = require_sha2();
|
7909
7935
|
var utils_1 = require_utils4();
|
7910
|
-
var
|
7911
|
-
var
|
7912
|
-
var
|
7913
|
-
var
|
7914
|
-
var
|
7936
|
+
var _shortw_utils_ts_1 = require__shortw_utils();
|
7937
|
+
var hash_to_curve_ts_1 = require_hash_to_curve();
|
7938
|
+
var modular_ts_1 = require_modular();
|
7939
|
+
var utils_ts_1 = require_utils5();
|
7940
|
+
var weierstrass_ts_1 = require_weierstrass();
|
7915
7941
|
var secp256k1P = BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f");
|
7916
7942
|
var secp256k1N = BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141");
|
7917
7943
|
var _1n = BigInt(1);
|
@@ -7923,24 +7949,24 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
7923
7949
|
const _23n = BigInt(23), _44n = BigInt(44), _88n = BigInt(88);
|
7924
7950
|
const b2 = y * y * y % P;
|
7925
7951
|
const b3 = b2 * b2 * y % P;
|
7926
|
-
const b6 = (0,
|
7927
|
-
const b9 = (0,
|
7928
|
-
const b11 = (0,
|
7929
|
-
const b22 = (0,
|
7930
|
-
const b44 = (0,
|
7931
|
-
const b88 = (0,
|
7932
|
-
const b176 = (0,
|
7933
|
-
const b220 = (0,
|
7934
|
-
const b223 = (0,
|
7935
|
-
const t1 = (0,
|
7936
|
-
const t2 = (0,
|
7937
|
-
const root = (0,
|
7952
|
+
const b6 = (0, modular_ts_1.pow2)(b3, _3n, P) * b3 % P;
|
7953
|
+
const b9 = (0, modular_ts_1.pow2)(b6, _3n, P) * b3 % P;
|
7954
|
+
const b11 = (0, modular_ts_1.pow2)(b9, _2n, P) * b2 % P;
|
7955
|
+
const b22 = (0, modular_ts_1.pow2)(b11, _11n, P) * b11 % P;
|
7956
|
+
const b44 = (0, modular_ts_1.pow2)(b22, _22n, P) * b22 % P;
|
7957
|
+
const b88 = (0, modular_ts_1.pow2)(b44, _44n, P) * b44 % P;
|
7958
|
+
const b176 = (0, modular_ts_1.pow2)(b88, _88n, P) * b88 % P;
|
7959
|
+
const b220 = (0, modular_ts_1.pow2)(b176, _44n, P) * b44 % P;
|
7960
|
+
const b223 = (0, modular_ts_1.pow2)(b220, _3n, P) * b3 % P;
|
7961
|
+
const t1 = (0, modular_ts_1.pow2)(b223, _23n, P) * b22 % P;
|
7962
|
+
const t2 = (0, modular_ts_1.pow2)(t1, _6n, P) * b2 % P;
|
7963
|
+
const root = (0, modular_ts_1.pow2)(t2, _2n, P);
|
7938
7964
|
if (!Fpk1.eql(Fpk1.sqr(root), y))
|
7939
7965
|
throw new Error("Cannot find square root");
|
7940
7966
|
return root;
|
7941
7967
|
}
|
7942
|
-
var Fpk1 = (0,
|
7943
|
-
exports.secp256k1 = (0,
|
7968
|
+
var Fpk1 = (0, modular_ts_1.Field)(secp256k1P, undefined, undefined, { sqrt: sqrtMod });
|
7969
|
+
exports.secp256k1 = (0, _shortw_utils_ts_1.createCurve)({
|
7944
7970
|
a: BigInt(0),
|
7945
7971
|
b: BigInt(7),
|
7946
7972
|
Fp: Fpk1,
|
@@ -7960,8 +7986,8 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
7960
7986
|
const POW_2_128 = BigInt("0x100000000000000000000000000000000");
|
7961
7987
|
const c1 = divNearest(b2 * k, n);
|
7962
7988
|
const c2 = divNearest(-b1 * k, n);
|
7963
|
-
let k1 = (0,
|
7964
|
-
let k2 = (0,
|
7989
|
+
let k1 = (0, modular_ts_1.mod)(k - c1 * a1 - c2 * a2, n);
|
7990
|
+
let k2 = (0, modular_ts_1.mod)(-c1 * b1 - c2 * b2, n);
|
7965
7991
|
const k1neg = k1 > POW_2_128;
|
7966
7992
|
const k2neg = k2 > POW_2_128;
|
7967
7993
|
if (k1neg)
|
@@ -7974,22 +8000,22 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
7974
8000
|
return { k1neg, k1, k2neg, k2 };
|
7975
8001
|
}
|
7976
8002
|
}
|
7977
|
-
},
|
8003
|
+
}, sha2_1.sha256);
|
7978
8004
|
var _0n = BigInt(0);
|
7979
8005
|
var TAGGED_HASH_PREFIXES = {};
|
7980
8006
|
function taggedHash(tag, ...messages) {
|
7981
8007
|
let tagP = TAGGED_HASH_PREFIXES[tag];
|
7982
8008
|
if (tagP === undefined) {
|
7983
|
-
const tagH = (0,
|
7984
|
-
tagP = (0,
|
8009
|
+
const tagH = (0, sha2_1.sha256)(Uint8Array.from(tag, (c) => c.charCodeAt(0)));
|
8010
|
+
tagP = (0, utils_ts_1.concatBytes)(tagH, tagH);
|
7985
8011
|
TAGGED_HASH_PREFIXES[tag] = tagP;
|
7986
8012
|
}
|
7987
|
-
return (0,
|
8013
|
+
return (0, sha2_1.sha256)((0, utils_ts_1.concatBytes)(tagP, ...messages));
|
7988
8014
|
}
|
7989
8015
|
var pointToBytes = (point) => point.toRawBytes(true).slice(1);
|
7990
|
-
var numTo32b = (n) => (0,
|
7991
|
-
var modP = (x) => (0,
|
7992
|
-
var modN = (x) => (0,
|
8016
|
+
var numTo32b = (n) => (0, utils_ts_1.numberToBytesBE)(n, 32);
|
8017
|
+
var modP = (x) => (0, modular_ts_1.mod)(x, secp256k1P);
|
8018
|
+
var modN = (x) => (0, modular_ts_1.mod)(x, secp256k1N);
|
7993
8019
|
var Point = exports.secp256k1.ProjectivePoint;
|
7994
8020
|
var GmulAdd = (Q, a, b) => Point.BASE.multiplyAndAddUnsafe(Q, a, b);
|
7995
8021
|
function schnorrGetExtPubKey(priv) {
|
@@ -7999,7 +8025,7 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
7999
8025
|
return { scalar, bytes: pointToBytes(p) };
|
8000
8026
|
}
|
8001
8027
|
function lift_x(x) {
|
8002
|
-
(0,
|
8028
|
+
(0, utils_ts_1.aInRange)("x", x, _1n, secp256k1P);
|
8003
8029
|
const xx = modP(x * x);
|
8004
8030
|
const c = modP(xx * x + BigInt(7));
|
8005
8031
|
let y = sqrtMod(c);
|
@@ -8009,7 +8035,7 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
8009
8035
|
p.assertValidity();
|
8010
8036
|
return p;
|
8011
8037
|
}
|
8012
|
-
var num =
|
8038
|
+
var num = utils_ts_1.bytesToNumberBE;
|
8013
8039
|
function challenge(...args) {
|
8014
8040
|
return modN(num(taggedHash("BIP0340/challenge", ...args)));
|
8015
8041
|
}
|
@@ -8017,9 +8043,9 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
8017
8043
|
return schnorrGetExtPubKey(privateKey).bytes;
|
8018
8044
|
}
|
8019
8045
|
function schnorrSign(message, privateKey, auxRand = (0, utils_1.randomBytes)(32)) {
|
8020
|
-
const m = (0,
|
8046
|
+
const m = (0, utils_ts_1.ensureBytes)("message", message);
|
8021
8047
|
const { bytes: px, scalar: d } = schnorrGetExtPubKey(privateKey);
|
8022
|
-
const a = (0,
|
8048
|
+
const a = (0, utils_ts_1.ensureBytes)("auxRand", auxRand, 32);
|
8023
8049
|
const t = numTo32b(d ^ num(taggedHash("BIP0340/aux", a)));
|
8024
8050
|
const rand = taggedHash("BIP0340/nonce", t, px, m);
|
8025
8051
|
const k_ = modN(num(rand));
|
@@ -8035,16 +8061,16 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
8035
8061
|
return sig;
|
8036
8062
|
}
|
8037
8063
|
function schnorrVerify(signature, message, publicKey) {
|
8038
|
-
const sig = (0,
|
8039
|
-
const m = (0,
|
8040
|
-
const pub = (0,
|
8064
|
+
const sig = (0, utils_ts_1.ensureBytes)("signature", signature, 64);
|
8065
|
+
const m = (0, utils_ts_1.ensureBytes)("message", message);
|
8066
|
+
const pub = (0, utils_ts_1.ensureBytes)("publicKey", publicKey, 32);
|
8041
8067
|
try {
|
8042
8068
|
const P = lift_x(num(pub));
|
8043
8069
|
const r = num(sig.subarray(0, 32));
|
8044
|
-
if (!(0,
|
8070
|
+
if (!(0, utils_ts_1.inRange)(r, _1n, secp256k1P))
|
8045
8071
|
return false;
|
8046
8072
|
const s = num(sig.subarray(32, 64));
|
8047
|
-
if (!(0,
|
8073
|
+
if (!(0, utils_ts_1.inRange)(s, _1n, secp256k1N))
|
8048
8074
|
return false;
|
8049
8075
|
const e = challenge(numTo32b(r), pointToBytes(P), m);
|
8050
8076
|
const R = GmulAdd(P, s, modN(-e));
|
@@ -8063,13 +8089,13 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
8063
8089
|
randomPrivateKey: exports.secp256k1.utils.randomPrivateKey,
|
8064
8090
|
lift_x,
|
8065
8091
|
pointToBytes,
|
8066
|
-
numberToBytesBE:
|
8067
|
-
bytesToNumberBE:
|
8092
|
+
numberToBytesBE: utils_ts_1.numberToBytesBE,
|
8093
|
+
bytesToNumberBE: utils_ts_1.bytesToNumberBE,
|
8068
8094
|
taggedHash,
|
8069
|
-
mod:
|
8095
|
+
mod: modular_ts_1.mod
|
8070
8096
|
}
|
8071
8097
|
}))();
|
8072
|
-
var isoMap = /* @__PURE__ */ (() => (0,
|
8098
|
+
var isoMap = /* @__PURE__ */ (() => (0, hash_to_curve_ts_1.isogenyMap)(Fpk1, [
|
8073
8099
|
[
|
8074
8100
|
"0x8e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38e38daaaaa8c7",
|
8075
8101
|
"0x7d3d4c80bc321d5b9f315cea7fd44c5d595d2fc0bf63b92dfff1044f17c6581",
|
@@ -8094,12 +8120,12 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
8094
8120
|
"0x0000000000000000000000000000000000000000000000000000000000000001"
|
8095
8121
|
]
|
8096
8122
|
].map((i) => i.map((j) => BigInt(j)))))();
|
8097
|
-
var mapSWU = /* @__PURE__ */ (() => (0,
|
8123
|
+
var mapSWU = /* @__PURE__ */ (() => (0, weierstrass_ts_1.mapToCurveSimpleSWU)(Fpk1, {
|
8098
8124
|
A: BigInt("0x3f8731abdd661adca08a5558f0f5d272e953d363cb6f0e5d405447c01a444533"),
|
8099
8125
|
B: BigInt("1771"),
|
8100
8126
|
Z: Fpk1.create(BigInt("-11"))
|
8101
8127
|
}))();
|
8102
|
-
var htf = /* @__PURE__ */ (() => (0,
|
8128
|
+
var htf = /* @__PURE__ */ (() => (0, hash_to_curve_ts_1.createHasher)(exports.secp256k1.ProjectivePoint, (scalars) => {
|
8103
8129
|
const { x, y } = mapSWU(Fpk1.create(scalars[0]));
|
8104
8130
|
return isoMap(x, y);
|
8105
8131
|
}, {
|
@@ -8109,7 +8135,7 @@ var require_secp256k1 = __commonJS((exports) => {
|
|
8109
8135
|
m: 1,
|
8110
8136
|
k: 128,
|
8111
8137
|
expand: "xmd",
|
8112
|
-
hash:
|
8138
|
+
hash: sha2_1.sha256
|
8113
8139
|
}))();
|
8114
8140
|
exports.hashToCurve = (() => htf.hashToCurve)();
|
8115
8141
|
exports.encodeToCurve = (() => htf.encodeToCurve)();
|
@@ -8226,33 +8252,33 @@ var require_elliptic = __commonJS((exports) => {
|
|
8226
8252
|
};
|
8227
8253
|
});
|
8228
8254
|
|
8229
|
-
// ../../node_modules
|
8255
|
+
// ../../node_modules/@noble/hashes/hkdf.js
|
8230
8256
|
var require_hkdf = __commonJS((exports) => {
|
8231
8257
|
Object.defineProperty(exports, "__esModule", { value: true });
|
8232
8258
|
exports.hkdf = undefined;
|
8233
8259
|
exports.extract = extract;
|
8234
8260
|
exports.expand = expand;
|
8235
|
-
var
|
8236
|
-
var
|
8237
|
-
var
|
8261
|
+
var _assert_ts_1 = require__assert();
|
8262
|
+
var hmac_ts_1 = require_hmac();
|
8263
|
+
var utils_ts_1 = require_utils4();
|
8238
8264
|
function extract(hash, ikm, salt) {
|
8239
|
-
(0,
|
8265
|
+
(0, _assert_ts_1.ahash)(hash);
|
8240
8266
|
if (salt === undefined)
|
8241
8267
|
salt = new Uint8Array(hash.outputLen);
|
8242
|
-
return (0,
|
8268
|
+
return (0, hmac_ts_1.hmac)(hash, (0, utils_ts_1.toBytes)(salt), (0, utils_ts_1.toBytes)(ikm));
|
8243
8269
|
}
|
8244
8270
|
var HKDF_COUNTER = /* @__PURE__ */ new Uint8Array([0]);
|
8245
8271
|
var EMPTY_BUFFER = /* @__PURE__ */ new Uint8Array;
|
8246
8272
|
function expand(hash, prk, info, length = 32) {
|
8247
|
-
(0,
|
8248
|
-
(0,
|
8273
|
+
(0, _assert_ts_1.ahash)(hash);
|
8274
|
+
(0, _assert_ts_1.anumber)(length);
|
8249
8275
|
if (length > 255 * hash.outputLen)
|
8250
8276
|
throw new Error("Length should be <= 255*HashLen");
|
8251
8277
|
const blocks = Math.ceil(length / hash.outputLen);
|
8252
8278
|
if (info === undefined)
|
8253
8279
|
info = EMPTY_BUFFER;
|
8254
8280
|
const okm = new Uint8Array(blocks * hash.outputLen);
|
8255
|
-
const HMAC =
|
8281
|
+
const HMAC = hmac_ts_1.hmac.create(hash, prk);
|
8256
8282
|
const HMACTmp = HMAC._cloneInto();
|
8257
8283
|
const T = new Uint8Array(HMAC.outputLen);
|
8258
8284
|
for (let counter = 0;counter < blocks; counter++) {
|
@@ -9088,7 +9114,7 @@ var require_parse2 = __commonJS((exports, module) => {
|
|
9088
9114
|
// ../../node_modules/@dotenvx/dotenvx/src/lib/helpers/dotenvParse.js
|
9089
9115
|
var require_dotenvParse = __commonJS((exports, module) => {
|
9090
9116
|
var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
|
9091
|
-
function dotenvParse(src, skipExpandForDoubleQuotes = false, skipConvertingWindowsNewlines = false) {
|
9117
|
+
function dotenvParse(src, skipExpandForDoubleQuotes = false, skipConvertingWindowsNewlines = false, collectAllValues = false) {
|
9092
9118
|
const obj = {};
|
9093
9119
|
let lines = src.toString();
|
9094
9120
|
if (!skipConvertingWindowsNewlines) {
|
@@ -9108,7 +9134,12 @@ var require_dotenvParse = __commonJS((exports, module) => {
|
|
9108
9134
|
value = value.replace(/\\r/g, "\r");
|
9109
9135
|
value = value.replace(/\\t/g, "\t");
|
9110
9136
|
}
|
9111
|
-
|
9137
|
+
if (collectAllValues) {
|
9138
|
+
obj[key] = obj[key] || [];
|
9139
|
+
obj[key].push(value);
|
9140
|
+
} else {
|
9141
|
+
obj[key] = value;
|
9142
|
+
}
|
9112
9143
|
}
|
9113
9144
|
return obj;
|
9114
9145
|
}
|
@@ -31162,6 +31193,23 @@ var require_lib4 = __commonJS((exports, module) => {
|
|
31162
31193
|
var fromUrl = require_from_url();
|
31163
31194
|
var parseUrl = require_parse_url();
|
31164
31195
|
var cache = new LRUCache2({ max: 1000 });
|
31196
|
+
function unknownHostedUrl(url) {
|
31197
|
+
try {
|
31198
|
+
const {
|
31199
|
+
protocol,
|
31200
|
+
hostname,
|
31201
|
+
pathname
|
31202
|
+
} = new URL(url);
|
31203
|
+
if (!hostname) {
|
31204
|
+
return null;
|
31205
|
+
}
|
31206
|
+
const proto = /(?:git\+)http:$/.test(protocol) ? "http:" : "https:";
|
31207
|
+
const path6 = pathname.replace(/\.git$/, "");
|
31208
|
+
return `${proto}//${hostname}${path6}`;
|
31209
|
+
} catch {
|
31210
|
+
return null;
|
31211
|
+
}
|
31212
|
+
}
|
31165
31213
|
|
31166
31214
|
class GitHost {
|
31167
31215
|
constructor(type2, user, auth, project, committish, defaultRepresentation, opts = {}) {
|
@@ -31205,6 +31253,22 @@ var require_lib4 = __commonJS((exports, module) => {
|
|
31205
31253
|
}
|
31206
31254
|
return cache.get(key2);
|
31207
31255
|
}
|
31256
|
+
static fromManifest(manifest, opts = {}) {
|
31257
|
+
if (!manifest || typeof manifest !== "object") {
|
31258
|
+
return;
|
31259
|
+
}
|
31260
|
+
const r2 = manifest.repository;
|
31261
|
+
const rurl = r2 && (typeof r2 === "string" ? r2 : typeof r2 === "object" && typeof r2.url === "string" ? r2.url : null);
|
31262
|
+
if (!rurl) {
|
31263
|
+
throw new Error("no repository");
|
31264
|
+
}
|
31265
|
+
const info = rurl && GitHost.fromUrl(rurl.replace(/^git\+/, ""), opts) || null;
|
31266
|
+
if (info) {
|
31267
|
+
return info;
|
31268
|
+
}
|
31269
|
+
const unk = unknownHostedUrl(rurl);
|
31270
|
+
return GitHost.fromUrl(unk, opts) || unk;
|
31271
|
+
}
|
31208
31272
|
static parseUrl(url) {
|
31209
31273
|
return parseUrl(url);
|
31210
31274
|
}
|
@@ -235068,7 +235132,7 @@ var is_in_ci_default = isInCi;
|
|
235068
235132
|
// ../../node_modules/yocto-spinner/index.js
|
235069
235133
|
import process2 from "node:process";
|
235070
235134
|
import { stripVTControlCharacters } from "node:util";
|
235071
|
-
var isUnicodeSupported = process2.platform !== "win32" || Boolean(process2.env.WT_SESSION);
|
235135
|
+
var isUnicodeSupported = process2.platform !== "win32" || Boolean(process2.env.WT_SESSION) || process2.env.TERM_PROGRAM === "vscode";
|
235072
235136
|
var isInteractive = (stream) => Boolean(stream.isTTY && process2.env.TERM !== "dumb" && !("CI" in process2.env));
|
235073
235137
|
var infoSymbol = exports_base.blue(isUnicodeSupported ? "ℹ" : "i");
|
235074
235138
|
var successSymbol = exports_base.green(isUnicodeSupported ? "✔" : "√");
|
@@ -245281,7 +245345,7 @@ function pruneCurrentEnv(currentEnv, env2) {
|
|
245281
245345
|
var package_default = {
|
245282
245346
|
name: "@settlemint/sdk-cli",
|
245283
245347
|
description: "Command-line interface for SettleMint SDK, providing development tools and project management capabilities",
|
245284
|
-
version: "2.1.4-
|
245348
|
+
version: "2.1.4-pr6d9b7c01",
|
245285
245349
|
type: "module",
|
245286
245350
|
private: false,
|
245287
245351
|
license: "FSL-1.1-MIT",
|
@@ -245329,10 +245393,10 @@ var package_default = {
|
|
245329
245393
|
"@inquirer/confirm": "5.1.9",
|
245330
245394
|
"@inquirer/input": "4.1.9",
|
245331
245395
|
"@inquirer/password": "4.0.12",
|
245332
|
-
"@inquirer/select": "4.
|
245333
|
-
"@settlemint/sdk-js": "2.1.4-
|
245334
|
-
"@settlemint/sdk-utils": "2.1.4-
|
245335
|
-
"@types/node": "22.
|
245396
|
+
"@inquirer/select": "4.2.0",
|
245397
|
+
"@settlemint/sdk-js": "2.1.4-pr6d9b7c01",
|
245398
|
+
"@settlemint/sdk-utils": "2.1.4-pr6d9b7c01",
|
245399
|
+
"@types/node": "22.15.1",
|
245336
245400
|
"@types/semver": "7.7.0",
|
245337
245401
|
"@types/which": "3.0.4",
|
245338
245402
|
"get-tsconfig": "4.10.0",
|
@@ -246489,13 +246553,21 @@ class Separator {
|
|
246489
246553
|
// ../utils/dist/terminal.mjs
|
246490
246554
|
import { spawn } from "node:child_process";
|
246491
246555
|
var import_console_table_printer2 = __toESM(require_dist2(), 1);
|
246492
|
-
|
246556
|
+
function shouldPrint() {
|
246557
|
+
return process.env.SETTLEMINT_DISABLE_TERMINAL !== "true";
|
246558
|
+
}
|
246559
|
+
var ascii = () => {
|
246560
|
+
if (!shouldPrint()) {
|
246561
|
+
return;
|
246562
|
+
}
|
246563
|
+
console.log(magentaBright(`
|
246493
246564
|
_________ __ __ .__ _____ .__ __
|
246494
246565
|
/ _____/ _____/ |__/ |_| | ____ / \\ |__| _____/ |_
|
246495
246566
|
\\_____ \\_/ __ \\ __\\ __\\ | _/ __ \\ / \\ / \\| |/ \\ __\\
|
246496
246567
|
/ \\ ___/| | | | | |_\\ ___// Y \\ | | \\ |
|
246497
246568
|
/_________/\\_____>__| |__| |____/\\_____>____|____/__|___|__/__|
|
246498
246569
|
`));
|
246570
|
+
};
|
246499
246571
|
var maskTokens2 = (output) => {
|
246500
246572
|
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
246501
246573
|
};
|
@@ -246507,6 +246579,13 @@ var cancel2 = (msg) => {
|
|
246507
246579
|
console.log("");
|
246508
246580
|
throw new CancelError2(msg);
|
246509
246581
|
};
|
246582
|
+
var CommandError = class extends Error {
|
246583
|
+
constructor(message, code, output) {
|
246584
|
+
super(message);
|
246585
|
+
this.code = code;
|
246586
|
+
this.output = output;
|
246587
|
+
}
|
246588
|
+
};
|
246510
246589
|
async function executeCommand(command, args, options) {
|
246511
246590
|
const child = spawn(command, args, { env: { ...process.env, ...options?.env } });
|
246512
246591
|
process.stdin.pipe(child.stdin);
|
@@ -246526,23 +246605,29 @@ async function executeCommand(command, args, options) {
|
|
246526
246605
|
}
|
246527
246606
|
output.push(maskedData);
|
246528
246607
|
});
|
246529
|
-
child.on("error", (err) => reject(err));
|
246608
|
+
child.on("error", (err) => reject(new CommandError(err.message, "code" in err && typeof err.code === "number" ? err.code : 1, output)));
|
246530
246609
|
child.on("close", (code) => {
|
246531
246610
|
if (code === 0 || code === null || code === 143) {
|
246532
246611
|
process.stdin.unpipe(child.stdin);
|
246533
246612
|
resolve(output);
|
246534
246613
|
return;
|
246535
246614
|
}
|
246536
|
-
reject(new
|
246615
|
+
reject(new CommandError(`Command "${command}" exited with code ${code}`, code, output));
|
246537
246616
|
});
|
246538
246617
|
});
|
246539
246618
|
}
|
246540
246619
|
var intro = (msg) => {
|
246620
|
+
if (!shouldPrint()) {
|
246621
|
+
return;
|
246622
|
+
}
|
246541
246623
|
console.log("");
|
246542
246624
|
console.log(magentaBright(maskTokens2(msg)));
|
246543
246625
|
console.log("");
|
246544
246626
|
};
|
246545
246627
|
var note = (message, level = "info") => {
|
246628
|
+
if (!shouldPrint()) {
|
246629
|
+
return;
|
246630
|
+
}
|
246546
246631
|
const maskedMessage = maskTokens2(message);
|
246547
246632
|
console.log("");
|
246548
246633
|
if (level === "warn") {
|
@@ -246567,6 +246652,9 @@ function list(title, items) {
|
|
246567
246652
|
${formatItems(items)}`);
|
246568
246653
|
}
|
246569
246654
|
var outro = (msg) => {
|
246655
|
+
if (!shouldPrint()) {
|
246656
|
+
return;
|
246657
|
+
}
|
246570
246658
|
console.log("");
|
246571
246659
|
console.log(inverse(greenBright(maskTokens2(msg))));
|
246572
246660
|
console.log("");
|
@@ -246586,7 +246674,7 @@ var spinner = async (options) => {
|
|
246586
246674
|
${error.stack}`));
|
246587
246675
|
throw new SpinnerError(errorMessage, error);
|
246588
246676
|
};
|
246589
|
-
if (is_in_ci_default) {
|
246677
|
+
if (is_in_ci_default || !shouldPrint()) {
|
246590
246678
|
try {
|
246591
246679
|
return await options.task();
|
246592
246680
|
} catch (err) {
|
@@ -246614,6 +246702,9 @@ function camelCaseToWords(s) {
|
|
246614
246702
|
return capitalized.replace(/\s+/g, " ").trim();
|
246615
246703
|
}
|
246616
246704
|
function table(title, data) {
|
246705
|
+
if (!shouldPrint()) {
|
246706
|
+
return;
|
246707
|
+
}
|
246617
246708
|
note(title);
|
246618
246709
|
if (!data || data.length === 0) {
|
246619
246710
|
note("No data to display");
|
@@ -248144,6 +248235,7 @@ var getEnv = (gqlClient) => {
|
|
248144
248235
|
};
|
248145
248236
|
var LoadBalancerFragment = graphql(`
|
248146
248237
|
fragment LoadBalancer on LoadBalancer {
|
248238
|
+
__typename
|
248147
248239
|
id
|
248148
248240
|
uniqueName
|
248149
248241
|
name
|
@@ -249035,6 +249127,7 @@ var LOCKS = {
|
|
249035
249127
|
"bun.lockb": "bun",
|
249036
249128
|
"deno.lock": "deno",
|
249037
249129
|
"pnpm-lock.yaml": "pnpm",
|
249130
|
+
"pnpm-workspace.yaml": "pnpm",
|
249038
249131
|
"yarn.lock": "yarn",
|
249039
249132
|
"package-lock.json": "npm",
|
249040
249133
|
"npm-shrinkwrap.json": "npm"
|
@@ -249970,10 +250063,16 @@ async function getPackageManagerExecutable(targetDir) {
|
|
249970
250063
|
}
|
249971
250064
|
return { command: "npx", args: [] };
|
249972
250065
|
}
|
250066
|
+
function shouldPrint2() {
|
250067
|
+
return process.env.SETTLEMINT_DISABLE_TERMINAL !== "true";
|
250068
|
+
}
|
249973
250069
|
var maskTokens3 = (output) => {
|
249974
250070
|
return output.replace(/sm_(pat|aat|sat)_[0-9a-zA-Z]+/g, "***");
|
249975
250071
|
};
|
249976
250072
|
var note2 = (message, level = "info") => {
|
250073
|
+
if (!shouldPrint2()) {
|
250074
|
+
return;
|
250075
|
+
}
|
249977
250076
|
const maskedMessage = maskTokens3(message);
|
249978
250077
|
console.log("");
|
249979
250078
|
if (level === "warn") {
|
@@ -250025,6 +250124,16 @@ function tryParseJson3(value2, defaultValue = null) {
|
|
250025
250124
|
return defaultValue;
|
250026
250125
|
}
|
250027
250126
|
}
|
250127
|
+
function extractJsonObject(value2) {
|
250128
|
+
if (value2.length > 5000) {
|
250129
|
+
throw new Error("Input too long");
|
250130
|
+
}
|
250131
|
+
const result = /\{([\s\S]*)\}/.exec(value2);
|
250132
|
+
if (!result) {
|
250133
|
+
return null;
|
250134
|
+
}
|
250135
|
+
return tryParseJson3(result[0]);
|
250136
|
+
}
|
250028
250137
|
async function retryWhenFailed2(fn, maxRetries = 5, initialSleepTime = 1000, stopOnError) {
|
250029
250138
|
let attempt = 0;
|
250030
250139
|
while (attempt < maxRetries) {
|
@@ -251526,6 +251635,9 @@ async function codegenTsconfig(env2, thegraphSubgraphNames) {
|
|
251526
251635
|
};
|
251527
251636
|
}
|
251528
251637
|
|
251638
|
+
// src/constants/default-subgraph.ts
|
251639
|
+
var DEFAULT_SUBGRAPH_NAME = "kit";
|
251640
|
+
|
251529
251641
|
// src/utils/subgraph/sanitize-name.ts
|
251530
251642
|
var import_slugify = __toESM(require_slugify(), 1);
|
251531
251643
|
function sanitizeName(value4, length = 35) {
|
@@ -251735,9 +251847,9 @@ var esm_default3 = createPrompt((config3, done) => {
|
|
251735
251847
|
firstRender.current = false;
|
251736
251848
|
if (items.length > pageSize) {
|
251737
251849
|
helpTipBottom = `
|
251738
|
-
${theme.style.help("
|
251850
|
+
${theme.style.help(`(${config3.instructions?.pager ?? "Use arrow keys to reveal more choices"})`)}`;
|
251739
251851
|
} else {
|
251740
|
-
helpTipTop = theme.style.help("
|
251852
|
+
helpTipTop = theme.style.help(`(${config3.instructions?.navigation ?? "Use arrow keys"})`);
|
251741
251853
|
}
|
251742
251854
|
}
|
251743
251855
|
const page = usePagination({
|
@@ -251788,7 +251900,13 @@ async function subgraphPrompt({
|
|
251788
251900
|
if (env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH) {
|
251789
251901
|
return [env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH];
|
251790
251902
|
}
|
251791
|
-
|
251903
|
+
if (subgraphNames.length === 1) {
|
251904
|
+
return subgraphNames;
|
251905
|
+
}
|
251906
|
+
if (subgraphNames.includes(DEFAULT_SUBGRAPH_NAME)) {
|
251907
|
+
return [DEFAULT_SUBGRAPH_NAME];
|
251908
|
+
}
|
251909
|
+
return [];
|
251792
251910
|
}
|
251793
251911
|
if (!allowNew) {
|
251794
251912
|
if (subgraphNames.length === 0) {
|
@@ -251973,7 +252091,8 @@ async function codegenBlockscout(env2) {
|
|
251973
252091
|
}
|
251974
252092
|
}
|
251975
252093
|
}
|
251976
|
-
|
252094
|
+
`,
|
252095
|
+
operationName: "IntrospectionQuery"
|
251977
252096
|
})
|
251978
252097
|
});
|
251979
252098
|
await writeFile6(introspectionJsonPath, JSON.stringify(data));
|
@@ -252095,7 +252214,6 @@ async function codegenViem(env2) {
|
|
252095
252214
|
note("[Codegen] No RPC endpoints found, skipping Viem resources generation", "warn");
|
252096
252215
|
return;
|
252097
252216
|
}
|
252098
|
-
note("Generating Viem resources");
|
252099
252217
|
const projectDir = await projectRoot3();
|
252100
252218
|
if (!await isPackageInstalled(PACKAGE_NAME7, projectDir)) {
|
252101
252219
|
await installDependencies(PACKAGE_NAME7, projectDir);
|
@@ -252179,6 +252297,7 @@ function codegenCommand() {
|
|
252179
252297
|
stopMessage: "Tested GraphQL schemas"
|
252180
252298
|
});
|
252181
252299
|
if (generateViem) {
|
252300
|
+
note("Generating Viem resources");
|
252182
252301
|
await codegenViem(env2);
|
252183
252302
|
}
|
252184
252303
|
if (hasura) {
|
@@ -252740,7 +252859,7 @@ async function theGraphPrompt({
|
|
252740
252859
|
envKey: "SETTLEMINT_THEGRAPH",
|
252741
252860
|
isRequired,
|
252742
252861
|
defaultHandler: async ({ defaultService: defaultMiddleware, choices }) => {
|
252743
|
-
const filteredChoices = filterRunningOnly ? choices.filter(({ value: middleware }) => middleware
|
252862
|
+
const filteredChoices = filterRunningOnly ? choices.filter(({ value: middleware }) => isRunning(middleware)) : choices;
|
252744
252863
|
return esm_default3({
|
252745
252864
|
message: "Which The Graph instance do you want to connect to?",
|
252746
252865
|
choices: filteredChoices,
|
@@ -252980,8 +253099,10 @@ async function getGraphEndpoint(settlemint, service, graphName) {
|
|
252980
253099
|
})
|
252981
253100
|
});
|
252982
253101
|
const endpoints = theGraphMiddleware.subgraphs.map(({ graphqlQueryEndpoint }) => graphqlQueryEndpoint?.displayValue);
|
253102
|
+
const hasKitSubgraph = endpoints.map((endpoint) => endpoint.split("/").pop()).some((endpoint) => endpoint === DEFAULT_SUBGRAPH_NAME);
|
252983
253103
|
return {
|
252984
|
-
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: endpoints
|
253104
|
+
SETTLEMINT_THEGRAPH_SUBGRAPHS_ENDPOINTS: endpoints,
|
253105
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: hasKitSubgraph ? DEFAULT_SUBGRAPH_NAME : undefined
|
252985
253106
|
};
|
252986
253107
|
}
|
252987
253108
|
function getIpfsEndpoints(service) {
|
@@ -253068,7 +253189,7 @@ async function blockchainNodeOrLoadBalancerPrompt({
|
|
253068
253189
|
envKey: "SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER",
|
253069
253190
|
isRequired,
|
253070
253191
|
defaultHandler: async ({ defaultService: defaultNode, choices }) => {
|
253071
|
-
const filteredChoices = filterRunningOnly ? choices.filter(({ value: node }) => node
|
253192
|
+
const filteredChoices = filterRunningOnly ? choices.filter(({ value: node }) => isRunning(node)) : choices;
|
253072
253193
|
return esm_default3({
|
253073
253194
|
message: promptMessage ?? "Which blockchain node or load balancer do you want to connect to?",
|
253074
253195
|
choices: filteredChoices,
|
@@ -253138,7 +253259,7 @@ function connectCommand() {
|
|
253138
253259
|
env: { ...env2, ...graphEndpoints },
|
253139
253260
|
accept: acceptDefaults,
|
253140
253261
|
message: "Which The Graph subgraph do you want to use as the default?"
|
253141
|
-
}) : [];
|
253262
|
+
}) : [graphEndpoints.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH];
|
253142
253263
|
const portal = await portalPrompt({
|
253143
253264
|
env: env2,
|
253144
253265
|
middlewares,
|
@@ -257162,13 +257283,16 @@ function getCreateCommand({
|
|
257162
257283
|
region: selectedRegion?.id ?? ""
|
257163
257284
|
});
|
257164
257285
|
if (wait) {
|
257165
|
-
await waitForCompletion({
|
257286
|
+
const isDeployed = await waitForCompletion({
|
257166
257287
|
settlemint,
|
257167
257288
|
type: waitFor?.resourceType ?? type4,
|
257168
257289
|
uniqueName: waitFor?.uniqueName ?? result.uniqueName,
|
257169
257290
|
action: "deploy",
|
257170
257291
|
restartIfTimeout
|
257171
257292
|
});
|
257293
|
+
if (!isDeployed) {
|
257294
|
+
throw new Error(`Failed to deploy ${waitFor?.resourceType ?? type4} ${waitFor?.uniqueName ?? result.uniqueName}`);
|
257295
|
+
}
|
257172
257296
|
if (waitFor) {
|
257173
257297
|
outro(`${capitalizeFirstLetter2(waitFor.resourceType)} ${waitFor.name} created successfully`);
|
257174
257298
|
}
|
@@ -257713,22 +257837,26 @@ function blockscoutInsightsCreateCommand() {
|
|
257713
257837
|
if (!applicationUniqueName) {
|
257714
257838
|
return missingApplication();
|
257715
257839
|
}
|
257716
|
-
let blockchainNodeUniqueName =
|
257717
|
-
|
257840
|
+
let blockchainNodeUniqueName = blockchainNode;
|
257841
|
+
let loadBalancerUniqueName = loadBalancer;
|
257718
257842
|
if (!blockchainNodeUniqueName && !loadBalancerUniqueName) {
|
257719
257843
|
const blockchainNodes = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
|
257720
257844
|
const loadBalancers = await serviceSpinner("load balancer", () => settlemint.loadBalancer.list(applicationUniqueName));
|
257721
|
-
const
|
257845
|
+
const nodeOrLoadbalancer = await blockchainNodeOrLoadBalancerPrompt({
|
257722
257846
|
env: env2,
|
257723
257847
|
nodes: blockchainNodes,
|
257724
257848
|
loadBalancers,
|
257725
257849
|
accept: acceptDefaults,
|
257726
257850
|
isRequired: true
|
257727
257851
|
});
|
257728
|
-
if (!
|
257852
|
+
if (!nodeOrLoadbalancer) {
|
257729
257853
|
return nothingSelectedError("blockchain node");
|
257730
257854
|
}
|
257731
|
-
|
257855
|
+
if (nodeOrLoadbalancer.__typename?.endsWith("LoadBalancer")) {
|
257856
|
+
loadBalancerUniqueName = nodeOrLoadbalancer.uniqueName;
|
257857
|
+
} else {
|
257858
|
+
blockchainNodeUniqueName = nodeOrLoadbalancer.uniqueName;
|
257859
|
+
}
|
257732
257860
|
}
|
257733
257861
|
const result = await showSpinner(() => settlemint.insights.create({
|
257734
257862
|
name: name3,
|
@@ -257841,7 +257969,17 @@ function loadBalancerEvmCreateCommand() {
|
|
257841
257969
|
type: "load balancer",
|
257842
257970
|
subType: "EVM",
|
257843
257971
|
execute: (cmd2, baseAction) => {
|
257844
|
-
addClusterServiceArgs(cmd2).option("--app, --application <application>", "The application unique name to create the load balancer in (defaults to application from env)").option("--blockchain-nodes <blockchainNodes...>", "Blockchain node unique names where the load balancer connects to (must be from the same network)").
|
257972
|
+
addClusterServiceArgs(cmd2).option("--app, --application <application>", "The application unique name to create the load balancer in (defaults to application from env)").option("--blockchain-nodes <blockchainNodes...>", "Blockchain node unique names where the load balancer connects to (must be from the same network)").option("--blockchain-network <blockchainNetwork>", "Blockchain network unique name where the load balancer connects to, can be skipped if the --blockchain-nodes option is used (defaults to network from env)").action(async (name3, {
|
257973
|
+
application,
|
257974
|
+
provider,
|
257975
|
+
region,
|
257976
|
+
size,
|
257977
|
+
type: type4,
|
257978
|
+
blockchainNodes,
|
257979
|
+
blockchainNetwork,
|
257980
|
+
acceptDefaults,
|
257981
|
+
...defaultArgs
|
257982
|
+
}) => {
|
257845
257983
|
return baseAction({
|
257846
257984
|
...defaultArgs,
|
257847
257985
|
acceptDefaults,
|
@@ -257852,11 +257990,12 @@ function loadBalancerEvmCreateCommand() {
|
|
257852
257990
|
if (!applicationUniqueName) {
|
257853
257991
|
return missingApplication();
|
257854
257992
|
}
|
257855
|
-
|
257993
|
+
const applicationBlockchainNodes = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
|
257994
|
+
let networkUniqueName = blockchainNetwork;
|
257856
257995
|
let connectedNodesUniqueNames = blockchainNodes;
|
257857
257996
|
if (!connectedNodesUniqueNames) {
|
257858
257997
|
const networks = await serviceSpinner("blockchain network", () => settlemint.blockchainNetwork.list(applicationUniqueName));
|
257859
|
-
const network = await blockchainNetworkPrompt({
|
257998
|
+
const network = networkUniqueName ? networks.find((network2) => network2.uniqueName === networkUniqueName) : await blockchainNetworkPrompt({
|
257860
257999
|
env: env2,
|
257861
258000
|
networks,
|
257862
258001
|
accept: acceptDefaults,
|
@@ -257866,31 +258005,29 @@ function loadBalancerEvmCreateCommand() {
|
|
257866
258005
|
return nothingSelectedError("blockchain network");
|
257867
258006
|
}
|
257868
258007
|
networkUniqueName = network.uniqueName;
|
257869
|
-
const blockchainNodes2 = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
|
257870
258008
|
const connectedNodes = await blockchainNodePrompt({
|
257871
258009
|
env: env2,
|
257872
|
-
nodes:
|
258010
|
+
nodes: applicationBlockchainNodes.filter((node) => node.blockchainNetwork?.uniqueName === network.uniqueName),
|
257873
258011
|
accept: acceptDefaults,
|
257874
258012
|
promptMessage: "Which blockchain node do you want to connect the load balancer to?",
|
257875
258013
|
allowAll: true
|
257876
258014
|
});
|
257877
|
-
connectedNodesUniqueNames = Array.isArray(connectedNodes) ?
|
258015
|
+
connectedNodesUniqueNames = Array.isArray(connectedNodes) ? applicationBlockchainNodes.map((node) => node.uniqueName) : connectedNodes ? [connectedNodes.uniqueName] : [];
|
257878
258016
|
}
|
257879
258017
|
if (connectedNodesUniqueNames.length === 0) {
|
257880
258018
|
return cancel2("A load balancer must connect to at least one blockchain node");
|
257881
258019
|
}
|
258020
|
+
const selectedBlockchainNodes = applicationBlockchainNodes.filter((node) => connectedNodesUniqueNames.includes(node.uniqueName));
|
258021
|
+
if (selectedBlockchainNodes.length === 0) {
|
258022
|
+
return cancel2(`Blockchain node(s) '${connectedNodesUniqueNames.join(", ")}' are not part of the application '${applicationUniqueName}'`);
|
258023
|
+
}
|
257882
258024
|
if (!networkUniqueName) {
|
257883
|
-
const applicationBlockchainNodes = await serviceSpinner("blockchain node", () => settlemint.blockchainNode.list(applicationUniqueName));
|
257884
|
-
const selectedBlockchainNodes = applicationBlockchainNodes.filter((node) => connectedNodesUniqueNames.includes(node.uniqueName));
|
257885
|
-
if (selectedBlockchainNodes.length === 0) {
|
257886
|
-
return cancel2(`Blockchain node(s) '${connectedNodesUniqueNames.join(", ")}' are not part of the application '${applicationUniqueName}'`);
|
257887
|
-
}
|
257888
|
-
const onTheSameNetwork = selectedBlockchainNodes.every((node) => node.blockchainNetwork?.uniqueName === selectedBlockchainNodes[0].blockchainNetwork?.uniqueName);
|
257889
|
-
if (!onTheSameNetwork) {
|
257890
|
-
return cancel2("Blockchain nodes must be on the same network");
|
257891
|
-
}
|
257892
258025
|
networkUniqueName = selectedBlockchainNodes[0].blockchainNetwork?.uniqueName;
|
257893
258026
|
}
|
258027
|
+
const onTheSameNetwork = selectedBlockchainNodes.every((node) => node.blockchainNetwork?.uniqueName === networkUniqueName);
|
258028
|
+
if (!onTheSameNetwork) {
|
258029
|
+
return cancel2("Blockchain nodes must be on the same network");
|
258030
|
+
}
|
257894
258031
|
const result = await showSpinner(() => settlemint.loadBalancer.create({
|
257895
258032
|
applicationUniqueName,
|
257896
258033
|
name: name3,
|
@@ -257906,7 +258043,8 @@ function loadBalancerEvmCreateCommand() {
|
|
257906
258043
|
mapDefaultEnv: () => {
|
257907
258044
|
return {
|
257908
258045
|
SETTLEMINT_APPLICATION: applicationUniqueName,
|
257909
|
-
SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: result.uniqueName
|
258046
|
+
SETTLEMINT_BLOCKCHAIN_NODE_OR_LOAD_BALANCER: result.uniqueName,
|
258047
|
+
...getBlockchainNodeOrLoadBalancerEndpoints(result)
|
257910
258048
|
};
|
257911
258049
|
}
|
257912
258050
|
};
|
@@ -258598,7 +258736,15 @@ function getRestartCommand({
|
|
258598
258736
|
stopMessage: `${capitalizeFirstLetter2(type4)} restart initiated`
|
258599
258737
|
});
|
258600
258738
|
if (wait) {
|
258601
|
-
await waitForCompletion({
|
258739
|
+
const isRestarted = await waitForCompletion({
|
258740
|
+
settlemint,
|
258741
|
+
type: type4,
|
258742
|
+
uniqueName: serviceUniqueName,
|
258743
|
+
action: "restart"
|
258744
|
+
});
|
258745
|
+
if (!isRestarted) {
|
258746
|
+
throw new Error(`Failed to restart ${type4} ${uniqueName}`);
|
258747
|
+
}
|
258602
258748
|
}
|
258603
258749
|
outro(`${capitalizeFirstLetter2(type4)} ${result.name} restart initiated successfully`);
|
258604
258750
|
});
|
@@ -258854,10 +259000,7 @@ function yamlOutput(data) {
|
|
258854
259000
|
// src/commands/platform/config.ts
|
258855
259001
|
function configCommand() {
|
258856
259002
|
return new Command("config").alias("cfg").description("Get platform configuration").option("--prod", "Connect to your production environment").option("-i, --instance <instance>", "The instance to connect to (defaults to the instance in the .env file)").addOption(new Option("-o, --output <output>", "The output format").choices(["json", "yaml"])).action(async ({ prod, instance, output }) => {
|
258857
|
-
|
258858
|
-
if (printToTerminal) {
|
258859
|
-
intro("Getting platform configuration");
|
258860
|
-
}
|
259003
|
+
intro("Getting platform configuration");
|
258861
259004
|
const env2 = await loadEnv(false, !!prod);
|
258862
259005
|
const selectedInstance = instance ? sanitizeAndValidateInstanceUrl(instance) : await instancePrompt(env2, true);
|
258863
259006
|
const settlemint = createSettleMintClient({
|
@@ -258887,19 +259030,17 @@ function configCommand() {
|
|
258887
259030
|
}))).sort((a8, b4) => a8.providerId.localeCompare(b4.providerId) || a8.regionId.localeCompare(b4.regionId)),
|
258888
259031
|
preDeployedContracts: platformConfig.preDeployedContracts.sort()
|
258889
259032
|
};
|
258890
|
-
if (
|
259033
|
+
if (output === "json") {
|
259034
|
+
jsonOutput(platformConfigData);
|
259035
|
+
} else if (output === "yaml") {
|
259036
|
+
yamlOutput(platformConfigData);
|
259037
|
+
} else {
|
258891
259038
|
table("Templates (Kits)", platformConfigData.kits);
|
258892
259039
|
table("Use cases (Smart Contract Sets)", platformConfigData.useCases);
|
258893
259040
|
table("Providers and regions", platformConfigData.deploymentEngineTargets);
|
258894
259041
|
list("Pre-deployed abis (Smart Contract Portal)", platformConfigData.preDeployedContracts);
|
258895
|
-
} else if (output === "json") {
|
258896
|
-
jsonOutput(platformConfigData);
|
258897
|
-
} else if (output === "yaml") {
|
258898
|
-
yamlOutput(platformConfigData);
|
258899
|
-
}
|
258900
|
-
if (printToTerminal) {
|
258901
|
-
outro("Platform configuration retrieved");
|
258902
259042
|
}
|
259043
|
+
outro("Platform configuration retrieved");
|
258903
259044
|
});
|
258904
259045
|
}
|
258905
259046
|
|
@@ -258946,6 +259087,9 @@ function getUrlPathForService(service, serviceType) {
|
|
258946
259087
|
if (serviceType === "insights") {
|
258947
259088
|
return `insights/${encodeURIComponent(service.id)}/details`;
|
258948
259089
|
}
|
259090
|
+
if (serviceType === "load-balancer") {
|
259091
|
+
return `loadbalancers/${encodeURIComponent(service.id)}/details`;
|
259092
|
+
}
|
258949
259093
|
return "";
|
258950
259094
|
}
|
258951
259095
|
function getWorkspaceUrlPath(workspace) {
|
@@ -258975,10 +259119,7 @@ function applicationsListCommand() {
|
|
258975
259119
|
command: "platform list applications -o yaml > applications.yaml"
|
258976
259120
|
}
|
258977
259121
|
])).option("-w, --workspace <workspace>", "The workspace unique name to list applications for (defaults to workspace from env)").addOption(new Option("-o, --output <output>", "The output format").choices(["wide", "json", "yaml"])).action(async ({ workspace, output }) => {
|
258978
|
-
|
258979
|
-
if (printToTerminal) {
|
258980
|
-
intro("Listing applications");
|
258981
|
-
}
|
259122
|
+
intro("Listing applications");
|
258982
259123
|
const env2 = await loadEnv(false, false);
|
258983
259124
|
const selectedInstance = await instancePrompt(env2, true);
|
258984
259125
|
const personalAccessToken = await getInstanceCredentials(selectedInstance);
|
@@ -258991,13 +259132,12 @@ function applicationsListCommand() {
|
|
258991
259132
|
});
|
258992
259133
|
const workspaceUniqueName = workspace ?? env2.SETTLEMINT_WORKSPACE ?? await selectWorkspace(settlemint, env2);
|
258993
259134
|
const applications = await applicationsSpinner(settlemint, workspaceUniqueName);
|
258994
|
-
const wide = output === "wide";
|
258995
259135
|
const applicationsData = applications.map((application) => {
|
258996
259136
|
const basicFields = {
|
258997
259137
|
name: application.name,
|
258998
259138
|
uniqueName: application.uniqueName
|
258999
259139
|
};
|
259000
|
-
if (
|
259140
|
+
if (output) {
|
259001
259141
|
return {
|
259002
259142
|
...basicFields,
|
259003
259143
|
url: getApplicationUrl(selectedInstance, application)
|
@@ -259005,17 +259145,15 @@ function applicationsListCommand() {
|
|
259005
259145
|
}
|
259006
259146
|
return basicFields;
|
259007
259147
|
});
|
259008
|
-
|
259009
|
-
|
259010
|
-
table(`Applications for workspace ${selectedWorkspace.name} (${selectedWorkspace.uniqueName}) - ${getWorkspaceUrl(selectedInstance, selectedWorkspace)}`, applicationsData);
|
259011
|
-
} else if (output === "json") {
|
259148
|
+
const selectedWorkspace = await settlemint.workspace.read(workspaceUniqueName);
|
259149
|
+
if (output === "json") {
|
259012
259150
|
jsonOutput(applicationsData);
|
259013
259151
|
} else if (output === "yaml") {
|
259014
259152
|
yamlOutput(applicationsData);
|
259153
|
+
} else {
|
259154
|
+
table(`Applications for workspace ${selectedWorkspace.name} (${selectedWorkspace.uniqueName}) - ${getWorkspaceUrl(selectedInstance, selectedWorkspace)}`, applicationsData);
|
259015
259155
|
}
|
259016
|
-
|
259017
|
-
outro("Applications listed");
|
259018
|
-
}
|
259156
|
+
outro("Applications listed");
|
259019
259157
|
});
|
259020
259158
|
}
|
259021
259159
|
async function selectWorkspace(settlemint, env2) {
|
@@ -259029,7 +259167,7 @@ function formatServiceSubType(service, printToTerminal = true) {
|
|
259029
259167
|
if ("__typename" in service && typeof service.__typename === "string") {
|
259030
259168
|
return printToTerminal ? camelCaseToWords2(service.__typename) : service.__typename;
|
259031
259169
|
}
|
259032
|
-
return
|
259170
|
+
return "Unknown";
|
259033
259171
|
}
|
259034
259172
|
|
259035
259173
|
// src/commands/platform/utils/formatting/format-health-status.ts
|
@@ -259060,6 +259198,7 @@ function formatStatus(status, printToTerminal = true) {
|
|
259060
259198
|
var SERVICE_TYPES = [
|
259061
259199
|
"blockchain-network",
|
259062
259200
|
"blockchain-node",
|
259201
|
+
"load-balancer",
|
259063
259202
|
"custom-deployment",
|
259064
259203
|
"insights",
|
259065
259204
|
"integration-tool",
|
@@ -259098,10 +259237,7 @@ function servicesCommand() {
|
|
259098
259237
|
command: "platform list services --type blockchain-network blockchain-node middleware"
|
259099
259238
|
}
|
259100
259239
|
])).option("--app, --application <application>", "The application unique name to list the services in (defaults to application from env)").addOption(new Option("-t, --type <type...>", "The type(s) of service to list").choices(SERVICE_TYPES)).addOption(new Option("-o, --output <output>", "The output format").choices(["wide", "json", "yaml"])).action(async ({ application, type: type4, output }) => {
|
259101
|
-
|
259102
|
-
if (printToTerminal) {
|
259103
|
-
intro("Listing application services");
|
259104
|
-
}
|
259240
|
+
intro("Listing application services");
|
259105
259241
|
const env2 = await loadEnv(false, false);
|
259106
259242
|
const selectedInstance = await instancePrompt(env2, true);
|
259107
259243
|
const personalAccessToken = await getInstanceCredentials(selectedInstance);
|
@@ -259113,6 +259249,7 @@ function servicesCommand() {
|
|
259113
259249
|
accessToken,
|
259114
259250
|
instance: selectedInstance
|
259115
259251
|
});
|
259252
|
+
const printToTerminal = !output || output === "wide";
|
259116
259253
|
const applicationUniqueName = application ?? env2.SETTLEMINT_APPLICATION ?? (printToTerminal ? await selectApplication(settlemint, env2) : null);
|
259117
259254
|
if (!applicationUniqueName) {
|
259118
259255
|
return nothingSelectedError("application");
|
@@ -259140,16 +259277,14 @@ function servicesCommand() {
|
|
259140
259277
|
},
|
259141
259278
|
services: servicesToShow
|
259142
259279
|
};
|
259143
|
-
if (
|
259144
|
-
table(`Services for ${selectedApplication.name} (${applicationUniqueName}) - ${getApplicationUrl(selectedInstance, selectedApplication)}`, servicesToShow);
|
259145
|
-
} else if (output === "json") {
|
259280
|
+
if (output === "json") {
|
259146
259281
|
jsonOutput(data);
|
259147
259282
|
} else if (output === "yaml") {
|
259148
259283
|
yamlOutput(data);
|
259284
|
+
} else {
|
259285
|
+
table(`Services for ${selectedApplication.name} (${applicationUniqueName}) - ${getApplicationUrl(selectedInstance, selectedApplication)}`, servicesToShow);
|
259149
259286
|
}
|
259150
|
-
|
259151
|
-
outro("Application services listed");
|
259152
|
-
}
|
259287
|
+
outro("Application services listed");
|
259153
259288
|
});
|
259154
259289
|
}
|
259155
259290
|
async function selectApplication(settlemint, env2) {
|
@@ -259218,6 +259353,8 @@ function getItemsForServiceType(services, serviceType) {
|
|
259218
259353
|
return services.blockchainNetworks;
|
259219
259354
|
case "blockchain-node":
|
259220
259355
|
return services.blockchainNodes;
|
259356
|
+
case "load-balancer":
|
259357
|
+
return services.loadBalancers;
|
259221
259358
|
default:
|
259222
259359
|
return [];
|
259223
259360
|
}
|
@@ -259682,15 +259819,21 @@ Please select another key or activate this key on the node and try again.`, "war
|
|
259682
259819
|
async function getHardhatConfigData(envConfig) {
|
259683
259820
|
try {
|
259684
259821
|
const { command, args } = await getPackageManagerExecutable();
|
259685
|
-
const output = await executeCommand(command, [
|
259686
|
-
|
259822
|
+
const output = await executeCommand(command, [
|
259823
|
+
...args,
|
259824
|
+
"ts-node",
|
259825
|
+
"-e",
|
259826
|
+
`import hardhat from "hardhat";
|
259827
|
+
console.log(JSON.stringify(hardhat.userConfig));`,
|
259828
|
+
"--transpileOnly"
|
259829
|
+
], {
|
259687
259830
|
env: {
|
259688
259831
|
...process.env,
|
259689
259832
|
...envConfig
|
259690
259833
|
},
|
259691
259834
|
silent: true
|
259692
259835
|
});
|
259693
|
-
const config3 =
|
259836
|
+
const config3 = extractJsonObject(output.join(" "));
|
259694
259837
|
if (isHardhatConfig(config3)) {
|
259695
259838
|
return config3;
|
259696
259839
|
}
|
@@ -260196,7 +260339,8 @@ function subgraphDeployCommand() {
|
|
260196
260339
|
await writeEnvSpinner(!!prod, {
|
260197
260340
|
...env2,
|
260198
260341
|
SETTLEMINT_THEGRAPH: theGraphMiddleware.uniqueName,
|
260199
|
-
...graphEndpoints
|
260342
|
+
...graphEndpoints,
|
260343
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH ?? graphName
|
260200
260344
|
});
|
260201
260345
|
outro(`Subgraph ${graphName} deployed successfully`);
|
260202
260346
|
});
|
@@ -260266,8 +260410,8 @@ function subgraphRemoveCommand() {
|
|
260266
260410
|
await writeEnvSpinner(!!prod, {
|
260267
260411
|
...env2,
|
260268
260412
|
SETTLEMINT_THEGRAPH: theGraphMiddleware.uniqueName,
|
260269
|
-
|
260270
|
-
|
260413
|
+
...graphEndpoints,
|
260414
|
+
SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH: env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH === graphName ? undefined : env2.SETTLEMINT_THEGRAPH_DEFAULT_SUBGRAPH
|
260271
260415
|
});
|
260272
260416
|
outro(`Subgraph ${graphName} removed successfully`);
|
260273
260417
|
});
|
@@ -260329,7 +260473,10 @@ function addHooksToCommand(cmd2, rootCmd, argv) {
|
|
260329
260473
|
rootCmd._lastCommand = thisCommand;
|
260330
260474
|
rootCmd._lastCommand._commandPath = commandPath;
|
260331
260475
|
}
|
260332
|
-
if (
|
260476
|
+
if (isJsonOrYamlOutput(thisCommand)) {
|
260477
|
+
process.env.SETTLEMINT_DISABLE_TERMINAL = "true";
|
260478
|
+
}
|
260479
|
+
if (isLeafCommand(thisCommand)) {
|
260333
260480
|
ascii();
|
260334
260481
|
await validateSdkVersionFromCommand(thisCommand);
|
260335
260482
|
}
|
@@ -260413,4 +260560,4 @@ async function sdkCliCommand(argv = process.argv) {
|
|
260413
260560
|
// src/cli.ts
|
260414
260561
|
sdkCliCommand();
|
260415
260562
|
|
260416
|
-
//# debugId=
|
260563
|
+
//# debugId=B5AC0A21F5DF7C0764756E2164756E21
|