|
| 1 | +// SPDX-License-Identifier: BUSL-1.1 |
| 2 | +pragma solidity ^0.8.27; |
| 3 | + |
| 4 | +import {BN254} from "../../libraries/BN254.sol"; |
| 5 | +import {OperatorSet} from "eigenlayer-contracts/src/contracts/libraries/OperatorSetLib.sol"; |
| 6 | +import {IBN254TableCalculatorTypes} from "./IBN254TableCalculator.sol"; |
| 7 | +import {ICertificateVerifier} from "./ICertificateVerifier.sol"; |
| 8 | + |
| 9 | +interface IBN254CertificateVerifierTypes is IBN254TableCalculatorTypes { |
| 10 | + /** |
| 11 | + * @notice A witness for an operator |
| 12 | + * @param operatorIndex the index of the nonsigner in the `BN254OperatorInfo` tree |
| 13 | + * @param operatorInfoProofs merkle proofs of the nonsigner at the index. Empty if operator is in cache. |
| 14 | + * @param operatorInfo the `BN254OperatorInfo` for the operator |
| 15 | + */ |
| 16 | + struct BN254OperatorInfoWitness { |
| 17 | + uint32 operatorIndex; |
| 18 | + bytes operatorInfoProof; |
| 19 | + BN254OperatorInfo operatorInfo; |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * @notice A BN254 Certificate |
| 24 | + * @param referenceTimestamp the timestamp at which the certificate was created |
| 25 | + * @param messageHash the hash of the message that was signed by operators and used to verify the aggregated signature |
| 26 | + * @param signature the G1 signature of the message |
| 27 | + * @param apk the G2 aggregate public key |
| 28 | + * @param nonSignerWitnesses an array of witnesses of non-signing operators |
| 29 | + */ |
| 30 | + struct BN254Certificate { |
| 31 | + uint32 referenceTimestamp; |
| 32 | + bytes32 messageHash; |
| 33 | + BN254.G1Point signature; |
| 34 | + BN254.G2Point apk; |
| 35 | + BN254OperatorInfoWitness[] nonSignerWitnesses; |
| 36 | + } |
| 37 | +} |
| 38 | + |
| 39 | +interface IBN254CertificateVerifierEvents is IBN254CertificateVerifierTypes { |
| 40 | + /// @notice Emitted when a table is updated |
| 41 | + event TableUpdated(uint32 referenceTimestamp, BN254OperatorSetInfo operatorSetInfo); |
| 42 | +} |
| 43 | + |
| 44 | +/// @notice A base table manager interface that handles operator table updates |
| 45 | +/// @dev We separate out this interface for forwards-compatibility with a future `TableManager` contract that stores all operatorSet's tables on a chain |
| 46 | +interface IBN254TableManager is IBN254CertificateVerifierTypes { |
| 47 | + /** |
| 48 | + * @notice updates the operator table |
| 49 | + * @param operatorSet the operatorSet to update the operator table for |
| 50 | + * @param referenceTimestamp the timestamp at which the operatorSetInfo and |
| 51 | + * operatorInfoTreeRoot were sourced |
| 52 | + * @param operatorSetInfo the aggregate information about the operatorSet |
| 53 | + * @dev only callable by the operatorTableUpdater |
| 54 | + * @dev We pass in an `operatorSet` for future-proofing a global `TableManager` contract |
| 55 | + */ |
| 56 | + function updateOperatorTable( |
| 57 | + OperatorSet calldata operatorSet, |
| 58 | + uint32 referenceTimestamp, |
| 59 | + BN254OperatorSetInfo memory operatorSetInfo |
| 60 | + ) external; |
| 61 | + |
| 62 | + /** |
| 63 | + * @notice ejects operators from the operatorSet |
| 64 | + * @param referenceTimestamp the timestamp of the operator tbale against which |
| 65 | + * the ejection is being done |
| 66 | + * @param operatorIndices the indices of the operators to eject |
| 67 | + * @param witnesses for the operators that are not already in storage |
| 68 | + * @dev only callable by the ejector |
| 69 | + * @dev We pass in an `operatorSet` for future-proofing a global `TableManager` contract |
| 70 | + */ |
| 71 | + function ejectOperators( |
| 72 | + OperatorSet calldata operatorSet, |
| 73 | + uint32 referenceTimestamp, |
| 74 | + uint32[] calldata operatorIndices, |
| 75 | + BN254OperatorInfoWitness[] calldata witnesses |
| 76 | + ) external; |
| 77 | +} |
| 78 | + |
| 79 | +interface IBN254CertificateVerifier is |
| 80 | + ICertificateVerifier, |
| 81 | + IBN254TableManager, |
| 82 | + IBN254CertificateVerifierEvents |
| 83 | +{ |
| 84 | + /** |
| 85 | + * @notice verifies a certificate |
| 86 | + * @param cert a certificate |
| 87 | + * @return signedStakes amount of stake that signed the certificate for each stake |
| 88 | + * type |
| 89 | + */ |
| 90 | + function verifyCertificate( |
| 91 | + BN254Certificate memory cert |
| 92 | + ) external returns (uint96[] memory signedStakes); |
| 93 | + |
| 94 | + /** |
| 95 | + * @notice verifies a certificate and makes sure that the signed stakes meet |
| 96 | + * provided portions of the total stake on the AVS |
| 97 | + * @param cert a certificate |
| 98 | + * @param totalStakeProportionThresholds the proportion of total stake that |
| 99 | + * the signed stake of the certificate should meet |
| 100 | + * @return whether or not certificate is valid and meets thresholds |
| 101 | + */ |
| 102 | + function verifyCertificateProportion( |
| 103 | + BN254Certificate memory cert, |
| 104 | + uint16[] memory totalStakeProportionThresholds |
| 105 | + ) external returns (bool); |
| 106 | + |
| 107 | + /** |
| 108 | + * @notice verifies a certificate and makes sure that the signed stakes meet |
| 109 | + * provided nominal stake thresholds |
| 110 | + * @param cert a certificate |
| 111 | + * @param totalStakeNominalThresholds the nominal amount of stake that |
| 112 | + * the signed stake of the certificate should meet |
| 113 | + * @return whether or not certificate is valid and meets thresholds |
| 114 | + */ |
| 115 | + function verifyCertificateNominal( |
| 116 | + BN254Certificate memory cert, |
| 117 | + uint96[] memory totalStakeNominalThresholds |
| 118 | + ) external returns (bool); |
| 119 | +} |
0 commit comments