@obolnetwork/obol-sdk 2.11.13 → 2.12.1
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/browser/src/index.js +702 -212
- package/dist/browser/src/index.js.map +1 -1
- package/dist/cjs/src/blsUtils.js +3843 -0
- package/dist/cjs/src/blsUtils.js.map +1 -0
- package/dist/cjs/src/index.js +790 -299
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/verification/clusterLockValidationWorker.js +14696 -0
- package/dist/cjs/src/verification/clusterLockValidationWorker.js.map +1 -0
- package/dist/cjs/src/verification/lockWorker.js +3840 -0
- package/dist/cjs/src/verification/lockWorker.js.map +1 -0
- package/dist/cjs/src/verification/parallelPool.js +4185 -0
- package/dist/cjs/src/verification/parallelPool.js.map +1 -0
- package/dist/esm/src/blsUtils.js +21 -0
- package/dist/esm/src/blsUtils.js.map +1 -0
- package/dist/esm/src/chunk-5ASVONSJ.js +10242 -0
- package/dist/esm/src/chunk-5ASVONSJ.js.map +1 -0
- package/dist/esm/src/chunk-LOSYOJC3.js +4370 -0
- package/dist/esm/src/chunk-LOSYOJC3.js.map +1 -0
- package/dist/esm/src/chunk-RYTIXFRX.js +382 -0
- package/dist/esm/src/chunk-RYTIXFRX.js.map +1 -0
- package/dist/esm/src/index.js +215 -14508
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/verification/clusterLockValidationWorker.js +18 -0
- package/dist/esm/src/verification/clusterLockValidationWorker.js.map +1 -0
- package/dist/esm/src/verification/lockWorker.js +55 -0
- package/dist/esm/src/verification/lockWorker.js.map +1 -0
- package/dist/esm/src/verification/parallelPool.js +16 -0
- package/dist/esm/src/verification/parallelPool.js.map +1 -0
- package/dist/types/src/blsUtils.d.ts +5 -0
- package/dist/types/src/errors.d.ts +13 -0
- package/dist/types/src/index.d.ts +1 -1
- package/dist/types/src/services.d.ts +4 -1
- package/dist/types/src/types.d.ts +6 -0
- package/dist/types/src/verification/clusterLockValidationWorker.d.ts +1 -0
- package/dist/types/src/verification/common.d.ts +26 -7
- package/dist/types/src/verification/lockWorker.d.ts +18 -0
- package/dist/types/src/verification/parallelPool.d.ts +11 -0
- package/dist/types/test/verification/parallelPool.spec.d.ts +1 -0
- package/dist/types/tsconfig.types.tsbuildinfo +1 -1
- package/package.json +1 -1
package/dist/cjs/src/index.js
CHANGED
|
@@ -114,6 +114,7 @@ __export(index_exports, {
|
|
|
114
114
|
CONFIG_VERSION: () => CONFIG_VERSION,
|
|
115
115
|
CONFLICT_ERROR_MSG: () => CONFLICT_ERROR_MSG,
|
|
116
116
|
Client: () => Client,
|
|
117
|
+
ClusterLockValidationTimeoutError: () => ClusterLockValidationTimeoutError,
|
|
117
118
|
ConflictError: () => ConflictError,
|
|
118
119
|
CreatorConfigHashSigningTypes: () => CreatorConfigHashSigningTypes,
|
|
119
120
|
CreatorTypedMessage: () => CreatorTypedMessage,
|
|
@@ -154,8 +155,13 @@ __export(index_exports, {
|
|
|
154
155
|
TermsAndConditionsSigningTypes: () => TermsAndConditionsSigningTypes,
|
|
155
156
|
UnsupportedChainError: () => UnsupportedChainError,
|
|
156
157
|
blsVerify: () => blsVerify,
|
|
158
|
+
builderBlsCheck: () => builderBlsCheck,
|
|
159
|
+
builderDomainForFork: () => builderDomainForFork,
|
|
157
160
|
clusterConfigOrDefinitionHash: () => clusterConfigOrDefinitionHash,
|
|
158
161
|
clusterLockHash: () => clusterLockHash,
|
|
162
|
+
depositBlsCheck: () => depositBlsCheck,
|
|
163
|
+
depositDomainForFork: () => depositDomainForFork,
|
|
164
|
+
hasUniqueDistributedKeys: () => hasUniqueDistributedKeys,
|
|
159
165
|
isChainSupportedForSplitters: () => isChainSupportedForSplitters,
|
|
160
166
|
isValidClusterLock: () => isValidClusterLock,
|
|
161
167
|
signCreatorConfigHashPayload: () => signCreatorConfigHashPayload,
|
|
@@ -164,6 +170,7 @@ __export(index_exports, {
|
|
|
164
170
|
signingRoot: () => signingRoot,
|
|
165
171
|
validateAddressSignature: () => validateAddressSignature,
|
|
166
172
|
validateClusterLock: () => validateClusterLock,
|
|
173
|
+
validateDepositDataStructure: () => validateDepositDataStructure,
|
|
167
174
|
validateEOASignature: () => validateEOASignature,
|
|
168
175
|
validateSmartContractSignature: () => validateSmartContractSignature,
|
|
169
176
|
verifyBuilderRegistration: () => verifyBuilderRegistration,
|
|
@@ -176,7 +183,7 @@ var import_uuid = require("uuid");
|
|
|
176
183
|
// package.json
|
|
177
184
|
var package_default = {
|
|
178
185
|
name: "@obolnetwork/obol-sdk",
|
|
179
|
-
version: "2.
|
|
186
|
+
version: "2.12.1",
|
|
180
187
|
description: "A package for creating Distributed Validators using the Obol API.",
|
|
181
188
|
bugs: {
|
|
182
189
|
url: "https://github.com/obolnetwork/obol-sdk/issues"
|
|
@@ -660,9 +667,22 @@ var UnsupportedChainError = class _UnsupportedChainError extends Error {
|
|
|
660
667
|
Object.setPrototypeOf(this, _UnsupportedChainError.prototype);
|
|
661
668
|
}
|
|
662
669
|
};
|
|
670
|
+
var ClusterLockValidationTimeoutError = class _ClusterLockValidationTimeoutError extends Error {
|
|
671
|
+
/**
|
|
672
|
+
* @param timeoutMs - Same value as SDK whole-lock validation worker timeout.
|
|
673
|
+
*/
|
|
674
|
+
constructor(timeoutMs) {
|
|
675
|
+
super(
|
|
676
|
+
`Cluster lock validation exceeded worker time limit (${timeoutMs} ms). Retry later; this does not imply invalid lock data.`
|
|
677
|
+
);
|
|
678
|
+
this.timeoutMs = timeoutMs;
|
|
679
|
+
this.name = "ClusterLockValidationTimeoutError";
|
|
680
|
+
Object.setPrototypeOf(this, _ClusterLockValidationTimeoutError.prototype);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
663
683
|
|
|
664
684
|
// src/verification/common.ts
|
|
665
|
-
var
|
|
685
|
+
var import_ssz7 = require("@chainsafe/ssz");
|
|
666
686
|
var import_elliptic = __toESM(require("elliptic"));
|
|
667
687
|
var semver = __toESM(require("semver"));
|
|
668
688
|
|
|
@@ -777,6 +797,9 @@ var signingRootType = new import_ssz.ContainerType({
|
|
|
777
797
|
});
|
|
778
798
|
|
|
779
799
|
// src/verification/v1.6.0.ts
|
|
800
|
+
var import_ssz3 = require("@chainsafe/ssz");
|
|
801
|
+
|
|
802
|
+
// src/verification/parallelPool.ts
|
|
780
803
|
var import_ssz2 = require("@chainsafe/ssz");
|
|
781
804
|
|
|
782
805
|
// node_modules/@noble/curves/node_modules/@noble/hashes/utils.js
|
|
@@ -4933,6 +4956,12 @@ function blsVerify(pubkey, message2, signature) {
|
|
|
4933
4956
|
return false;
|
|
4934
4957
|
}
|
|
4935
4958
|
}
|
|
4959
|
+
function blsAggregatePublicKeys(pubkeys) {
|
|
4960
|
+
if (pubkeys.length === 0) {
|
|
4961
|
+
throw new Error("cannot aggregate empty pubkey set");
|
|
4962
|
+
}
|
|
4963
|
+
return ls.aggregatePublicKeys(pubkeys).toBytes();
|
|
4964
|
+
}
|
|
4936
4965
|
function blsVerifyAggregate(pubkeys, message2, signature) {
|
|
4937
4966
|
try {
|
|
4938
4967
|
return ls.verify(
|
|
@@ -4944,6 +4973,13 @@ function blsVerifyAggregate(pubkeys, message2, signature) {
|
|
|
4944
4973
|
return false;
|
|
4945
4974
|
}
|
|
4946
4975
|
}
|
|
4976
|
+
function blsVerifyWithAggregatedPubkey(aggregatedPubkey, message2, signature) {
|
|
4977
|
+
try {
|
|
4978
|
+
return ls.verify(signature, ls.hash(message2, ETH2_DST), aggregatedPubkey);
|
|
4979
|
+
} catch (e) {
|
|
4980
|
+
return false;
|
|
4981
|
+
}
|
|
4982
|
+
}
|
|
4947
4983
|
function blsVerifyMultiple(pubkeys, messages, signature) {
|
|
4948
4984
|
try {
|
|
4949
4985
|
if (pubkeys.length !== messages.length) return false;
|
|
@@ -4959,28 +4995,395 @@ function blsVerifyMultiple(pubkeys, messages, signature) {
|
|
|
4959
4995
|
function blsAggregateSignatures(signatures) {
|
|
4960
4996
|
return ls.Signature.toBytes(ls.aggregateSignatures(signatures));
|
|
4961
4997
|
}
|
|
4998
|
+
function lagrangeCoeffAtZero(shareIndex, indices) {
|
|
4999
|
+
const { Fr } = bls12_381.fields;
|
|
5000
|
+
let num = BigInt(1);
|
|
5001
|
+
let den = BigInt(1);
|
|
5002
|
+
for (const j of indices) {
|
|
5003
|
+
if (j === shareIndex) continue;
|
|
5004
|
+
num = Fr.mul(num, Fr.neg(j));
|
|
5005
|
+
den = Fr.mul(den, Fr.sub(shareIndex, j));
|
|
5006
|
+
}
|
|
5007
|
+
return Fr.mul(num, Fr.inv(den));
|
|
5008
|
+
}
|
|
5009
|
+
function blsRecoverWithIndices(shares, indices) {
|
|
5010
|
+
try {
|
|
5011
|
+
let recovered = bls12_381.G1.Point.ZERO;
|
|
5012
|
+
for (let i = 0; i < shares.length; i++) {
|
|
5013
|
+
const point = bls12_381.G1.Point.fromBytes(shares[i]);
|
|
5014
|
+
const coeff = lagrangeCoeffAtZero(indices[i], indices);
|
|
5015
|
+
recovered = recovered.add(point.multiply(coeff));
|
|
5016
|
+
}
|
|
5017
|
+
return recovered.toBytes();
|
|
5018
|
+
} catch (e) {
|
|
5019
|
+
return null;
|
|
5020
|
+
}
|
|
5021
|
+
}
|
|
5022
|
+
function blsRecoverDistributedPubkeyFromShares(pubshares, threshold) {
|
|
5023
|
+
if (threshold <= 0 || pubshares.length < threshold) return null;
|
|
5024
|
+
const selected = pubshares.slice(0, threshold);
|
|
5025
|
+
const indices = selected.map((_, i) => BigInt(i + 1));
|
|
5026
|
+
return blsRecoverWithIndices(selected, indices);
|
|
5027
|
+
}
|
|
5028
|
+
function blsVerifyExtraShares(pubshares, threshold, distributedPubkey) {
|
|
5029
|
+
if (threshold <= 0 || pubshares.length < threshold) return false;
|
|
5030
|
+
try {
|
|
5031
|
+
const baseShares = pubshares.slice(0, threshold - 1);
|
|
5032
|
+
const baseIndices = baseShares.map((_, i) => BigInt(i + 1));
|
|
5033
|
+
for (let i = threshold; i < pubshares.length; i++) {
|
|
5034
|
+
const shares = [...baseShares, pubshares[i]];
|
|
5035
|
+
const indices = [...baseIndices, BigInt(i + 1)];
|
|
5036
|
+
const recovered = blsRecoverWithIndices(shares, indices);
|
|
5037
|
+
if (!recovered || recovered.length !== distributedPubkey.length || !recovered.every((b, j) => b === distributedPubkey[j])) {
|
|
5038
|
+
return false;
|
|
5039
|
+
}
|
|
5040
|
+
}
|
|
5041
|
+
return true;
|
|
5042
|
+
} catch (e) {
|
|
5043
|
+
return false;
|
|
5044
|
+
}
|
|
5045
|
+
}
|
|
5046
|
+
|
|
5047
|
+
// src/verification/parallelPool.ts
|
|
5048
|
+
var MIN_PARALLEL_VALIDATORS = 50;
|
|
5049
|
+
var MIN_PARALLEL_BATCH_PAIRS = 100;
|
|
5050
|
+
var MAX_WORKERS = 8;
|
|
5051
|
+
var MIN_VALIDATORS_PER_WORKER = 25;
|
|
5052
|
+
var MIN_PAIRS_PER_WORKER = 50;
|
|
5053
|
+
var MIN_PARALLEL_AGGREGATE_KEYS = 400;
|
|
5054
|
+
var MIN_KEYS_PER_WORKER_AGG = 100;
|
|
5055
|
+
var MIN_VALIDATORS_FOR_VALIDATION_WORKER = 50;
|
|
5056
|
+
var VALIDATION_WORKER_TIMEOUT_MS = 12e4;
|
|
5057
|
+
var WORKER_TIMEOUT_MS = 6e4;
|
|
5058
|
+
var MAX_CONCURRENT_WORKERS_CAP = 8;
|
|
5059
|
+
function maxConcurrentWorkers(numWorkers) {
|
|
5060
|
+
return Math.min(numWorkers, MAX_CONCURRENT_WORKERS_CAP);
|
|
5061
|
+
}
|
|
5062
|
+
var workerThreadsCache;
|
|
5063
|
+
var osCache;
|
|
5064
|
+
var workerPathByFile = /* @__PURE__ */ new Map();
|
|
5065
|
+
function loadWorkerThreads() {
|
|
5066
|
+
if (workerThreadsCache !== void 0) return workerThreadsCache;
|
|
5067
|
+
try {
|
|
5068
|
+
workerThreadsCache = require("worker_threads");
|
|
5069
|
+
} catch (e) {
|
|
5070
|
+
workerThreadsCache = null;
|
|
5071
|
+
}
|
|
5072
|
+
return workerThreadsCache;
|
|
5073
|
+
}
|
|
5074
|
+
function loadOs() {
|
|
5075
|
+
if (osCache !== void 0) return osCache;
|
|
5076
|
+
try {
|
|
5077
|
+
osCache = require("os");
|
|
5078
|
+
} catch (e) {
|
|
5079
|
+
osCache = null;
|
|
5080
|
+
}
|
|
5081
|
+
return osCache;
|
|
5082
|
+
}
|
|
5083
|
+
function getWorkerPath(filename) {
|
|
5084
|
+
const cached = workerPathByFile.get(filename);
|
|
5085
|
+
if (cached !== void 0) return cached;
|
|
5086
|
+
if (typeof __dirname === "undefined") {
|
|
5087
|
+
workerPathByFile.set(filename, null);
|
|
5088
|
+
return null;
|
|
5089
|
+
}
|
|
5090
|
+
const path = require("path");
|
|
5091
|
+
const fs = require("fs");
|
|
5092
|
+
const candidates = [
|
|
5093
|
+
path.join(__dirname, filename),
|
|
5094
|
+
path.join(__dirname, "verification", filename)
|
|
5095
|
+
];
|
|
5096
|
+
try {
|
|
5097
|
+
for (const candidate of candidates) {
|
|
5098
|
+
if (fs.existsSync(candidate)) {
|
|
5099
|
+
workerPathByFile.set(filename, candidate);
|
|
5100
|
+
return candidate;
|
|
5101
|
+
}
|
|
5102
|
+
}
|
|
5103
|
+
} catch (e) {
|
|
5104
|
+
}
|
|
5105
|
+
workerPathByFile.set(filename, null);
|
|
5106
|
+
return null;
|
|
5107
|
+
}
|
|
5108
|
+
function mapWithConcurrency(items, concurrency, fn) {
|
|
5109
|
+
return __async(this, null, function* () {
|
|
5110
|
+
const results = new Array(items.length);
|
|
5111
|
+
let next = 0;
|
|
5112
|
+
const runners = Array.from(
|
|
5113
|
+
{ length: Math.min(concurrency, items.length) },
|
|
5114
|
+
() => __async(null, null, function* () {
|
|
5115
|
+
while (next < items.length) {
|
|
5116
|
+
const i = next++;
|
|
5117
|
+
results[i] = yield fn(items[i], i);
|
|
5118
|
+
}
|
|
5119
|
+
})
|
|
5120
|
+
);
|
|
5121
|
+
yield Promise.all(runners);
|
|
5122
|
+
return results;
|
|
5123
|
+
});
|
|
5124
|
+
}
|
|
5125
|
+
function chunkArrays(arr, n) {
|
|
5126
|
+
const size = Math.ceil(arr.length / n);
|
|
5127
|
+
const out = [];
|
|
5128
|
+
for (let i = 0; i < arr.length; i += size) {
|
|
5129
|
+
out.push(arr.slice(i, i + size));
|
|
5130
|
+
}
|
|
5131
|
+
return out;
|
|
5132
|
+
}
|
|
5133
|
+
function verifySharesSync(shares, distributedKeys, threshold) {
|
|
5134
|
+
for (let i = 0; i < shares.length; i++) {
|
|
5135
|
+
const sharesBytes = shares[i].map((s) => (0, import_ssz2.fromHexString)(s));
|
|
5136
|
+
const dkBytes = (0, import_ssz2.fromHexString)(distributedKeys[i]);
|
|
5137
|
+
const recovered = blsRecoverDistributedPubkeyFromShares(
|
|
5138
|
+
sharesBytes,
|
|
5139
|
+
threshold
|
|
5140
|
+
);
|
|
5141
|
+
if (!recovered) return false;
|
|
5142
|
+
if (recovered.length !== dkBytes.length) return false;
|
|
5143
|
+
for (let j = 0; j < recovered.length; j++) {
|
|
5144
|
+
if (recovered[j] !== dkBytes[j]) return false;
|
|
5145
|
+
}
|
|
5146
|
+
if (!blsVerifyExtraShares(sharesBytes, threshold, dkBytes)) {
|
|
5147
|
+
return false;
|
|
5148
|
+
}
|
|
5149
|
+
}
|
|
5150
|
+
return true;
|
|
5151
|
+
}
|
|
5152
|
+
function runWorkerAggregatePubkeys(wt, workerFile, data) {
|
|
5153
|
+
return __async(this, null, function* () {
|
|
5154
|
+
return yield new Promise((resolve) => {
|
|
5155
|
+
let settled = false;
|
|
5156
|
+
const worker = new wt.Worker(workerFile, { workerData: data });
|
|
5157
|
+
const finish = (result) => {
|
|
5158
|
+
if (settled) return;
|
|
5159
|
+
settled = true;
|
|
5160
|
+
clearTimeout(timer);
|
|
5161
|
+
worker.terminate();
|
|
5162
|
+
resolve(result);
|
|
5163
|
+
};
|
|
5164
|
+
const timer = setTimeout(() => {
|
|
5165
|
+
finish(null);
|
|
5166
|
+
}, WORKER_TIMEOUT_MS);
|
|
5167
|
+
worker.once("message", (msg) => {
|
|
5168
|
+
finish(msg instanceof Uint8Array ? msg : null);
|
|
5169
|
+
});
|
|
5170
|
+
worker.once("error", () => {
|
|
5171
|
+
finish(null);
|
|
5172
|
+
});
|
|
5173
|
+
worker.once("exit", (code2) => {
|
|
5174
|
+
if (code2 !== 0) finish(null);
|
|
5175
|
+
});
|
|
5176
|
+
});
|
|
5177
|
+
});
|
|
5178
|
+
}
|
|
5179
|
+
function runWorker(wt, workerFile, data) {
|
|
5180
|
+
return __async(this, null, function* () {
|
|
5181
|
+
return yield new Promise((resolve) => {
|
|
5182
|
+
let settled = false;
|
|
5183
|
+
const worker = new wt.Worker(workerFile, { workerData: data });
|
|
5184
|
+
const finish = (result) => {
|
|
5185
|
+
if (settled) return;
|
|
5186
|
+
settled = true;
|
|
5187
|
+
clearTimeout(timer);
|
|
5188
|
+
worker.terminate();
|
|
5189
|
+
resolve(result);
|
|
5190
|
+
};
|
|
5191
|
+
const timer = setTimeout(() => {
|
|
5192
|
+
finish(false);
|
|
5193
|
+
}, WORKER_TIMEOUT_MS);
|
|
5194
|
+
worker.once("message", (msg) => {
|
|
5195
|
+
finish(msg === true);
|
|
5196
|
+
});
|
|
5197
|
+
worker.once("error", () => {
|
|
5198
|
+
finish(false);
|
|
5199
|
+
});
|
|
5200
|
+
worker.once("exit", (code2) => {
|
|
5201
|
+
if (code2 !== 0) finish(false);
|
|
5202
|
+
});
|
|
5203
|
+
});
|
|
5204
|
+
});
|
|
5205
|
+
}
|
|
5206
|
+
function poolSize(itemCount, minPerWorker) {
|
|
5207
|
+
const wt = loadWorkerThreads();
|
|
5208
|
+
const os = loadOs();
|
|
5209
|
+
const workerFile = getWorkerPath("lockWorker.js");
|
|
5210
|
+
const numCpus = os ? Math.max(1, os.cpus().length) : 1;
|
|
5211
|
+
const numWorkers = Math.min(
|
|
5212
|
+
MAX_WORKERS,
|
|
5213
|
+
Math.max(1, Math.floor(itemCount / minPerWorker)),
|
|
5214
|
+
numCpus
|
|
5215
|
+
);
|
|
5216
|
+
return { numWorkers, wt, workerFile };
|
|
5217
|
+
}
|
|
5218
|
+
function runWorkerChunks(wt, workerFile, chunks) {
|
|
5219
|
+
return __async(this, null, function* () {
|
|
5220
|
+
const results = yield mapWithConcurrency(
|
|
5221
|
+
chunks,
|
|
5222
|
+
maxConcurrentWorkers(chunks.length),
|
|
5223
|
+
(data) => __async(null, null, function* () {
|
|
5224
|
+
return yield runWorker(wt, workerFile, data);
|
|
5225
|
+
})
|
|
5226
|
+
);
|
|
5227
|
+
return results.every(Boolean);
|
|
5228
|
+
});
|
|
5229
|
+
}
|
|
5230
|
+
function verifySharesBinding(shares, distributedKeys, threshold) {
|
|
5231
|
+
return __async(this, null, function* () {
|
|
5232
|
+
if (shares.length !== distributedKeys.length) return false;
|
|
5233
|
+
if (shares.length === 0) return true;
|
|
5234
|
+
const { numWorkers, wt, workerFile } = poolSize(
|
|
5235
|
+
shares.length,
|
|
5236
|
+
MIN_VALIDATORS_PER_WORKER
|
|
5237
|
+
);
|
|
5238
|
+
if (wt === null || workerFile === null || shares.length < MIN_PARALLEL_VALIDATORS || numWorkers < 2) {
|
|
5239
|
+
return verifySharesSync(shares, distributedKeys, threshold);
|
|
5240
|
+
}
|
|
5241
|
+
const shareChunks = chunkArrays(shares, numWorkers);
|
|
5242
|
+
const keyChunks = chunkArrays(distributedKeys, numWorkers);
|
|
5243
|
+
return yield runWorkerChunks(
|
|
5244
|
+
wt,
|
|
5245
|
+
workerFile,
|
|
5246
|
+
shareChunks.map((chunk, i) => ({
|
|
5247
|
+
mode: "shareBinding",
|
|
5248
|
+
shares: chunk,
|
|
5249
|
+
distributedKeys: keyChunks[i],
|
|
5250
|
+
threshold
|
|
5251
|
+
}))
|
|
5252
|
+
);
|
|
5253
|
+
});
|
|
5254
|
+
}
|
|
5255
|
+
function verifyBlsChecksParallel(checks) {
|
|
5256
|
+
return __async(this, null, function* () {
|
|
5257
|
+
if (checks.length === 0) return true;
|
|
5258
|
+
return yield verifyBatchParallel(
|
|
5259
|
+
checks.map((c) => c.pubkey),
|
|
5260
|
+
checks.map((c) => c.message),
|
|
5261
|
+
checks.map((c) => c.signature)
|
|
5262
|
+
);
|
|
5263
|
+
});
|
|
5264
|
+
}
|
|
5265
|
+
function verifyBatchParallel(pubkeys, messages, signatures) {
|
|
5266
|
+
return __async(this, null, function* () {
|
|
5267
|
+
if (pubkeys.length !== messages.length || pubkeys.length !== signatures.length) {
|
|
5268
|
+
return false;
|
|
5269
|
+
}
|
|
5270
|
+
if (pubkeys.length === 0) return true;
|
|
5271
|
+
const { numWorkers, wt, workerFile } = poolSize(
|
|
5272
|
+
pubkeys.length,
|
|
5273
|
+
MIN_PAIRS_PER_WORKER
|
|
5274
|
+
);
|
|
5275
|
+
if (wt === null || workerFile === null || pubkeys.length < MIN_PARALLEL_BATCH_PAIRS || numWorkers < 2) {
|
|
5276
|
+
return blsVerifyMultiple(
|
|
5277
|
+
pubkeys,
|
|
5278
|
+
messages,
|
|
5279
|
+
blsAggregateSignatures(signatures)
|
|
5280
|
+
);
|
|
5281
|
+
}
|
|
5282
|
+
const pkChunks = chunkArrays(pubkeys, numWorkers);
|
|
5283
|
+
const msgChunks = chunkArrays(messages, numWorkers);
|
|
5284
|
+
const sigChunks = chunkArrays(signatures, numWorkers);
|
|
5285
|
+
return yield runWorkerChunks(
|
|
5286
|
+
wt,
|
|
5287
|
+
workerFile,
|
|
5288
|
+
pkChunks.map((pks, i) => ({
|
|
5289
|
+
mode: "verifyBatch",
|
|
5290
|
+
pubkeys: pks,
|
|
5291
|
+
messages: msgChunks[i],
|
|
5292
|
+
signatures: sigChunks[i]
|
|
5293
|
+
}))
|
|
5294
|
+
);
|
|
5295
|
+
});
|
|
5296
|
+
}
|
|
5297
|
+
function verifyAggregateParallel(pubkeys, message2, signature) {
|
|
5298
|
+
return __async(this, null, function* () {
|
|
5299
|
+
if (pubkeys.length === 0) return false;
|
|
5300
|
+
const { numWorkers, wt, workerFile } = poolSize(
|
|
5301
|
+
pubkeys.length,
|
|
5302
|
+
MIN_KEYS_PER_WORKER_AGG
|
|
5303
|
+
);
|
|
5304
|
+
if (wt === null || workerFile === null || pubkeys.length < MIN_PARALLEL_AGGREGATE_KEYS || numWorkers < 2) {
|
|
5305
|
+
return blsVerifyAggregate(pubkeys, message2, signature);
|
|
5306
|
+
}
|
|
5307
|
+
const pkChunks = chunkArrays(pubkeys, numWorkers);
|
|
5308
|
+
const partials = yield mapWithConcurrency(
|
|
5309
|
+
pkChunks,
|
|
5310
|
+
maxConcurrentWorkers(pkChunks.length),
|
|
5311
|
+
(chunk) => __async(null, null, function* () {
|
|
5312
|
+
return yield runWorkerAggregatePubkeys(wt, workerFile, {
|
|
5313
|
+
mode: "aggregatePubkeys",
|
|
5314
|
+
pubkeys: chunk
|
|
5315
|
+
});
|
|
5316
|
+
})
|
|
5317
|
+
);
|
|
5318
|
+
if (partials.some((p) => p === null)) return false;
|
|
5319
|
+
const aggregated = blsAggregatePublicKeys(partials);
|
|
5320
|
+
return blsVerifyWithAggregatedPubkey(aggregated, message2, signature);
|
|
5321
|
+
});
|
|
5322
|
+
}
|
|
5323
|
+
function validateClusterLockInWorker(lock, safeRpcUrl) {
|
|
5324
|
+
return __async(this, null, function* () {
|
|
5325
|
+
var _a6, _b2;
|
|
5326
|
+
const n = (_b2 = (_a6 = lock.distributed_validators) == null ? void 0 : _a6.length) != null ? _b2 : 0;
|
|
5327
|
+
if (n < MIN_VALIDATORS_FOR_VALIDATION_WORKER) return null;
|
|
5328
|
+
const wt = loadWorkerThreads();
|
|
5329
|
+
const workerFile = getWorkerPath("clusterLockValidationWorker.js");
|
|
5330
|
+
if (wt === null || workerFile === null) return null;
|
|
5331
|
+
return yield new Promise((resolve, reject) => {
|
|
5332
|
+
let settled = false;
|
|
5333
|
+
const worker = new wt.Worker(workerFile, {
|
|
5334
|
+
workerData: { lock, safeRpcUrl }
|
|
5335
|
+
});
|
|
5336
|
+
let timer;
|
|
5337
|
+
const finish = (result) => {
|
|
5338
|
+
if (settled) return;
|
|
5339
|
+
settled = true;
|
|
5340
|
+
clearTimeout(timer);
|
|
5341
|
+
worker.terminate();
|
|
5342
|
+
resolve(result);
|
|
5343
|
+
};
|
|
5344
|
+
timer = setTimeout(() => {
|
|
5345
|
+
if (settled) return;
|
|
5346
|
+
settled = true;
|
|
5347
|
+
clearTimeout(timer);
|
|
5348
|
+
void worker.terminate();
|
|
5349
|
+
reject(
|
|
5350
|
+
new ClusterLockValidationTimeoutError(VALIDATION_WORKER_TIMEOUT_MS)
|
|
5351
|
+
);
|
|
5352
|
+
}, VALIDATION_WORKER_TIMEOUT_MS);
|
|
5353
|
+
worker.once("message", (msg) => {
|
|
5354
|
+
finish(msg === true);
|
|
5355
|
+
});
|
|
5356
|
+
worker.once("error", () => {
|
|
5357
|
+
finish(null);
|
|
5358
|
+
});
|
|
5359
|
+
worker.once("exit", (code2) => {
|
|
5360
|
+
if (code2 !== 0) finish(null);
|
|
5361
|
+
});
|
|
5362
|
+
});
|
|
5363
|
+
});
|
|
5364
|
+
}
|
|
4962
5365
|
|
|
4963
5366
|
// src/verification/v1.6.0.ts
|
|
4964
5367
|
var clusterDefinitionContainerTypeV1X6 = (configOnly) => {
|
|
4965
5368
|
let returnedContainerType = {
|
|
4966
|
-
uuid: new
|
|
4967
|
-
name: new
|
|
4968
|
-
version: new
|
|
4969
|
-
timestamp: new
|
|
5369
|
+
uuid: new import_ssz3.ByteListType(64),
|
|
5370
|
+
name: new import_ssz3.ByteListType(256),
|
|
5371
|
+
version: new import_ssz3.ByteListType(16),
|
|
5372
|
+
timestamp: new import_ssz3.ByteListType(32),
|
|
4970
5373
|
num_validators: new import_uint.UintNumberType(8),
|
|
4971
5374
|
threshold: new import_uint.UintNumberType(8),
|
|
4972
|
-
dkg_algorithm: new
|
|
4973
|
-
fork_version: new
|
|
4974
|
-
operators: new
|
|
5375
|
+
dkg_algorithm: new import_ssz3.ByteListType(32),
|
|
5376
|
+
fork_version: new import_ssz3.ByteVectorType(4),
|
|
5377
|
+
operators: new import_ssz3.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
4975
5378
|
creator: newCreatorContainerType(configOnly),
|
|
4976
|
-
validators: new
|
|
5379
|
+
validators: new import_ssz3.ListCompositeType(validatorsContainerType, 65536)
|
|
4977
5380
|
};
|
|
4978
5381
|
if (!configOnly) {
|
|
4979
5382
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
4980
|
-
config_hash: new
|
|
5383
|
+
config_hash: new import_ssz3.ByteVectorType(32)
|
|
4981
5384
|
});
|
|
4982
5385
|
}
|
|
4983
|
-
return new
|
|
5386
|
+
return new import_ssz3.ContainerType(returnedContainerType);
|
|
4984
5387
|
};
|
|
4985
5388
|
var hashClusterDefinitionV1X6 = (cluster, configOnly) => {
|
|
4986
5389
|
const definitionType = clusterDefinitionContainerTypeV1X6(configOnly);
|
|
@@ -4992,44 +5395,44 @@ var hashClusterDefinitionV1X6 = (cluster, configOnly) => {
|
|
|
4992
5395
|
val.num_validators = cluster.num_validators;
|
|
4993
5396
|
val.threshold = cluster.threshold;
|
|
4994
5397
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
4995
|
-
val.fork_version = (0,
|
|
5398
|
+
val.fork_version = (0, import_ssz3.fromHexString)(cluster.fork_version);
|
|
4996
5399
|
val.operators = cluster.operators.map((operator) => {
|
|
4997
|
-
return configOnly ? { address: (0,
|
|
4998
|
-
address: (0,
|
|
5400
|
+
return configOnly ? { address: (0, import_ssz3.fromHexString)(operator.address) } : {
|
|
5401
|
+
address: (0, import_ssz3.fromHexString)(operator.address),
|
|
4999
5402
|
enr: strToUint8Array(operator.enr),
|
|
5000
|
-
config_signature: (0,
|
|
5001
|
-
enr_signature: (0,
|
|
5403
|
+
config_signature: (0, import_ssz3.fromHexString)(operator.config_signature),
|
|
5404
|
+
enr_signature: (0, import_ssz3.fromHexString)(operator.enr_signature)
|
|
5002
5405
|
};
|
|
5003
5406
|
});
|
|
5004
|
-
val.creator = configOnly ? { address: (0,
|
|
5005
|
-
address: (0,
|
|
5006
|
-
config_signature: (0,
|
|
5407
|
+
val.creator = configOnly ? { address: (0, import_ssz3.fromHexString)(cluster.creator.address) } : {
|
|
5408
|
+
address: (0, import_ssz3.fromHexString)(cluster.creator.address),
|
|
5409
|
+
config_signature: (0, import_ssz3.fromHexString)(
|
|
5007
5410
|
cluster.creator.config_signature
|
|
5008
5411
|
)
|
|
5009
5412
|
};
|
|
5010
5413
|
val.validators = cluster.validators.map((validator) => {
|
|
5011
5414
|
return {
|
|
5012
|
-
fee_recipient_address: (0,
|
|
5013
|
-
withdrawal_address: (0,
|
|
5415
|
+
fee_recipient_address: (0, import_ssz3.fromHexString)(validator.fee_recipient_address),
|
|
5416
|
+
withdrawal_address: (0, import_ssz3.fromHexString)(validator.withdrawal_address)
|
|
5014
5417
|
};
|
|
5015
5418
|
});
|
|
5016
5419
|
if (!configOnly) {
|
|
5017
|
-
val.config_hash = (0,
|
|
5420
|
+
val.config_hash = (0, import_ssz3.fromHexString)(cluster.config_hash);
|
|
5018
5421
|
}
|
|
5019
5422
|
return val;
|
|
5020
5423
|
};
|
|
5021
|
-
var dvContainerTypeV1X6 = new
|
|
5022
|
-
distributed_public_key: new
|
|
5023
|
-
public_shares: new
|
|
5024
|
-
pubkey: new
|
|
5025
|
-
withdrawal_credentials: new
|
|
5424
|
+
var dvContainerTypeV1X6 = new import_ssz3.ContainerType({
|
|
5425
|
+
distributed_public_key: new import_ssz3.ByteVectorType(48),
|
|
5426
|
+
public_shares: new import_ssz3.ListCompositeType(new import_ssz3.ByteVectorType(48), 256),
|
|
5427
|
+
pubkey: new import_ssz3.ByteVectorType(48),
|
|
5428
|
+
withdrawal_credentials: new import_ssz3.ByteVectorType(32),
|
|
5026
5429
|
amount: new import_uint.UintNumberType(8),
|
|
5027
|
-
signature: new
|
|
5430
|
+
signature: new import_ssz3.ByteVectorType(96)
|
|
5028
5431
|
});
|
|
5029
5432
|
var clusterLockContainerTypeV1X6 = () => {
|
|
5030
|
-
return new
|
|
5433
|
+
return new import_ssz3.ContainerType({
|
|
5031
5434
|
cluster_definition: clusterDefinitionContainerTypeV1X6(false),
|
|
5032
|
-
distributed_validators: new
|
|
5435
|
+
distributed_validators: new import_ssz3.ListCompositeType(dvContainerTypeV1X6, 65536)
|
|
5033
5436
|
});
|
|
5034
5437
|
};
|
|
5035
5438
|
var hashClusterLockV1X6 = (cluster) => {
|
|
@@ -5043,65 +5446,77 @@ var hashClusterLockV1X6 = (cluster) => {
|
|
|
5043
5446
|
(dValidator) => {
|
|
5044
5447
|
var _a6, _b2, _c, _d;
|
|
5045
5448
|
return {
|
|
5046
|
-
distributed_public_key: (0,
|
|
5449
|
+
distributed_public_key: (0, import_ssz3.fromHexString)(
|
|
5047
5450
|
dValidator.distributed_public_key
|
|
5048
5451
|
),
|
|
5049
5452
|
public_shares: dValidator.public_shares.map(
|
|
5050
|
-
(publicShare) => (0,
|
|
5453
|
+
(publicShare) => (0, import_ssz3.fromHexString)(publicShare)
|
|
5051
5454
|
),
|
|
5052
|
-
pubkey: (0,
|
|
5053
|
-
withdrawal_credentials: (0,
|
|
5455
|
+
pubkey: (0, import_ssz3.fromHexString)((_a6 = dValidator.deposit_data) == null ? void 0 : _a6.pubkey),
|
|
5456
|
+
withdrawal_credentials: (0, import_ssz3.fromHexString)(
|
|
5054
5457
|
(_b2 = dValidator.deposit_data) == null ? void 0 : _b2.withdrawal_credentials
|
|
5055
5458
|
),
|
|
5056
5459
|
amount: parseInt((_c = dValidator.deposit_data) == null ? void 0 : _c.amount),
|
|
5057
|
-
signature: (0,
|
|
5460
|
+
signature: (0, import_ssz3.fromHexString)((_d = dValidator.deposit_data) == null ? void 0 : _d.signature)
|
|
5058
5461
|
};
|
|
5059
5462
|
}
|
|
5060
5463
|
);
|
|
5061
5464
|
return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
|
|
5062
5465
|
};
|
|
5063
5466
|
var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
5064
|
-
var _a6;
|
|
5065
5467
|
const validators = clusterLock.distributed_validators;
|
|
5468
|
+
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
5469
|
+
const threshold = clusterLock.cluster_definition.threshold;
|
|
5470
|
+
for (const validator of validators) {
|
|
5471
|
+
if (validator.public_shares.length !== operatorCount) {
|
|
5472
|
+
return false;
|
|
5473
|
+
}
|
|
5474
|
+
const uniqueShareCount = new Set(validator.public_shares).size;
|
|
5475
|
+
if (uniqueShareCount !== validator.public_shares.length) {
|
|
5476
|
+
return false;
|
|
5477
|
+
}
|
|
5478
|
+
}
|
|
5479
|
+
const allShares = validators.map((v) => v.public_shares);
|
|
5480
|
+
const allDKs = validators.map((v) => v.distributed_public_key);
|
|
5481
|
+
if (!(yield verifySharesBinding(allShares, allDKs, threshold))) {
|
|
5482
|
+
return false;
|
|
5483
|
+
}
|
|
5066
5484
|
const pubShares = [];
|
|
5067
|
-
const
|
|
5068
|
-
const builderRegistrationAndDepositDataMessages = [];
|
|
5069
|
-
const blsSignatures = [];
|
|
5485
|
+
const blsChecks = [];
|
|
5070
5486
|
for (let i = 0; i < validators.length; i++) {
|
|
5071
5487
|
const validator = validators[i];
|
|
5072
5488
|
const validatorPublicShares = validator.public_shares;
|
|
5073
5489
|
const distributedPublicKey = validator.distributed_public_key;
|
|
5074
|
-
|
|
5075
|
-
|
|
5490
|
+
if (validatorPublicShares.length !== operatorCount) {
|
|
5491
|
+
return false;
|
|
5076
5492
|
}
|
|
5077
|
-
const
|
|
5493
|
+
const normalizedShares = validatorPublicShares.map((s) => s.toLowerCase());
|
|
5494
|
+
if (new Set(normalizedShares).size !== normalizedShares.length) {
|
|
5495
|
+
return false;
|
|
5496
|
+
}
|
|
5497
|
+
const validatorPublicSharesBytes = validatorPublicShares.map(
|
|
5498
|
+
(share) => (0, import_ssz3.fromHexString)(share)
|
|
5499
|
+
);
|
|
5500
|
+
for (const share of validatorPublicSharesBytes) {
|
|
5501
|
+
pubShares.push(share);
|
|
5502
|
+
}
|
|
5503
|
+
const depositCheck = depositBlsCheck(
|
|
5078
5504
|
distributedPublicKey,
|
|
5079
5505
|
validator.deposit_data,
|
|
5080
5506
|
clusterLock.cluster_definition.validators[i].withdrawal_address,
|
|
5081
5507
|
clusterLock.cluster_definition.fork_version
|
|
5082
5508
|
);
|
|
5083
|
-
if (!
|
|
5084
|
-
|
|
5085
|
-
}
|
|
5086
|
-
pubKeys.push((0, import_ssz2.fromHexString)(validator.distributed_public_key));
|
|
5087
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5088
|
-
blsSignatures.push(
|
|
5089
|
-
(0, import_ssz2.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5090
|
-
);
|
|
5509
|
+
if (!depositCheck) return false;
|
|
5510
|
+
blsChecks.push(depositCheck);
|
|
5091
5511
|
}
|
|
5092
|
-
|
|
5093
|
-
if (!blsVerifyMultiple(
|
|
5094
|
-
pubKeys,
|
|
5095
|
-
builderRegistrationAndDepositDataMessages,
|
|
5096
|
-
aggregateBLSSignature
|
|
5097
|
-
)) {
|
|
5512
|
+
if (!(yield verifyBlsChecksParallel(blsChecks))) {
|
|
5098
5513
|
return false;
|
|
5099
5514
|
}
|
|
5100
|
-
if (!
|
|
5515
|
+
if (!(yield verifyAggregateParallel(
|
|
5101
5516
|
pubShares,
|
|
5102
|
-
(0,
|
|
5103
|
-
(0,
|
|
5104
|
-
)) {
|
|
5517
|
+
(0, import_ssz3.fromHexString)(clusterLock.lock_hash),
|
|
5518
|
+
(0, import_ssz3.fromHexString)(clusterLock.signature_aggregate)
|
|
5519
|
+
))) {
|
|
5105
5520
|
return false;
|
|
5106
5521
|
}
|
|
5107
5522
|
return true;
|
|
@@ -5109,27 +5524,27 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5109
5524
|
|
|
5110
5525
|
// src/verification/v1.7.0.ts
|
|
5111
5526
|
var import_uint2 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
5112
|
-
var
|
|
5527
|
+
var import_ssz4 = require("@chainsafe/ssz");
|
|
5113
5528
|
var clusterDefinitionContainerTypeV1X7 = (configOnly) => {
|
|
5114
5529
|
let returnedContainerType = {
|
|
5115
|
-
uuid: new
|
|
5116
|
-
name: new
|
|
5117
|
-
version: new
|
|
5118
|
-
timestamp: new
|
|
5530
|
+
uuid: new import_ssz4.ByteListType(64),
|
|
5531
|
+
name: new import_ssz4.ByteListType(256),
|
|
5532
|
+
version: new import_ssz4.ByteListType(16),
|
|
5533
|
+
timestamp: new import_ssz4.ByteListType(32),
|
|
5119
5534
|
num_validators: new import_uint2.UintNumberType(8),
|
|
5120
5535
|
threshold: new import_uint2.UintNumberType(8),
|
|
5121
|
-
dkg_algorithm: new
|
|
5122
|
-
fork_version: new
|
|
5123
|
-
operators: new
|
|
5536
|
+
dkg_algorithm: new import_ssz4.ByteListType(32),
|
|
5537
|
+
fork_version: new import_ssz4.ByteVectorType(4),
|
|
5538
|
+
operators: new import_ssz4.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
5124
5539
|
creator: newCreatorContainerType(configOnly),
|
|
5125
|
-
validators: new
|
|
5540
|
+
validators: new import_ssz4.ListCompositeType(validatorsContainerType, 65536)
|
|
5126
5541
|
};
|
|
5127
5542
|
if (!configOnly) {
|
|
5128
5543
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
5129
|
-
config_hash: new
|
|
5544
|
+
config_hash: new import_ssz4.ByteVectorType(32)
|
|
5130
5545
|
});
|
|
5131
5546
|
}
|
|
5132
|
-
return new
|
|
5547
|
+
return new import_ssz4.ContainerType(returnedContainerType);
|
|
5133
5548
|
};
|
|
5134
5549
|
var hashClusterDefinitionV1X7 = (cluster, configOnly) => {
|
|
5135
5550
|
const definitionType = clusterDefinitionContainerTypeV1X7(configOnly);
|
|
@@ -5141,42 +5556,42 @@ var hashClusterDefinitionV1X7 = (cluster, configOnly) => {
|
|
|
5141
5556
|
val.num_validators = cluster.num_validators;
|
|
5142
5557
|
val.threshold = cluster.threshold;
|
|
5143
5558
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
5144
|
-
val.fork_version = (0,
|
|
5559
|
+
val.fork_version = (0, import_ssz4.fromHexString)(cluster.fork_version);
|
|
5145
5560
|
val.operators = cluster.operators.map((operator) => {
|
|
5146
|
-
return configOnly ? { address: (0,
|
|
5147
|
-
address: (0,
|
|
5561
|
+
return configOnly ? { address: (0, import_ssz4.fromHexString)(operator.address) } : {
|
|
5562
|
+
address: (0, import_ssz4.fromHexString)(operator.address),
|
|
5148
5563
|
enr: strToUint8Array(operator.enr),
|
|
5149
|
-
config_signature: (0,
|
|
5150
|
-
enr_signature: (0,
|
|
5564
|
+
config_signature: (0, import_ssz4.fromHexString)(operator.config_signature),
|
|
5565
|
+
enr_signature: (0, import_ssz4.fromHexString)(operator.enr_signature)
|
|
5151
5566
|
};
|
|
5152
5567
|
});
|
|
5153
|
-
val.creator = configOnly ? { address: (0,
|
|
5154
|
-
address: (0,
|
|
5155
|
-
config_signature: (0,
|
|
5568
|
+
val.creator = configOnly ? { address: (0, import_ssz4.fromHexString)(cluster.creator.address) } : {
|
|
5569
|
+
address: (0, import_ssz4.fromHexString)(cluster.creator.address),
|
|
5570
|
+
config_signature: (0, import_ssz4.fromHexString)(
|
|
5156
5571
|
cluster.creator.config_signature
|
|
5157
5572
|
)
|
|
5158
5573
|
};
|
|
5159
5574
|
val.validators = cluster.validators.map((validator) => {
|
|
5160
5575
|
return {
|
|
5161
|
-
fee_recipient_address: (0,
|
|
5162
|
-
withdrawal_address: (0,
|
|
5576
|
+
fee_recipient_address: (0, import_ssz4.fromHexString)(validator.fee_recipient_address),
|
|
5577
|
+
withdrawal_address: (0, import_ssz4.fromHexString)(validator.withdrawal_address)
|
|
5163
5578
|
};
|
|
5164
5579
|
});
|
|
5165
5580
|
if (!configOnly) {
|
|
5166
|
-
val.config_hash = (0,
|
|
5581
|
+
val.config_hash = (0, import_ssz4.fromHexString)(cluster.config_hash);
|
|
5167
5582
|
}
|
|
5168
5583
|
return val;
|
|
5169
5584
|
};
|
|
5170
|
-
var dvContainerTypeV1X7 = new
|
|
5171
|
-
distributed_public_key: new
|
|
5172
|
-
public_shares: new
|
|
5585
|
+
var dvContainerTypeV1X7 = new import_ssz4.ContainerType({
|
|
5586
|
+
distributed_public_key: new import_ssz4.ByteVectorType(48),
|
|
5587
|
+
public_shares: new import_ssz4.ListCompositeType(new import_ssz4.ByteVectorType(48), 256),
|
|
5173
5588
|
deposit_data: depositDataContainer,
|
|
5174
5589
|
builder_registration: builderRegistrationContainer
|
|
5175
5590
|
});
|
|
5176
5591
|
var clusterLockContainerTypeV1X7 = () => {
|
|
5177
|
-
return new
|
|
5592
|
+
return new import_ssz4.ContainerType({
|
|
5178
5593
|
cluster_definition: clusterDefinitionContainerTypeV1X7(false),
|
|
5179
|
-
distributed_validators: new
|
|
5594
|
+
distributed_validators: new import_ssz4.ListCompositeType(dvContainerTypeV1X7, 65536)
|
|
5180
5595
|
});
|
|
5181
5596
|
};
|
|
5182
5597
|
var hashClusterLockV1X7 = (cluster) => {
|
|
@@ -5190,34 +5605,34 @@ var hashClusterLockV1X7 = (cluster) => {
|
|
|
5190
5605
|
(dValidator) => {
|
|
5191
5606
|
var _a6, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
5192
5607
|
return {
|
|
5193
|
-
distributed_public_key: (0,
|
|
5608
|
+
distributed_public_key: (0, import_ssz4.fromHexString)(
|
|
5194
5609
|
dValidator.distributed_public_key
|
|
5195
5610
|
),
|
|
5196
5611
|
public_shares: dValidator.public_shares.map(
|
|
5197
|
-
(publicShare) => (0,
|
|
5612
|
+
(publicShare) => (0, import_ssz4.fromHexString)(publicShare)
|
|
5198
5613
|
),
|
|
5199
5614
|
deposit_data: {
|
|
5200
|
-
pubkey: (0,
|
|
5201
|
-
withdrawal_credentials: (0,
|
|
5615
|
+
pubkey: (0, import_ssz4.fromHexString)((_a6 = dValidator.deposit_data) == null ? void 0 : _a6.pubkey),
|
|
5616
|
+
withdrawal_credentials: (0, import_ssz4.fromHexString)(
|
|
5202
5617
|
(_b2 = dValidator.deposit_data) == null ? void 0 : _b2.withdrawal_credentials
|
|
5203
5618
|
),
|
|
5204
5619
|
amount: parseInt((_c = dValidator.deposit_data) == null ? void 0 : _c.amount),
|
|
5205
|
-
signature: (0,
|
|
5620
|
+
signature: (0, import_ssz4.fromHexString)(
|
|
5206
5621
|
(_d = dValidator.deposit_data) == null ? void 0 : _d.signature
|
|
5207
5622
|
)
|
|
5208
5623
|
},
|
|
5209
5624
|
builder_registration: {
|
|
5210
5625
|
message: {
|
|
5211
|
-
fee_recipient: (0,
|
|
5626
|
+
fee_recipient: (0, import_ssz4.fromHexString)(
|
|
5212
5627
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.message.fee_recipient
|
|
5213
5628
|
),
|
|
5214
5629
|
gas_limit: (_f = dValidator.builder_registration) == null ? void 0 : _f.message.gas_limit,
|
|
5215
5630
|
timestamp: (_g = dValidator.builder_registration) == null ? void 0 : _g.message.timestamp,
|
|
5216
|
-
pubkey: (0,
|
|
5631
|
+
pubkey: (0, import_ssz4.fromHexString)(
|
|
5217
5632
|
(_h = dValidator.builder_registration) == null ? void 0 : _h.message.pubkey
|
|
5218
5633
|
)
|
|
5219
5634
|
},
|
|
5220
|
-
signature: (0,
|
|
5635
|
+
signature: (0, import_ssz4.fromHexString)(
|
|
5221
5636
|
(_i = dValidator.builder_registration) == null ? void 0 : _i.signature
|
|
5222
5637
|
)
|
|
5223
5638
|
}
|
|
@@ -5227,63 +5642,69 @@ var hashClusterLockV1X7 = (cluster) => {
|
|
|
5227
5642
|
return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
|
|
5228
5643
|
};
|
|
5229
5644
|
var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
5230
|
-
var _a6, _b2;
|
|
5231
5645
|
const validators = clusterLock.distributed_validators;
|
|
5646
|
+
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
5647
|
+
const threshold = clusterLock.cluster_definition.threshold;
|
|
5648
|
+
for (const validator of validators) {
|
|
5649
|
+
if (validator.public_shares.length !== operatorCount) {
|
|
5650
|
+
return false;
|
|
5651
|
+
}
|
|
5652
|
+
const uniqueShareCount = new Set(validator.public_shares).size;
|
|
5653
|
+
if (uniqueShareCount !== validator.public_shares.length) {
|
|
5654
|
+
return false;
|
|
5655
|
+
}
|
|
5656
|
+
}
|
|
5657
|
+
const allShares = validators.map((v) => v.public_shares);
|
|
5658
|
+
const allDKs = validators.map((v) => v.distributed_public_key);
|
|
5659
|
+
if (!(yield verifySharesBinding(allShares, allDKs, threshold))) {
|
|
5660
|
+
return false;
|
|
5661
|
+
}
|
|
5232
5662
|
const pubShares = [];
|
|
5233
|
-
const
|
|
5234
|
-
const builderRegistrationAndDepositDataMessages = [];
|
|
5235
|
-
const blsSignatures = [];
|
|
5663
|
+
const blsChecks = [];
|
|
5236
5664
|
for (let i = 0; i < validators.length; i++) {
|
|
5237
5665
|
const validator = validators[i];
|
|
5238
5666
|
const validatorPublicShares = validator.public_shares;
|
|
5239
5667
|
const distributedPublicKey = validator.distributed_public_key;
|
|
5240
|
-
|
|
5241
|
-
|
|
5668
|
+
if (validatorPublicShares.length !== operatorCount) {
|
|
5669
|
+
return false;
|
|
5242
5670
|
}
|
|
5243
|
-
const
|
|
5671
|
+
const normalizedShares = validatorPublicShares.map((s) => s.toLowerCase());
|
|
5672
|
+
if (new Set(normalizedShares).size !== normalizedShares.length) {
|
|
5673
|
+
return false;
|
|
5674
|
+
}
|
|
5675
|
+
const validatorPublicSharesBytes = validatorPublicShares.map(
|
|
5676
|
+
(share) => (0, import_ssz4.fromHexString)(share)
|
|
5677
|
+
);
|
|
5678
|
+
for (const share of validatorPublicSharesBytes) {
|
|
5679
|
+
pubShares.push(share);
|
|
5680
|
+
}
|
|
5681
|
+
const depositCheck = depositBlsCheck(
|
|
5244
5682
|
distributedPublicKey,
|
|
5245
5683
|
validator.deposit_data,
|
|
5246
5684
|
clusterLock.cluster_definition.validators[i].withdrawal_address,
|
|
5247
5685
|
clusterLock.cluster_definition.fork_version
|
|
5248
5686
|
);
|
|
5249
|
-
if (!
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
pubKeys.push((0, import_ssz3.fromHexString)(distributedPublicKey));
|
|
5253
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5254
|
-
blsSignatures.push(
|
|
5255
|
-
(0, import_ssz3.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5256
|
-
);
|
|
5257
|
-
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
5687
|
+
if (!depositCheck) return false;
|
|
5688
|
+
blsChecks.push(depositCheck);
|
|
5689
|
+
const builderCheck = builderBlsCheck(
|
|
5258
5690
|
validator,
|
|
5259
5691
|
clusterLock.cluster_definition.validators[i].fee_recipient_address,
|
|
5260
5692
|
clusterLock.cluster_definition.fork_version
|
|
5261
5693
|
);
|
|
5262
|
-
if (!
|
|
5263
|
-
|
|
5264
|
-
}
|
|
5265
|
-
pubKeys.push((0, import_ssz3.fromHexString)(distributedPublicKey));
|
|
5266
|
-
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
5267
|
-
blsSignatures.push(
|
|
5268
|
-
(0, import_ssz3.fromHexString)((_b2 = validator.builder_registration) == null ? void 0 : _b2.signature)
|
|
5269
|
-
);
|
|
5694
|
+
if (!builderCheck) return false;
|
|
5695
|
+
blsChecks.push(builderCheck);
|
|
5270
5696
|
}
|
|
5271
|
-
|
|
5272
|
-
if (!blsVerifyMultiple(
|
|
5273
|
-
pubKeys,
|
|
5274
|
-
builderRegistrationAndDepositDataMessages,
|
|
5275
|
-
aggregateBLSSignature
|
|
5276
|
-
)) {
|
|
5697
|
+
if (!(yield verifyBlsChecksParallel(blsChecks))) {
|
|
5277
5698
|
return false;
|
|
5278
5699
|
}
|
|
5279
5700
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
5280
5701
|
return false;
|
|
5281
5702
|
}
|
|
5282
|
-
if (!
|
|
5703
|
+
if (!(yield verifyAggregateParallel(
|
|
5283
5704
|
pubShares,
|
|
5284
|
-
(0,
|
|
5285
|
-
(0,
|
|
5286
|
-
)) {
|
|
5705
|
+
(0, import_ssz4.fromHexString)(clusterLock.lock_hash),
|
|
5706
|
+
(0, import_ssz4.fromHexString)(clusterLock.signature_aggregate)
|
|
5707
|
+
))) {
|
|
5287
5708
|
return false;
|
|
5288
5709
|
}
|
|
5289
5710
|
return true;
|
|
@@ -13708,31 +14129,31 @@ var ENR = class _ENR extends BaseENR {
|
|
|
13708
14129
|
|
|
13709
14130
|
// src/verification/v1.8.0.ts
|
|
13710
14131
|
var import_uint3 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
13711
|
-
var
|
|
14132
|
+
var import_ssz5 = require("@chainsafe/ssz");
|
|
13712
14133
|
var clusterDefinitionContainerTypeV1X8 = (configOnly) => {
|
|
13713
14134
|
let returnedContainerType = {
|
|
13714
|
-
uuid: new
|
|
13715
|
-
name: new
|
|
13716
|
-
version: new
|
|
13717
|
-
timestamp: new
|
|
14135
|
+
uuid: new import_ssz5.ByteListType(64),
|
|
14136
|
+
name: new import_ssz5.ByteListType(256),
|
|
14137
|
+
version: new import_ssz5.ByteListType(16),
|
|
14138
|
+
timestamp: new import_ssz5.ByteListType(32),
|
|
13718
14139
|
num_validators: new import_uint3.UintNumberType(8),
|
|
13719
14140
|
threshold: new import_uint3.UintNumberType(8),
|
|
13720
|
-
dkg_algorithm: new
|
|
13721
|
-
fork_version: new
|
|
13722
|
-
operators: new
|
|
14141
|
+
dkg_algorithm: new import_ssz5.ByteListType(32),
|
|
14142
|
+
fork_version: new import_ssz5.ByteVectorType(4),
|
|
14143
|
+
operators: new import_ssz5.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
13723
14144
|
creator: newCreatorContainerType(configOnly),
|
|
13724
|
-
validators: new
|
|
13725
|
-
deposit_amounts: new
|
|
14145
|
+
validators: new import_ssz5.ListCompositeType(validatorsContainerType, 65536),
|
|
14146
|
+
deposit_amounts: new import_ssz5.ListBasicType(
|
|
13726
14147
|
new import_uint3.UintNumberType(8),
|
|
13727
14148
|
256
|
|
13728
14149
|
)
|
|
13729
14150
|
};
|
|
13730
14151
|
if (!configOnly) {
|
|
13731
14152
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
13732
|
-
config_hash: new
|
|
14153
|
+
config_hash: new import_ssz5.ByteVectorType(32)
|
|
13733
14154
|
});
|
|
13734
14155
|
}
|
|
13735
|
-
return new
|
|
14156
|
+
return new import_ssz5.ContainerType(returnedContainerType);
|
|
13736
14157
|
};
|
|
13737
14158
|
var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
13738
14159
|
const definitionType = clusterDefinitionContainerTypeV1X8(configOnly);
|
|
@@ -13744,25 +14165,25 @@ var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
|
13744
14165
|
val.num_validators = cluster.num_validators;
|
|
13745
14166
|
val.threshold = cluster.threshold;
|
|
13746
14167
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
13747
|
-
val.fork_version = (0,
|
|
14168
|
+
val.fork_version = (0, import_ssz5.fromHexString)(cluster.fork_version);
|
|
13748
14169
|
val.operators = cluster.operators.map((operator) => {
|
|
13749
|
-
return configOnly ? { address: (0,
|
|
13750
|
-
address: (0,
|
|
14170
|
+
return configOnly ? { address: (0, import_ssz5.fromHexString)(operator.address) } : {
|
|
14171
|
+
address: (0, import_ssz5.fromHexString)(operator.address),
|
|
13751
14172
|
enr: strToUint8Array(operator.enr),
|
|
13752
|
-
config_signature: (0,
|
|
13753
|
-
enr_signature: (0,
|
|
14173
|
+
config_signature: (0, import_ssz5.fromHexString)(operator.config_signature),
|
|
14174
|
+
enr_signature: (0, import_ssz5.fromHexString)(operator.enr_signature)
|
|
13754
14175
|
};
|
|
13755
14176
|
});
|
|
13756
|
-
val.creator = configOnly ? { address: (0,
|
|
13757
|
-
address: (0,
|
|
13758
|
-
config_signature: (0,
|
|
14177
|
+
val.creator = configOnly ? { address: (0, import_ssz5.fromHexString)(cluster.creator.address) } : {
|
|
14178
|
+
address: (0, import_ssz5.fromHexString)(cluster.creator.address),
|
|
14179
|
+
config_signature: (0, import_ssz5.fromHexString)(
|
|
13759
14180
|
cluster.creator.config_signature
|
|
13760
14181
|
)
|
|
13761
14182
|
};
|
|
13762
14183
|
val.validators = cluster.validators.map((validator) => {
|
|
13763
14184
|
return {
|
|
13764
|
-
fee_recipient_address: (0,
|
|
13765
|
-
withdrawal_address: (0,
|
|
14185
|
+
fee_recipient_address: (0, import_ssz5.fromHexString)(validator.fee_recipient_address),
|
|
14186
|
+
withdrawal_address: (0, import_ssz5.fromHexString)(validator.withdrawal_address)
|
|
13766
14187
|
};
|
|
13767
14188
|
});
|
|
13768
14189
|
if (cluster.deposit_amounts) {
|
|
@@ -13771,20 +14192,20 @@ var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
|
13771
14192
|
});
|
|
13772
14193
|
}
|
|
13773
14194
|
if (!configOnly) {
|
|
13774
|
-
val.config_hash = (0,
|
|
14195
|
+
val.config_hash = (0, import_ssz5.fromHexString)(cluster.config_hash);
|
|
13775
14196
|
}
|
|
13776
14197
|
return val;
|
|
13777
14198
|
};
|
|
13778
|
-
var dvContainerTypeV1X8 = new
|
|
13779
|
-
distributed_public_key: new
|
|
13780
|
-
public_shares: new
|
|
13781
|
-
partial_deposit_data: new
|
|
14199
|
+
var dvContainerTypeV1X8 = new import_ssz5.ContainerType({
|
|
14200
|
+
distributed_public_key: new import_ssz5.ByteVectorType(48),
|
|
14201
|
+
public_shares: new import_ssz5.ListCompositeType(new import_ssz5.ByteVectorType(48), 256),
|
|
14202
|
+
partial_deposit_data: new import_ssz5.ListCompositeType(depositDataContainer, 256),
|
|
13782
14203
|
builder_registration: builderRegistrationContainer
|
|
13783
14204
|
});
|
|
13784
14205
|
var clusterLockContainerTypeV1X8 = () => {
|
|
13785
|
-
return new
|
|
14206
|
+
return new import_ssz5.ContainerType({
|
|
13786
14207
|
cluster_definition: clusterDefinitionContainerTypeV1X8(false),
|
|
13787
|
-
distributed_validators: new
|
|
14208
|
+
distributed_validators: new import_ssz5.ListCompositeType(dvContainerTypeV1X8, 65536)
|
|
13788
14209
|
});
|
|
13789
14210
|
};
|
|
13790
14211
|
var hashClusterLockV1X8 = (cluster) => {
|
|
@@ -13798,35 +14219,35 @@ var hashClusterLockV1X8 = (cluster) => {
|
|
|
13798
14219
|
(dValidator) => {
|
|
13799
14220
|
var _a6, _b2, _c, _d, _e;
|
|
13800
14221
|
return {
|
|
13801
|
-
distributed_public_key: (0,
|
|
14222
|
+
distributed_public_key: (0, import_ssz5.fromHexString)(
|
|
13802
14223
|
dValidator.distributed_public_key
|
|
13803
14224
|
),
|
|
13804
14225
|
public_shares: dValidator.public_shares.map(
|
|
13805
|
-
(publicShare) => (0,
|
|
14226
|
+
(publicShare) => (0, import_ssz5.fromHexString)(publicShare)
|
|
13806
14227
|
),
|
|
13807
14228
|
// should be fixed
|
|
13808
14229
|
partial_deposit_data: dValidator.partial_deposit_data.map((depositData) => {
|
|
13809
14230
|
return {
|
|
13810
|
-
pubkey: (0,
|
|
13811
|
-
withdrawal_credentials: (0,
|
|
14231
|
+
pubkey: (0, import_ssz5.fromHexString)(depositData.pubkey),
|
|
14232
|
+
withdrawal_credentials: (0, import_ssz5.fromHexString)(
|
|
13812
14233
|
depositData.withdrawal_credentials
|
|
13813
14234
|
),
|
|
13814
14235
|
amount: parseInt(depositData.amount),
|
|
13815
|
-
signature: (0,
|
|
14236
|
+
signature: (0, import_ssz5.fromHexString)(depositData.signature)
|
|
13816
14237
|
};
|
|
13817
14238
|
}),
|
|
13818
14239
|
builder_registration: {
|
|
13819
14240
|
message: {
|
|
13820
|
-
fee_recipient: (0,
|
|
14241
|
+
fee_recipient: (0, import_ssz5.fromHexString)(
|
|
13821
14242
|
(_a6 = dValidator.builder_registration) == null ? void 0 : _a6.message.fee_recipient
|
|
13822
14243
|
),
|
|
13823
14244
|
gas_limit: (_b2 = dValidator.builder_registration) == null ? void 0 : _b2.message.gas_limit,
|
|
13824
14245
|
timestamp: (_c = dValidator.builder_registration) == null ? void 0 : _c.message.timestamp,
|
|
13825
|
-
pubkey: (0,
|
|
14246
|
+
pubkey: (0, import_ssz5.fromHexString)(
|
|
13826
14247
|
(_d = dValidator.builder_registration) == null ? void 0 : _d.message.pubkey
|
|
13827
14248
|
)
|
|
13828
14249
|
},
|
|
13829
|
-
signature: (0,
|
|
14250
|
+
signature: (0, import_ssz5.fromHexString)(
|
|
13830
14251
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.signature
|
|
13831
14252
|
)
|
|
13832
14253
|
}
|
|
@@ -13836,18 +14257,44 @@ var hashClusterLockV1X8 = (cluster) => {
|
|
|
13836
14257
|
return "0x" + Buffer.from(lockType.hashTreeRoot(val).buffer).toString("hex");
|
|
13837
14258
|
};
|
|
13838
14259
|
var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
13839
|
-
var _a6;
|
|
13840
14260
|
const validators = clusterLock.distributed_validators;
|
|
14261
|
+
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
14262
|
+
const threshold = clusterLock.cluster_definition.threshold;
|
|
14263
|
+
for (const validator of validators) {
|
|
14264
|
+
if (validator.public_shares.length !== operatorCount) {
|
|
14265
|
+
return false;
|
|
14266
|
+
}
|
|
14267
|
+
const uniqueShareCount = new Set(validator.public_shares).size;
|
|
14268
|
+
if (uniqueShareCount !== validator.public_shares.length) {
|
|
14269
|
+
return false;
|
|
14270
|
+
}
|
|
14271
|
+
}
|
|
14272
|
+
const allShares = validators.map((v) => v.public_shares);
|
|
14273
|
+
const allDKs = validators.map((v) => v.distributed_public_key);
|
|
14274
|
+
if (!(yield verifySharesBinding(allShares, allDKs, threshold))) {
|
|
14275
|
+
return false;
|
|
14276
|
+
}
|
|
13841
14277
|
const pubShares = [];
|
|
13842
|
-
const
|
|
13843
|
-
const
|
|
13844
|
-
const
|
|
14278
|
+
const blsChecks = [];
|
|
14279
|
+
const forkVersion = clusterLock.cluster_definition.fork_version;
|
|
14280
|
+
const depositDomain = depositDomainForFork(forkVersion);
|
|
14281
|
+
const builderDomain = builderDomainForFork(forkVersion);
|
|
13845
14282
|
for (let i = 0; i < validators.length; i++) {
|
|
13846
14283
|
const validator = validators[i];
|
|
13847
14284
|
const validatorPublicShares = validator.public_shares;
|
|
13848
14285
|
const distributedPublicKey = validator.distributed_public_key;
|
|
13849
|
-
|
|
13850
|
-
|
|
14286
|
+
if (validatorPublicShares.length !== operatorCount) {
|
|
14287
|
+
return false;
|
|
14288
|
+
}
|
|
14289
|
+
const normalizedShares = validatorPublicShares.map((s) => s.toLowerCase());
|
|
14290
|
+
if (new Set(normalizedShares).size !== normalizedShares.length) {
|
|
14291
|
+
return false;
|
|
14292
|
+
}
|
|
14293
|
+
const validatorPublicSharesBytes = validatorPublicShares.map(
|
|
14294
|
+
(share) => (0, import_ssz5.fromHexString)(share)
|
|
14295
|
+
);
|
|
14296
|
+
for (const share of validatorPublicSharesBytes) {
|
|
14297
|
+
pubShares.push(share);
|
|
13851
14298
|
}
|
|
13852
14299
|
const depositAmounts = clusterLock.cluster_definition.deposit_amounts;
|
|
13853
14300
|
if (!!depositAmounts && depositAmounts !== null) {
|
|
@@ -13858,52 +14305,38 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13858
14305
|
return false;
|
|
13859
14306
|
}
|
|
13860
14307
|
}
|
|
13861
|
-
for (const
|
|
13862
|
-
const
|
|
13863
|
-
const { isValidDepositData, depositDataMsg } = verifyDepositData(
|
|
14308
|
+
for (const depositData of validator.partial_deposit_data) {
|
|
14309
|
+
const check = depositBlsCheck(
|
|
13864
14310
|
distributedPublicKey,
|
|
13865
14311
|
depositData,
|
|
13866
14312
|
clusterLock.cluster_definition.validators[i].withdrawal_address,
|
|
13867
|
-
|
|
13868
|
-
clusterLock.cluster_definition.compounding
|
|
14313
|
+
forkVersion,
|
|
14314
|
+
clusterLock.cluster_definition.compounding,
|
|
14315
|
+
depositDomain
|
|
13869
14316
|
);
|
|
13870
|
-
if (!
|
|
13871
|
-
|
|
13872
|
-
}
|
|
13873
|
-
pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
|
|
13874
|
-
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
13875
|
-
blsSignatures.push((0, import_ssz4.fromHexString)(depositData == null ? void 0 : depositData.signature));
|
|
14317
|
+
if (!check) return false;
|
|
14318
|
+
blsChecks.push(check);
|
|
13876
14319
|
}
|
|
13877
|
-
const
|
|
14320
|
+
const builderCheck = builderBlsCheck(
|
|
13878
14321
|
validator,
|
|
13879
14322
|
clusterLock.cluster_definition.validators[i].fee_recipient_address,
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
if (!isValidBuilderRegistration) {
|
|
13883
|
-
return false;
|
|
13884
|
-
}
|
|
13885
|
-
pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
|
|
13886
|
-
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
13887
|
-
blsSignatures.push(
|
|
13888
|
-
(0, import_ssz4.fromHexString)((_a6 = validator.builder_registration) == null ? void 0 : _a6.signature)
|
|
14323
|
+
forkVersion,
|
|
14324
|
+
builderDomain
|
|
13889
14325
|
);
|
|
14326
|
+
if (!builderCheck) return false;
|
|
14327
|
+
blsChecks.push(builderCheck);
|
|
13890
14328
|
}
|
|
13891
|
-
|
|
13892
|
-
if (!blsVerifyMultiple(
|
|
13893
|
-
pubKeys,
|
|
13894
|
-
builderRegistrationAndDepositDataMessages,
|
|
13895
|
-
aggregateBLSSignature
|
|
13896
|
-
)) {
|
|
14329
|
+
if (!(yield verifyBlsChecksParallel(blsChecks))) {
|
|
13897
14330
|
return false;
|
|
13898
14331
|
}
|
|
13899
14332
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
13900
14333
|
return false;
|
|
13901
14334
|
}
|
|
13902
|
-
if (!
|
|
14335
|
+
if (!(yield verifyAggregateParallel(
|
|
13903
14336
|
pubShares,
|
|
13904
|
-
(0,
|
|
13905
|
-
(0,
|
|
13906
|
-
)) {
|
|
14337
|
+
(0, import_ssz5.fromHexString)(clusterLock.lock_hash),
|
|
14338
|
+
(0, import_ssz5.fromHexString)(clusterLock.signature_aggregate)
|
|
14339
|
+
))) {
|
|
13907
14340
|
return false;
|
|
13908
14341
|
}
|
|
13909
14342
|
return true;
|
|
@@ -13983,34 +14416,34 @@ var validateSmartContractSignature = (_0) => __async(null, [_0], function* ({
|
|
|
13983
14416
|
|
|
13984
14417
|
// src/verification/v1.10.0.ts
|
|
13985
14418
|
var import_uint4 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
13986
|
-
var
|
|
14419
|
+
var import_ssz6 = require("@chainsafe/ssz");
|
|
13987
14420
|
var clusterDefinitionContainerTypeV1X10 = (configOnly) => {
|
|
13988
14421
|
let returnedContainerType = {
|
|
13989
|
-
uuid: new
|
|
13990
|
-
name: new
|
|
13991
|
-
version: new
|
|
13992
|
-
timestamp: new
|
|
14422
|
+
uuid: new import_ssz6.ByteListType(64),
|
|
14423
|
+
name: new import_ssz6.ByteListType(256),
|
|
14424
|
+
version: new import_ssz6.ByteListType(16),
|
|
14425
|
+
timestamp: new import_ssz6.ByteListType(32),
|
|
13993
14426
|
num_validators: new import_uint4.UintNumberType(8),
|
|
13994
14427
|
threshold: new import_uint4.UintNumberType(8),
|
|
13995
|
-
dkg_algorithm: new
|
|
13996
|
-
fork_version: new
|
|
13997
|
-
operators: new
|
|
14428
|
+
dkg_algorithm: new import_ssz6.ByteListType(32),
|
|
14429
|
+
fork_version: new import_ssz6.ByteVectorType(4),
|
|
14430
|
+
operators: new import_ssz6.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
13998
14431
|
creator: newCreatorContainerType(configOnly),
|
|
13999
|
-
validators: new
|
|
14000
|
-
deposit_amounts: new
|
|
14432
|
+
validators: new import_ssz6.ListCompositeType(validatorsContainerType, 65536),
|
|
14433
|
+
deposit_amounts: new import_ssz6.ListBasicType(
|
|
14001
14434
|
new import_uint4.UintNumberType(8),
|
|
14002
14435
|
256
|
|
14003
14436
|
),
|
|
14004
|
-
consensus_protocol: new
|
|
14437
|
+
consensus_protocol: new import_ssz6.ByteListType(256),
|
|
14005
14438
|
target_gas_limit: new import_uint4.UintNumberType(8),
|
|
14006
|
-
compounding: new
|
|
14439
|
+
compounding: new import_ssz6.BooleanType()
|
|
14007
14440
|
};
|
|
14008
14441
|
if (!configOnly) {
|
|
14009
14442
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
14010
|
-
config_hash: new
|
|
14443
|
+
config_hash: new import_ssz6.ByteVectorType(32)
|
|
14011
14444
|
});
|
|
14012
14445
|
}
|
|
14013
|
-
return new
|
|
14446
|
+
return new import_ssz6.ContainerType(returnedContainerType);
|
|
14014
14447
|
};
|
|
14015
14448
|
var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
14016
14449
|
const definitionType = clusterDefinitionContainerTypeV1X10(configOnly);
|
|
@@ -14022,25 +14455,25 @@ var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
|
14022
14455
|
val.num_validators = cluster.num_validators;
|
|
14023
14456
|
val.threshold = cluster.threshold;
|
|
14024
14457
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
14025
|
-
val.fork_version = (0,
|
|
14458
|
+
val.fork_version = (0, import_ssz6.fromHexString)(cluster.fork_version);
|
|
14026
14459
|
val.operators = cluster.operators.map((operator) => {
|
|
14027
|
-
return configOnly ? { address: (0,
|
|
14028
|
-
address: (0,
|
|
14460
|
+
return configOnly ? { address: (0, import_ssz6.fromHexString)(operator.address) } : {
|
|
14461
|
+
address: (0, import_ssz6.fromHexString)(operator.address),
|
|
14029
14462
|
enr: strToUint8Array(operator.enr),
|
|
14030
|
-
config_signature: (0,
|
|
14031
|
-
enr_signature: (0,
|
|
14463
|
+
config_signature: (0, import_ssz6.fromHexString)(operator.config_signature),
|
|
14464
|
+
enr_signature: (0, import_ssz6.fromHexString)(operator.enr_signature)
|
|
14032
14465
|
};
|
|
14033
14466
|
});
|
|
14034
|
-
val.creator = configOnly ? { address: (0,
|
|
14035
|
-
address: (0,
|
|
14036
|
-
config_signature: (0,
|
|
14467
|
+
val.creator = configOnly ? { address: (0, import_ssz6.fromHexString)(cluster.creator.address) } : {
|
|
14468
|
+
address: (0, import_ssz6.fromHexString)(cluster.creator.address),
|
|
14469
|
+
config_signature: (0, import_ssz6.fromHexString)(
|
|
14037
14470
|
cluster.creator.config_signature
|
|
14038
14471
|
)
|
|
14039
14472
|
};
|
|
14040
14473
|
val.validators = cluster.validators.map((validator) => {
|
|
14041
14474
|
return {
|
|
14042
|
-
fee_recipient_address: (0,
|
|
14043
|
-
withdrawal_address: (0,
|
|
14475
|
+
fee_recipient_address: (0, import_ssz6.fromHexString)(validator.fee_recipient_address),
|
|
14476
|
+
withdrawal_address: (0, import_ssz6.fromHexString)(validator.withdrawal_address)
|
|
14044
14477
|
};
|
|
14045
14478
|
});
|
|
14046
14479
|
if (cluster.deposit_amounts) {
|
|
@@ -14058,20 +14491,20 @@ var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
|
14058
14491
|
val.compounding = cluster.compounding;
|
|
14059
14492
|
}
|
|
14060
14493
|
if (!configOnly) {
|
|
14061
|
-
val.config_hash = (0,
|
|
14494
|
+
val.config_hash = (0, import_ssz6.fromHexString)(cluster.config_hash);
|
|
14062
14495
|
}
|
|
14063
14496
|
return val;
|
|
14064
14497
|
};
|
|
14065
|
-
var dvContainerTypeV1X10 = new
|
|
14066
|
-
distributed_public_key: new
|
|
14067
|
-
public_shares: new
|
|
14068
|
-
partial_deposit_data: new
|
|
14498
|
+
var dvContainerTypeV1X10 = new import_ssz6.ContainerType({
|
|
14499
|
+
distributed_public_key: new import_ssz6.ByteVectorType(48),
|
|
14500
|
+
public_shares: new import_ssz6.ListCompositeType(new import_ssz6.ByteVectorType(48), 256),
|
|
14501
|
+
partial_deposit_data: new import_ssz6.ListCompositeType(depositDataContainer, 256),
|
|
14069
14502
|
builder_registration: builderRegistrationContainer
|
|
14070
14503
|
});
|
|
14071
14504
|
var clusterLockContainerTypeV1X10 = () => {
|
|
14072
|
-
return new
|
|
14505
|
+
return new import_ssz6.ContainerType({
|
|
14073
14506
|
cluster_definition: clusterDefinitionContainerTypeV1X10(false),
|
|
14074
|
-
distributed_validators: new
|
|
14507
|
+
distributed_validators: new import_ssz6.ListCompositeType(dvContainerTypeV1X10, 65536)
|
|
14075
14508
|
});
|
|
14076
14509
|
};
|
|
14077
14510
|
var hashClusterLockV1X10 = (cluster) => {
|
|
@@ -14085,35 +14518,35 @@ var hashClusterLockV1X10 = (cluster) => {
|
|
|
14085
14518
|
(dValidator) => {
|
|
14086
14519
|
var _a6, _b2, _c, _d, _e;
|
|
14087
14520
|
return {
|
|
14088
|
-
distributed_public_key: (0,
|
|
14521
|
+
distributed_public_key: (0, import_ssz6.fromHexString)(
|
|
14089
14522
|
dValidator.distributed_public_key
|
|
14090
14523
|
),
|
|
14091
14524
|
public_shares: dValidator.public_shares.map(
|
|
14092
|
-
(publicShare) => (0,
|
|
14525
|
+
(publicShare) => (0, import_ssz6.fromHexString)(publicShare)
|
|
14093
14526
|
),
|
|
14094
14527
|
// should be fixed
|
|
14095
14528
|
partial_deposit_data: dValidator.partial_deposit_data.map((depositData) => {
|
|
14096
14529
|
return {
|
|
14097
|
-
pubkey: (0,
|
|
14098
|
-
withdrawal_credentials: (0,
|
|
14530
|
+
pubkey: (0, import_ssz6.fromHexString)(depositData.pubkey),
|
|
14531
|
+
withdrawal_credentials: (0, import_ssz6.fromHexString)(
|
|
14099
14532
|
depositData.withdrawal_credentials
|
|
14100
14533
|
),
|
|
14101
14534
|
amount: parseInt(depositData.amount),
|
|
14102
|
-
signature: (0,
|
|
14535
|
+
signature: (0, import_ssz6.fromHexString)(depositData.signature)
|
|
14103
14536
|
};
|
|
14104
14537
|
}),
|
|
14105
14538
|
builder_registration: {
|
|
14106
14539
|
message: {
|
|
14107
|
-
fee_recipient: (0,
|
|
14540
|
+
fee_recipient: (0, import_ssz6.fromHexString)(
|
|
14108
14541
|
(_a6 = dValidator.builder_registration) == null ? void 0 : _a6.message.fee_recipient
|
|
14109
14542
|
),
|
|
14110
14543
|
gas_limit: (_b2 = dValidator.builder_registration) == null ? void 0 : _b2.message.gas_limit,
|
|
14111
14544
|
timestamp: (_c = dValidator.builder_registration) == null ? void 0 : _c.message.timestamp,
|
|
14112
|
-
pubkey: (0,
|
|
14545
|
+
pubkey: (0, import_ssz6.fromHexString)(
|
|
14113
14546
|
(_d = dValidator.builder_registration) == null ? void 0 : _d.message.pubkey
|
|
14114
14547
|
)
|
|
14115
14548
|
},
|
|
14116
|
-
signature: (0,
|
|
14549
|
+
signature: (0, import_ssz6.fromHexString)(
|
|
14117
14550
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.signature
|
|
14118
14551
|
)
|
|
14119
14552
|
}
|
|
@@ -14272,8 +14705,8 @@ var computeSigningRoot = (sszObjectRoot, domain) => {
|
|
|
14272
14705
|
};
|
|
14273
14706
|
var computeDepositMsgRoot = (msg) => {
|
|
14274
14707
|
const depositMsgVal = depositMessageType.defaultValue();
|
|
14275
|
-
depositMsgVal.pubkey = (0,
|
|
14276
|
-
depositMsgVal.withdrawal_credentials = (0,
|
|
14708
|
+
depositMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
|
|
14709
|
+
depositMsgVal.withdrawal_credentials = (0, import_ssz7.fromHexString)(
|
|
14277
14710
|
msg.withdrawal_credentials
|
|
14278
14711
|
);
|
|
14279
14712
|
depositMsgVal.amount = parseInt(msg.amount);
|
|
@@ -14287,16 +14720,16 @@ var computeForkDataRoot = (currentVersion, genesisValidatorsRoot) => {
|
|
|
14287
14720
|
};
|
|
14288
14721
|
var computebuilderRegistrationMsgRoot = (msg) => {
|
|
14289
14722
|
const builderRegistrationMsgVal = builderRegistrationMessageType.defaultValue();
|
|
14290
|
-
builderRegistrationMsgVal.fee_recipient = (0,
|
|
14723
|
+
builderRegistrationMsgVal.fee_recipient = (0, import_ssz7.fromHexString)(msg.fee_recipient);
|
|
14291
14724
|
builderRegistrationMsgVal.gas_limit = msg.gas_limit;
|
|
14292
14725
|
builderRegistrationMsgVal.timestamp = msg.timestamp;
|
|
14293
|
-
builderRegistrationMsgVal.pubkey = (0,
|
|
14726
|
+
builderRegistrationMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
|
|
14294
14727
|
return Buffer.from(
|
|
14295
14728
|
builderRegistrationMessageType.hashTreeRoot(builderRegistrationMsgVal).buffer
|
|
14296
14729
|
);
|
|
14297
14730
|
};
|
|
14298
|
-
var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0,
|
|
14299
|
-
const forkVersion = (0,
|
|
14731
|
+
var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, import_ssz7.fromHexString)(GENESIS_VALIDATOR_ROOT)) => {
|
|
14732
|
+
const forkVersion = (0, import_ssz7.fromHexString)(
|
|
14300
14733
|
lockForkVersion.substring(2, lockForkVersion.length)
|
|
14301
14734
|
);
|
|
14302
14735
|
const forkDataRoot = computeForkDataRoot(forkVersion, genesisValidatorsRoot);
|
|
@@ -14305,37 +14738,62 @@ var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, im
|
|
|
14305
14738
|
domain.set(forkDataRoot.subarray(0, 28), 4);
|
|
14306
14739
|
return domain;
|
|
14307
14740
|
};
|
|
14308
|
-
var
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
14312
|
-
);
|
|
14741
|
+
var depositDomainForFork = (forkVersion) => computeDomain((0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
|
|
14742
|
+
var builderDomainForFork = (forkVersion) => computeDomain((0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
|
|
14743
|
+
var validateDepositDataStructure = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding, precomputedDepositDomain) => {
|
|
14744
|
+
const depositDomain = precomputedDepositDomain != null ? precomputedDepositDomain : computeDomain((0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT), forkVersion);
|
|
14313
14745
|
const withdrawalPrefix = compounding ? "0x02" : "0x01";
|
|
14314
14746
|
const expectedWithdrawalCredentials = withdrawalPrefix + "0".repeat(22) + withdrawalAddress.toLowerCase().slice(2);
|
|
14315
14747
|
if (expectedWithdrawalCredentials !== depositData.withdrawal_credentials) {
|
|
14316
|
-
return {
|
|
14748
|
+
return { valid: false, message: new Uint8Array(0) };
|
|
14317
14749
|
}
|
|
14318
14750
|
if (distributedPublicKey !== depositData.pubkey) {
|
|
14319
|
-
return {
|
|
14751
|
+
return { valid: false, message: new Uint8Array(0) };
|
|
14320
14752
|
}
|
|
14321
14753
|
const depositMessageBuffer = computeDepositMsgRoot(depositData);
|
|
14322
|
-
const
|
|
14754
|
+
const message2 = signingRoot(depositDomain, depositMessageBuffer);
|
|
14323
14755
|
if (!depositData.signature) {
|
|
14324
|
-
return {
|
|
14756
|
+
return { valid: false, message: message2 };
|
|
14757
|
+
}
|
|
14758
|
+
return { valid: true, message: message2 };
|
|
14759
|
+
};
|
|
14760
|
+
var depositBlsCheck = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding, precomputedDepositDomain) => {
|
|
14761
|
+
const { valid, message: message2 } = validateDepositDataStructure(
|
|
14762
|
+
distributedPublicKey,
|
|
14763
|
+
depositData,
|
|
14764
|
+
withdrawalAddress,
|
|
14765
|
+
forkVersion,
|
|
14766
|
+
compounding,
|
|
14767
|
+
precomputedDepositDomain
|
|
14768
|
+
);
|
|
14769
|
+
if (!valid || !depositData.signature || !depositData.pubkey) return null;
|
|
14770
|
+
return {
|
|
14771
|
+
pubkey: (0, import_ssz7.fromHexString)(depositData.pubkey),
|
|
14772
|
+
message: message2,
|
|
14773
|
+
signature: (0, import_ssz7.fromHexString)(depositData.signature)
|
|
14774
|
+
};
|
|
14775
|
+
};
|
|
14776
|
+
var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding) => {
|
|
14777
|
+
const { valid, message: message2 } = validateDepositDataStructure(
|
|
14778
|
+
distributedPublicKey,
|
|
14779
|
+
depositData,
|
|
14780
|
+
withdrawalAddress,
|
|
14781
|
+
forkVersion,
|
|
14782
|
+
compounding
|
|
14783
|
+
);
|
|
14784
|
+
if (!valid || !depositData.signature || !depositData.pubkey) {
|
|
14785
|
+
return { isValidDepositData: false, depositDataMsg: message2 };
|
|
14325
14786
|
}
|
|
14326
14787
|
const isValidDepositData = blsVerify(
|
|
14327
|
-
(0,
|
|
14328
|
-
|
|
14329
|
-
(0,
|
|
14788
|
+
(0, import_ssz7.fromHexString)(depositData.pubkey),
|
|
14789
|
+
message2,
|
|
14790
|
+
(0, import_ssz7.fromHexString)(depositData.signature)
|
|
14330
14791
|
);
|
|
14331
|
-
return { isValidDepositData, depositDataMsg:
|
|
14792
|
+
return { isValidDepositData, depositDataMsg: message2 };
|
|
14332
14793
|
};
|
|
14333
|
-
var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) => {
|
|
14794
|
+
var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion, precomputedBuilderDomain) => {
|
|
14334
14795
|
var _a6;
|
|
14335
|
-
const builderDomain = computeDomain(
|
|
14336
|
-
(0, import_ssz6.fromHexString)(DOMAIN_APPLICATION_BUILDER),
|
|
14337
|
-
forkVersion
|
|
14338
|
-
);
|
|
14796
|
+
const builderDomain = precomputedBuilderDomain != null ? precomputedBuilderDomain : computeDomain((0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER), forkVersion);
|
|
14339
14797
|
if (validator.distributed_public_key !== ((_a6 = validator.builder_registration) == null ? void 0 : _a6.message.pubkey)) {
|
|
14340
14798
|
return {
|
|
14341
14799
|
isValidBuilderRegistration: false,
|
|
@@ -14360,6 +14818,22 @@ var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) =>
|
|
|
14360
14818
|
builderRegistrationMsg: builderRegistrationMessage
|
|
14361
14819
|
};
|
|
14362
14820
|
};
|
|
14821
|
+
var builderBlsCheck = (validator, feeRecipientAddress, forkVersion, precomputedBuilderDomain) => {
|
|
14822
|
+
var _a6;
|
|
14823
|
+
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
14824
|
+
validator,
|
|
14825
|
+
feeRecipientAddress,
|
|
14826
|
+
forkVersion,
|
|
14827
|
+
precomputedBuilderDomain
|
|
14828
|
+
);
|
|
14829
|
+
const sig = (_a6 = validator.builder_registration) == null ? void 0 : _a6.signature;
|
|
14830
|
+
if (!isValidBuilderRegistration || !sig) return null;
|
|
14831
|
+
return {
|
|
14832
|
+
pubkey: (0, import_ssz7.fromHexString)(validator.distributed_public_key),
|
|
14833
|
+
message: builderRegistrationMsg,
|
|
14834
|
+
signature: (0, import_ssz7.fromHexString)(sig)
|
|
14835
|
+
};
|
|
14836
|
+
};
|
|
14363
14837
|
var verifyNodeSignatures = (clusterLock) => {
|
|
14364
14838
|
const ec2 = new import_elliptic.default.ec("secp256k1");
|
|
14365
14839
|
const nodeSignatures = clusterLock.node_signatures;
|
|
@@ -14401,6 +14875,12 @@ var verifyLockData = (clusterLock) => __async(null, null, function* () {
|
|
|
14401
14875
|
}
|
|
14402
14876
|
return false;
|
|
14403
14877
|
});
|
|
14878
|
+
var hasUniqueDistributedKeys = (clusterLock) => {
|
|
14879
|
+
const dvKeys = clusterLock.distributed_validators.map(
|
|
14880
|
+
(v) => v.distributed_public_key.toLowerCase()
|
|
14881
|
+
);
|
|
14882
|
+
return new Set(dvKeys).size === dvKeys.length;
|
|
14883
|
+
};
|
|
14404
14884
|
var isValidClusterLock = (clusterLock, safeRpcUrl) => __async(null, null, function* () {
|
|
14405
14885
|
try {
|
|
14406
14886
|
const definitionType = definitionFlow(clusterLock.cluster_definition);
|
|
@@ -14421,6 +14901,9 @@ var isValidClusterLock = (clusterLock, safeRpcUrl) => __async(null, null, functi
|
|
|
14421
14901
|
if (clusterLockHash(clusterLock) !== clusterLock.lock_hash) {
|
|
14422
14902
|
return false;
|
|
14423
14903
|
}
|
|
14904
|
+
if (!hasUniqueDistributedKeys(clusterLock)) {
|
|
14905
|
+
return false;
|
|
14906
|
+
}
|
|
14424
14907
|
const isValidLockData = yield verifyLockData(clusterLock);
|
|
14425
14908
|
if (!isValidLockData) {
|
|
14426
14909
|
return false;
|
|
@@ -18086,7 +18569,7 @@ var Incentives = class {
|
|
|
18086
18569
|
|
|
18087
18570
|
// src/exits/exit.ts
|
|
18088
18571
|
var elliptic2 = __toESM(require("elliptic"));
|
|
18089
|
-
var
|
|
18572
|
+
var import_ssz9 = require("@chainsafe/ssz");
|
|
18090
18573
|
|
|
18091
18574
|
// src/exits/ethUtils.ts
|
|
18092
18575
|
function getCapellaFork(fork_version) {
|
|
@@ -18123,15 +18606,15 @@ function getGenesisValidatorsRoot(beaconNodeApiUrl) {
|
|
|
18123
18606
|
}
|
|
18124
18607
|
|
|
18125
18608
|
// src/exits/verificationHelpers.ts
|
|
18126
|
-
var
|
|
18609
|
+
var import_ssz8 = require("@chainsafe/ssz");
|
|
18127
18610
|
var GENESIS_VALIDATOR_ROOT_HEX_STRING = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
18128
|
-
var ForkDataType = new
|
|
18129
|
-
currentVersion: new
|
|
18130
|
-
genesisValidatorsRoot: new
|
|
18611
|
+
var ForkDataType = new import_ssz8.ContainerType({
|
|
18612
|
+
currentVersion: new import_ssz8.ByteVectorType(4),
|
|
18613
|
+
genesisValidatorsRoot: new import_ssz8.ByteVectorType(32)
|
|
18131
18614
|
});
|
|
18132
|
-
var SigningRootType = new
|
|
18133
|
-
objectRoot: new
|
|
18134
|
-
domain: new
|
|
18615
|
+
var SigningRootType = new import_ssz8.ContainerType({
|
|
18616
|
+
objectRoot: new import_ssz8.ByteVectorType(32),
|
|
18617
|
+
domain: new import_ssz8.ByteVectorType(32)
|
|
18135
18618
|
});
|
|
18136
18619
|
function computeForkDataRoot2(currentVersion, genesisValidatorsRoot) {
|
|
18137
18620
|
const forkDataVal = ForkDataType.defaultValue();
|
|
@@ -18140,7 +18623,7 @@ function computeForkDataRoot2(currentVersion, genesisValidatorsRoot) {
|
|
|
18140
18623
|
return Buffer.from(ForkDataType.hashTreeRoot(forkDataVal).buffer);
|
|
18141
18624
|
}
|
|
18142
18625
|
function computeDomain2(domainType, forkVersionString, genesisValidatorsRootOverride) {
|
|
18143
|
-
const forkVersionBytes = (0,
|
|
18626
|
+
const forkVersionBytes = (0, import_ssz8.fromHexString)(
|
|
18144
18627
|
forkVersionString.substring(2, forkVersionString.length)
|
|
18145
18628
|
);
|
|
18146
18629
|
if (forkVersionBytes.length !== 4) {
|
|
@@ -18149,7 +18632,7 @@ function computeDomain2(domainType, forkVersionString, genesisValidatorsRootOver
|
|
|
18149
18632
|
if (domainType.length !== 4) {
|
|
18150
18633
|
throw new Error("Domain type must be 4 bytes");
|
|
18151
18634
|
}
|
|
18152
|
-
const actualGenesisValidatorsRoot = genesisValidatorsRootOverride != null ? genesisValidatorsRootOverride : (0,
|
|
18635
|
+
const actualGenesisValidatorsRoot = genesisValidatorsRootOverride != null ? genesisValidatorsRootOverride : (0, import_ssz8.fromHexString)(GENESIS_VALIDATOR_ROOT_HEX_STRING.substring(2));
|
|
18153
18636
|
if (actualGenesisValidatorsRoot.length !== 32) {
|
|
18154
18637
|
throw new Error("genesisValidatorsRoot must be 32 bytes");
|
|
18155
18638
|
}
|
|
@@ -18181,25 +18664,25 @@ function signingRoot2(domain, messageBuffer) {
|
|
|
18181
18664
|
|
|
18182
18665
|
// src/exits/exit.ts
|
|
18183
18666
|
var DOMAIN_VOLUNTARY_EXIT = "0x04000000";
|
|
18184
|
-
var SSZExitMessageType = new
|
|
18185
|
-
epoch: new
|
|
18186
|
-
validator_index: new
|
|
18667
|
+
var SSZExitMessageType = new import_ssz9.ContainerType({
|
|
18668
|
+
epoch: new import_ssz9.UintNumberType(8),
|
|
18669
|
+
validator_index: new import_ssz9.UintNumberType(8)
|
|
18187
18670
|
});
|
|
18188
|
-
var SSZPartialExitsPayloadType = new
|
|
18189
|
-
partial_exits: new
|
|
18190
|
-
new
|
|
18191
|
-
public_key: new
|
|
18192
|
-
signed_exit_message: new
|
|
18193
|
-
message: new
|
|
18194
|
-
epoch: new
|
|
18195
|
-
validator_index: new
|
|
18671
|
+
var SSZPartialExitsPayloadType = new import_ssz9.ContainerType({
|
|
18672
|
+
partial_exits: new import_ssz9.ListCompositeType(
|
|
18673
|
+
new import_ssz9.ContainerType({
|
|
18674
|
+
public_key: new import_ssz9.ByteVectorType(48),
|
|
18675
|
+
signed_exit_message: new import_ssz9.ContainerType({
|
|
18676
|
+
message: new import_ssz9.ContainerType({
|
|
18677
|
+
epoch: new import_ssz9.UintNumberType(8),
|
|
18678
|
+
validator_index: new import_ssz9.UintNumberType(8)
|
|
18196
18679
|
}),
|
|
18197
|
-
signature: new
|
|
18680
|
+
signature: new import_ssz9.ByteVectorType(96)
|
|
18198
18681
|
})
|
|
18199
18682
|
}),
|
|
18200
18683
|
65536
|
|
18201
18684
|
),
|
|
18202
|
-
share_idx: new
|
|
18685
|
+
share_idx: new import_ssz9.UintNumberType(8)
|
|
18203
18686
|
});
|
|
18204
18687
|
var Exit = class _Exit {
|
|
18205
18688
|
/**
|
|
@@ -18242,7 +18725,7 @@ var Exit = class _Exit {
|
|
|
18242
18725
|
static computeExitPayloadRoot(exits) {
|
|
18243
18726
|
const sszValue = SSZPartialExitsPayloadType.defaultValue();
|
|
18244
18727
|
sszValue.partial_exits = exits.partial_exits.map((pe) => ({
|
|
18245
|
-
public_key: (0,
|
|
18728
|
+
public_key: (0, import_ssz9.fromHexString)(pe.public_key),
|
|
18246
18729
|
signed_exit_message: {
|
|
18247
18730
|
message: {
|
|
18248
18731
|
epoch: _Exit.safeParseInt(pe.signed_exit_message.message.epoch),
|
|
@@ -18250,7 +18733,7 @@ var Exit = class _Exit {
|
|
|
18250
18733
|
pe.signed_exit_message.message.validator_index
|
|
18251
18734
|
)
|
|
18252
18735
|
},
|
|
18253
|
-
signature: (0,
|
|
18736
|
+
signature: (0, import_ssz9.fromHexString)(pe.signed_exit_message.signature)
|
|
18254
18737
|
}
|
|
18255
18738
|
}));
|
|
18256
18739
|
sszValue.share_idx = exits.share_idx;
|
|
@@ -18300,18 +18783,18 @@ var Exit = class _Exit {
|
|
|
18300
18783
|
signedExitMessage.message
|
|
18301
18784
|
);
|
|
18302
18785
|
const exitDomain = computeDomain2(
|
|
18303
|
-
(0,
|
|
18786
|
+
(0, import_ssz9.fromHexString)(DOMAIN_VOLUNTARY_EXIT),
|
|
18304
18787
|
capellaForkVersionString,
|
|
18305
|
-
(0,
|
|
18788
|
+
(0, import_ssz9.fromHexString)(genesisValidatorsRootString)
|
|
18306
18789
|
);
|
|
18307
18790
|
const messageSigningRoot = signingRoot2(
|
|
18308
18791
|
exitDomain,
|
|
18309
18792
|
partialExitMessageBuffer
|
|
18310
18793
|
);
|
|
18311
18794
|
return blsVerify(
|
|
18312
|
-
(0,
|
|
18795
|
+
(0, import_ssz9.fromHexString)(publicShareKey),
|
|
18313
18796
|
messageSigningRoot,
|
|
18314
|
-
(0,
|
|
18797
|
+
(0, import_ssz9.fromHexString)(signedExitMessage.signature)
|
|
18315
18798
|
);
|
|
18316
18799
|
});
|
|
18317
18800
|
}
|
|
@@ -18614,7 +19097,7 @@ var Exit = class _Exit {
|
|
|
18614
19097
|
);
|
|
18615
19098
|
}
|
|
18616
19099
|
try {
|
|
18617
|
-
const sigBytes = (0,
|
|
19100
|
+
const sigBytes = (0, import_ssz9.fromHexString)(cleanSigStr);
|
|
18618
19101
|
const sigIdx = parseInt(sigIdxStr, 10);
|
|
18619
19102
|
signaturesByIndex.set(sigIdx + 1, sigBytes);
|
|
18620
19103
|
} catch (err) {
|
|
@@ -19358,8 +19841,9 @@ var EOA = class {
|
|
|
19358
19841
|
// src/services.ts
|
|
19359
19842
|
var validateClusterLock = (lock, safeRpcUrl) => __async(null, null, function* () {
|
|
19360
19843
|
try {
|
|
19361
|
-
const
|
|
19362
|
-
return
|
|
19844
|
+
const inWorker = yield validateClusterLockInWorker(lock, safeRpcUrl);
|
|
19845
|
+
if (inWorker !== null) return inWorker;
|
|
19846
|
+
return yield isValidClusterLock(lock, safeRpcUrl);
|
|
19363
19847
|
} catch (err) {
|
|
19364
19848
|
throw err;
|
|
19365
19849
|
}
|
|
@@ -19959,6 +20443,7 @@ var Client = class extends Base {
|
|
|
19959
20443
|
CONFIG_VERSION,
|
|
19960
20444
|
CONFLICT_ERROR_MSG,
|
|
19961
20445
|
Client,
|
|
20446
|
+
ClusterLockValidationTimeoutError,
|
|
19962
20447
|
ConflictError,
|
|
19963
20448
|
CreatorConfigHashSigningTypes,
|
|
19964
20449
|
CreatorTypedMessage,
|
|
@@ -19999,8 +20484,13 @@ var Client = class extends Base {
|
|
|
19999
20484
|
TermsAndConditionsSigningTypes,
|
|
20000
20485
|
UnsupportedChainError,
|
|
20001
20486
|
blsVerify,
|
|
20487
|
+
builderBlsCheck,
|
|
20488
|
+
builderDomainForFork,
|
|
20002
20489
|
clusterConfigOrDefinitionHash,
|
|
20003
20490
|
clusterLockHash,
|
|
20491
|
+
depositBlsCheck,
|
|
20492
|
+
depositDomainForFork,
|
|
20493
|
+
hasUniqueDistributedKeys,
|
|
20004
20494
|
isChainSupportedForSplitters,
|
|
20005
20495
|
isValidClusterLock,
|
|
20006
20496
|
signCreatorConfigHashPayload,
|
|
@@ -20009,6 +20499,7 @@ var Client = class extends Base {
|
|
|
20009
20499
|
signingRoot,
|
|
20010
20500
|
validateAddressSignature,
|
|
20011
20501
|
validateClusterLock,
|
|
20502
|
+
validateDepositDataStructure,
|
|
20012
20503
|
validateEOASignature,
|
|
20013
20504
|
validateSmartContractSignature,
|
|
20014
20505
|
verifyBuilderRegistration,
|