@@ -38,56 +38,10 @@ contract ECDSACertificateVerifier is Initializable, ECDSACertificateVerifierStor
3838 }
3939
4040 /**
41- * @notice Override domainSeparator to not include chainId
42- * @return The domain separator hash without chainId
41+ *
42+ * EXTERNAL FUNCTIONS
43+ *
4344 */
44- function domainSeparator () public view override returns (bytes32 ) {
45- return keccak256 (
46- abi.encode (
47- EIP712_DOMAIN_TYPEHASH_NO_CHAINID,
48- keccak256 (bytes ("EigenLayer " )),
49- keccak256 (bytes (_majorVersion ())),
50- address (this )
51- )
52- );
53- }
54-
55- /**
56- * @notice Calculate the EIP-712 digest for a certificate
57- * @param referenceTimestamp The reference timestamp
58- * @param messageHash The message hash
59- * @return The EIP-712 digest
60- * @dev This function is public to allow offchain tools to calculate the same digest
61- * @dev Note: This does not support smart contract based signatures for multichain
62- */
63- function calculateCertificateDigest (uint32 referenceTimestamp , bytes32 messageHash ) public view returns (bytes32 ) {
64- bytes32 structHash = keccak256 (abi.encode (ECDSA_CERTIFICATE_TYPEHASH, referenceTimestamp, messageHash));
65- return _calculateSignableDigest (structHash);
66- }
67-
68- ///@inheritdoc IBaseCertificateVerifier
69- function getOperatorSetOwner (
70- OperatorSet memory operatorSet
71- ) external view returns (address ) {
72- bytes32 operatorSetKey = operatorSet.key ();
73- return _operatorSetOwners[operatorSetKey];
74- }
75-
76- ///@inheritdoc IBaseCertificateVerifier
77- function maxOperatorTableStaleness (
78- OperatorSet memory operatorSet
79- ) external view returns (uint32 ) {
80- bytes32 operatorSetKey = operatorSet.key ();
81- return _maxStalenessPeriods[operatorSetKey];
82- }
83-
84- ///@inheritdoc IBaseCertificateVerifier
85- function latestReferenceTimestamp (
86- OperatorSet memory operatorSet
87- ) external view returns (uint32 ) {
88- bytes32 operatorSetKey = operatorSet.key ();
89- return _latestReferenceTimestamps[operatorSetKey];
90- }
9145
9246 ///@inheritdoc IECDSACertificateVerifier
9347 function updateOperatorTable (
@@ -158,62 +112,6 @@ contract ECDSACertificateVerifier is Initializable, ECDSACertificateVerifierStor
158112 return true ;
159113 }
160114
161- /// @inheritdoc IECDSACertificateVerifier
162- function getOperatorInfos (
163- OperatorSet memory operatorSet ,
164- uint32 referenceTimestamp
165- ) external view returns (ECDSAOperatorInfo[] memory ) {
166- bytes32 operatorSetKey = operatorSet.key ();
167- uint32 numOperators = uint32 (_numOperators[operatorSetKey][referenceTimestamp]);
168- ECDSAOperatorInfo[] memory operatorInfos = new ECDSAOperatorInfo [](numOperators);
169-
170- for (uint32 i = 0 ; i < numOperators; i++ ) {
171- operatorInfos[i] = _operatorInfos[operatorSetKey][referenceTimestamp][i];
172- }
173-
174- return operatorInfos;
175- }
176-
177- /// @inheritdoc IECDSACertificateVerifier
178- function getOperatorInfo (
179- OperatorSet memory operatorSet ,
180- uint32 referenceTimestamp ,
181- uint32 operatorIndex
182- ) external view returns (ECDSAOperatorInfo memory ) {
183- bytes32 operatorSetKey = operatorSet.key ();
184- require (operatorIndex < _numOperators[operatorSetKey][referenceTimestamp], "Operator index out of bounds " );
185- return _operatorInfos[operatorSetKey][referenceTimestamp][operatorIndex];
186- }
187-
188- /// @inheritdoc IECDSACertificateVerifier
189- function getOperatorCount (
190- OperatorSet memory operatorSet ,
191- uint32 referenceTimestamp
192- ) external view returns (uint32 ) {
193- bytes32 operatorSetKey = operatorSet.key ();
194- return uint32 (_numOperators[operatorSetKey][referenceTimestamp]);
195- }
196-
197- /// @inheritdoc IECDSACertificateVerifier
198- function getTotalStakes (
199- OperatorSet calldata operatorSet ,
200- uint32 referenceTimestamp
201- ) public view returns (uint256 [] memory ) {
202- bytes32 operatorSetKey = operatorSet.key ();
203- require (_latestReferenceTimestamps[operatorSetKey] == referenceTimestamp, ReferenceTimestampDoesNotExist ());
204- uint256 operatorCount = _numOperators[operatorSetKey][referenceTimestamp];
205- require (operatorCount > 0 , ReferenceTimestampDoesNotExist ());
206- uint256 stakeTypesCount = _operatorInfos[operatorSetKey][referenceTimestamp][0 ].weights.length ;
207- uint256 [] memory totalStakes = new uint256 [](stakeTypesCount);
208- for (uint256 i = 0 ; i < operatorCount; i++ ) {
209- uint256 [] memory weights = _operatorInfos[operatorSetKey][referenceTimestamp][uint32 (i)].weights;
210- for (uint256 j = 0 ; j < weights.length && j < stakeTypesCount; j++ ) {
211- totalStakes[j] += weights[j];
212- }
213- }
214- return totalStakes;
215- }
216-
217115 /**
218116 * @notice Internal function to verify a certificate
219117 * @param cert The certificate to verify
@@ -273,6 +171,12 @@ contract ECDSACertificateVerifier is Initializable, ECDSACertificateVerifierStor
273171 return signedStakes;
274172 }
275173
174+ /**
175+ *
176+ * INTERNAL FUNCTIONS
177+ *
178+ */
179+
276180 /**
277181 * @notice Parse signatures from the concatenated signature bytes
278182 * @param messageHash The message hash that was signed
@@ -317,4 +221,108 @@ contract ECDSACertificateVerifier is Initializable, ECDSACertificateVerifierStor
317221
318222 return (signers, true );
319223 }
224+
225+ /**
226+ *
227+ * VIEW FUNCTIONS
228+ *
229+ */
230+
231+ ///@inheritdoc IBaseCertificateVerifier
232+ function getOperatorSetOwner (
233+ OperatorSet memory operatorSet
234+ ) external view returns (address ) {
235+ bytes32 operatorSetKey = operatorSet.key ();
236+ return _operatorSetOwners[operatorSetKey];
237+ }
238+
239+ ///@inheritdoc IBaseCertificateVerifier
240+ function maxOperatorTableStaleness (
241+ OperatorSet memory operatorSet
242+ ) external view returns (uint32 ) {
243+ bytes32 operatorSetKey = operatorSet.key ();
244+ return _maxStalenessPeriods[operatorSetKey];
245+ }
246+
247+ ///@inheritdoc IBaseCertificateVerifier
248+ function latestReferenceTimestamp (
249+ OperatorSet memory operatorSet
250+ ) external view returns (uint32 ) {
251+ bytes32 operatorSetKey = operatorSet.key ();
252+ return _latestReferenceTimestamps[operatorSetKey];
253+ }
254+
255+ /// @inheritdoc IECDSACertificateVerifier
256+ function getOperatorInfos (
257+ OperatorSet memory operatorSet ,
258+ uint32 referenceTimestamp
259+ ) external view returns (ECDSAOperatorInfo[] memory ) {
260+ bytes32 operatorSetKey = operatorSet.key ();
261+ uint32 numOperators = uint32 (_numOperators[operatorSetKey][referenceTimestamp]);
262+ ECDSAOperatorInfo[] memory operatorInfos = new ECDSAOperatorInfo [](numOperators);
263+
264+ for (uint32 i = 0 ; i < numOperators; i++ ) {
265+ operatorInfos[i] = _operatorInfos[operatorSetKey][referenceTimestamp][i];
266+ }
267+
268+ return operatorInfos;
269+ }
270+
271+ /// @inheritdoc IECDSACertificateVerifier
272+ function getOperatorInfo (
273+ OperatorSet memory operatorSet ,
274+ uint32 referenceTimestamp ,
275+ uint32 operatorIndex
276+ ) external view returns (ECDSAOperatorInfo memory ) {
277+ bytes32 operatorSetKey = operatorSet.key ();
278+ require (operatorIndex < _numOperators[operatorSetKey][referenceTimestamp], "Operator index out of bounds " );
279+ return _operatorInfos[operatorSetKey][referenceTimestamp][operatorIndex];
280+ }
281+
282+ /// @inheritdoc IECDSACertificateVerifier
283+ function getOperatorCount (
284+ OperatorSet memory operatorSet ,
285+ uint32 referenceTimestamp
286+ ) external view returns (uint32 ) {
287+ bytes32 operatorSetKey = operatorSet.key ();
288+ return uint32 (_numOperators[operatorSetKey][referenceTimestamp]);
289+ }
290+
291+ /// @inheritdoc IECDSACertificateVerifier
292+ function getTotalStakes (
293+ OperatorSet calldata operatorSet ,
294+ uint32 referenceTimestamp
295+ ) public view returns (uint256 [] memory ) {
296+ bytes32 operatorSetKey = operatorSet.key ();
297+ require (_latestReferenceTimestamps[operatorSetKey] == referenceTimestamp, ReferenceTimestampDoesNotExist ());
298+ uint256 operatorCount = _numOperators[operatorSetKey][referenceTimestamp];
299+ require (operatorCount > 0 , ReferenceTimestampDoesNotExist ());
300+ uint256 stakeTypesCount = _operatorInfos[operatorSetKey][referenceTimestamp][0 ].weights.length ;
301+ uint256 [] memory totalStakes = new uint256 [](stakeTypesCount);
302+ for (uint256 i = 0 ; i < operatorCount; i++ ) {
303+ uint256 [] memory weights = _operatorInfos[operatorSetKey][referenceTimestamp][uint32 (i)].weights;
304+ for (uint256 j = 0 ; j < weights.length && j < stakeTypesCount; j++ ) {
305+ totalStakes[j] += weights[j];
306+ }
307+ }
308+ return totalStakes;
309+ }
310+
311+ /// @inheritdoc IECDSACertificateVerifier
312+ function domainSeparator () public view override (IECDSACertificateVerifier, SignatureUtilsMixin) returns (bytes32 ) {
313+ return keccak256 (
314+ abi.encode (
315+ EIP712_DOMAIN_TYPEHASH_NO_CHAINID,
316+ keccak256 (bytes ("EigenLayer " )),
317+ keccak256 (bytes (_majorVersion ())),
318+ address (this )
319+ )
320+ );
321+ }
322+
323+ /// @inheritdoc IECDSACertificateVerifier
324+ function calculateCertificateDigest (uint32 referenceTimestamp , bytes32 messageHash ) public view returns (bytes32 ) {
325+ bytes32 structHash = keccak256 (abi.encode (ECDSA_CERTIFICATE_TYPEHASH, referenceTimestamp, messageHash));
326+ return _calculateSignableDigest (structHash);
327+ }
320328}
0 commit comments