-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(protocol): improve protocol documentation (#14399)
Co-authored-by: Brechtpd <[email protected]> Co-authored-by: David <[email protected]> Co-authored-by: d1onys1us <[email protected]>
- Loading branch information
1 parent
fd54f13
commit fbbc417
Showing
39 changed files
with
1,015 additions
and
397 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,36 +9,48 @@ pragma solidity ^0.8.20; | |
import { AddressResolver } from "../common/AddressResolver.sol"; | ||
import { EssentialContract } from "../common/EssentialContract.sol"; | ||
import { Proxied } from "../common/Proxied.sol"; | ||
import { LibVerifyZKP } from "./libs/proofTypes/LibVerifyZKP.sol"; | ||
import { LibZKPVerifier } from "./libs/verifiers/LibZKPVerifier.sol"; | ||
import { IProofVerifier } from "./IProofVerifier.sol"; | ||
import { LibBytesUtils } from "../thirdparty/LibBytesUtils.sol"; | ||
|
||
/// @custom:security-contact [email protected] | ||
/** | ||
* @title ProofVerifier | ||
* @dev Contract for verifying proofs in the rollup. | ||
*/ | ||
contract ProofVerifier is EssentialContract, IProofVerifier { | ||
uint256[50] private __gap; | ||
|
||
error L1_INVALID_PROOF(); | ||
|
||
/** | ||
* @notice Initializes the contract with the provided address manager. | ||
* @param _addressManager The address of the address manager contract. | ||
*/ | ||
function init(address _addressManager) external initializer { | ||
EssentialContract._init(_addressManager); | ||
} | ||
|
||
/** | ||
* Verifying proofs | ||
* @notice Verifies the provided proofs. | ||
* @dev Throws an error if verification fails. | ||
* | ||
* @param blockProofs Raw bytes of proof(s) | ||
* @param blockProofs Raw bytes of proof(s). | ||
* @param instance Hashed evidence & config data. If set to zero, proof is | ||
* assumed to be from oracle/system prover. | ||
*/ | ||
function verifyProofs( | ||
uint256, //Can be used later when supporting different types of proofs | ||
uint256, /*blockId*/ | ||
bytes calldata blockProofs, | ||
bytes32 instance | ||
) | ||
external | ||
view | ||
{ | ||
// Not checked if oracle/system prover | ||
// If instance is zero, proof is considered as from oracle/system prover | ||
// and not checked. | ||
if (instance == 0) return; | ||
|
||
// Validate the instance using bytes utilities. | ||
if ( | ||
!LibBytesUtils.equal( | ||
LibBytesUtils.slice(blockProofs, 2, 32), | ||
|
@@ -57,13 +69,18 @@ contract ProofVerifier is EssentialContract, IProofVerifier { | |
revert L1_INVALID_PROOF(); | ||
} | ||
|
||
// Extract verifier ID from the proof. | ||
uint16 verifierId = uint16(bytes2(blockProofs[0:2])); | ||
|
||
// Verify ZK proof | ||
LibVerifyZKP.verifyProof( | ||
// Delegate to the ZKP verifier library to validate the proof. | ||
LibZKPVerifier.verifyProof( | ||
AddressResolver(address(this)), blockProofs[2:], verifierId | ||
); | ||
} | ||
} | ||
|
||
/** | ||
* @title ProxiedProofVerifier | ||
* @dev Proxied version of the ProofVerifier contract. | ||
*/ | ||
contract ProxiedProofVerifier is Proxied, ProofVerifier { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.