@@ -6,14 +6,14 @@ import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/Ownabl
66import {UUPSUpgradeable} from "@openzeppelin-upgrades/contracts/proxy/utils/UUPSUpgradeable.sol " ;
77import {IAlignedProofAggregationService} from "./IAlignedProofAggregationService.sol " ;
88import {ISP1Verifier} from "@sp1-contracts/ISP1Verifier.sol " ;
9+ import {IRiscZeroVerifier} from "@risc0-contracts/IRiscZeroVerifier.sol " ;
910
1011contract AlignedProofAggregationService is
1112 IAlignedProofAggregationService ,
1213 Initializable ,
1314 OwnableUpgradeable ,
1415 UUPSUpgradeable
1516{
16-
1717 /// @notice Map the merkle root to a boolean to indicate it was verified
1818 mapping (bytes32 => bool ) public aggregatedProofs;
1919
@@ -24,6 +24,8 @@ contract AlignedProofAggregationService is
2424 /// https://docs.succinct.xyz/onchain-verification/contract-addresses
2525 address public sp1VerifierAddress;
2626
27+ address public risc0VerifierAddress;
28+
2729 /// @notice The address of the Wallet that is allowed to call the verify function.
2830 address public alignedAggregatorAddress;
2931
@@ -46,7 +48,7 @@ contract AlignedProofAggregationService is
4648 sp1VerifierAddress = _sp1VerifierAddress;
4749 }
4850
49- function verify (
51+ function verifySP1 (
5052 bytes32 blobVersionedHash ,
5153 bytes32 sp1ProgramVKey ,
5254 bytes calldata sp1PublicValues ,
@@ -55,18 +57,40 @@ contract AlignedProofAggregationService is
5557 (bytes32 merkleRoot ) = abi.decode (sp1PublicValues, (bytes32 ));
5658
5759 // In dev mode, poofs are mocked, so we skip the verification part
58- if (_isVerificationEnabled ()) {
60+ if (_isSP1VerificationEnabled ()) {
5961 ISP1Verifier (sp1VerifierAddress).verifyProof (sp1ProgramVKey, sp1PublicValues, sp1ProofBytes);
6062 }
6163
6264 aggregatedProofs[merkleRoot] = true ;
6365 emit AggregatedProofVerified (merkleRoot, blobVersionedHash);
6466 }
6567
66- function _isVerificationEnabled () internal view returns (bool ) {
68+ function verifyRisc0 (
69+ bytes32 blobVersionedHash ,
70+ bytes calldata risc0ReceiptSeal ,
71+ bytes32 risc0ImageId ,
72+ bytes calldata risc0JournalBytes
73+ ) public onlyAlignedAggregator {
74+ (bytes32 merkleRoot ) = abi.decode (risc0JournalBytes, (bytes32 ));
75+
76+ // In dev mode, poofs are mocked, so we skip the verification part
77+ if (_isRisc0VerificationEnabled ()) {
78+ bytes32 risc0JournalDigest = sha256 (risc0JournalBytes);
79+ IRiscZeroVerifier (risc0VerifierAddress).verify (risc0ReceiptSeal, risc0ImageId, risc0JournalDigest);
80+ }
81+
82+ aggregatedProofs[merkleRoot] = true ;
83+ emit AggregatedProofVerified (merkleRoot, blobVersionedHash);
84+ }
85+
86+ function _isSP1VerificationEnabled () internal view returns (bool ) {
6787 return sp1VerifierAddress != VERIFIER_MOCK_ADDRESS;
6888 }
6989
90+ function _isRisc0VerificationEnabled () internal view returns (bool ) {
91+ return risc0VerifierAddress != VERIFIER_MOCK_ADDRESS;
92+ }
93+
7094 function _authorizeUpgrade (address newImplementation )
7195 internal
7296 override
0 commit comments