@obolnetwork/obol-sdk 2.11.13 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/src/index.js +445 -134
- package/dist/browser/src/index.js.map +1 -1
- package/dist/cjs/src/blsUtils.js +3826 -0
- package/dist/cjs/src/blsUtils.js.map +1 -0
- package/dist/cjs/src/index.js +528 -222
- package/dist/cjs/src/index.js.map +1 -1
- package/dist/cjs/src/verification/lockWorker.js +3828 -0
- package/dist/cjs/src/verification/lockWorker.js.map +1 -0
- package/dist/cjs/src/verification/parallelPool.js +3992 -0
- package/dist/cjs/src/verification/parallelPool.js.map +1 -0
- package/dist/esm/src/blsUtils.js +17 -0
- package/dist/esm/src/blsUtils.js.map +1 -0
- package/dist/esm/src/chunk-267HIPEB.js +4355 -0
- package/dist/esm/src/chunk-267HIPEB.js.map +1 -0
- package/dist/esm/src/chunk-OYZHSNKR.js +186 -0
- package/dist/esm/src/chunk-OYZHSNKR.js.map +1 -0
- package/dist/esm/src/index.js +834 -5000
- package/dist/esm/src/index.js.map +1 -1
- package/dist/esm/src/verification/lockWorker.js +50 -0
- package/dist/esm/src/verification/lockWorker.js.map +1 -0
- package/dist/esm/src/verification/parallelPool.js +10 -0
- package/dist/esm/src/verification/parallelPool.js.map +1 -0
- package/dist/types/src/blsUtils.d.ts +2 -0
- package/dist/types/src/verification/common.d.ts +9 -0
- package/dist/types/src/verification/lockWorker.d.ts +13 -0
- package/dist/types/src/verification/parallelPool.d.ts +2 -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
|
@@ -156,6 +156,7 @@ __export(index_exports, {
|
|
|
156
156
|
blsVerify: () => blsVerify,
|
|
157
157
|
clusterConfigOrDefinitionHash: () => clusterConfigOrDefinitionHash,
|
|
158
158
|
clusterLockHash: () => clusterLockHash,
|
|
159
|
+
hasUniqueDistributedKeys: () => hasUniqueDistributedKeys,
|
|
159
160
|
isChainSupportedForSplitters: () => isChainSupportedForSplitters,
|
|
160
161
|
isValidClusterLock: () => isValidClusterLock,
|
|
161
162
|
signCreatorConfigHashPayload: () => signCreatorConfigHashPayload,
|
|
@@ -176,7 +177,7 @@ var import_uuid = require("uuid");
|
|
|
176
177
|
// package.json
|
|
177
178
|
var package_default = {
|
|
178
179
|
name: "@obolnetwork/obol-sdk",
|
|
179
|
-
version: "2.
|
|
180
|
+
version: "2.12.0",
|
|
180
181
|
description: "A package for creating Distributed Validators using the Obol API.",
|
|
181
182
|
bugs: {
|
|
182
183
|
url: "https://github.com/obolnetwork/obol-sdk/issues"
|
|
@@ -662,7 +663,7 @@ var UnsupportedChainError = class _UnsupportedChainError extends Error {
|
|
|
662
663
|
};
|
|
663
664
|
|
|
664
665
|
// src/verification/common.ts
|
|
665
|
-
var
|
|
666
|
+
var import_ssz7 = require("@chainsafe/ssz");
|
|
666
667
|
var import_elliptic = __toESM(require("elliptic"));
|
|
667
668
|
var semver = __toESM(require("semver"));
|
|
668
669
|
|
|
@@ -777,7 +778,7 @@ var signingRootType = new import_ssz.ContainerType({
|
|
|
777
778
|
});
|
|
778
779
|
|
|
779
780
|
// src/verification/v1.6.0.ts
|
|
780
|
-
var
|
|
781
|
+
var import_ssz3 = require("@chainsafe/ssz");
|
|
781
782
|
|
|
782
783
|
// node_modules/@noble/curves/node_modules/@noble/hashes/utils.js
|
|
783
784
|
function isBytes(a) {
|
|
@@ -4959,28 +4960,248 @@ function blsVerifyMultiple(pubkeys, messages, signature) {
|
|
|
4959
4960
|
function blsAggregateSignatures(signatures) {
|
|
4960
4961
|
return ls.Signature.toBytes(ls.aggregateSignatures(signatures));
|
|
4961
4962
|
}
|
|
4963
|
+
function lagrangeCoeffAtZero(shareIndex, indices) {
|
|
4964
|
+
const { Fr } = bls12_381.fields;
|
|
4965
|
+
let num = BigInt(1);
|
|
4966
|
+
let den = BigInt(1);
|
|
4967
|
+
for (const j of indices) {
|
|
4968
|
+
if (j === shareIndex) continue;
|
|
4969
|
+
num = Fr.mul(num, Fr.neg(j));
|
|
4970
|
+
den = Fr.mul(den, Fr.sub(shareIndex, j));
|
|
4971
|
+
}
|
|
4972
|
+
return Fr.mul(num, Fr.inv(den));
|
|
4973
|
+
}
|
|
4974
|
+
function blsRecoverWithIndices(shares, indices) {
|
|
4975
|
+
try {
|
|
4976
|
+
let recovered = bls12_381.G1.Point.ZERO;
|
|
4977
|
+
for (let i = 0; i < shares.length; i++) {
|
|
4978
|
+
const point = bls12_381.G1.Point.fromBytes(shares[i]);
|
|
4979
|
+
const coeff = lagrangeCoeffAtZero(indices[i], indices);
|
|
4980
|
+
recovered = recovered.add(point.multiply(coeff));
|
|
4981
|
+
}
|
|
4982
|
+
return recovered.toBytes();
|
|
4983
|
+
} catch (e) {
|
|
4984
|
+
return null;
|
|
4985
|
+
}
|
|
4986
|
+
}
|
|
4987
|
+
function blsRecoverDistributedPubkeyFromShares(pubshares, threshold) {
|
|
4988
|
+
if (threshold <= 0 || pubshares.length < threshold) return null;
|
|
4989
|
+
const selected = pubshares.slice(0, threshold);
|
|
4990
|
+
const indices = selected.map((_, i) => BigInt(i + 1));
|
|
4991
|
+
return blsRecoverWithIndices(selected, indices);
|
|
4992
|
+
}
|
|
4993
|
+
function blsVerifyExtraShares(pubshares, threshold, distributedPubkey) {
|
|
4994
|
+
if (threshold <= 0 || pubshares.length < threshold) return false;
|
|
4995
|
+
try {
|
|
4996
|
+
const baseShares = pubshares.slice(0, threshold - 1);
|
|
4997
|
+
const baseIndices = baseShares.map((_, i) => BigInt(i + 1));
|
|
4998
|
+
for (let i = threshold; i < pubshares.length; i++) {
|
|
4999
|
+
const shares = [...baseShares, pubshares[i]];
|
|
5000
|
+
const indices = [...baseIndices, BigInt(i + 1)];
|
|
5001
|
+
const recovered = blsRecoverWithIndices(shares, indices);
|
|
5002
|
+
if (!recovered || recovered.length !== distributedPubkey.length || !recovered.every((b, j) => b === distributedPubkey[j])) {
|
|
5003
|
+
return false;
|
|
5004
|
+
}
|
|
5005
|
+
}
|
|
5006
|
+
return true;
|
|
5007
|
+
} catch (e) {
|
|
5008
|
+
return false;
|
|
5009
|
+
}
|
|
5010
|
+
}
|
|
5011
|
+
|
|
5012
|
+
// src/verification/parallelPool.ts
|
|
5013
|
+
var import_ssz2 = require("@chainsafe/ssz");
|
|
5014
|
+
var MIN_PARALLEL_VALIDATORS = 50;
|
|
5015
|
+
var MIN_PARALLEL_BATCH_PAIRS = 100;
|
|
5016
|
+
var MAX_WORKERS = 8;
|
|
5017
|
+
var MIN_VALIDATORS_PER_WORKER = 25;
|
|
5018
|
+
var MIN_PAIRS_PER_WORKER = 50;
|
|
5019
|
+
var WORKER_TIMEOUT_MS = 6e4;
|
|
5020
|
+
var workerThreadsCache;
|
|
5021
|
+
var osCache;
|
|
5022
|
+
var workerPathCache;
|
|
5023
|
+
function loadWorkerThreads() {
|
|
5024
|
+
if (workerThreadsCache !== void 0) return workerThreadsCache;
|
|
5025
|
+
try {
|
|
5026
|
+
workerThreadsCache = require("worker_threads");
|
|
5027
|
+
} catch (e) {
|
|
5028
|
+
workerThreadsCache = null;
|
|
5029
|
+
}
|
|
5030
|
+
return workerThreadsCache;
|
|
5031
|
+
}
|
|
5032
|
+
function loadOs() {
|
|
5033
|
+
if (osCache !== void 0) return osCache;
|
|
5034
|
+
try {
|
|
5035
|
+
osCache = require("os");
|
|
5036
|
+
} catch (e) {
|
|
5037
|
+
osCache = null;
|
|
5038
|
+
}
|
|
5039
|
+
return osCache;
|
|
5040
|
+
}
|
|
5041
|
+
function getWorkerPath() {
|
|
5042
|
+
if (workerPathCache !== void 0) return workerPathCache;
|
|
5043
|
+
if (typeof __dirname === "undefined") return workerPathCache = null;
|
|
5044
|
+
const path = require("path");
|
|
5045
|
+
const candidate = path.join(__dirname, "lockWorker.js");
|
|
5046
|
+
try {
|
|
5047
|
+
const fs = require("fs");
|
|
5048
|
+
if (!fs.existsSync(candidate)) return workerPathCache = null;
|
|
5049
|
+
} catch (e) {
|
|
5050
|
+
return workerPathCache = null;
|
|
5051
|
+
}
|
|
5052
|
+
return workerPathCache = candidate;
|
|
5053
|
+
}
|
|
5054
|
+
function chunkArrays(arr, n) {
|
|
5055
|
+
const size = Math.ceil(arr.length / n);
|
|
5056
|
+
const out = [];
|
|
5057
|
+
for (let i = 0; i < arr.length; i += size) {
|
|
5058
|
+
out.push(arr.slice(i, i + size));
|
|
5059
|
+
}
|
|
5060
|
+
return out;
|
|
5061
|
+
}
|
|
5062
|
+
function verifySharesSync(shares, distributedKeys, threshold) {
|
|
5063
|
+
for (let i = 0; i < shares.length; i++) {
|
|
5064
|
+
const sharesBytes = shares[i].map((s) => (0, import_ssz2.fromHexString)(s));
|
|
5065
|
+
const dkBytes = (0, import_ssz2.fromHexString)(distributedKeys[i]);
|
|
5066
|
+
const recovered = blsRecoverDistributedPubkeyFromShares(
|
|
5067
|
+
sharesBytes,
|
|
5068
|
+
threshold
|
|
5069
|
+
);
|
|
5070
|
+
if (!recovered) return false;
|
|
5071
|
+
if (recovered.length !== dkBytes.length) return false;
|
|
5072
|
+
for (let j = 0; j < recovered.length; j++) {
|
|
5073
|
+
if (recovered[j] !== dkBytes[j]) return false;
|
|
5074
|
+
}
|
|
5075
|
+
if (!blsVerifyExtraShares(sharesBytes, threshold, dkBytes)) {
|
|
5076
|
+
return false;
|
|
5077
|
+
}
|
|
5078
|
+
}
|
|
5079
|
+
return true;
|
|
5080
|
+
}
|
|
5081
|
+
function runWorker(wt, workerFile, data) {
|
|
5082
|
+
return __async(this, null, function* () {
|
|
5083
|
+
return yield new Promise((resolve) => {
|
|
5084
|
+
let settled = false;
|
|
5085
|
+
const worker = new wt.Worker(workerFile, { workerData: data });
|
|
5086
|
+
const finish = (result) => {
|
|
5087
|
+
if (settled) return;
|
|
5088
|
+
settled = true;
|
|
5089
|
+
clearTimeout(timer);
|
|
5090
|
+
worker.terminate();
|
|
5091
|
+
resolve(result);
|
|
5092
|
+
};
|
|
5093
|
+
const timer = setTimeout(() => {
|
|
5094
|
+
finish(false);
|
|
5095
|
+
}, WORKER_TIMEOUT_MS);
|
|
5096
|
+
worker.once("message", (msg) => {
|
|
5097
|
+
finish(msg === true);
|
|
5098
|
+
});
|
|
5099
|
+
worker.once("error", () => {
|
|
5100
|
+
finish(false);
|
|
5101
|
+
});
|
|
5102
|
+
worker.once("exit", (code2) => {
|
|
5103
|
+
if (code2 !== 0) finish(false);
|
|
5104
|
+
});
|
|
5105
|
+
});
|
|
5106
|
+
});
|
|
5107
|
+
}
|
|
5108
|
+
function poolSize(itemCount, minPerWorker) {
|
|
5109
|
+
const wt = loadWorkerThreads();
|
|
5110
|
+
const os = loadOs();
|
|
5111
|
+
const workerFile = getWorkerPath();
|
|
5112
|
+
const numCpus = os ? os.cpus().length : 1;
|
|
5113
|
+
const numWorkers = Math.min(
|
|
5114
|
+
MAX_WORKERS,
|
|
5115
|
+
Math.max(1, Math.floor(itemCount / minPerWorker)),
|
|
5116
|
+
numCpus
|
|
5117
|
+
);
|
|
5118
|
+
return { numWorkers, wt, workerFile };
|
|
5119
|
+
}
|
|
5120
|
+
function verifySharesBinding(shares, distributedKeys, threshold) {
|
|
5121
|
+
return __async(this, null, function* () {
|
|
5122
|
+
if (shares.length !== distributedKeys.length) return false;
|
|
5123
|
+
if (shares.length === 0) return true;
|
|
5124
|
+
const { numWorkers, wt, workerFile } = poolSize(
|
|
5125
|
+
shares.length,
|
|
5126
|
+
MIN_VALIDATORS_PER_WORKER
|
|
5127
|
+
);
|
|
5128
|
+
if (wt === null || workerFile === null || shares.length < MIN_PARALLEL_VALIDATORS || numWorkers < 2) {
|
|
5129
|
+
return verifySharesSync(shares, distributedKeys, threshold);
|
|
5130
|
+
}
|
|
5131
|
+
const shareChunks = chunkArrays(shares, numWorkers);
|
|
5132
|
+
const keyChunks = chunkArrays(distributedKeys, numWorkers);
|
|
5133
|
+
const results = yield Promise.all(
|
|
5134
|
+
shareChunks.map(
|
|
5135
|
+
(chunk, i) => __async(null, null, function* () {
|
|
5136
|
+
return yield runWorker(wt, workerFile, {
|
|
5137
|
+
mode: "shareBinding",
|
|
5138
|
+
shares: chunk,
|
|
5139
|
+
distributedKeys: keyChunks[i],
|
|
5140
|
+
threshold
|
|
5141
|
+
});
|
|
5142
|
+
})
|
|
5143
|
+
)
|
|
5144
|
+
);
|
|
5145
|
+
return results.every(Boolean);
|
|
5146
|
+
});
|
|
5147
|
+
}
|
|
5148
|
+
function verifyBatchParallel(pubkeys, messages, signatures) {
|
|
5149
|
+
return __async(this, null, function* () {
|
|
5150
|
+
if (pubkeys.length !== messages.length || pubkeys.length !== signatures.length) {
|
|
5151
|
+
return false;
|
|
5152
|
+
}
|
|
5153
|
+
if (pubkeys.length === 0) return true;
|
|
5154
|
+
const { numWorkers, wt, workerFile } = poolSize(
|
|
5155
|
+
pubkeys.length,
|
|
5156
|
+
MIN_PAIRS_PER_WORKER
|
|
5157
|
+
);
|
|
5158
|
+
if (wt === null || workerFile === null || pubkeys.length < MIN_PARALLEL_BATCH_PAIRS || numWorkers < 2) {
|
|
5159
|
+
return blsVerifyMultiple(
|
|
5160
|
+
pubkeys,
|
|
5161
|
+
messages,
|
|
5162
|
+
blsAggregateSignatures(signatures)
|
|
5163
|
+
);
|
|
5164
|
+
}
|
|
5165
|
+
const pkChunks = chunkArrays(pubkeys, numWorkers);
|
|
5166
|
+
const msgChunks = chunkArrays(messages, numWorkers);
|
|
5167
|
+
const sigChunks = chunkArrays(signatures, numWorkers);
|
|
5168
|
+
const results = yield Promise.all(
|
|
5169
|
+
pkChunks.map(
|
|
5170
|
+
(pks, i) => __async(null, null, function* () {
|
|
5171
|
+
return yield runWorker(wt, workerFile, {
|
|
5172
|
+
mode: "verifyBatch",
|
|
5173
|
+
pubkeys: pks,
|
|
5174
|
+
messages: msgChunks[i],
|
|
5175
|
+
aggregateSignature: blsAggregateSignatures(sigChunks[i])
|
|
5176
|
+
});
|
|
5177
|
+
})
|
|
5178
|
+
)
|
|
5179
|
+
);
|
|
5180
|
+
return results.every(Boolean);
|
|
5181
|
+
});
|
|
5182
|
+
}
|
|
4962
5183
|
|
|
4963
5184
|
// src/verification/v1.6.0.ts
|
|
4964
5185
|
var clusterDefinitionContainerTypeV1X6 = (configOnly) => {
|
|
4965
5186
|
let returnedContainerType = {
|
|
4966
|
-
uuid: new
|
|
4967
|
-
name: new
|
|
4968
|
-
version: new
|
|
4969
|
-
timestamp: new
|
|
5187
|
+
uuid: new import_ssz3.ByteListType(64),
|
|
5188
|
+
name: new import_ssz3.ByteListType(256),
|
|
5189
|
+
version: new import_ssz3.ByteListType(16),
|
|
5190
|
+
timestamp: new import_ssz3.ByteListType(32),
|
|
4970
5191
|
num_validators: new import_uint.UintNumberType(8),
|
|
4971
5192
|
threshold: new import_uint.UintNumberType(8),
|
|
4972
|
-
dkg_algorithm: new
|
|
4973
|
-
fork_version: new
|
|
4974
|
-
operators: new
|
|
5193
|
+
dkg_algorithm: new import_ssz3.ByteListType(32),
|
|
5194
|
+
fork_version: new import_ssz3.ByteVectorType(4),
|
|
5195
|
+
operators: new import_ssz3.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
4975
5196
|
creator: newCreatorContainerType(configOnly),
|
|
4976
|
-
validators: new
|
|
5197
|
+
validators: new import_ssz3.ListCompositeType(validatorsContainerType, 65536)
|
|
4977
5198
|
};
|
|
4978
5199
|
if (!configOnly) {
|
|
4979
5200
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
4980
|
-
config_hash: new
|
|
5201
|
+
config_hash: new import_ssz3.ByteVectorType(32)
|
|
4981
5202
|
});
|
|
4982
5203
|
}
|
|
4983
|
-
return new
|
|
5204
|
+
return new import_ssz3.ContainerType(returnedContainerType);
|
|
4984
5205
|
};
|
|
4985
5206
|
var hashClusterDefinitionV1X6 = (cluster, configOnly) => {
|
|
4986
5207
|
const definitionType = clusterDefinitionContainerTypeV1X6(configOnly);
|
|
@@ -4992,44 +5213,44 @@ var hashClusterDefinitionV1X6 = (cluster, configOnly) => {
|
|
|
4992
5213
|
val.num_validators = cluster.num_validators;
|
|
4993
5214
|
val.threshold = cluster.threshold;
|
|
4994
5215
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
4995
|
-
val.fork_version = (0,
|
|
5216
|
+
val.fork_version = (0, import_ssz3.fromHexString)(cluster.fork_version);
|
|
4996
5217
|
val.operators = cluster.operators.map((operator) => {
|
|
4997
|
-
return configOnly ? { address: (0,
|
|
4998
|
-
address: (0,
|
|
5218
|
+
return configOnly ? { address: (0, import_ssz3.fromHexString)(operator.address) } : {
|
|
5219
|
+
address: (0, import_ssz3.fromHexString)(operator.address),
|
|
4999
5220
|
enr: strToUint8Array(operator.enr),
|
|
5000
|
-
config_signature: (0,
|
|
5001
|
-
enr_signature: (0,
|
|
5221
|
+
config_signature: (0, import_ssz3.fromHexString)(operator.config_signature),
|
|
5222
|
+
enr_signature: (0, import_ssz3.fromHexString)(operator.enr_signature)
|
|
5002
5223
|
};
|
|
5003
5224
|
});
|
|
5004
|
-
val.creator = configOnly ? { address: (0,
|
|
5005
|
-
address: (0,
|
|
5006
|
-
config_signature: (0,
|
|
5225
|
+
val.creator = configOnly ? { address: (0, import_ssz3.fromHexString)(cluster.creator.address) } : {
|
|
5226
|
+
address: (0, import_ssz3.fromHexString)(cluster.creator.address),
|
|
5227
|
+
config_signature: (0, import_ssz3.fromHexString)(
|
|
5007
5228
|
cluster.creator.config_signature
|
|
5008
5229
|
)
|
|
5009
5230
|
};
|
|
5010
5231
|
val.validators = cluster.validators.map((validator) => {
|
|
5011
5232
|
return {
|
|
5012
|
-
fee_recipient_address: (0,
|
|
5013
|
-
withdrawal_address: (0,
|
|
5233
|
+
fee_recipient_address: (0, import_ssz3.fromHexString)(validator.fee_recipient_address),
|
|
5234
|
+
withdrawal_address: (0, import_ssz3.fromHexString)(validator.withdrawal_address)
|
|
5014
5235
|
};
|
|
5015
5236
|
});
|
|
5016
5237
|
if (!configOnly) {
|
|
5017
|
-
val.config_hash = (0,
|
|
5238
|
+
val.config_hash = (0, import_ssz3.fromHexString)(cluster.config_hash);
|
|
5018
5239
|
}
|
|
5019
5240
|
return val;
|
|
5020
5241
|
};
|
|
5021
|
-
var dvContainerTypeV1X6 = new
|
|
5022
|
-
distributed_public_key: new
|
|
5023
|
-
public_shares: new
|
|
5024
|
-
pubkey: new
|
|
5025
|
-
withdrawal_credentials: new
|
|
5242
|
+
var dvContainerTypeV1X6 = new import_ssz3.ContainerType({
|
|
5243
|
+
distributed_public_key: new import_ssz3.ByteVectorType(48),
|
|
5244
|
+
public_shares: new import_ssz3.ListCompositeType(new import_ssz3.ByteVectorType(48), 256),
|
|
5245
|
+
pubkey: new import_ssz3.ByteVectorType(48),
|
|
5246
|
+
withdrawal_credentials: new import_ssz3.ByteVectorType(32),
|
|
5026
5247
|
amount: new import_uint.UintNumberType(8),
|
|
5027
|
-
signature: new
|
|
5248
|
+
signature: new import_ssz3.ByteVectorType(96)
|
|
5028
5249
|
});
|
|
5029
5250
|
var clusterLockContainerTypeV1X6 = () => {
|
|
5030
|
-
return new
|
|
5251
|
+
return new import_ssz3.ContainerType({
|
|
5031
5252
|
cluster_definition: clusterDefinitionContainerTypeV1X6(false),
|
|
5032
|
-
distributed_validators: new
|
|
5253
|
+
distributed_validators: new import_ssz3.ListCompositeType(dvContainerTypeV1X6, 65536)
|
|
5033
5254
|
});
|
|
5034
5255
|
};
|
|
5035
5256
|
var hashClusterLockV1X6 = (cluster) => {
|
|
@@ -5043,18 +5264,18 @@ var hashClusterLockV1X6 = (cluster) => {
|
|
|
5043
5264
|
(dValidator) => {
|
|
5044
5265
|
var _a6, _b2, _c, _d;
|
|
5045
5266
|
return {
|
|
5046
|
-
distributed_public_key: (0,
|
|
5267
|
+
distributed_public_key: (0, import_ssz3.fromHexString)(
|
|
5047
5268
|
dValidator.distributed_public_key
|
|
5048
5269
|
),
|
|
5049
5270
|
public_shares: dValidator.public_shares.map(
|
|
5050
|
-
(publicShare) => (0,
|
|
5271
|
+
(publicShare) => (0, import_ssz3.fromHexString)(publicShare)
|
|
5051
5272
|
),
|
|
5052
|
-
pubkey: (0,
|
|
5053
|
-
withdrawal_credentials: (0,
|
|
5273
|
+
pubkey: (0, import_ssz3.fromHexString)((_a6 = dValidator.deposit_data) == null ? void 0 : _a6.pubkey),
|
|
5274
|
+
withdrawal_credentials: (0, import_ssz3.fromHexString)(
|
|
5054
5275
|
(_b2 = dValidator.deposit_data) == null ? void 0 : _b2.withdrawal_credentials
|
|
5055
5276
|
),
|
|
5056
5277
|
amount: parseInt((_c = dValidator.deposit_data) == null ? void 0 : _c.amount),
|
|
5057
|
-
signature: (0,
|
|
5278
|
+
signature: (0, import_ssz3.fromHexString)((_d = dValidator.deposit_data) == null ? void 0 : _d.signature)
|
|
5058
5279
|
};
|
|
5059
5280
|
}
|
|
5060
5281
|
);
|
|
@@ -5063,6 +5284,22 @@ var hashClusterLockV1X6 = (cluster) => {
|
|
|
5063
5284
|
var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
5064
5285
|
var _a6;
|
|
5065
5286
|
const validators = clusterLock.distributed_validators;
|
|
5287
|
+
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
5288
|
+
const threshold = clusterLock.cluster_definition.threshold;
|
|
5289
|
+
for (const validator of validators) {
|
|
5290
|
+
if (validator.public_shares.length !== operatorCount) {
|
|
5291
|
+
return false;
|
|
5292
|
+
}
|
|
5293
|
+
const uniqueShareCount = new Set(validator.public_shares).size;
|
|
5294
|
+
if (uniqueShareCount !== validator.public_shares.length) {
|
|
5295
|
+
return false;
|
|
5296
|
+
}
|
|
5297
|
+
}
|
|
5298
|
+
const allShares = validators.map((v) => v.public_shares);
|
|
5299
|
+
const allDKs = validators.map((v) => v.distributed_public_key);
|
|
5300
|
+
if (!(yield verifySharesBinding(allShares, allDKs, threshold))) {
|
|
5301
|
+
return false;
|
|
5302
|
+
}
|
|
5066
5303
|
const pubShares = [];
|
|
5067
5304
|
const pubKeys = [];
|
|
5068
5305
|
const builderRegistrationAndDepositDataMessages = [];
|
|
@@ -5071,8 +5308,18 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5071
5308
|
const validator = validators[i];
|
|
5072
5309
|
const validatorPublicShares = validator.public_shares;
|
|
5073
5310
|
const distributedPublicKey = validator.distributed_public_key;
|
|
5074
|
-
|
|
5075
|
-
|
|
5311
|
+
if (validatorPublicShares.length !== operatorCount) {
|
|
5312
|
+
return false;
|
|
5313
|
+
}
|
|
5314
|
+
const normalizedShares = validatorPublicShares.map((s) => s.toLowerCase());
|
|
5315
|
+
if (new Set(normalizedShares).size !== normalizedShares.length) {
|
|
5316
|
+
return false;
|
|
5317
|
+
}
|
|
5318
|
+
const validatorPublicSharesBytes = validatorPublicShares.map(
|
|
5319
|
+
(share) => (0, import_ssz3.fromHexString)(share)
|
|
5320
|
+
);
|
|
5321
|
+
for (const share of validatorPublicSharesBytes) {
|
|
5322
|
+
pubShares.push(share);
|
|
5076
5323
|
}
|
|
5077
5324
|
const { isValidDepositData, depositDataMsg } = verifyDepositData(
|
|
5078
5325
|
distributedPublicKey,
|
|
@@ -5083,24 +5330,23 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5083
5330
|
if (!isValidDepositData) {
|
|
5084
5331
|
return false;
|
|
5085
5332
|
}
|
|
5086
|
-
pubKeys.push((0,
|
|
5333
|
+
pubKeys.push((0, import_ssz3.fromHexString)(validator.distributed_public_key));
|
|
5087
5334
|
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5088
5335
|
blsSignatures.push(
|
|
5089
|
-
(0,
|
|
5336
|
+
(0, import_ssz3.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5090
5337
|
);
|
|
5091
5338
|
}
|
|
5092
|
-
|
|
5093
|
-
if (!blsVerifyMultiple(
|
|
5339
|
+
if (!(yield verifyBatchParallel(
|
|
5094
5340
|
pubKeys,
|
|
5095
5341
|
builderRegistrationAndDepositDataMessages,
|
|
5096
|
-
|
|
5097
|
-
)) {
|
|
5342
|
+
blsSignatures
|
|
5343
|
+
))) {
|
|
5098
5344
|
return false;
|
|
5099
5345
|
}
|
|
5100
5346
|
if (!blsVerifyAggregate(
|
|
5101
5347
|
pubShares,
|
|
5102
|
-
(0,
|
|
5103
|
-
(0,
|
|
5348
|
+
(0, import_ssz3.fromHexString)(clusterLock.lock_hash),
|
|
5349
|
+
(0, import_ssz3.fromHexString)(clusterLock.signature_aggregate)
|
|
5104
5350
|
)) {
|
|
5105
5351
|
return false;
|
|
5106
5352
|
}
|
|
@@ -5109,27 +5355,27 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5109
5355
|
|
|
5110
5356
|
// src/verification/v1.7.0.ts
|
|
5111
5357
|
var import_uint2 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
5112
|
-
var
|
|
5358
|
+
var import_ssz4 = require("@chainsafe/ssz");
|
|
5113
5359
|
var clusterDefinitionContainerTypeV1X7 = (configOnly) => {
|
|
5114
5360
|
let returnedContainerType = {
|
|
5115
|
-
uuid: new
|
|
5116
|
-
name: new
|
|
5117
|
-
version: new
|
|
5118
|
-
timestamp: new
|
|
5361
|
+
uuid: new import_ssz4.ByteListType(64),
|
|
5362
|
+
name: new import_ssz4.ByteListType(256),
|
|
5363
|
+
version: new import_ssz4.ByteListType(16),
|
|
5364
|
+
timestamp: new import_ssz4.ByteListType(32),
|
|
5119
5365
|
num_validators: new import_uint2.UintNumberType(8),
|
|
5120
5366
|
threshold: new import_uint2.UintNumberType(8),
|
|
5121
|
-
dkg_algorithm: new
|
|
5122
|
-
fork_version: new
|
|
5123
|
-
operators: new
|
|
5367
|
+
dkg_algorithm: new import_ssz4.ByteListType(32),
|
|
5368
|
+
fork_version: new import_ssz4.ByteVectorType(4),
|
|
5369
|
+
operators: new import_ssz4.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
5124
5370
|
creator: newCreatorContainerType(configOnly),
|
|
5125
|
-
validators: new
|
|
5371
|
+
validators: new import_ssz4.ListCompositeType(validatorsContainerType, 65536)
|
|
5126
5372
|
};
|
|
5127
5373
|
if (!configOnly) {
|
|
5128
5374
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
5129
|
-
config_hash: new
|
|
5375
|
+
config_hash: new import_ssz4.ByteVectorType(32)
|
|
5130
5376
|
});
|
|
5131
5377
|
}
|
|
5132
|
-
return new
|
|
5378
|
+
return new import_ssz4.ContainerType(returnedContainerType);
|
|
5133
5379
|
};
|
|
5134
5380
|
var hashClusterDefinitionV1X7 = (cluster, configOnly) => {
|
|
5135
5381
|
const definitionType = clusterDefinitionContainerTypeV1X7(configOnly);
|
|
@@ -5141,42 +5387,42 @@ var hashClusterDefinitionV1X7 = (cluster, configOnly) => {
|
|
|
5141
5387
|
val.num_validators = cluster.num_validators;
|
|
5142
5388
|
val.threshold = cluster.threshold;
|
|
5143
5389
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
5144
|
-
val.fork_version = (0,
|
|
5390
|
+
val.fork_version = (0, import_ssz4.fromHexString)(cluster.fork_version);
|
|
5145
5391
|
val.operators = cluster.operators.map((operator) => {
|
|
5146
|
-
return configOnly ? { address: (0,
|
|
5147
|
-
address: (0,
|
|
5392
|
+
return configOnly ? { address: (0, import_ssz4.fromHexString)(operator.address) } : {
|
|
5393
|
+
address: (0, import_ssz4.fromHexString)(operator.address),
|
|
5148
5394
|
enr: strToUint8Array(operator.enr),
|
|
5149
|
-
config_signature: (0,
|
|
5150
|
-
enr_signature: (0,
|
|
5395
|
+
config_signature: (0, import_ssz4.fromHexString)(operator.config_signature),
|
|
5396
|
+
enr_signature: (0, import_ssz4.fromHexString)(operator.enr_signature)
|
|
5151
5397
|
};
|
|
5152
5398
|
});
|
|
5153
|
-
val.creator = configOnly ? { address: (0,
|
|
5154
|
-
address: (0,
|
|
5155
|
-
config_signature: (0,
|
|
5399
|
+
val.creator = configOnly ? { address: (0, import_ssz4.fromHexString)(cluster.creator.address) } : {
|
|
5400
|
+
address: (0, import_ssz4.fromHexString)(cluster.creator.address),
|
|
5401
|
+
config_signature: (0, import_ssz4.fromHexString)(
|
|
5156
5402
|
cluster.creator.config_signature
|
|
5157
5403
|
)
|
|
5158
5404
|
};
|
|
5159
5405
|
val.validators = cluster.validators.map((validator) => {
|
|
5160
5406
|
return {
|
|
5161
|
-
fee_recipient_address: (0,
|
|
5162
|
-
withdrawal_address: (0,
|
|
5407
|
+
fee_recipient_address: (0, import_ssz4.fromHexString)(validator.fee_recipient_address),
|
|
5408
|
+
withdrawal_address: (0, import_ssz4.fromHexString)(validator.withdrawal_address)
|
|
5163
5409
|
};
|
|
5164
5410
|
});
|
|
5165
5411
|
if (!configOnly) {
|
|
5166
|
-
val.config_hash = (0,
|
|
5412
|
+
val.config_hash = (0, import_ssz4.fromHexString)(cluster.config_hash);
|
|
5167
5413
|
}
|
|
5168
5414
|
return val;
|
|
5169
5415
|
};
|
|
5170
|
-
var dvContainerTypeV1X7 = new
|
|
5171
|
-
distributed_public_key: new
|
|
5172
|
-
public_shares: new
|
|
5416
|
+
var dvContainerTypeV1X7 = new import_ssz4.ContainerType({
|
|
5417
|
+
distributed_public_key: new import_ssz4.ByteVectorType(48),
|
|
5418
|
+
public_shares: new import_ssz4.ListCompositeType(new import_ssz4.ByteVectorType(48), 256),
|
|
5173
5419
|
deposit_data: depositDataContainer,
|
|
5174
5420
|
builder_registration: builderRegistrationContainer
|
|
5175
5421
|
});
|
|
5176
5422
|
var clusterLockContainerTypeV1X7 = () => {
|
|
5177
|
-
return new
|
|
5423
|
+
return new import_ssz4.ContainerType({
|
|
5178
5424
|
cluster_definition: clusterDefinitionContainerTypeV1X7(false),
|
|
5179
|
-
distributed_validators: new
|
|
5425
|
+
distributed_validators: new import_ssz4.ListCompositeType(dvContainerTypeV1X7, 65536)
|
|
5180
5426
|
});
|
|
5181
5427
|
};
|
|
5182
5428
|
var hashClusterLockV1X7 = (cluster) => {
|
|
@@ -5190,34 +5436,34 @@ var hashClusterLockV1X7 = (cluster) => {
|
|
|
5190
5436
|
(dValidator) => {
|
|
5191
5437
|
var _a6, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
5192
5438
|
return {
|
|
5193
|
-
distributed_public_key: (0,
|
|
5439
|
+
distributed_public_key: (0, import_ssz4.fromHexString)(
|
|
5194
5440
|
dValidator.distributed_public_key
|
|
5195
5441
|
),
|
|
5196
5442
|
public_shares: dValidator.public_shares.map(
|
|
5197
|
-
(publicShare) => (0,
|
|
5443
|
+
(publicShare) => (0, import_ssz4.fromHexString)(publicShare)
|
|
5198
5444
|
),
|
|
5199
5445
|
deposit_data: {
|
|
5200
|
-
pubkey: (0,
|
|
5201
|
-
withdrawal_credentials: (0,
|
|
5446
|
+
pubkey: (0, import_ssz4.fromHexString)((_a6 = dValidator.deposit_data) == null ? void 0 : _a6.pubkey),
|
|
5447
|
+
withdrawal_credentials: (0, import_ssz4.fromHexString)(
|
|
5202
5448
|
(_b2 = dValidator.deposit_data) == null ? void 0 : _b2.withdrawal_credentials
|
|
5203
5449
|
),
|
|
5204
5450
|
amount: parseInt((_c = dValidator.deposit_data) == null ? void 0 : _c.amount),
|
|
5205
|
-
signature: (0,
|
|
5451
|
+
signature: (0, import_ssz4.fromHexString)(
|
|
5206
5452
|
(_d = dValidator.deposit_data) == null ? void 0 : _d.signature
|
|
5207
5453
|
)
|
|
5208
5454
|
},
|
|
5209
5455
|
builder_registration: {
|
|
5210
5456
|
message: {
|
|
5211
|
-
fee_recipient: (0,
|
|
5457
|
+
fee_recipient: (0, import_ssz4.fromHexString)(
|
|
5212
5458
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.message.fee_recipient
|
|
5213
5459
|
),
|
|
5214
5460
|
gas_limit: (_f = dValidator.builder_registration) == null ? void 0 : _f.message.gas_limit,
|
|
5215
5461
|
timestamp: (_g = dValidator.builder_registration) == null ? void 0 : _g.message.timestamp,
|
|
5216
|
-
pubkey: (0,
|
|
5462
|
+
pubkey: (0, import_ssz4.fromHexString)(
|
|
5217
5463
|
(_h = dValidator.builder_registration) == null ? void 0 : _h.message.pubkey
|
|
5218
5464
|
)
|
|
5219
5465
|
},
|
|
5220
|
-
signature: (0,
|
|
5466
|
+
signature: (0, import_ssz4.fromHexString)(
|
|
5221
5467
|
(_i = dValidator.builder_registration) == null ? void 0 : _i.signature
|
|
5222
5468
|
)
|
|
5223
5469
|
}
|
|
@@ -5229,6 +5475,22 @@ var hashClusterLockV1X7 = (cluster) => {
|
|
|
5229
5475
|
var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
5230
5476
|
var _a6, _b2;
|
|
5231
5477
|
const validators = clusterLock.distributed_validators;
|
|
5478
|
+
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
5479
|
+
const threshold = clusterLock.cluster_definition.threshold;
|
|
5480
|
+
for (const validator of validators) {
|
|
5481
|
+
if (validator.public_shares.length !== operatorCount) {
|
|
5482
|
+
return false;
|
|
5483
|
+
}
|
|
5484
|
+
const uniqueShareCount = new Set(validator.public_shares).size;
|
|
5485
|
+
if (uniqueShareCount !== validator.public_shares.length) {
|
|
5486
|
+
return false;
|
|
5487
|
+
}
|
|
5488
|
+
}
|
|
5489
|
+
const allShares = validators.map((v) => v.public_shares);
|
|
5490
|
+
const allDKs = validators.map((v) => v.distributed_public_key);
|
|
5491
|
+
if (!(yield verifySharesBinding(allShares, allDKs, threshold))) {
|
|
5492
|
+
return false;
|
|
5493
|
+
}
|
|
5232
5494
|
const pubShares = [];
|
|
5233
5495
|
const pubKeys = [];
|
|
5234
5496
|
const builderRegistrationAndDepositDataMessages = [];
|
|
@@ -5237,8 +5499,18 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5237
5499
|
const validator = validators[i];
|
|
5238
5500
|
const validatorPublicShares = validator.public_shares;
|
|
5239
5501
|
const distributedPublicKey = validator.distributed_public_key;
|
|
5240
|
-
|
|
5241
|
-
|
|
5502
|
+
if (validatorPublicShares.length !== operatorCount) {
|
|
5503
|
+
return false;
|
|
5504
|
+
}
|
|
5505
|
+
const normalizedShares = validatorPublicShares.map((s) => s.toLowerCase());
|
|
5506
|
+
if (new Set(normalizedShares).size !== normalizedShares.length) {
|
|
5507
|
+
return false;
|
|
5508
|
+
}
|
|
5509
|
+
const validatorPublicSharesBytes = validatorPublicShares.map(
|
|
5510
|
+
(share) => (0, import_ssz4.fromHexString)(share)
|
|
5511
|
+
);
|
|
5512
|
+
for (const share of validatorPublicSharesBytes) {
|
|
5513
|
+
pubShares.push(share);
|
|
5242
5514
|
}
|
|
5243
5515
|
const { isValidDepositData, depositDataMsg } = verifyDepositData(
|
|
5244
5516
|
distributedPublicKey,
|
|
@@ -5249,10 +5521,10 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5249
5521
|
if (!isValidDepositData) {
|
|
5250
5522
|
return false;
|
|
5251
5523
|
}
|
|
5252
|
-
pubKeys.push((0,
|
|
5524
|
+
pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
|
|
5253
5525
|
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5254
5526
|
blsSignatures.push(
|
|
5255
|
-
(0,
|
|
5527
|
+
(0, import_ssz4.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5256
5528
|
);
|
|
5257
5529
|
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
5258
5530
|
validator,
|
|
@@ -5262,18 +5534,17 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5262
5534
|
if (!isValidBuilderRegistration) {
|
|
5263
5535
|
return false;
|
|
5264
5536
|
}
|
|
5265
|
-
pubKeys.push((0,
|
|
5537
|
+
pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
|
|
5266
5538
|
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
5267
5539
|
blsSignatures.push(
|
|
5268
|
-
(0,
|
|
5540
|
+
(0, import_ssz4.fromHexString)((_b2 = validator.builder_registration) == null ? void 0 : _b2.signature)
|
|
5269
5541
|
);
|
|
5270
5542
|
}
|
|
5271
|
-
|
|
5272
|
-
if (!blsVerifyMultiple(
|
|
5543
|
+
if (!(yield verifyBatchParallel(
|
|
5273
5544
|
pubKeys,
|
|
5274
5545
|
builderRegistrationAndDepositDataMessages,
|
|
5275
|
-
|
|
5276
|
-
)) {
|
|
5546
|
+
blsSignatures
|
|
5547
|
+
))) {
|
|
5277
5548
|
return false;
|
|
5278
5549
|
}
|
|
5279
5550
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
@@ -5281,8 +5552,8 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5281
5552
|
}
|
|
5282
5553
|
if (!blsVerifyAggregate(
|
|
5283
5554
|
pubShares,
|
|
5284
|
-
(0,
|
|
5285
|
-
(0,
|
|
5555
|
+
(0, import_ssz4.fromHexString)(clusterLock.lock_hash),
|
|
5556
|
+
(0, import_ssz4.fromHexString)(clusterLock.signature_aggregate)
|
|
5286
5557
|
)) {
|
|
5287
5558
|
return false;
|
|
5288
5559
|
}
|
|
@@ -13708,31 +13979,31 @@ var ENR = class _ENR extends BaseENR {
|
|
|
13708
13979
|
|
|
13709
13980
|
// src/verification/v1.8.0.ts
|
|
13710
13981
|
var import_uint3 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
13711
|
-
var
|
|
13982
|
+
var import_ssz5 = require("@chainsafe/ssz");
|
|
13712
13983
|
var clusterDefinitionContainerTypeV1X8 = (configOnly) => {
|
|
13713
13984
|
let returnedContainerType = {
|
|
13714
|
-
uuid: new
|
|
13715
|
-
name: new
|
|
13716
|
-
version: new
|
|
13717
|
-
timestamp: new
|
|
13985
|
+
uuid: new import_ssz5.ByteListType(64),
|
|
13986
|
+
name: new import_ssz5.ByteListType(256),
|
|
13987
|
+
version: new import_ssz5.ByteListType(16),
|
|
13988
|
+
timestamp: new import_ssz5.ByteListType(32),
|
|
13718
13989
|
num_validators: new import_uint3.UintNumberType(8),
|
|
13719
13990
|
threshold: new import_uint3.UintNumberType(8),
|
|
13720
|
-
dkg_algorithm: new
|
|
13721
|
-
fork_version: new
|
|
13722
|
-
operators: new
|
|
13991
|
+
dkg_algorithm: new import_ssz5.ByteListType(32),
|
|
13992
|
+
fork_version: new import_ssz5.ByteVectorType(4),
|
|
13993
|
+
operators: new import_ssz5.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
13723
13994
|
creator: newCreatorContainerType(configOnly),
|
|
13724
|
-
validators: new
|
|
13725
|
-
deposit_amounts: new
|
|
13995
|
+
validators: new import_ssz5.ListCompositeType(validatorsContainerType, 65536),
|
|
13996
|
+
deposit_amounts: new import_ssz5.ListBasicType(
|
|
13726
13997
|
new import_uint3.UintNumberType(8),
|
|
13727
13998
|
256
|
|
13728
13999
|
)
|
|
13729
14000
|
};
|
|
13730
14001
|
if (!configOnly) {
|
|
13731
14002
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
13732
|
-
config_hash: new
|
|
14003
|
+
config_hash: new import_ssz5.ByteVectorType(32)
|
|
13733
14004
|
});
|
|
13734
14005
|
}
|
|
13735
|
-
return new
|
|
14006
|
+
return new import_ssz5.ContainerType(returnedContainerType);
|
|
13736
14007
|
};
|
|
13737
14008
|
var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
13738
14009
|
const definitionType = clusterDefinitionContainerTypeV1X8(configOnly);
|
|
@@ -13744,25 +14015,25 @@ var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
|
13744
14015
|
val.num_validators = cluster.num_validators;
|
|
13745
14016
|
val.threshold = cluster.threshold;
|
|
13746
14017
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
13747
|
-
val.fork_version = (0,
|
|
14018
|
+
val.fork_version = (0, import_ssz5.fromHexString)(cluster.fork_version);
|
|
13748
14019
|
val.operators = cluster.operators.map((operator) => {
|
|
13749
|
-
return configOnly ? { address: (0,
|
|
13750
|
-
address: (0,
|
|
14020
|
+
return configOnly ? { address: (0, import_ssz5.fromHexString)(operator.address) } : {
|
|
14021
|
+
address: (0, import_ssz5.fromHexString)(operator.address),
|
|
13751
14022
|
enr: strToUint8Array(operator.enr),
|
|
13752
|
-
config_signature: (0,
|
|
13753
|
-
enr_signature: (0,
|
|
14023
|
+
config_signature: (0, import_ssz5.fromHexString)(operator.config_signature),
|
|
14024
|
+
enr_signature: (0, import_ssz5.fromHexString)(operator.enr_signature)
|
|
13754
14025
|
};
|
|
13755
14026
|
});
|
|
13756
|
-
val.creator = configOnly ? { address: (0,
|
|
13757
|
-
address: (0,
|
|
13758
|
-
config_signature: (0,
|
|
14027
|
+
val.creator = configOnly ? { address: (0, import_ssz5.fromHexString)(cluster.creator.address) } : {
|
|
14028
|
+
address: (0, import_ssz5.fromHexString)(cluster.creator.address),
|
|
14029
|
+
config_signature: (0, import_ssz5.fromHexString)(
|
|
13759
14030
|
cluster.creator.config_signature
|
|
13760
14031
|
)
|
|
13761
14032
|
};
|
|
13762
14033
|
val.validators = cluster.validators.map((validator) => {
|
|
13763
14034
|
return {
|
|
13764
|
-
fee_recipient_address: (0,
|
|
13765
|
-
withdrawal_address: (0,
|
|
14035
|
+
fee_recipient_address: (0, import_ssz5.fromHexString)(validator.fee_recipient_address),
|
|
14036
|
+
withdrawal_address: (0, import_ssz5.fromHexString)(validator.withdrawal_address)
|
|
13766
14037
|
};
|
|
13767
14038
|
});
|
|
13768
14039
|
if (cluster.deposit_amounts) {
|
|
@@ -13771,20 +14042,20 @@ var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
|
13771
14042
|
});
|
|
13772
14043
|
}
|
|
13773
14044
|
if (!configOnly) {
|
|
13774
|
-
val.config_hash = (0,
|
|
14045
|
+
val.config_hash = (0, import_ssz5.fromHexString)(cluster.config_hash);
|
|
13775
14046
|
}
|
|
13776
14047
|
return val;
|
|
13777
14048
|
};
|
|
13778
|
-
var dvContainerTypeV1X8 = new
|
|
13779
|
-
distributed_public_key: new
|
|
13780
|
-
public_shares: new
|
|
13781
|
-
partial_deposit_data: new
|
|
14049
|
+
var dvContainerTypeV1X8 = new import_ssz5.ContainerType({
|
|
14050
|
+
distributed_public_key: new import_ssz5.ByteVectorType(48),
|
|
14051
|
+
public_shares: new import_ssz5.ListCompositeType(new import_ssz5.ByteVectorType(48), 256),
|
|
14052
|
+
partial_deposit_data: new import_ssz5.ListCompositeType(depositDataContainer, 256),
|
|
13782
14053
|
builder_registration: builderRegistrationContainer
|
|
13783
14054
|
});
|
|
13784
14055
|
var clusterLockContainerTypeV1X8 = () => {
|
|
13785
|
-
return new
|
|
14056
|
+
return new import_ssz5.ContainerType({
|
|
13786
14057
|
cluster_definition: clusterDefinitionContainerTypeV1X8(false),
|
|
13787
|
-
distributed_validators: new
|
|
14058
|
+
distributed_validators: new import_ssz5.ListCompositeType(dvContainerTypeV1X8, 65536)
|
|
13788
14059
|
});
|
|
13789
14060
|
};
|
|
13790
14061
|
var hashClusterLockV1X8 = (cluster) => {
|
|
@@ -13798,35 +14069,35 @@ var hashClusterLockV1X8 = (cluster) => {
|
|
|
13798
14069
|
(dValidator) => {
|
|
13799
14070
|
var _a6, _b2, _c, _d, _e;
|
|
13800
14071
|
return {
|
|
13801
|
-
distributed_public_key: (0,
|
|
14072
|
+
distributed_public_key: (0, import_ssz5.fromHexString)(
|
|
13802
14073
|
dValidator.distributed_public_key
|
|
13803
14074
|
),
|
|
13804
14075
|
public_shares: dValidator.public_shares.map(
|
|
13805
|
-
(publicShare) => (0,
|
|
14076
|
+
(publicShare) => (0, import_ssz5.fromHexString)(publicShare)
|
|
13806
14077
|
),
|
|
13807
14078
|
// should be fixed
|
|
13808
14079
|
partial_deposit_data: dValidator.partial_deposit_data.map((depositData) => {
|
|
13809
14080
|
return {
|
|
13810
|
-
pubkey: (0,
|
|
13811
|
-
withdrawal_credentials: (0,
|
|
14081
|
+
pubkey: (0, import_ssz5.fromHexString)(depositData.pubkey),
|
|
14082
|
+
withdrawal_credentials: (0, import_ssz5.fromHexString)(
|
|
13812
14083
|
depositData.withdrawal_credentials
|
|
13813
14084
|
),
|
|
13814
14085
|
amount: parseInt(depositData.amount),
|
|
13815
|
-
signature: (0,
|
|
14086
|
+
signature: (0, import_ssz5.fromHexString)(depositData.signature)
|
|
13816
14087
|
};
|
|
13817
14088
|
}),
|
|
13818
14089
|
builder_registration: {
|
|
13819
14090
|
message: {
|
|
13820
|
-
fee_recipient: (0,
|
|
14091
|
+
fee_recipient: (0, import_ssz5.fromHexString)(
|
|
13821
14092
|
(_a6 = dValidator.builder_registration) == null ? void 0 : _a6.message.fee_recipient
|
|
13822
14093
|
),
|
|
13823
14094
|
gas_limit: (_b2 = dValidator.builder_registration) == null ? void 0 : _b2.message.gas_limit,
|
|
13824
14095
|
timestamp: (_c = dValidator.builder_registration) == null ? void 0 : _c.message.timestamp,
|
|
13825
|
-
pubkey: (0,
|
|
14096
|
+
pubkey: (0, import_ssz5.fromHexString)(
|
|
13826
14097
|
(_d = dValidator.builder_registration) == null ? void 0 : _d.message.pubkey
|
|
13827
14098
|
)
|
|
13828
14099
|
},
|
|
13829
|
-
signature: (0,
|
|
14100
|
+
signature: (0, import_ssz5.fromHexString)(
|
|
13830
14101
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.signature
|
|
13831
14102
|
)
|
|
13832
14103
|
}
|
|
@@ -13838,6 +14109,22 @@ var hashClusterLockV1X8 = (cluster) => {
|
|
|
13838
14109
|
var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
13839
14110
|
var _a6;
|
|
13840
14111
|
const validators = clusterLock.distributed_validators;
|
|
14112
|
+
const operatorCount = clusterLock.cluster_definition.operators.length;
|
|
14113
|
+
const threshold = clusterLock.cluster_definition.threshold;
|
|
14114
|
+
for (const validator of validators) {
|
|
14115
|
+
if (validator.public_shares.length !== operatorCount) {
|
|
14116
|
+
return false;
|
|
14117
|
+
}
|
|
14118
|
+
const uniqueShareCount = new Set(validator.public_shares).size;
|
|
14119
|
+
if (uniqueShareCount !== validator.public_shares.length) {
|
|
14120
|
+
return false;
|
|
14121
|
+
}
|
|
14122
|
+
}
|
|
14123
|
+
const allShares = validators.map((v) => v.public_shares);
|
|
14124
|
+
const allDKs = validators.map((v) => v.distributed_public_key);
|
|
14125
|
+
if (!(yield verifySharesBinding(allShares, allDKs, threshold))) {
|
|
14126
|
+
return false;
|
|
14127
|
+
}
|
|
13841
14128
|
const pubShares = [];
|
|
13842
14129
|
const pubKeys = [];
|
|
13843
14130
|
const builderRegistrationAndDepositDataMessages = [];
|
|
@@ -13846,8 +14133,18 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13846
14133
|
const validator = validators[i];
|
|
13847
14134
|
const validatorPublicShares = validator.public_shares;
|
|
13848
14135
|
const distributedPublicKey = validator.distributed_public_key;
|
|
13849
|
-
|
|
13850
|
-
|
|
14136
|
+
if (validatorPublicShares.length !== operatorCount) {
|
|
14137
|
+
return false;
|
|
14138
|
+
}
|
|
14139
|
+
const normalizedShares = validatorPublicShares.map((s) => s.toLowerCase());
|
|
14140
|
+
if (new Set(normalizedShares).size !== normalizedShares.length) {
|
|
14141
|
+
return false;
|
|
14142
|
+
}
|
|
14143
|
+
const validatorPublicSharesBytes = validatorPublicShares.map(
|
|
14144
|
+
(share) => (0, import_ssz5.fromHexString)(share)
|
|
14145
|
+
);
|
|
14146
|
+
for (const share of validatorPublicSharesBytes) {
|
|
14147
|
+
pubShares.push(share);
|
|
13851
14148
|
}
|
|
13852
14149
|
const depositAmounts = clusterLock.cluster_definition.deposit_amounts;
|
|
13853
14150
|
if (!!depositAmounts && depositAmounts !== null) {
|
|
@@ -13870,9 +14167,9 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13870
14167
|
if (!isValidDepositData) {
|
|
13871
14168
|
return false;
|
|
13872
14169
|
}
|
|
13873
|
-
pubKeys.push((0,
|
|
14170
|
+
pubKeys.push((0, import_ssz5.fromHexString)(distributedPublicKey));
|
|
13874
14171
|
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
13875
|
-
blsSignatures.push((0,
|
|
14172
|
+
blsSignatures.push((0, import_ssz5.fromHexString)(depositData == null ? void 0 : depositData.signature));
|
|
13876
14173
|
}
|
|
13877
14174
|
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
13878
14175
|
validator,
|
|
@@ -13882,18 +14179,17 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13882
14179
|
if (!isValidBuilderRegistration) {
|
|
13883
14180
|
return false;
|
|
13884
14181
|
}
|
|
13885
|
-
pubKeys.push((0,
|
|
14182
|
+
pubKeys.push((0, import_ssz5.fromHexString)(distributedPublicKey));
|
|
13886
14183
|
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
13887
14184
|
blsSignatures.push(
|
|
13888
|
-
(0,
|
|
14185
|
+
(0, import_ssz5.fromHexString)((_a6 = validator.builder_registration) == null ? void 0 : _a6.signature)
|
|
13889
14186
|
);
|
|
13890
14187
|
}
|
|
13891
|
-
|
|
13892
|
-
if (!blsVerifyMultiple(
|
|
14188
|
+
if (!(yield verifyBatchParallel(
|
|
13893
14189
|
pubKeys,
|
|
13894
14190
|
builderRegistrationAndDepositDataMessages,
|
|
13895
|
-
|
|
13896
|
-
)) {
|
|
14191
|
+
blsSignatures
|
|
14192
|
+
))) {
|
|
13897
14193
|
return false;
|
|
13898
14194
|
}
|
|
13899
14195
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
@@ -13901,8 +14197,8 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13901
14197
|
}
|
|
13902
14198
|
if (!blsVerifyAggregate(
|
|
13903
14199
|
pubShares,
|
|
13904
|
-
(0,
|
|
13905
|
-
(0,
|
|
14200
|
+
(0, import_ssz5.fromHexString)(clusterLock.lock_hash),
|
|
14201
|
+
(0, import_ssz5.fromHexString)(clusterLock.signature_aggregate)
|
|
13906
14202
|
)) {
|
|
13907
14203
|
return false;
|
|
13908
14204
|
}
|
|
@@ -13983,34 +14279,34 @@ var validateSmartContractSignature = (_0) => __async(null, [_0], function* ({
|
|
|
13983
14279
|
|
|
13984
14280
|
// src/verification/v1.10.0.ts
|
|
13985
14281
|
var import_uint4 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
13986
|
-
var
|
|
14282
|
+
var import_ssz6 = require("@chainsafe/ssz");
|
|
13987
14283
|
var clusterDefinitionContainerTypeV1X10 = (configOnly) => {
|
|
13988
14284
|
let returnedContainerType = {
|
|
13989
|
-
uuid: new
|
|
13990
|
-
name: new
|
|
13991
|
-
version: new
|
|
13992
|
-
timestamp: new
|
|
14285
|
+
uuid: new import_ssz6.ByteListType(64),
|
|
14286
|
+
name: new import_ssz6.ByteListType(256),
|
|
14287
|
+
version: new import_ssz6.ByteListType(16),
|
|
14288
|
+
timestamp: new import_ssz6.ByteListType(32),
|
|
13993
14289
|
num_validators: new import_uint4.UintNumberType(8),
|
|
13994
14290
|
threshold: new import_uint4.UintNumberType(8),
|
|
13995
|
-
dkg_algorithm: new
|
|
13996
|
-
fork_version: new
|
|
13997
|
-
operators: new
|
|
14291
|
+
dkg_algorithm: new import_ssz6.ByteListType(32),
|
|
14292
|
+
fork_version: new import_ssz6.ByteVectorType(4),
|
|
14293
|
+
operators: new import_ssz6.ListCompositeType(newOperatorContainerType(configOnly), 256),
|
|
13998
14294
|
creator: newCreatorContainerType(configOnly),
|
|
13999
|
-
validators: new
|
|
14000
|
-
deposit_amounts: new
|
|
14295
|
+
validators: new import_ssz6.ListCompositeType(validatorsContainerType, 65536),
|
|
14296
|
+
deposit_amounts: new import_ssz6.ListBasicType(
|
|
14001
14297
|
new import_uint4.UintNumberType(8),
|
|
14002
14298
|
256
|
|
14003
14299
|
),
|
|
14004
|
-
consensus_protocol: new
|
|
14300
|
+
consensus_protocol: new import_ssz6.ByteListType(256),
|
|
14005
14301
|
target_gas_limit: new import_uint4.UintNumberType(8),
|
|
14006
|
-
compounding: new
|
|
14302
|
+
compounding: new import_ssz6.BooleanType()
|
|
14007
14303
|
};
|
|
14008
14304
|
if (!configOnly) {
|
|
14009
14305
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
14010
|
-
config_hash: new
|
|
14306
|
+
config_hash: new import_ssz6.ByteVectorType(32)
|
|
14011
14307
|
});
|
|
14012
14308
|
}
|
|
14013
|
-
return new
|
|
14309
|
+
return new import_ssz6.ContainerType(returnedContainerType);
|
|
14014
14310
|
};
|
|
14015
14311
|
var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
14016
14312
|
const definitionType = clusterDefinitionContainerTypeV1X10(configOnly);
|
|
@@ -14022,25 +14318,25 @@ var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
|
14022
14318
|
val.num_validators = cluster.num_validators;
|
|
14023
14319
|
val.threshold = cluster.threshold;
|
|
14024
14320
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
14025
|
-
val.fork_version = (0,
|
|
14321
|
+
val.fork_version = (0, import_ssz6.fromHexString)(cluster.fork_version);
|
|
14026
14322
|
val.operators = cluster.operators.map((operator) => {
|
|
14027
|
-
return configOnly ? { address: (0,
|
|
14028
|
-
address: (0,
|
|
14323
|
+
return configOnly ? { address: (0, import_ssz6.fromHexString)(operator.address) } : {
|
|
14324
|
+
address: (0, import_ssz6.fromHexString)(operator.address),
|
|
14029
14325
|
enr: strToUint8Array(operator.enr),
|
|
14030
|
-
config_signature: (0,
|
|
14031
|
-
enr_signature: (0,
|
|
14326
|
+
config_signature: (0, import_ssz6.fromHexString)(operator.config_signature),
|
|
14327
|
+
enr_signature: (0, import_ssz6.fromHexString)(operator.enr_signature)
|
|
14032
14328
|
};
|
|
14033
14329
|
});
|
|
14034
|
-
val.creator = configOnly ? { address: (0,
|
|
14035
|
-
address: (0,
|
|
14036
|
-
config_signature: (0,
|
|
14330
|
+
val.creator = configOnly ? { address: (0, import_ssz6.fromHexString)(cluster.creator.address) } : {
|
|
14331
|
+
address: (0, import_ssz6.fromHexString)(cluster.creator.address),
|
|
14332
|
+
config_signature: (0, import_ssz6.fromHexString)(
|
|
14037
14333
|
cluster.creator.config_signature
|
|
14038
14334
|
)
|
|
14039
14335
|
};
|
|
14040
14336
|
val.validators = cluster.validators.map((validator) => {
|
|
14041
14337
|
return {
|
|
14042
|
-
fee_recipient_address: (0,
|
|
14043
|
-
withdrawal_address: (0,
|
|
14338
|
+
fee_recipient_address: (0, import_ssz6.fromHexString)(validator.fee_recipient_address),
|
|
14339
|
+
withdrawal_address: (0, import_ssz6.fromHexString)(validator.withdrawal_address)
|
|
14044
14340
|
};
|
|
14045
14341
|
});
|
|
14046
14342
|
if (cluster.deposit_amounts) {
|
|
@@ -14058,20 +14354,20 @@ var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
|
14058
14354
|
val.compounding = cluster.compounding;
|
|
14059
14355
|
}
|
|
14060
14356
|
if (!configOnly) {
|
|
14061
|
-
val.config_hash = (0,
|
|
14357
|
+
val.config_hash = (0, import_ssz6.fromHexString)(cluster.config_hash);
|
|
14062
14358
|
}
|
|
14063
14359
|
return val;
|
|
14064
14360
|
};
|
|
14065
|
-
var dvContainerTypeV1X10 = new
|
|
14066
|
-
distributed_public_key: new
|
|
14067
|
-
public_shares: new
|
|
14068
|
-
partial_deposit_data: new
|
|
14361
|
+
var dvContainerTypeV1X10 = new import_ssz6.ContainerType({
|
|
14362
|
+
distributed_public_key: new import_ssz6.ByteVectorType(48),
|
|
14363
|
+
public_shares: new import_ssz6.ListCompositeType(new import_ssz6.ByteVectorType(48), 256),
|
|
14364
|
+
partial_deposit_data: new import_ssz6.ListCompositeType(depositDataContainer, 256),
|
|
14069
14365
|
builder_registration: builderRegistrationContainer
|
|
14070
14366
|
});
|
|
14071
14367
|
var clusterLockContainerTypeV1X10 = () => {
|
|
14072
|
-
return new
|
|
14368
|
+
return new import_ssz6.ContainerType({
|
|
14073
14369
|
cluster_definition: clusterDefinitionContainerTypeV1X10(false),
|
|
14074
|
-
distributed_validators: new
|
|
14370
|
+
distributed_validators: new import_ssz6.ListCompositeType(dvContainerTypeV1X10, 65536)
|
|
14075
14371
|
});
|
|
14076
14372
|
};
|
|
14077
14373
|
var hashClusterLockV1X10 = (cluster) => {
|
|
@@ -14085,35 +14381,35 @@ var hashClusterLockV1X10 = (cluster) => {
|
|
|
14085
14381
|
(dValidator) => {
|
|
14086
14382
|
var _a6, _b2, _c, _d, _e;
|
|
14087
14383
|
return {
|
|
14088
|
-
distributed_public_key: (0,
|
|
14384
|
+
distributed_public_key: (0, import_ssz6.fromHexString)(
|
|
14089
14385
|
dValidator.distributed_public_key
|
|
14090
14386
|
),
|
|
14091
14387
|
public_shares: dValidator.public_shares.map(
|
|
14092
|
-
(publicShare) => (0,
|
|
14388
|
+
(publicShare) => (0, import_ssz6.fromHexString)(publicShare)
|
|
14093
14389
|
),
|
|
14094
14390
|
// should be fixed
|
|
14095
14391
|
partial_deposit_data: dValidator.partial_deposit_data.map((depositData) => {
|
|
14096
14392
|
return {
|
|
14097
|
-
pubkey: (0,
|
|
14098
|
-
withdrawal_credentials: (0,
|
|
14393
|
+
pubkey: (0, import_ssz6.fromHexString)(depositData.pubkey),
|
|
14394
|
+
withdrawal_credentials: (0, import_ssz6.fromHexString)(
|
|
14099
14395
|
depositData.withdrawal_credentials
|
|
14100
14396
|
),
|
|
14101
14397
|
amount: parseInt(depositData.amount),
|
|
14102
|
-
signature: (0,
|
|
14398
|
+
signature: (0, import_ssz6.fromHexString)(depositData.signature)
|
|
14103
14399
|
};
|
|
14104
14400
|
}),
|
|
14105
14401
|
builder_registration: {
|
|
14106
14402
|
message: {
|
|
14107
|
-
fee_recipient: (0,
|
|
14403
|
+
fee_recipient: (0, import_ssz6.fromHexString)(
|
|
14108
14404
|
(_a6 = dValidator.builder_registration) == null ? void 0 : _a6.message.fee_recipient
|
|
14109
14405
|
),
|
|
14110
14406
|
gas_limit: (_b2 = dValidator.builder_registration) == null ? void 0 : _b2.message.gas_limit,
|
|
14111
14407
|
timestamp: (_c = dValidator.builder_registration) == null ? void 0 : _c.message.timestamp,
|
|
14112
|
-
pubkey: (0,
|
|
14408
|
+
pubkey: (0, import_ssz6.fromHexString)(
|
|
14113
14409
|
(_d = dValidator.builder_registration) == null ? void 0 : _d.message.pubkey
|
|
14114
14410
|
)
|
|
14115
14411
|
},
|
|
14116
|
-
signature: (0,
|
|
14412
|
+
signature: (0, import_ssz6.fromHexString)(
|
|
14117
14413
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.signature
|
|
14118
14414
|
)
|
|
14119
14415
|
}
|
|
@@ -14272,8 +14568,8 @@ var computeSigningRoot = (sszObjectRoot, domain) => {
|
|
|
14272
14568
|
};
|
|
14273
14569
|
var computeDepositMsgRoot = (msg) => {
|
|
14274
14570
|
const depositMsgVal = depositMessageType.defaultValue();
|
|
14275
|
-
depositMsgVal.pubkey = (0,
|
|
14276
|
-
depositMsgVal.withdrawal_credentials = (0,
|
|
14571
|
+
depositMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
|
|
14572
|
+
depositMsgVal.withdrawal_credentials = (0, import_ssz7.fromHexString)(
|
|
14277
14573
|
msg.withdrawal_credentials
|
|
14278
14574
|
);
|
|
14279
14575
|
depositMsgVal.amount = parseInt(msg.amount);
|
|
@@ -14287,16 +14583,16 @@ var computeForkDataRoot = (currentVersion, genesisValidatorsRoot) => {
|
|
|
14287
14583
|
};
|
|
14288
14584
|
var computebuilderRegistrationMsgRoot = (msg) => {
|
|
14289
14585
|
const builderRegistrationMsgVal = builderRegistrationMessageType.defaultValue();
|
|
14290
|
-
builderRegistrationMsgVal.fee_recipient = (0,
|
|
14586
|
+
builderRegistrationMsgVal.fee_recipient = (0, import_ssz7.fromHexString)(msg.fee_recipient);
|
|
14291
14587
|
builderRegistrationMsgVal.gas_limit = msg.gas_limit;
|
|
14292
14588
|
builderRegistrationMsgVal.timestamp = msg.timestamp;
|
|
14293
|
-
builderRegistrationMsgVal.pubkey = (0,
|
|
14589
|
+
builderRegistrationMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
|
|
14294
14590
|
return Buffer.from(
|
|
14295
14591
|
builderRegistrationMessageType.hashTreeRoot(builderRegistrationMsgVal).buffer
|
|
14296
14592
|
);
|
|
14297
14593
|
};
|
|
14298
|
-
var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0,
|
|
14299
|
-
const forkVersion = (0,
|
|
14594
|
+
var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, import_ssz7.fromHexString)(GENESIS_VALIDATOR_ROOT)) => {
|
|
14595
|
+
const forkVersion = (0, import_ssz7.fromHexString)(
|
|
14300
14596
|
lockForkVersion.substring(2, lockForkVersion.length)
|
|
14301
14597
|
);
|
|
14302
14598
|
const forkDataRoot = computeForkDataRoot(forkVersion, genesisValidatorsRoot);
|
|
@@ -14307,7 +14603,7 @@ var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, im
|
|
|
14307
14603
|
};
|
|
14308
14604
|
var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding) => {
|
|
14309
14605
|
const depositDomain = computeDomain(
|
|
14310
|
-
(0,
|
|
14606
|
+
(0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT),
|
|
14311
14607
|
forkVersion
|
|
14312
14608
|
);
|
|
14313
14609
|
const withdrawalPrefix = compounding ? "0x02" : "0x01";
|
|
@@ -14324,16 +14620,16 @@ var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, f
|
|
|
14324
14620
|
return { isValidDepositData: false, depositDataMsg: depositDataRoot };
|
|
14325
14621
|
}
|
|
14326
14622
|
const isValidDepositData = blsVerify(
|
|
14327
|
-
(0,
|
|
14623
|
+
(0, import_ssz7.fromHexString)(depositData.pubkey),
|
|
14328
14624
|
depositDataRoot,
|
|
14329
|
-
(0,
|
|
14625
|
+
(0, import_ssz7.fromHexString)(depositData.signature)
|
|
14330
14626
|
);
|
|
14331
14627
|
return { isValidDepositData, depositDataMsg: depositDataRoot };
|
|
14332
14628
|
};
|
|
14333
14629
|
var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) => {
|
|
14334
14630
|
var _a6;
|
|
14335
14631
|
const builderDomain = computeDomain(
|
|
14336
|
-
(0,
|
|
14632
|
+
(0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER),
|
|
14337
14633
|
forkVersion
|
|
14338
14634
|
);
|
|
14339
14635
|
if (validator.distributed_public_key !== ((_a6 = validator.builder_registration) == null ? void 0 : _a6.message.pubkey)) {
|
|
@@ -14401,6 +14697,12 @@ var verifyLockData = (clusterLock) => __async(null, null, function* () {
|
|
|
14401
14697
|
}
|
|
14402
14698
|
return false;
|
|
14403
14699
|
});
|
|
14700
|
+
var hasUniqueDistributedKeys = (clusterLock) => {
|
|
14701
|
+
const dvKeys = clusterLock.distributed_validators.map(
|
|
14702
|
+
(v) => v.distributed_public_key.toLowerCase()
|
|
14703
|
+
);
|
|
14704
|
+
return new Set(dvKeys).size === dvKeys.length;
|
|
14705
|
+
};
|
|
14404
14706
|
var isValidClusterLock = (clusterLock, safeRpcUrl) => __async(null, null, function* () {
|
|
14405
14707
|
try {
|
|
14406
14708
|
const definitionType = definitionFlow(clusterLock.cluster_definition);
|
|
@@ -14421,6 +14723,9 @@ var isValidClusterLock = (clusterLock, safeRpcUrl) => __async(null, null, functi
|
|
|
14421
14723
|
if (clusterLockHash(clusterLock) !== clusterLock.lock_hash) {
|
|
14422
14724
|
return false;
|
|
14423
14725
|
}
|
|
14726
|
+
if (!hasUniqueDistributedKeys(clusterLock)) {
|
|
14727
|
+
return false;
|
|
14728
|
+
}
|
|
14424
14729
|
const isValidLockData = yield verifyLockData(clusterLock);
|
|
14425
14730
|
if (!isValidLockData) {
|
|
14426
14731
|
return false;
|
|
@@ -18086,7 +18391,7 @@ var Incentives = class {
|
|
|
18086
18391
|
|
|
18087
18392
|
// src/exits/exit.ts
|
|
18088
18393
|
var elliptic2 = __toESM(require("elliptic"));
|
|
18089
|
-
var
|
|
18394
|
+
var import_ssz9 = require("@chainsafe/ssz");
|
|
18090
18395
|
|
|
18091
18396
|
// src/exits/ethUtils.ts
|
|
18092
18397
|
function getCapellaFork(fork_version) {
|
|
@@ -18123,15 +18428,15 @@ function getGenesisValidatorsRoot(beaconNodeApiUrl) {
|
|
|
18123
18428
|
}
|
|
18124
18429
|
|
|
18125
18430
|
// src/exits/verificationHelpers.ts
|
|
18126
|
-
var
|
|
18431
|
+
var import_ssz8 = require("@chainsafe/ssz");
|
|
18127
18432
|
var GENESIS_VALIDATOR_ROOT_HEX_STRING = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
18128
|
-
var ForkDataType = new
|
|
18129
|
-
currentVersion: new
|
|
18130
|
-
genesisValidatorsRoot: new
|
|
18433
|
+
var ForkDataType = new import_ssz8.ContainerType({
|
|
18434
|
+
currentVersion: new import_ssz8.ByteVectorType(4),
|
|
18435
|
+
genesisValidatorsRoot: new import_ssz8.ByteVectorType(32)
|
|
18131
18436
|
});
|
|
18132
|
-
var SigningRootType = new
|
|
18133
|
-
objectRoot: new
|
|
18134
|
-
domain: new
|
|
18437
|
+
var SigningRootType = new import_ssz8.ContainerType({
|
|
18438
|
+
objectRoot: new import_ssz8.ByteVectorType(32),
|
|
18439
|
+
domain: new import_ssz8.ByteVectorType(32)
|
|
18135
18440
|
});
|
|
18136
18441
|
function computeForkDataRoot2(currentVersion, genesisValidatorsRoot) {
|
|
18137
18442
|
const forkDataVal = ForkDataType.defaultValue();
|
|
@@ -18140,7 +18445,7 @@ function computeForkDataRoot2(currentVersion, genesisValidatorsRoot) {
|
|
|
18140
18445
|
return Buffer.from(ForkDataType.hashTreeRoot(forkDataVal).buffer);
|
|
18141
18446
|
}
|
|
18142
18447
|
function computeDomain2(domainType, forkVersionString, genesisValidatorsRootOverride) {
|
|
18143
|
-
const forkVersionBytes = (0,
|
|
18448
|
+
const forkVersionBytes = (0, import_ssz8.fromHexString)(
|
|
18144
18449
|
forkVersionString.substring(2, forkVersionString.length)
|
|
18145
18450
|
);
|
|
18146
18451
|
if (forkVersionBytes.length !== 4) {
|
|
@@ -18149,7 +18454,7 @@ function computeDomain2(domainType, forkVersionString, genesisValidatorsRootOver
|
|
|
18149
18454
|
if (domainType.length !== 4) {
|
|
18150
18455
|
throw new Error("Domain type must be 4 bytes");
|
|
18151
18456
|
}
|
|
18152
|
-
const actualGenesisValidatorsRoot = genesisValidatorsRootOverride != null ? genesisValidatorsRootOverride : (0,
|
|
18457
|
+
const actualGenesisValidatorsRoot = genesisValidatorsRootOverride != null ? genesisValidatorsRootOverride : (0, import_ssz8.fromHexString)(GENESIS_VALIDATOR_ROOT_HEX_STRING.substring(2));
|
|
18153
18458
|
if (actualGenesisValidatorsRoot.length !== 32) {
|
|
18154
18459
|
throw new Error("genesisValidatorsRoot must be 32 bytes");
|
|
18155
18460
|
}
|
|
@@ -18181,25 +18486,25 @@ function signingRoot2(domain, messageBuffer) {
|
|
|
18181
18486
|
|
|
18182
18487
|
// src/exits/exit.ts
|
|
18183
18488
|
var DOMAIN_VOLUNTARY_EXIT = "0x04000000";
|
|
18184
|
-
var SSZExitMessageType = new
|
|
18185
|
-
epoch: new
|
|
18186
|
-
validator_index: new
|
|
18489
|
+
var SSZExitMessageType = new import_ssz9.ContainerType({
|
|
18490
|
+
epoch: new import_ssz9.UintNumberType(8),
|
|
18491
|
+
validator_index: new import_ssz9.UintNumberType(8)
|
|
18187
18492
|
});
|
|
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
|
|
18493
|
+
var SSZPartialExitsPayloadType = new import_ssz9.ContainerType({
|
|
18494
|
+
partial_exits: new import_ssz9.ListCompositeType(
|
|
18495
|
+
new import_ssz9.ContainerType({
|
|
18496
|
+
public_key: new import_ssz9.ByteVectorType(48),
|
|
18497
|
+
signed_exit_message: new import_ssz9.ContainerType({
|
|
18498
|
+
message: new import_ssz9.ContainerType({
|
|
18499
|
+
epoch: new import_ssz9.UintNumberType(8),
|
|
18500
|
+
validator_index: new import_ssz9.UintNumberType(8)
|
|
18196
18501
|
}),
|
|
18197
|
-
signature: new
|
|
18502
|
+
signature: new import_ssz9.ByteVectorType(96)
|
|
18198
18503
|
})
|
|
18199
18504
|
}),
|
|
18200
18505
|
65536
|
|
18201
18506
|
),
|
|
18202
|
-
share_idx: new
|
|
18507
|
+
share_idx: new import_ssz9.UintNumberType(8)
|
|
18203
18508
|
});
|
|
18204
18509
|
var Exit = class _Exit {
|
|
18205
18510
|
/**
|
|
@@ -18242,7 +18547,7 @@ var Exit = class _Exit {
|
|
|
18242
18547
|
static computeExitPayloadRoot(exits) {
|
|
18243
18548
|
const sszValue = SSZPartialExitsPayloadType.defaultValue();
|
|
18244
18549
|
sszValue.partial_exits = exits.partial_exits.map((pe) => ({
|
|
18245
|
-
public_key: (0,
|
|
18550
|
+
public_key: (0, import_ssz9.fromHexString)(pe.public_key),
|
|
18246
18551
|
signed_exit_message: {
|
|
18247
18552
|
message: {
|
|
18248
18553
|
epoch: _Exit.safeParseInt(pe.signed_exit_message.message.epoch),
|
|
@@ -18250,7 +18555,7 @@ var Exit = class _Exit {
|
|
|
18250
18555
|
pe.signed_exit_message.message.validator_index
|
|
18251
18556
|
)
|
|
18252
18557
|
},
|
|
18253
|
-
signature: (0,
|
|
18558
|
+
signature: (0, import_ssz9.fromHexString)(pe.signed_exit_message.signature)
|
|
18254
18559
|
}
|
|
18255
18560
|
}));
|
|
18256
18561
|
sszValue.share_idx = exits.share_idx;
|
|
@@ -18300,18 +18605,18 @@ var Exit = class _Exit {
|
|
|
18300
18605
|
signedExitMessage.message
|
|
18301
18606
|
);
|
|
18302
18607
|
const exitDomain = computeDomain2(
|
|
18303
|
-
(0,
|
|
18608
|
+
(0, import_ssz9.fromHexString)(DOMAIN_VOLUNTARY_EXIT),
|
|
18304
18609
|
capellaForkVersionString,
|
|
18305
|
-
(0,
|
|
18610
|
+
(0, import_ssz9.fromHexString)(genesisValidatorsRootString)
|
|
18306
18611
|
);
|
|
18307
18612
|
const messageSigningRoot = signingRoot2(
|
|
18308
18613
|
exitDomain,
|
|
18309
18614
|
partialExitMessageBuffer
|
|
18310
18615
|
);
|
|
18311
18616
|
return blsVerify(
|
|
18312
|
-
(0,
|
|
18617
|
+
(0, import_ssz9.fromHexString)(publicShareKey),
|
|
18313
18618
|
messageSigningRoot,
|
|
18314
|
-
(0,
|
|
18619
|
+
(0, import_ssz9.fromHexString)(signedExitMessage.signature)
|
|
18315
18620
|
);
|
|
18316
18621
|
});
|
|
18317
18622
|
}
|
|
@@ -18614,7 +18919,7 @@ var Exit = class _Exit {
|
|
|
18614
18919
|
);
|
|
18615
18920
|
}
|
|
18616
18921
|
try {
|
|
18617
|
-
const sigBytes = (0,
|
|
18922
|
+
const sigBytes = (0, import_ssz9.fromHexString)(cleanSigStr);
|
|
18618
18923
|
const sigIdx = parseInt(sigIdxStr, 10);
|
|
18619
18924
|
signaturesByIndex.set(sigIdx + 1, sigBytes);
|
|
18620
18925
|
} catch (err) {
|
|
@@ -20001,6 +20306,7 @@ var Client = class extends Base {
|
|
|
20001
20306
|
blsVerify,
|
|
20002
20307
|
clusterConfigOrDefinitionHash,
|
|
20003
20308
|
clusterLockHash,
|
|
20309
|
+
hasUniqueDistributedKeys,
|
|
20004
20310
|
isChainSupportedForSplitters,
|
|
20005
20311
|
isValidClusterLock,
|
|
20006
20312
|
signCreatorConfigHashPayload,
|