@@ -36,6 +36,14 @@ contract AlignedProofAggregationService is
36
36
/// if the sp1 verifier address is set to this address, then we skip verification
37
37
address public constant VERIFIER_MOCK_ADDRESS = address (0xFF );
38
38
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
+
39
47
constructor () {
40
48
_disableInitializers ();
41
49
}
@@ -44,45 +52,47 @@ contract AlignedProofAggregationService is
44
52
address newOwner ,
45
53
address _alignedAggregatorAddress ,
46
54
address _sp1VerifierAddress ,
47
- address _risc0VerifierAddress
55
+ address _risc0VerifierAddress ,
56
+ bytes32 _risc0AggregatorProgramImageId ,
57
+ bytes32 _sp1AggregatorProgramVKHash
48
58
) public initializer {
49
59
__Ownable_init ();
50
60
__UUPSUpgradeable_init ();
51
61
_transferOwnership (newOwner);
52
62
alignedAggregatorAddress = _alignedAggregatorAddress;
53
63
sp1VerifierAddress = _sp1VerifierAddress;
54
64
risc0VerifierAddress = _risc0VerifierAddress;
65
+ risc0AggregatorProgramImageId = _risc0AggregatorProgramImageId;
66
+ sp1AggregatorProgramVKHash = _sp1AggregatorProgramVKHash;
55
67
}
56
68
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
+ {
63
73
(bytes32 merkleRoot ) = abi.decode (sp1PublicValues, (bytes32 ));
64
74
65
75
// In dev mode, poofs are mocked, so we skip the verification part
66
76
if (_isSP1VerificationEnabled ()) {
67
- ISP1Verifier (sp1VerifierAddress).verifyProof (sp1ProgramVKey , sp1PublicValues, sp1ProofBytes);
77
+ ISP1Verifier (sp1VerifierAddress).verifyProof (sp1AggregatorProgramVKHash , sp1PublicValues, sp1ProofBytes);
68
78
}
69
79
70
80
aggregatedProofs[merkleRoot] = true ;
71
81
emit AggregatedProofVerified (merkleRoot, blobVersionedHash);
72
82
}
73
83
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
+ {
80
88
(bytes32 merkleRoot ) = abi.decode (risc0JournalBytes, (bytes32 ));
81
89
82
90
// In dev mode, poofs are mocked, so we skip the verification part
83
91
if (_isRisc0VerificationEnabled ()) {
84
92
bytes32 risc0JournalDigest = sha256 (risc0JournalBytes);
85
- IRiscZeroVerifier (risc0VerifierAddress).verify (risc0ReceiptSeal, risc0ImageId, risc0JournalDigest);
93
+ IRiscZeroVerifier (risc0VerifierAddress).verify (
94
+ risc0ReceiptSeal, risc0AggregatorProgramImageId, risc0JournalDigest
95
+ );
86
96
}
87
97
88
98
aggregatedProofs[merkleRoot] = true ;
@@ -115,4 +125,16 @@ contract AlignedProofAggregationService is
115
125
function setRisc0VerifierAddress (address _risc0VerifierAddress ) external onlyOwner {
116
126
risc0VerifierAddress = _risc0VerifierAddress;
117
127
}
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
+ }
118
140
}
0 commit comments