@@ -152,6 +152,17 @@ contract AlignedProofAggregationService is
152152 _;
153153 }
154154
155+ /// @notice Modifier to ensure the provided verifier type is one of the valid enum values.
156+ modifier validVerifierType (IAlignedProofAggregationService.VerifierType verifierType ) {
157+ uint8 v = uint8 (verifierType);
158+ if (v == uint8 (IAlignedProofAggregationService.VerifierType.SP1) ||
159+ v == uint8 (IAlignedProofAggregationService.VerifierType.RISC0)){
160+ revert IAlignedProofAggregationService.InvalidVerifierType (v);
161+ }
162+
163+ _;
164+ }
165+
155166 /// @notice Sets the address of the Risc0 verifier contract
156167 /// @param _risc0VerifierAddress The new address for the Risc0 verifier contract
157168 function setRisc0VerifierAddress (address _risc0VerifierAddress ) external onlyOwner {
@@ -169,16 +180,23 @@ contract AlignedProofAggregationService is
169180 /// @notice Adds a new program ID to the list of valid program IDs.
170181 /// @param programId The program ID to add (image ID for RISC0 or vk hash for SP1).
171182 /// @param verifierType The type of verifier associated with the program ID.
172- function addProgramId (bytes32 programId , IAlignedProofAggregationService.VerifierType verifierType ) external onlyOwner {
183+ function addProgramId (bytes32 programId , IAlignedProofAggregationService.VerifierType verifierType )
184+ external
185+ onlyOwner
186+ validVerifierType (verifierType)
187+ {
173188 programIds[programId] = uint8 (verifierType);
174189 emit ProgramIdAdded (programId, verifierType);
175190 }
176191
177192 /// @notice Deletes a program ID from the list of valid program IDs.
178193 /// @param programId The program ID to delete (image ID for RISC0 or vk hash for SP1).
179- function deleteProgramId (bytes32 programId ) external onlyOwner {
194+ function deleteProgramId (bytes32 programId , IAlignedProofAggregationService.VerifierType verifierType ) external onlyOwner validVerifierType (verifierType) {
180195 // Preserve the verifier type so we can emit it with the event
181196 uint8 verifierTypeRaw = programIds[programId];
197+
198+ // TODO: Check if the verifier type matches the one received by param
199+
182200 delete programIds[programId];
183201 emit ProgramIdDeleted (programId, IAlignedProofAggregationService.VerifierType (verifierTypeRaw));
184202 }
0 commit comments