Skip to content

Commit cd5612e

Browse files
fix: include timestamp with BN254CertificateVerifier certificate generation (#1610)
**Motivation:** As is, BN254 signatures do not necessarily sign over a timestamp. To enforce this, we include it within the onchain code to ensure that signatures _must_ sign over a timestamp to prevent mutation issues. **Modifications:** * Add `calculateCertificateDigest` to the `BN254CertificateVerifier` * Add `getGlobalTableUpdateSignableDigest` to `OperatorTableUpdater` for offchain services * Update tests accordingly **Result:** BN254 certificates now signing over a reference timestamp --------- Co-authored-by: Yash Patil <40046473+ypatil12@users.noreply.github.com>
1 parent f461f70 commit cd5612e

File tree

36 files changed

+361
-92
lines changed

36 files changed

+361
-92
lines changed

docs/multichain/destination/CertificateVerifier.md

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ Certificates can be created at any time, but must contain a `referenceTimestamp`
2828

2929
**Note: Setting a max staleness period to 0 enables certificates to be confirmed against any `referenceTimestamp`. In addition, setting a `maxStalenessPeriod` that is greater than 0 and less than the frequency of table updates (daily on testnet, weekly on mainnet) is impossible due bounds enfroced by the [`CrossChainRegistry`](../source/CrossChainRegistry.md#parameterization).** See the [staleness period](#staleness-period) in the appendix for some examples.
3030

31+
Both the `BN254CertificateVerifier` and `ECDSACertificateVerifier` contain a `msgHash` parameter. This value is the the hash of a task that was completed by operators. **NOTE: The msgHash is NOT signed by operators as part of completion of a task**. The value signed by operators is the signable digest, which is the hash of the `msgHash` and `referenceTimestamp`. This signable digest is given by `certificateVerifier.calculateCertificateDigest`.
32+
3133
---
3234

3335
## ECDSACertificateVerifier
@@ -117,12 +119,15 @@ For the `msgHash`, it is up to the off-chain AVS software to add relevant metada
117119

118120
```solidity
119121
/**
120-
* @notice A Certificate used to verify a set of ECDSA signatures
121-
* @param referenceTimestamp a reference timestamp that corresponds to a timestamp at which an operator table was updated for the operatorSet.
122-
* @param messageHash the hash of the message that was signed by the operators.
123-
* The messageHash should be calculated using `calculateCertificateDigest`
124-
* @param sig the concatenated signature of each signing operator, in ascending order of signer address
122+
* @notice A Certificate used to verify a set of ECDSA signatures for an off-chain task
123+
* @param referenceTimestamp a reference timestamp that corresponds to a timestamp at which an operator table was updated for the operatorSet
124+
* @param messageHash the hash of a task that was completed by operators. The messageHash is defined by the AVS, see `TaskMailbox.sol` for an example implementation.
125+
* NOTE: This value is NOT the message that is signed by operators - see `calculateCertificateDigest` for the signable digest.
126+
* @param sig the concatenated signature of each signing operator, in ascending order of signer address. The signature should be over the signable digest,
127+
* which is calculated by `calculateCertificateDigest`
128+
* @dev The signers can be sorted via OZ sort library
125129
* @dev ECDSA certificates DO NOT support smart contract signatures
130+
* @dev The `referenceTimestamp` is used to key into the operatorSet's stake weights. It is NOT the timestamp at which the certificate was generated off-chain
126131
*/
127132
struct ECDSACertificate {
128133
uint32 referenceTimestamp;
@@ -415,14 +420,14 @@ The contract supports 3 verification patterns:
415420

416421
```solidity
417422
/**
418-
* @notice A struct that contains information about a single operator for a given BN254 operatorSet
419-
* @param pubkey The G1 public key of the operator
420-
* @param weights The weights of the operator for a single operatorSet
421-
*
422-
* @dev The `weights` array is as a list of arbitrary stake types. For example,
423-
* it can be [slashable_stake, delegated_stake, strategy_i_stake, ...]
424-
*
425-
* @dev It is up to the AVS to define the `weights` array, which is used by the `IBN254CertificateVerifier` to verify Certificates
423+
* @notice A BN254 Certificate
424+
* @param referenceTimestamp a reference timestamp that corresponds to a timestamp at which an operator table was updated for the operatorSet.
425+
* @param messageHash the hash of a task that was completed by operators. The messageHash is defined by the AVS, see `TaskMailbox.sol` for an example implementation.
426+
* NOTE: This value is NOT the message that is signed by operators - see `calculateCertificateDigest` for the signable digest.
427+
* @param signature the G1 signature of the message. The signature is over the signable digest, which is calculated by `calculateCertificateDigest`
428+
* @param apk the G2 aggregate public key
429+
* @param nonSignerWitnesses an array of witnesses of non-signing operators
430+
* @dev The `referenceTimestamp` is used to key into the operatorSet's stake weights. It is NOT the timestamp at which the certificate was generated off-chain
426431
*/
427432
struct BN254Certificate {
428433
uint32 referenceTimestamp;

pkg/bindings/BN254CertificateVerifier/binding.go

Lines changed: 33 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/BN254CertificateVerifierStorage/binding.go

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/bindings/BeaconChainProofs/binding.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)