@obolnetwork/obol-sdk 2.11.12 → 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 +446 -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 +530 -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 +835 -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/index.d.ts +1 -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
|
@@ -129,6 +129,7 @@ __export(index_exports, {
|
|
|
129
129
|
Domain: () => Domain,
|
|
130
130
|
EIP712_DOMAIN_NAME: () => EIP712_DOMAIN_NAME,
|
|
131
131
|
EIP712_DOMAIN_VERSION: () => EIP712_DOMAIN_VERSION,
|
|
132
|
+
ENR: () => ENR,
|
|
132
133
|
ENRTypedMessage: () => ENRTypedMessage,
|
|
133
134
|
EOA: () => EOA,
|
|
134
135
|
ETHER_TO_GWEI: () => ETHER_TO_GWEI,
|
|
@@ -155,6 +156,7 @@ __export(index_exports, {
|
|
|
155
156
|
blsVerify: () => blsVerify,
|
|
156
157
|
clusterConfigOrDefinitionHash: () => clusterConfigOrDefinitionHash,
|
|
157
158
|
clusterLockHash: () => clusterLockHash,
|
|
159
|
+
hasUniqueDistributedKeys: () => hasUniqueDistributedKeys,
|
|
158
160
|
isChainSupportedForSplitters: () => isChainSupportedForSplitters,
|
|
159
161
|
isValidClusterLock: () => isValidClusterLock,
|
|
160
162
|
signCreatorConfigHashPayload: () => signCreatorConfigHashPayload,
|
|
@@ -175,7 +177,7 @@ var import_uuid = require("uuid");
|
|
|
175
177
|
// package.json
|
|
176
178
|
var package_default = {
|
|
177
179
|
name: "@obolnetwork/obol-sdk",
|
|
178
|
-
version: "2.
|
|
180
|
+
version: "2.12.0",
|
|
179
181
|
description: "A package for creating Distributed Validators using the Obol API.",
|
|
180
182
|
bugs: {
|
|
181
183
|
url: "https://github.com/obolnetwork/obol-sdk/issues"
|
|
@@ -661,7 +663,7 @@ var UnsupportedChainError = class _UnsupportedChainError extends Error {
|
|
|
661
663
|
};
|
|
662
664
|
|
|
663
665
|
// src/verification/common.ts
|
|
664
|
-
var
|
|
666
|
+
var import_ssz7 = require("@chainsafe/ssz");
|
|
665
667
|
var import_elliptic = __toESM(require("elliptic"));
|
|
666
668
|
var semver = __toESM(require("semver"));
|
|
667
669
|
|
|
@@ -776,7 +778,7 @@ var signingRootType = new import_ssz.ContainerType({
|
|
|
776
778
|
});
|
|
777
779
|
|
|
778
780
|
// src/verification/v1.6.0.ts
|
|
779
|
-
var
|
|
781
|
+
var import_ssz3 = require("@chainsafe/ssz");
|
|
780
782
|
|
|
781
783
|
// node_modules/@noble/curves/node_modules/@noble/hashes/utils.js
|
|
782
784
|
function isBytes(a) {
|
|
@@ -4958,28 +4960,248 @@ function blsVerifyMultiple(pubkeys, messages, signature) {
|
|
|
4958
4960
|
function blsAggregateSignatures(signatures) {
|
|
4959
4961
|
return ls.Signature.toBytes(ls.aggregateSignatures(signatures));
|
|
4960
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
|
+
}
|
|
4961
5183
|
|
|
4962
5184
|
// src/verification/v1.6.0.ts
|
|
4963
5185
|
var clusterDefinitionContainerTypeV1X6 = (configOnly) => {
|
|
4964
5186
|
let returnedContainerType = {
|
|
4965
|
-
uuid: new
|
|
4966
|
-
name: new
|
|
4967
|
-
version: new
|
|
4968
|
-
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),
|
|
4969
5191
|
num_validators: new import_uint.UintNumberType(8),
|
|
4970
5192
|
threshold: new import_uint.UintNumberType(8),
|
|
4971
|
-
dkg_algorithm: new
|
|
4972
|
-
fork_version: new
|
|
4973
|
-
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),
|
|
4974
5196
|
creator: newCreatorContainerType(configOnly),
|
|
4975
|
-
validators: new
|
|
5197
|
+
validators: new import_ssz3.ListCompositeType(validatorsContainerType, 65536)
|
|
4976
5198
|
};
|
|
4977
5199
|
if (!configOnly) {
|
|
4978
5200
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
4979
|
-
config_hash: new
|
|
5201
|
+
config_hash: new import_ssz3.ByteVectorType(32)
|
|
4980
5202
|
});
|
|
4981
5203
|
}
|
|
4982
|
-
return new
|
|
5204
|
+
return new import_ssz3.ContainerType(returnedContainerType);
|
|
4983
5205
|
};
|
|
4984
5206
|
var hashClusterDefinitionV1X6 = (cluster, configOnly) => {
|
|
4985
5207
|
const definitionType = clusterDefinitionContainerTypeV1X6(configOnly);
|
|
@@ -4991,44 +5213,44 @@ var hashClusterDefinitionV1X6 = (cluster, configOnly) => {
|
|
|
4991
5213
|
val.num_validators = cluster.num_validators;
|
|
4992
5214
|
val.threshold = cluster.threshold;
|
|
4993
5215
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
4994
|
-
val.fork_version = (0,
|
|
5216
|
+
val.fork_version = (0, import_ssz3.fromHexString)(cluster.fork_version);
|
|
4995
5217
|
val.operators = cluster.operators.map((operator) => {
|
|
4996
|
-
return configOnly ? { address: (0,
|
|
4997
|
-
address: (0,
|
|
5218
|
+
return configOnly ? { address: (0, import_ssz3.fromHexString)(operator.address) } : {
|
|
5219
|
+
address: (0, import_ssz3.fromHexString)(operator.address),
|
|
4998
5220
|
enr: strToUint8Array(operator.enr),
|
|
4999
|
-
config_signature: (0,
|
|
5000
|
-
enr_signature: (0,
|
|
5221
|
+
config_signature: (0, import_ssz3.fromHexString)(operator.config_signature),
|
|
5222
|
+
enr_signature: (0, import_ssz3.fromHexString)(operator.enr_signature)
|
|
5001
5223
|
};
|
|
5002
5224
|
});
|
|
5003
|
-
val.creator = configOnly ? { address: (0,
|
|
5004
|
-
address: (0,
|
|
5005
|
-
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)(
|
|
5006
5228
|
cluster.creator.config_signature
|
|
5007
5229
|
)
|
|
5008
5230
|
};
|
|
5009
5231
|
val.validators = cluster.validators.map((validator) => {
|
|
5010
5232
|
return {
|
|
5011
|
-
fee_recipient_address: (0,
|
|
5012
|
-
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)
|
|
5013
5235
|
};
|
|
5014
5236
|
});
|
|
5015
5237
|
if (!configOnly) {
|
|
5016
|
-
val.config_hash = (0,
|
|
5238
|
+
val.config_hash = (0, import_ssz3.fromHexString)(cluster.config_hash);
|
|
5017
5239
|
}
|
|
5018
5240
|
return val;
|
|
5019
5241
|
};
|
|
5020
|
-
var dvContainerTypeV1X6 = new
|
|
5021
|
-
distributed_public_key: new
|
|
5022
|
-
public_shares: new
|
|
5023
|
-
pubkey: new
|
|
5024
|
-
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),
|
|
5025
5247
|
amount: new import_uint.UintNumberType(8),
|
|
5026
|
-
signature: new
|
|
5248
|
+
signature: new import_ssz3.ByteVectorType(96)
|
|
5027
5249
|
});
|
|
5028
5250
|
var clusterLockContainerTypeV1X6 = () => {
|
|
5029
|
-
return new
|
|
5251
|
+
return new import_ssz3.ContainerType({
|
|
5030
5252
|
cluster_definition: clusterDefinitionContainerTypeV1X6(false),
|
|
5031
|
-
distributed_validators: new
|
|
5253
|
+
distributed_validators: new import_ssz3.ListCompositeType(dvContainerTypeV1X6, 65536)
|
|
5032
5254
|
});
|
|
5033
5255
|
};
|
|
5034
5256
|
var hashClusterLockV1X6 = (cluster) => {
|
|
@@ -5042,18 +5264,18 @@ var hashClusterLockV1X6 = (cluster) => {
|
|
|
5042
5264
|
(dValidator) => {
|
|
5043
5265
|
var _a6, _b2, _c, _d;
|
|
5044
5266
|
return {
|
|
5045
|
-
distributed_public_key: (0,
|
|
5267
|
+
distributed_public_key: (0, import_ssz3.fromHexString)(
|
|
5046
5268
|
dValidator.distributed_public_key
|
|
5047
5269
|
),
|
|
5048
5270
|
public_shares: dValidator.public_shares.map(
|
|
5049
|
-
(publicShare) => (0,
|
|
5271
|
+
(publicShare) => (0, import_ssz3.fromHexString)(publicShare)
|
|
5050
5272
|
),
|
|
5051
|
-
pubkey: (0,
|
|
5052
|
-
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)(
|
|
5053
5275
|
(_b2 = dValidator.deposit_data) == null ? void 0 : _b2.withdrawal_credentials
|
|
5054
5276
|
),
|
|
5055
5277
|
amount: parseInt((_c = dValidator.deposit_data) == null ? void 0 : _c.amount),
|
|
5056
|
-
signature: (0,
|
|
5278
|
+
signature: (0, import_ssz3.fromHexString)((_d = dValidator.deposit_data) == null ? void 0 : _d.signature)
|
|
5057
5279
|
};
|
|
5058
5280
|
}
|
|
5059
5281
|
);
|
|
@@ -5062,6 +5284,22 @@ var hashClusterLockV1X6 = (cluster) => {
|
|
|
5062
5284
|
var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
5063
5285
|
var _a6;
|
|
5064
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
|
+
}
|
|
5065
5303
|
const pubShares = [];
|
|
5066
5304
|
const pubKeys = [];
|
|
5067
5305
|
const builderRegistrationAndDepositDataMessages = [];
|
|
@@ -5070,8 +5308,18 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5070
5308
|
const validator = validators[i];
|
|
5071
5309
|
const validatorPublicShares = validator.public_shares;
|
|
5072
5310
|
const distributedPublicKey = validator.distributed_public_key;
|
|
5073
|
-
|
|
5074
|
-
|
|
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);
|
|
5075
5323
|
}
|
|
5076
5324
|
const { isValidDepositData, depositDataMsg } = verifyDepositData(
|
|
5077
5325
|
distributedPublicKey,
|
|
@@ -5082,24 +5330,23 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5082
5330
|
if (!isValidDepositData) {
|
|
5083
5331
|
return false;
|
|
5084
5332
|
}
|
|
5085
|
-
pubKeys.push((0,
|
|
5333
|
+
pubKeys.push((0, import_ssz3.fromHexString)(validator.distributed_public_key));
|
|
5086
5334
|
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5087
5335
|
blsSignatures.push(
|
|
5088
|
-
(0,
|
|
5336
|
+
(0, import_ssz3.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5089
5337
|
);
|
|
5090
5338
|
}
|
|
5091
|
-
|
|
5092
|
-
if (!blsVerifyMultiple(
|
|
5339
|
+
if (!(yield verifyBatchParallel(
|
|
5093
5340
|
pubKeys,
|
|
5094
5341
|
builderRegistrationAndDepositDataMessages,
|
|
5095
|
-
|
|
5096
|
-
)) {
|
|
5342
|
+
blsSignatures
|
|
5343
|
+
))) {
|
|
5097
5344
|
return false;
|
|
5098
5345
|
}
|
|
5099
5346
|
if (!blsVerifyAggregate(
|
|
5100
5347
|
pubShares,
|
|
5101
|
-
(0,
|
|
5102
|
-
(0,
|
|
5348
|
+
(0, import_ssz3.fromHexString)(clusterLock.lock_hash),
|
|
5349
|
+
(0, import_ssz3.fromHexString)(clusterLock.signature_aggregate)
|
|
5103
5350
|
)) {
|
|
5104
5351
|
return false;
|
|
5105
5352
|
}
|
|
@@ -5108,27 +5355,27 @@ var verifyDVV1X6 = (clusterLock) => __async(null, null, function* () {
|
|
|
5108
5355
|
|
|
5109
5356
|
// src/verification/v1.7.0.ts
|
|
5110
5357
|
var import_uint2 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
5111
|
-
var
|
|
5358
|
+
var import_ssz4 = require("@chainsafe/ssz");
|
|
5112
5359
|
var clusterDefinitionContainerTypeV1X7 = (configOnly) => {
|
|
5113
5360
|
let returnedContainerType = {
|
|
5114
|
-
uuid: new
|
|
5115
|
-
name: new
|
|
5116
|
-
version: new
|
|
5117
|
-
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),
|
|
5118
5365
|
num_validators: new import_uint2.UintNumberType(8),
|
|
5119
5366
|
threshold: new import_uint2.UintNumberType(8),
|
|
5120
|
-
dkg_algorithm: new
|
|
5121
|
-
fork_version: new
|
|
5122
|
-
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),
|
|
5123
5370
|
creator: newCreatorContainerType(configOnly),
|
|
5124
|
-
validators: new
|
|
5371
|
+
validators: new import_ssz4.ListCompositeType(validatorsContainerType, 65536)
|
|
5125
5372
|
};
|
|
5126
5373
|
if (!configOnly) {
|
|
5127
5374
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
5128
|
-
config_hash: new
|
|
5375
|
+
config_hash: new import_ssz4.ByteVectorType(32)
|
|
5129
5376
|
});
|
|
5130
5377
|
}
|
|
5131
|
-
return new
|
|
5378
|
+
return new import_ssz4.ContainerType(returnedContainerType);
|
|
5132
5379
|
};
|
|
5133
5380
|
var hashClusterDefinitionV1X7 = (cluster, configOnly) => {
|
|
5134
5381
|
const definitionType = clusterDefinitionContainerTypeV1X7(configOnly);
|
|
@@ -5140,42 +5387,42 @@ var hashClusterDefinitionV1X7 = (cluster, configOnly) => {
|
|
|
5140
5387
|
val.num_validators = cluster.num_validators;
|
|
5141
5388
|
val.threshold = cluster.threshold;
|
|
5142
5389
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
5143
|
-
val.fork_version = (0,
|
|
5390
|
+
val.fork_version = (0, import_ssz4.fromHexString)(cluster.fork_version);
|
|
5144
5391
|
val.operators = cluster.operators.map((operator) => {
|
|
5145
|
-
return configOnly ? { address: (0,
|
|
5146
|
-
address: (0,
|
|
5392
|
+
return configOnly ? { address: (0, import_ssz4.fromHexString)(operator.address) } : {
|
|
5393
|
+
address: (0, import_ssz4.fromHexString)(operator.address),
|
|
5147
5394
|
enr: strToUint8Array(operator.enr),
|
|
5148
|
-
config_signature: (0,
|
|
5149
|
-
enr_signature: (0,
|
|
5395
|
+
config_signature: (0, import_ssz4.fromHexString)(operator.config_signature),
|
|
5396
|
+
enr_signature: (0, import_ssz4.fromHexString)(operator.enr_signature)
|
|
5150
5397
|
};
|
|
5151
5398
|
});
|
|
5152
|
-
val.creator = configOnly ? { address: (0,
|
|
5153
|
-
address: (0,
|
|
5154
|
-
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)(
|
|
5155
5402
|
cluster.creator.config_signature
|
|
5156
5403
|
)
|
|
5157
5404
|
};
|
|
5158
5405
|
val.validators = cluster.validators.map((validator) => {
|
|
5159
5406
|
return {
|
|
5160
|
-
fee_recipient_address: (0,
|
|
5161
|
-
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)
|
|
5162
5409
|
};
|
|
5163
5410
|
});
|
|
5164
5411
|
if (!configOnly) {
|
|
5165
|
-
val.config_hash = (0,
|
|
5412
|
+
val.config_hash = (0, import_ssz4.fromHexString)(cluster.config_hash);
|
|
5166
5413
|
}
|
|
5167
5414
|
return val;
|
|
5168
5415
|
};
|
|
5169
|
-
var dvContainerTypeV1X7 = new
|
|
5170
|
-
distributed_public_key: new
|
|
5171
|
-
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),
|
|
5172
5419
|
deposit_data: depositDataContainer,
|
|
5173
5420
|
builder_registration: builderRegistrationContainer
|
|
5174
5421
|
});
|
|
5175
5422
|
var clusterLockContainerTypeV1X7 = () => {
|
|
5176
|
-
return new
|
|
5423
|
+
return new import_ssz4.ContainerType({
|
|
5177
5424
|
cluster_definition: clusterDefinitionContainerTypeV1X7(false),
|
|
5178
|
-
distributed_validators: new
|
|
5425
|
+
distributed_validators: new import_ssz4.ListCompositeType(dvContainerTypeV1X7, 65536)
|
|
5179
5426
|
});
|
|
5180
5427
|
};
|
|
5181
5428
|
var hashClusterLockV1X7 = (cluster) => {
|
|
@@ -5189,34 +5436,34 @@ var hashClusterLockV1X7 = (cluster) => {
|
|
|
5189
5436
|
(dValidator) => {
|
|
5190
5437
|
var _a6, _b2, _c, _d, _e, _f, _g, _h, _i;
|
|
5191
5438
|
return {
|
|
5192
|
-
distributed_public_key: (0,
|
|
5439
|
+
distributed_public_key: (0, import_ssz4.fromHexString)(
|
|
5193
5440
|
dValidator.distributed_public_key
|
|
5194
5441
|
),
|
|
5195
5442
|
public_shares: dValidator.public_shares.map(
|
|
5196
|
-
(publicShare) => (0,
|
|
5443
|
+
(publicShare) => (0, import_ssz4.fromHexString)(publicShare)
|
|
5197
5444
|
),
|
|
5198
5445
|
deposit_data: {
|
|
5199
|
-
pubkey: (0,
|
|
5200
|
-
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)(
|
|
5201
5448
|
(_b2 = dValidator.deposit_data) == null ? void 0 : _b2.withdrawal_credentials
|
|
5202
5449
|
),
|
|
5203
5450
|
amount: parseInt((_c = dValidator.deposit_data) == null ? void 0 : _c.amount),
|
|
5204
|
-
signature: (0,
|
|
5451
|
+
signature: (0, import_ssz4.fromHexString)(
|
|
5205
5452
|
(_d = dValidator.deposit_data) == null ? void 0 : _d.signature
|
|
5206
5453
|
)
|
|
5207
5454
|
},
|
|
5208
5455
|
builder_registration: {
|
|
5209
5456
|
message: {
|
|
5210
|
-
fee_recipient: (0,
|
|
5457
|
+
fee_recipient: (0, import_ssz4.fromHexString)(
|
|
5211
5458
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.message.fee_recipient
|
|
5212
5459
|
),
|
|
5213
5460
|
gas_limit: (_f = dValidator.builder_registration) == null ? void 0 : _f.message.gas_limit,
|
|
5214
5461
|
timestamp: (_g = dValidator.builder_registration) == null ? void 0 : _g.message.timestamp,
|
|
5215
|
-
pubkey: (0,
|
|
5462
|
+
pubkey: (0, import_ssz4.fromHexString)(
|
|
5216
5463
|
(_h = dValidator.builder_registration) == null ? void 0 : _h.message.pubkey
|
|
5217
5464
|
)
|
|
5218
5465
|
},
|
|
5219
|
-
signature: (0,
|
|
5466
|
+
signature: (0, import_ssz4.fromHexString)(
|
|
5220
5467
|
(_i = dValidator.builder_registration) == null ? void 0 : _i.signature
|
|
5221
5468
|
)
|
|
5222
5469
|
}
|
|
@@ -5228,6 +5475,22 @@ var hashClusterLockV1X7 = (cluster) => {
|
|
|
5228
5475
|
var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
5229
5476
|
var _a6, _b2;
|
|
5230
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
|
+
}
|
|
5231
5494
|
const pubShares = [];
|
|
5232
5495
|
const pubKeys = [];
|
|
5233
5496
|
const builderRegistrationAndDepositDataMessages = [];
|
|
@@ -5236,8 +5499,18 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5236
5499
|
const validator = validators[i];
|
|
5237
5500
|
const validatorPublicShares = validator.public_shares;
|
|
5238
5501
|
const distributedPublicKey = validator.distributed_public_key;
|
|
5239
|
-
|
|
5240
|
-
|
|
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);
|
|
5241
5514
|
}
|
|
5242
5515
|
const { isValidDepositData, depositDataMsg } = verifyDepositData(
|
|
5243
5516
|
distributedPublicKey,
|
|
@@ -5248,10 +5521,10 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5248
5521
|
if (!isValidDepositData) {
|
|
5249
5522
|
return false;
|
|
5250
5523
|
}
|
|
5251
|
-
pubKeys.push((0,
|
|
5524
|
+
pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
|
|
5252
5525
|
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
5253
5526
|
blsSignatures.push(
|
|
5254
|
-
(0,
|
|
5527
|
+
(0, import_ssz4.fromHexString)((_a6 = validator.deposit_data) == null ? void 0 : _a6.signature)
|
|
5255
5528
|
);
|
|
5256
5529
|
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
5257
5530
|
validator,
|
|
@@ -5261,18 +5534,17 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5261
5534
|
if (!isValidBuilderRegistration) {
|
|
5262
5535
|
return false;
|
|
5263
5536
|
}
|
|
5264
|
-
pubKeys.push((0,
|
|
5537
|
+
pubKeys.push((0, import_ssz4.fromHexString)(distributedPublicKey));
|
|
5265
5538
|
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
5266
5539
|
blsSignatures.push(
|
|
5267
|
-
(0,
|
|
5540
|
+
(0, import_ssz4.fromHexString)((_b2 = validator.builder_registration) == null ? void 0 : _b2.signature)
|
|
5268
5541
|
);
|
|
5269
5542
|
}
|
|
5270
|
-
|
|
5271
|
-
if (!blsVerifyMultiple(
|
|
5543
|
+
if (!(yield verifyBatchParallel(
|
|
5272
5544
|
pubKeys,
|
|
5273
5545
|
builderRegistrationAndDepositDataMessages,
|
|
5274
|
-
|
|
5275
|
-
)) {
|
|
5546
|
+
blsSignatures
|
|
5547
|
+
))) {
|
|
5276
5548
|
return false;
|
|
5277
5549
|
}
|
|
5278
5550
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
@@ -5280,8 +5552,8 @@ var verifyDVV1X7 = (clusterLock) => __async(null, null, function* () {
|
|
|
5280
5552
|
}
|
|
5281
5553
|
if (!blsVerifyAggregate(
|
|
5282
5554
|
pubShares,
|
|
5283
|
-
(0,
|
|
5284
|
-
(0,
|
|
5555
|
+
(0, import_ssz4.fromHexString)(clusterLock.lock_hash),
|
|
5556
|
+
(0, import_ssz4.fromHexString)(clusterLock.signature_aggregate)
|
|
5285
5557
|
)) {
|
|
5286
5558
|
return false;
|
|
5287
5559
|
}
|
|
@@ -13707,31 +13979,31 @@ var ENR = class _ENR extends BaseENR {
|
|
|
13707
13979
|
|
|
13708
13980
|
// src/verification/v1.8.0.ts
|
|
13709
13981
|
var import_uint3 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
13710
|
-
var
|
|
13982
|
+
var import_ssz5 = require("@chainsafe/ssz");
|
|
13711
13983
|
var clusterDefinitionContainerTypeV1X8 = (configOnly) => {
|
|
13712
13984
|
let returnedContainerType = {
|
|
13713
|
-
uuid: new
|
|
13714
|
-
name: new
|
|
13715
|
-
version: new
|
|
13716
|
-
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),
|
|
13717
13989
|
num_validators: new import_uint3.UintNumberType(8),
|
|
13718
13990
|
threshold: new import_uint3.UintNumberType(8),
|
|
13719
|
-
dkg_algorithm: new
|
|
13720
|
-
fork_version: new
|
|
13721
|
-
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),
|
|
13722
13994
|
creator: newCreatorContainerType(configOnly),
|
|
13723
|
-
validators: new
|
|
13724
|
-
deposit_amounts: new
|
|
13995
|
+
validators: new import_ssz5.ListCompositeType(validatorsContainerType, 65536),
|
|
13996
|
+
deposit_amounts: new import_ssz5.ListBasicType(
|
|
13725
13997
|
new import_uint3.UintNumberType(8),
|
|
13726
13998
|
256
|
|
13727
13999
|
)
|
|
13728
14000
|
};
|
|
13729
14001
|
if (!configOnly) {
|
|
13730
14002
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
13731
|
-
config_hash: new
|
|
14003
|
+
config_hash: new import_ssz5.ByteVectorType(32)
|
|
13732
14004
|
});
|
|
13733
14005
|
}
|
|
13734
|
-
return new
|
|
14006
|
+
return new import_ssz5.ContainerType(returnedContainerType);
|
|
13735
14007
|
};
|
|
13736
14008
|
var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
13737
14009
|
const definitionType = clusterDefinitionContainerTypeV1X8(configOnly);
|
|
@@ -13743,25 +14015,25 @@ var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
|
13743
14015
|
val.num_validators = cluster.num_validators;
|
|
13744
14016
|
val.threshold = cluster.threshold;
|
|
13745
14017
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
13746
|
-
val.fork_version = (0,
|
|
14018
|
+
val.fork_version = (0, import_ssz5.fromHexString)(cluster.fork_version);
|
|
13747
14019
|
val.operators = cluster.operators.map((operator) => {
|
|
13748
|
-
return configOnly ? { address: (0,
|
|
13749
|
-
address: (0,
|
|
14020
|
+
return configOnly ? { address: (0, import_ssz5.fromHexString)(operator.address) } : {
|
|
14021
|
+
address: (0, import_ssz5.fromHexString)(operator.address),
|
|
13750
14022
|
enr: strToUint8Array(operator.enr),
|
|
13751
|
-
config_signature: (0,
|
|
13752
|
-
enr_signature: (0,
|
|
14023
|
+
config_signature: (0, import_ssz5.fromHexString)(operator.config_signature),
|
|
14024
|
+
enr_signature: (0, import_ssz5.fromHexString)(operator.enr_signature)
|
|
13753
14025
|
};
|
|
13754
14026
|
});
|
|
13755
|
-
val.creator = configOnly ? { address: (0,
|
|
13756
|
-
address: (0,
|
|
13757
|
-
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)(
|
|
13758
14030
|
cluster.creator.config_signature
|
|
13759
14031
|
)
|
|
13760
14032
|
};
|
|
13761
14033
|
val.validators = cluster.validators.map((validator) => {
|
|
13762
14034
|
return {
|
|
13763
|
-
fee_recipient_address: (0,
|
|
13764
|
-
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)
|
|
13765
14037
|
};
|
|
13766
14038
|
});
|
|
13767
14039
|
if (cluster.deposit_amounts) {
|
|
@@ -13770,20 +14042,20 @@ var hashClusterDefinitionV1X8 = (cluster, configOnly) => {
|
|
|
13770
14042
|
});
|
|
13771
14043
|
}
|
|
13772
14044
|
if (!configOnly) {
|
|
13773
|
-
val.config_hash = (0,
|
|
14045
|
+
val.config_hash = (0, import_ssz5.fromHexString)(cluster.config_hash);
|
|
13774
14046
|
}
|
|
13775
14047
|
return val;
|
|
13776
14048
|
};
|
|
13777
|
-
var dvContainerTypeV1X8 = new
|
|
13778
|
-
distributed_public_key: new
|
|
13779
|
-
public_shares: new
|
|
13780
|
-
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),
|
|
13781
14053
|
builder_registration: builderRegistrationContainer
|
|
13782
14054
|
});
|
|
13783
14055
|
var clusterLockContainerTypeV1X8 = () => {
|
|
13784
|
-
return new
|
|
14056
|
+
return new import_ssz5.ContainerType({
|
|
13785
14057
|
cluster_definition: clusterDefinitionContainerTypeV1X8(false),
|
|
13786
|
-
distributed_validators: new
|
|
14058
|
+
distributed_validators: new import_ssz5.ListCompositeType(dvContainerTypeV1X8, 65536)
|
|
13787
14059
|
});
|
|
13788
14060
|
};
|
|
13789
14061
|
var hashClusterLockV1X8 = (cluster) => {
|
|
@@ -13797,35 +14069,35 @@ var hashClusterLockV1X8 = (cluster) => {
|
|
|
13797
14069
|
(dValidator) => {
|
|
13798
14070
|
var _a6, _b2, _c, _d, _e;
|
|
13799
14071
|
return {
|
|
13800
|
-
distributed_public_key: (0,
|
|
14072
|
+
distributed_public_key: (0, import_ssz5.fromHexString)(
|
|
13801
14073
|
dValidator.distributed_public_key
|
|
13802
14074
|
),
|
|
13803
14075
|
public_shares: dValidator.public_shares.map(
|
|
13804
|
-
(publicShare) => (0,
|
|
14076
|
+
(publicShare) => (0, import_ssz5.fromHexString)(publicShare)
|
|
13805
14077
|
),
|
|
13806
14078
|
// should be fixed
|
|
13807
14079
|
partial_deposit_data: dValidator.partial_deposit_data.map((depositData) => {
|
|
13808
14080
|
return {
|
|
13809
|
-
pubkey: (0,
|
|
13810
|
-
withdrawal_credentials: (0,
|
|
14081
|
+
pubkey: (0, import_ssz5.fromHexString)(depositData.pubkey),
|
|
14082
|
+
withdrawal_credentials: (0, import_ssz5.fromHexString)(
|
|
13811
14083
|
depositData.withdrawal_credentials
|
|
13812
14084
|
),
|
|
13813
14085
|
amount: parseInt(depositData.amount),
|
|
13814
|
-
signature: (0,
|
|
14086
|
+
signature: (0, import_ssz5.fromHexString)(depositData.signature)
|
|
13815
14087
|
};
|
|
13816
14088
|
}),
|
|
13817
14089
|
builder_registration: {
|
|
13818
14090
|
message: {
|
|
13819
|
-
fee_recipient: (0,
|
|
14091
|
+
fee_recipient: (0, import_ssz5.fromHexString)(
|
|
13820
14092
|
(_a6 = dValidator.builder_registration) == null ? void 0 : _a6.message.fee_recipient
|
|
13821
14093
|
),
|
|
13822
14094
|
gas_limit: (_b2 = dValidator.builder_registration) == null ? void 0 : _b2.message.gas_limit,
|
|
13823
14095
|
timestamp: (_c = dValidator.builder_registration) == null ? void 0 : _c.message.timestamp,
|
|
13824
|
-
pubkey: (0,
|
|
14096
|
+
pubkey: (0, import_ssz5.fromHexString)(
|
|
13825
14097
|
(_d = dValidator.builder_registration) == null ? void 0 : _d.message.pubkey
|
|
13826
14098
|
)
|
|
13827
14099
|
},
|
|
13828
|
-
signature: (0,
|
|
14100
|
+
signature: (0, import_ssz5.fromHexString)(
|
|
13829
14101
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.signature
|
|
13830
14102
|
)
|
|
13831
14103
|
}
|
|
@@ -13837,6 +14109,22 @@ var hashClusterLockV1X8 = (cluster) => {
|
|
|
13837
14109
|
var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
13838
14110
|
var _a6;
|
|
13839
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
|
+
}
|
|
13840
14128
|
const pubShares = [];
|
|
13841
14129
|
const pubKeys = [];
|
|
13842
14130
|
const builderRegistrationAndDepositDataMessages = [];
|
|
@@ -13845,8 +14133,18 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13845
14133
|
const validator = validators[i];
|
|
13846
14134
|
const validatorPublicShares = validator.public_shares;
|
|
13847
14135
|
const distributedPublicKey = validator.distributed_public_key;
|
|
13848
|
-
|
|
13849
|
-
|
|
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);
|
|
13850
14148
|
}
|
|
13851
14149
|
const depositAmounts = clusterLock.cluster_definition.deposit_amounts;
|
|
13852
14150
|
if (!!depositAmounts && depositAmounts !== null) {
|
|
@@ -13869,9 +14167,9 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13869
14167
|
if (!isValidDepositData) {
|
|
13870
14168
|
return false;
|
|
13871
14169
|
}
|
|
13872
|
-
pubKeys.push((0,
|
|
14170
|
+
pubKeys.push((0, import_ssz5.fromHexString)(distributedPublicKey));
|
|
13873
14171
|
builderRegistrationAndDepositDataMessages.push(depositDataMsg);
|
|
13874
|
-
blsSignatures.push((0,
|
|
14172
|
+
blsSignatures.push((0, import_ssz5.fromHexString)(depositData == null ? void 0 : depositData.signature));
|
|
13875
14173
|
}
|
|
13876
14174
|
const { isValidBuilderRegistration, builderRegistrationMsg } = verifyBuilderRegistration(
|
|
13877
14175
|
validator,
|
|
@@ -13881,18 +14179,17 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13881
14179
|
if (!isValidBuilderRegistration) {
|
|
13882
14180
|
return false;
|
|
13883
14181
|
}
|
|
13884
|
-
pubKeys.push((0,
|
|
14182
|
+
pubKeys.push((0, import_ssz5.fromHexString)(distributedPublicKey));
|
|
13885
14183
|
builderRegistrationAndDepositDataMessages.push(builderRegistrationMsg);
|
|
13886
14184
|
blsSignatures.push(
|
|
13887
|
-
(0,
|
|
14185
|
+
(0, import_ssz5.fromHexString)((_a6 = validator.builder_registration) == null ? void 0 : _a6.signature)
|
|
13888
14186
|
);
|
|
13889
14187
|
}
|
|
13890
|
-
|
|
13891
|
-
if (!blsVerifyMultiple(
|
|
14188
|
+
if (!(yield verifyBatchParallel(
|
|
13892
14189
|
pubKeys,
|
|
13893
14190
|
builderRegistrationAndDepositDataMessages,
|
|
13894
|
-
|
|
13895
|
-
)) {
|
|
14191
|
+
blsSignatures
|
|
14192
|
+
))) {
|
|
13896
14193
|
return false;
|
|
13897
14194
|
}
|
|
13898
14195
|
if (!verifyNodeSignatures(clusterLock)) {
|
|
@@ -13900,8 +14197,8 @@ var verifyDVV1X8 = (clusterLock) => __async(null, null, function* () {
|
|
|
13900
14197
|
}
|
|
13901
14198
|
if (!blsVerifyAggregate(
|
|
13902
14199
|
pubShares,
|
|
13903
|
-
(0,
|
|
13904
|
-
(0,
|
|
14200
|
+
(0, import_ssz5.fromHexString)(clusterLock.lock_hash),
|
|
14201
|
+
(0, import_ssz5.fromHexString)(clusterLock.signature_aggregate)
|
|
13905
14202
|
)) {
|
|
13906
14203
|
return false;
|
|
13907
14204
|
}
|
|
@@ -13982,34 +14279,34 @@ var validateSmartContractSignature = (_0) => __async(null, [_0], function* ({
|
|
|
13982
14279
|
|
|
13983
14280
|
// src/verification/v1.10.0.ts
|
|
13984
14281
|
var import_uint4 = require("@chainsafe/ssz/lib/type/uint.js");
|
|
13985
|
-
var
|
|
14282
|
+
var import_ssz6 = require("@chainsafe/ssz");
|
|
13986
14283
|
var clusterDefinitionContainerTypeV1X10 = (configOnly) => {
|
|
13987
14284
|
let returnedContainerType = {
|
|
13988
|
-
uuid: new
|
|
13989
|
-
name: new
|
|
13990
|
-
version: new
|
|
13991
|
-
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),
|
|
13992
14289
|
num_validators: new import_uint4.UintNumberType(8),
|
|
13993
14290
|
threshold: new import_uint4.UintNumberType(8),
|
|
13994
|
-
dkg_algorithm: new
|
|
13995
|
-
fork_version: new
|
|
13996
|
-
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),
|
|
13997
14294
|
creator: newCreatorContainerType(configOnly),
|
|
13998
|
-
validators: new
|
|
13999
|
-
deposit_amounts: new
|
|
14295
|
+
validators: new import_ssz6.ListCompositeType(validatorsContainerType, 65536),
|
|
14296
|
+
deposit_amounts: new import_ssz6.ListBasicType(
|
|
14000
14297
|
new import_uint4.UintNumberType(8),
|
|
14001
14298
|
256
|
|
14002
14299
|
),
|
|
14003
|
-
consensus_protocol: new
|
|
14300
|
+
consensus_protocol: new import_ssz6.ByteListType(256),
|
|
14004
14301
|
target_gas_limit: new import_uint4.UintNumberType(8),
|
|
14005
|
-
compounding: new
|
|
14302
|
+
compounding: new import_ssz6.BooleanType()
|
|
14006
14303
|
};
|
|
14007
14304
|
if (!configOnly) {
|
|
14008
14305
|
returnedContainerType = __spreadProps(__spreadValues({}, returnedContainerType), {
|
|
14009
|
-
config_hash: new
|
|
14306
|
+
config_hash: new import_ssz6.ByteVectorType(32)
|
|
14010
14307
|
});
|
|
14011
14308
|
}
|
|
14012
|
-
return new
|
|
14309
|
+
return new import_ssz6.ContainerType(returnedContainerType);
|
|
14013
14310
|
};
|
|
14014
14311
|
var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
14015
14312
|
const definitionType = clusterDefinitionContainerTypeV1X10(configOnly);
|
|
@@ -14021,25 +14318,25 @@ var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
|
14021
14318
|
val.num_validators = cluster.num_validators;
|
|
14022
14319
|
val.threshold = cluster.threshold;
|
|
14023
14320
|
val.dkg_algorithm = strToUint8Array(cluster.dkg_algorithm);
|
|
14024
|
-
val.fork_version = (0,
|
|
14321
|
+
val.fork_version = (0, import_ssz6.fromHexString)(cluster.fork_version);
|
|
14025
14322
|
val.operators = cluster.operators.map((operator) => {
|
|
14026
|
-
return configOnly ? { address: (0,
|
|
14027
|
-
address: (0,
|
|
14323
|
+
return configOnly ? { address: (0, import_ssz6.fromHexString)(operator.address) } : {
|
|
14324
|
+
address: (0, import_ssz6.fromHexString)(operator.address),
|
|
14028
14325
|
enr: strToUint8Array(operator.enr),
|
|
14029
|
-
config_signature: (0,
|
|
14030
|
-
enr_signature: (0,
|
|
14326
|
+
config_signature: (0, import_ssz6.fromHexString)(operator.config_signature),
|
|
14327
|
+
enr_signature: (0, import_ssz6.fromHexString)(operator.enr_signature)
|
|
14031
14328
|
};
|
|
14032
14329
|
});
|
|
14033
|
-
val.creator = configOnly ? { address: (0,
|
|
14034
|
-
address: (0,
|
|
14035
|
-
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)(
|
|
14036
14333
|
cluster.creator.config_signature
|
|
14037
14334
|
)
|
|
14038
14335
|
};
|
|
14039
14336
|
val.validators = cluster.validators.map((validator) => {
|
|
14040
14337
|
return {
|
|
14041
|
-
fee_recipient_address: (0,
|
|
14042
|
-
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)
|
|
14043
14340
|
};
|
|
14044
14341
|
});
|
|
14045
14342
|
if (cluster.deposit_amounts) {
|
|
@@ -14057,20 +14354,20 @@ var hashClusterDefinitionV1X10 = (cluster, configOnly) => {
|
|
|
14057
14354
|
val.compounding = cluster.compounding;
|
|
14058
14355
|
}
|
|
14059
14356
|
if (!configOnly) {
|
|
14060
|
-
val.config_hash = (0,
|
|
14357
|
+
val.config_hash = (0, import_ssz6.fromHexString)(cluster.config_hash);
|
|
14061
14358
|
}
|
|
14062
14359
|
return val;
|
|
14063
14360
|
};
|
|
14064
|
-
var dvContainerTypeV1X10 = new
|
|
14065
|
-
distributed_public_key: new
|
|
14066
|
-
public_shares: new
|
|
14067
|
-
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),
|
|
14068
14365
|
builder_registration: builderRegistrationContainer
|
|
14069
14366
|
});
|
|
14070
14367
|
var clusterLockContainerTypeV1X10 = () => {
|
|
14071
|
-
return new
|
|
14368
|
+
return new import_ssz6.ContainerType({
|
|
14072
14369
|
cluster_definition: clusterDefinitionContainerTypeV1X10(false),
|
|
14073
|
-
distributed_validators: new
|
|
14370
|
+
distributed_validators: new import_ssz6.ListCompositeType(dvContainerTypeV1X10, 65536)
|
|
14074
14371
|
});
|
|
14075
14372
|
};
|
|
14076
14373
|
var hashClusterLockV1X10 = (cluster) => {
|
|
@@ -14084,35 +14381,35 @@ var hashClusterLockV1X10 = (cluster) => {
|
|
|
14084
14381
|
(dValidator) => {
|
|
14085
14382
|
var _a6, _b2, _c, _d, _e;
|
|
14086
14383
|
return {
|
|
14087
|
-
distributed_public_key: (0,
|
|
14384
|
+
distributed_public_key: (0, import_ssz6.fromHexString)(
|
|
14088
14385
|
dValidator.distributed_public_key
|
|
14089
14386
|
),
|
|
14090
14387
|
public_shares: dValidator.public_shares.map(
|
|
14091
|
-
(publicShare) => (0,
|
|
14388
|
+
(publicShare) => (0, import_ssz6.fromHexString)(publicShare)
|
|
14092
14389
|
),
|
|
14093
14390
|
// should be fixed
|
|
14094
14391
|
partial_deposit_data: dValidator.partial_deposit_data.map((depositData) => {
|
|
14095
14392
|
return {
|
|
14096
|
-
pubkey: (0,
|
|
14097
|
-
withdrawal_credentials: (0,
|
|
14393
|
+
pubkey: (0, import_ssz6.fromHexString)(depositData.pubkey),
|
|
14394
|
+
withdrawal_credentials: (0, import_ssz6.fromHexString)(
|
|
14098
14395
|
depositData.withdrawal_credentials
|
|
14099
14396
|
),
|
|
14100
14397
|
amount: parseInt(depositData.amount),
|
|
14101
|
-
signature: (0,
|
|
14398
|
+
signature: (0, import_ssz6.fromHexString)(depositData.signature)
|
|
14102
14399
|
};
|
|
14103
14400
|
}),
|
|
14104
14401
|
builder_registration: {
|
|
14105
14402
|
message: {
|
|
14106
|
-
fee_recipient: (0,
|
|
14403
|
+
fee_recipient: (0, import_ssz6.fromHexString)(
|
|
14107
14404
|
(_a6 = dValidator.builder_registration) == null ? void 0 : _a6.message.fee_recipient
|
|
14108
14405
|
),
|
|
14109
14406
|
gas_limit: (_b2 = dValidator.builder_registration) == null ? void 0 : _b2.message.gas_limit,
|
|
14110
14407
|
timestamp: (_c = dValidator.builder_registration) == null ? void 0 : _c.message.timestamp,
|
|
14111
|
-
pubkey: (0,
|
|
14408
|
+
pubkey: (0, import_ssz6.fromHexString)(
|
|
14112
14409
|
(_d = dValidator.builder_registration) == null ? void 0 : _d.message.pubkey
|
|
14113
14410
|
)
|
|
14114
14411
|
},
|
|
14115
|
-
signature: (0,
|
|
14412
|
+
signature: (0, import_ssz6.fromHexString)(
|
|
14116
14413
|
(_e = dValidator.builder_registration) == null ? void 0 : _e.signature
|
|
14117
14414
|
)
|
|
14118
14415
|
}
|
|
@@ -14271,8 +14568,8 @@ var computeSigningRoot = (sszObjectRoot, domain) => {
|
|
|
14271
14568
|
};
|
|
14272
14569
|
var computeDepositMsgRoot = (msg) => {
|
|
14273
14570
|
const depositMsgVal = depositMessageType.defaultValue();
|
|
14274
|
-
depositMsgVal.pubkey = (0,
|
|
14275
|
-
depositMsgVal.withdrawal_credentials = (0,
|
|
14571
|
+
depositMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
|
|
14572
|
+
depositMsgVal.withdrawal_credentials = (0, import_ssz7.fromHexString)(
|
|
14276
14573
|
msg.withdrawal_credentials
|
|
14277
14574
|
);
|
|
14278
14575
|
depositMsgVal.amount = parseInt(msg.amount);
|
|
@@ -14286,16 +14583,16 @@ var computeForkDataRoot = (currentVersion, genesisValidatorsRoot) => {
|
|
|
14286
14583
|
};
|
|
14287
14584
|
var computebuilderRegistrationMsgRoot = (msg) => {
|
|
14288
14585
|
const builderRegistrationMsgVal = builderRegistrationMessageType.defaultValue();
|
|
14289
|
-
builderRegistrationMsgVal.fee_recipient = (0,
|
|
14586
|
+
builderRegistrationMsgVal.fee_recipient = (0, import_ssz7.fromHexString)(msg.fee_recipient);
|
|
14290
14587
|
builderRegistrationMsgVal.gas_limit = msg.gas_limit;
|
|
14291
14588
|
builderRegistrationMsgVal.timestamp = msg.timestamp;
|
|
14292
|
-
builderRegistrationMsgVal.pubkey = (0,
|
|
14589
|
+
builderRegistrationMsgVal.pubkey = (0, import_ssz7.fromHexString)(msg.pubkey);
|
|
14293
14590
|
return Buffer.from(
|
|
14294
14591
|
builderRegistrationMessageType.hashTreeRoot(builderRegistrationMsgVal).buffer
|
|
14295
14592
|
);
|
|
14296
14593
|
};
|
|
14297
|
-
var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0,
|
|
14298
|
-
const forkVersion = (0,
|
|
14594
|
+
var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, import_ssz7.fromHexString)(GENESIS_VALIDATOR_ROOT)) => {
|
|
14595
|
+
const forkVersion = (0, import_ssz7.fromHexString)(
|
|
14299
14596
|
lockForkVersion.substring(2, lockForkVersion.length)
|
|
14300
14597
|
);
|
|
14301
14598
|
const forkDataRoot = computeForkDataRoot(forkVersion, genesisValidatorsRoot);
|
|
@@ -14306,7 +14603,7 @@ var computeDomain = (domainType, lockForkVersion, genesisValidatorsRoot = (0, im
|
|
|
14306
14603
|
};
|
|
14307
14604
|
var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, forkVersion, compounding) => {
|
|
14308
14605
|
const depositDomain = computeDomain(
|
|
14309
|
-
(0,
|
|
14606
|
+
(0, import_ssz7.fromHexString)(DOMAIN_DEPOSIT),
|
|
14310
14607
|
forkVersion
|
|
14311
14608
|
);
|
|
14312
14609
|
const withdrawalPrefix = compounding ? "0x02" : "0x01";
|
|
@@ -14323,16 +14620,16 @@ var verifyDepositData = (distributedPublicKey, depositData, withdrawalAddress, f
|
|
|
14323
14620
|
return { isValidDepositData: false, depositDataMsg: depositDataRoot };
|
|
14324
14621
|
}
|
|
14325
14622
|
const isValidDepositData = blsVerify(
|
|
14326
|
-
(0,
|
|
14623
|
+
(0, import_ssz7.fromHexString)(depositData.pubkey),
|
|
14327
14624
|
depositDataRoot,
|
|
14328
|
-
(0,
|
|
14625
|
+
(0, import_ssz7.fromHexString)(depositData.signature)
|
|
14329
14626
|
);
|
|
14330
14627
|
return { isValidDepositData, depositDataMsg: depositDataRoot };
|
|
14331
14628
|
};
|
|
14332
14629
|
var verifyBuilderRegistration = (validator, feeRecipientAddress, forkVersion) => {
|
|
14333
14630
|
var _a6;
|
|
14334
14631
|
const builderDomain = computeDomain(
|
|
14335
|
-
(0,
|
|
14632
|
+
(0, import_ssz7.fromHexString)(DOMAIN_APPLICATION_BUILDER),
|
|
14336
14633
|
forkVersion
|
|
14337
14634
|
);
|
|
14338
14635
|
if (validator.distributed_public_key !== ((_a6 = validator.builder_registration) == null ? void 0 : _a6.message.pubkey)) {
|
|
@@ -14400,6 +14697,12 @@ var verifyLockData = (clusterLock) => __async(null, null, function* () {
|
|
|
14400
14697
|
}
|
|
14401
14698
|
return false;
|
|
14402
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
|
+
};
|
|
14403
14706
|
var isValidClusterLock = (clusterLock, safeRpcUrl) => __async(null, null, function* () {
|
|
14404
14707
|
try {
|
|
14405
14708
|
const definitionType = definitionFlow(clusterLock.cluster_definition);
|
|
@@ -14420,6 +14723,9 @@ var isValidClusterLock = (clusterLock, safeRpcUrl) => __async(null, null, functi
|
|
|
14420
14723
|
if (clusterLockHash(clusterLock) !== clusterLock.lock_hash) {
|
|
14421
14724
|
return false;
|
|
14422
14725
|
}
|
|
14726
|
+
if (!hasUniqueDistributedKeys(clusterLock)) {
|
|
14727
|
+
return false;
|
|
14728
|
+
}
|
|
14423
14729
|
const isValidLockData = yield verifyLockData(clusterLock);
|
|
14424
14730
|
if (!isValidLockData) {
|
|
14425
14731
|
return false;
|
|
@@ -18085,7 +18391,7 @@ var Incentives = class {
|
|
|
18085
18391
|
|
|
18086
18392
|
// src/exits/exit.ts
|
|
18087
18393
|
var elliptic2 = __toESM(require("elliptic"));
|
|
18088
|
-
var
|
|
18394
|
+
var import_ssz9 = require("@chainsafe/ssz");
|
|
18089
18395
|
|
|
18090
18396
|
// src/exits/ethUtils.ts
|
|
18091
18397
|
function getCapellaFork(fork_version) {
|
|
@@ -18122,15 +18428,15 @@ function getGenesisValidatorsRoot(beaconNodeApiUrl) {
|
|
|
18122
18428
|
}
|
|
18123
18429
|
|
|
18124
18430
|
// src/exits/verificationHelpers.ts
|
|
18125
|
-
var
|
|
18431
|
+
var import_ssz8 = require("@chainsafe/ssz");
|
|
18126
18432
|
var GENESIS_VALIDATOR_ROOT_HEX_STRING = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
18127
|
-
var ForkDataType = new
|
|
18128
|
-
currentVersion: new
|
|
18129
|
-
genesisValidatorsRoot: new
|
|
18433
|
+
var ForkDataType = new import_ssz8.ContainerType({
|
|
18434
|
+
currentVersion: new import_ssz8.ByteVectorType(4),
|
|
18435
|
+
genesisValidatorsRoot: new import_ssz8.ByteVectorType(32)
|
|
18130
18436
|
});
|
|
18131
|
-
var SigningRootType = new
|
|
18132
|
-
objectRoot: new
|
|
18133
|
-
domain: new
|
|
18437
|
+
var SigningRootType = new import_ssz8.ContainerType({
|
|
18438
|
+
objectRoot: new import_ssz8.ByteVectorType(32),
|
|
18439
|
+
domain: new import_ssz8.ByteVectorType(32)
|
|
18134
18440
|
});
|
|
18135
18441
|
function computeForkDataRoot2(currentVersion, genesisValidatorsRoot) {
|
|
18136
18442
|
const forkDataVal = ForkDataType.defaultValue();
|
|
@@ -18139,7 +18445,7 @@ function computeForkDataRoot2(currentVersion, genesisValidatorsRoot) {
|
|
|
18139
18445
|
return Buffer.from(ForkDataType.hashTreeRoot(forkDataVal).buffer);
|
|
18140
18446
|
}
|
|
18141
18447
|
function computeDomain2(domainType, forkVersionString, genesisValidatorsRootOverride) {
|
|
18142
|
-
const forkVersionBytes = (0,
|
|
18448
|
+
const forkVersionBytes = (0, import_ssz8.fromHexString)(
|
|
18143
18449
|
forkVersionString.substring(2, forkVersionString.length)
|
|
18144
18450
|
);
|
|
18145
18451
|
if (forkVersionBytes.length !== 4) {
|
|
@@ -18148,7 +18454,7 @@ function computeDomain2(domainType, forkVersionString, genesisValidatorsRootOver
|
|
|
18148
18454
|
if (domainType.length !== 4) {
|
|
18149
18455
|
throw new Error("Domain type must be 4 bytes");
|
|
18150
18456
|
}
|
|
18151
|
-
const actualGenesisValidatorsRoot = genesisValidatorsRootOverride != null ? genesisValidatorsRootOverride : (0,
|
|
18457
|
+
const actualGenesisValidatorsRoot = genesisValidatorsRootOverride != null ? genesisValidatorsRootOverride : (0, import_ssz8.fromHexString)(GENESIS_VALIDATOR_ROOT_HEX_STRING.substring(2));
|
|
18152
18458
|
if (actualGenesisValidatorsRoot.length !== 32) {
|
|
18153
18459
|
throw new Error("genesisValidatorsRoot must be 32 bytes");
|
|
18154
18460
|
}
|
|
@@ -18180,25 +18486,25 @@ function signingRoot2(domain, messageBuffer) {
|
|
|
18180
18486
|
|
|
18181
18487
|
// src/exits/exit.ts
|
|
18182
18488
|
var DOMAIN_VOLUNTARY_EXIT = "0x04000000";
|
|
18183
|
-
var SSZExitMessageType = new
|
|
18184
|
-
epoch: new
|
|
18185
|
-
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)
|
|
18186
18492
|
});
|
|
18187
|
-
var SSZPartialExitsPayloadType = new
|
|
18188
|
-
partial_exits: new
|
|
18189
|
-
new
|
|
18190
|
-
public_key: new
|
|
18191
|
-
signed_exit_message: new
|
|
18192
|
-
message: new
|
|
18193
|
-
epoch: new
|
|
18194
|
-
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)
|
|
18195
18501
|
}),
|
|
18196
|
-
signature: new
|
|
18502
|
+
signature: new import_ssz9.ByteVectorType(96)
|
|
18197
18503
|
})
|
|
18198
18504
|
}),
|
|
18199
18505
|
65536
|
|
18200
18506
|
),
|
|
18201
|
-
share_idx: new
|
|
18507
|
+
share_idx: new import_ssz9.UintNumberType(8)
|
|
18202
18508
|
});
|
|
18203
18509
|
var Exit = class _Exit {
|
|
18204
18510
|
/**
|
|
@@ -18241,7 +18547,7 @@ var Exit = class _Exit {
|
|
|
18241
18547
|
static computeExitPayloadRoot(exits) {
|
|
18242
18548
|
const sszValue = SSZPartialExitsPayloadType.defaultValue();
|
|
18243
18549
|
sszValue.partial_exits = exits.partial_exits.map((pe) => ({
|
|
18244
|
-
public_key: (0,
|
|
18550
|
+
public_key: (0, import_ssz9.fromHexString)(pe.public_key),
|
|
18245
18551
|
signed_exit_message: {
|
|
18246
18552
|
message: {
|
|
18247
18553
|
epoch: _Exit.safeParseInt(pe.signed_exit_message.message.epoch),
|
|
@@ -18249,7 +18555,7 @@ var Exit = class _Exit {
|
|
|
18249
18555
|
pe.signed_exit_message.message.validator_index
|
|
18250
18556
|
)
|
|
18251
18557
|
},
|
|
18252
|
-
signature: (0,
|
|
18558
|
+
signature: (0, import_ssz9.fromHexString)(pe.signed_exit_message.signature)
|
|
18253
18559
|
}
|
|
18254
18560
|
}));
|
|
18255
18561
|
sszValue.share_idx = exits.share_idx;
|
|
@@ -18299,18 +18605,18 @@ var Exit = class _Exit {
|
|
|
18299
18605
|
signedExitMessage.message
|
|
18300
18606
|
);
|
|
18301
18607
|
const exitDomain = computeDomain2(
|
|
18302
|
-
(0,
|
|
18608
|
+
(0, import_ssz9.fromHexString)(DOMAIN_VOLUNTARY_EXIT),
|
|
18303
18609
|
capellaForkVersionString,
|
|
18304
|
-
(0,
|
|
18610
|
+
(0, import_ssz9.fromHexString)(genesisValidatorsRootString)
|
|
18305
18611
|
);
|
|
18306
18612
|
const messageSigningRoot = signingRoot2(
|
|
18307
18613
|
exitDomain,
|
|
18308
18614
|
partialExitMessageBuffer
|
|
18309
18615
|
);
|
|
18310
18616
|
return blsVerify(
|
|
18311
|
-
(0,
|
|
18617
|
+
(0, import_ssz9.fromHexString)(publicShareKey),
|
|
18312
18618
|
messageSigningRoot,
|
|
18313
|
-
(0,
|
|
18619
|
+
(0, import_ssz9.fromHexString)(signedExitMessage.signature)
|
|
18314
18620
|
);
|
|
18315
18621
|
});
|
|
18316
18622
|
}
|
|
@@ -18613,7 +18919,7 @@ var Exit = class _Exit {
|
|
|
18613
18919
|
);
|
|
18614
18920
|
}
|
|
18615
18921
|
try {
|
|
18616
|
-
const sigBytes = (0,
|
|
18922
|
+
const sigBytes = (0, import_ssz9.fromHexString)(cleanSigStr);
|
|
18617
18923
|
const sigIdx = parseInt(sigIdxStr, 10);
|
|
18618
18924
|
signaturesByIndex.set(sigIdx + 1, sigBytes);
|
|
18619
18925
|
} catch (err) {
|
|
@@ -19973,6 +20279,7 @@ var Client = class extends Base {
|
|
|
19973
20279
|
Domain,
|
|
19974
20280
|
EIP712_DOMAIN_NAME,
|
|
19975
20281
|
EIP712_DOMAIN_VERSION,
|
|
20282
|
+
ENR,
|
|
19976
20283
|
ENRTypedMessage,
|
|
19977
20284
|
EOA,
|
|
19978
20285
|
ETHER_TO_GWEI,
|
|
@@ -19999,6 +20306,7 @@ var Client = class extends Base {
|
|
|
19999
20306
|
blsVerify,
|
|
20000
20307
|
clusterConfigOrDefinitionHash,
|
|
20001
20308
|
clusterLockHash,
|
|
20309
|
+
hasUniqueDistributedKeys,
|
|
20002
20310
|
isChainSupportedForSplitters,
|
|
20003
20311
|
isValidClusterLock,
|
|
20004
20312
|
signCreatorConfigHashPayload,
|