@@ -36,6 +36,14 @@ contract AlignedProofAggregationService is
3636 /// if the sp1 verifier address is set to this address, then we skip verification
3737 address public constant VERIFIER_MOCK_ADDRESS = address (0xFF );
3838
39+ /// The unique identifier (image ID) of the RISC Zero aggregator program.
40+ /// This ensures that only proofs generated by a trusted Risc0 program can be verified.
41+ bytes32 public risc0AggregatorProgramImageId;
42+
43+ /// The verification key hash for the SP1 aggregator program.
44+ /// This ensures that only proofs generated by a trusted SP1 program can be verified.
45+ bytes32 public sp1AggregatorProgramVKHash;
46+
3947 constructor () {
4048 _disableInitializers ();
4149 }
@@ -44,45 +52,47 @@ contract AlignedProofAggregationService is
4452 address newOwner ,
4553 address _alignedAggregatorAddress ,
4654 address _sp1VerifierAddress ,
47- address _risc0VerifierAddress
55+ address _risc0VerifierAddress ,
56+ bytes32 _risc0AggregatorProgramImageId ,
57+ bytes32 _sp1AggregatorProgramVKHash
4858 ) public initializer {
4959 __Ownable_init ();
5060 __UUPSUpgradeable_init ();
5161 _transferOwnership (newOwner);
5262 alignedAggregatorAddress = _alignedAggregatorAddress;
5363 sp1VerifierAddress = _sp1VerifierAddress;
5464 risc0VerifierAddress = _risc0VerifierAddress;
65+ risc0AggregatorProgramImageId = _risc0AggregatorProgramImageId;
66+ sp1AggregatorProgramVKHash = _sp1AggregatorProgramVKHash;
5567 }
5668
57- function verifySP1 (
58- bytes32 blobVersionedHash ,
59- bytes32 sp1ProgramVKey ,
60- bytes calldata sp1PublicValues ,
61- bytes calldata sp1ProofBytes
62- ) public onlyAlignedAggregator {
69+ function verifySP1 (bytes32 blobVersionedHash , bytes calldata sp1PublicValues , bytes calldata sp1ProofBytes )
70+ public
71+ onlyAlignedAggregator
72+ {
6373 (bytes32 merkleRoot ) = abi.decode (sp1PublicValues, (bytes32 ));
6474
6575 // In dev mode, poofs are mocked, so we skip the verification part
6676 if (_isSP1VerificationEnabled ()) {
67- ISP1Verifier (sp1VerifierAddress).verifyProof (sp1ProgramVKey , sp1PublicValues, sp1ProofBytes);
77+ ISP1Verifier (sp1VerifierAddress).verifyProof (sp1AggregatorProgramVKHash , sp1PublicValues, sp1ProofBytes);
6878 }
6979
7080 aggregatedProofs[merkleRoot] = true ;
7181 emit AggregatedProofVerified (merkleRoot, blobVersionedHash);
7282 }
7383
74- function verifyRisc0 (
75- bytes32 blobVersionedHash ,
76- bytes calldata risc0ReceiptSeal ,
77- bytes32 risc0ImageId ,
78- bytes calldata risc0JournalBytes
79- ) public onlyAlignedAggregator {
84+ function verifyRisc0 (bytes32 blobVersionedHash , bytes calldata risc0ReceiptSeal , bytes calldata risc0JournalBytes )
85+ public
86+ onlyAlignedAggregator
87+ {
8088 (bytes32 merkleRoot ) = abi.decode (risc0JournalBytes, (bytes32 ));
8189
8290 // In dev mode, poofs are mocked, so we skip the verification part
8391 if (_isRisc0VerificationEnabled ()) {
8492 bytes32 risc0JournalDigest = sha256 (risc0JournalBytes);
85- IRiscZeroVerifier (risc0VerifierAddress).verify (risc0ReceiptSeal, risc0ImageId, risc0JournalDigest);
93+ IRiscZeroVerifier (risc0VerifierAddress).verify (
94+ risc0ReceiptSeal, risc0AggregatorProgramImageId, risc0JournalDigest
95+ );
8696 }
8797
8898 aggregatedProofs[merkleRoot] = true ;
@@ -115,4 +125,16 @@ contract AlignedProofAggregationService is
115125 function setRisc0VerifierAddress (address _risc0VerifierAddress ) external onlyOwner {
116126 risc0VerifierAddress = _risc0VerifierAddress;
117127 }
128+
129+ /// @notice Sets the image id of the Risc0 program
130+ /// @param _risc0AggregatorProgramImageId The new imageid for the Risc0 aggregator program
131+ function setRisc0AggregatorProgramImageId (bytes32 _risc0AggregatorProgramImageId ) external onlyOwner {
132+ risc0AggregatorProgramImageId = _risc0AggregatorProgramImageId;
133+ }
134+
135+ /// @notice Sets the vk hash of the sp1 program
136+ /// @param _sp1AggregatorProgramVKHash The new vk hash for the sp1 aggregator program
137+ function setSP1AggregatorProgramVKHash (bytes32 _sp1AggregatorProgramVKHash ) external onlyOwner {
138+ sp1AggregatorProgramVKHash = _sp1AggregatorProgramVKHash;
139+ }
118140}
0 commit comments