Skip to content

Commit 84e9432

Browse files
committed
feat: integrate sp1 verifier
1 parent 897caae commit 84e9432

File tree

3 files changed

+19
-9
lines changed

3 files changed

+19
-9
lines changed

contracts/remappings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ eigenlayer-scripts/=lib/eigenlayer-middleware/lib/eigenlayer-contracts/script/
55
forge-std/=lib/forge-std/src/
66
@openzeppelin/contracts/=lib/eigenlayer-middleware/lib/openzeppelin-contracts/contracts/
77
@openzeppelin-upgrades/contracts/=lib/eigenlayer-middleware/lib/openzeppelin-contracts-upgradeable/contracts/
8+
@sp1-contracts/=lib/sp1-contracts/contracts/src/

contracts/src/core/AlignedProofAggregationService.sol

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initia
55
import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/OwnableUpgradeable.sol";
66
import {UUPSUpgradeable} from "@openzeppelin-upgrades/contracts/proxy/utils/UUPSUpgradeable.sol";
77
import {IAlignedProofAggregationService} from "./IAlignedProofAggregationService.sol";
8+
import {ISP1Verifier} from "@sp1-contracts/ISP1Verifier.sol";
89

9-
/// Template for contract, SP1 verifiers needs to be added
1010
contract AlignedProofAggregationService is
1111
IAlignedProofAggregationService,
1212
Initializable,
@@ -47,9 +47,9 @@ contract AlignedProofAggregationService is
4747

4848
function verify(
4949
bytes32 blobVersionedHash,
50-
//bytes32 sp1ProgramVKey,
51-
bytes calldata sp1PublicValues
52-
//bytes calldata sp1ProofBytes
50+
bytes32 sp1ProgramVKey,
51+
bytes calldata sp1PublicValues,
52+
bytes calldata sp1ProofBytes
5353
) public onlyAlignedAggregator {
5454
// In dev mode, poofs are mocked, so we skip the verification part
5555
if (sp1VerifierAddress == VERIFIER_MOCK_ADDRESS) {
@@ -58,6 +58,15 @@ contract AlignedProofAggregationService is
5858
return;
5959
}
6060

61+
try ISP1Verifier(sp1VerifierAddress).verifyProof(sp1ProgramVKey, sp1PublicValues, sp1ProofBytes) {
62+
(bytes32 merkleRoot) = abi.decode(sp1PublicValues, (bytes32));
63+
_newAggregatedProof(merkleRoot, blobVersionedHash);
64+
} catch {
65+
AggregatedProof storage proof = aggregatedProofs[currentAggregatedProofNumber];
66+
proof.status = AggregatedProofStatus.Failed;
67+
emit NewAggregatedProof(currentAggregatedProofNumber, AggregatedProofStatus.Failed, 0x0, 0x0);
68+
currentAggregatedProofNumber += 1;
69+
}
6170
}
6271

6372
function markCurrentAggregatedProofAsMissed() public onlyAlignedAggregator {

contracts/src/core/IAlignedProofAggregationService.sol

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ interface IAlignedProofAggregationService {
2525
/// @dev This function is called by the aligned proof aggregator after collecting the proofs and aggregating them
2626
/// to be verified on-chain. We expect the blobTransactionHash to be called before
2727
/// @param blobVersionedHash the versioned hash of the blob transaction that contains the leaves that compose the merkle root.
28-
/// param sp1ProgramVKey Public verifying key
28+
/// @param sp1ProgramVKey Public verifying key
2929
/// @param sp1PublicValues Values used to perform the execution
30-
/// param sp1ProofBytes Groth16 proof
30+
/// @param sp1ProofBytes Groth16 proof
3131
function verify(
3232
bytes32 blobVersionedHash,
33-
//bytes32 sp1ProgramVKey,
34-
bytes calldata sp1PublicValues
35-
//bytes calldata sp1ProofBytes
33+
bytes32 sp1ProgramVKey,
34+
bytes calldata sp1PublicValues,
35+
bytes calldata sp1ProofBytes
3636
) external;
3737

3838
function getAggregatedProof(uint64 proofNumber)

0 commit comments

Comments
 (0)