Skip to content

Commit c3311d3

Browse files
committed
feat: zisk integration in aligned proof aggregation service contract
1 parent b47e4e2 commit c3311d3

10 files changed

Lines changed: 140 additions & 12 deletions

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ show_aligned_error_codes: ## Show AlignedLayer error codes
107107

108108
__CONTRACTS_DEPLOYMENT_ANVIL__: ## ____
109109

110-
anvil_deploy_all_contracts: anvil_deploy_eigen_contracts anvil_deploy_risc0_contracts anvil_deploy_sp1_contracts anvil_deploy_aligned_contracts
110+
anvil_deploy_all_contracts: anvil_deploy_eigen_contracts anvil_deploy_risc0_contracts anvil_deploy_sp1_contracts anvil_deploy_zisk_contracts anvil_deploy_aligned_contracts
111111

112112
anvil_deploy_eigen_contracts: ## Deploy EigenLayer Contracts on ANVIL
113113
@echo "Deploying Eigen Contracts..."
@@ -121,6 +121,10 @@ anvil_deploy_sp1_contracts: ## Deploy SP1 Contracts used by Aggregation Mode on
121121
@echo "Deploying SP1 Contracts..."
122122
. contracts/scripts/anvil/deploy_sp1_contracts.sh
123123

124+
anvil_deploy_zisk_contracts: ## Deploy Zisk Contracts used by Aggregation Mode on ANVIL
125+
@echo "Deploying Zisk Contracts..."
126+
. contracts/scripts/anvil/deploy_zisk_contracts.sh
127+
124128
anvil_deploy_aligned_contracts: ## Deploy Aligned Contracts (Verification Layer and Aggregation Mode) on ANVIL
125129
@echo "Deploying Aligned Contracts..."
126130
. contracts/scripts/anvil/deploy_aligned_contracts.sh

contracts/script/deploy/AlignedProofAggregationServiceDeployer.s.sol

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ contract AlignedProofAggregationServiceDeployer is Script {
1818
address risc0VerifierAddress = stdJson.readAddress(config_data, ".address.risc0VerifierAddress");
1919
bytes32 risc0AggregationProgramImageId =
2020
stdJson.readBytes32(config_data, ".programs_id.risc0AggregationProgramImageId");
21+
address ziskVerifierAddress = stdJson.readAddress(config_data, ".address.ziskVerifierAddress");
22+
bytes32 ziskAggregationProgramVKHash =
23+
stdJson.readBytes32(config_data, ".programs_id.ziskAggregationProgramVKHash");
2124

2225
address ownerAddress = stdJson.readAddress(config_data, ".permissions.owner");
2326

@@ -28,13 +31,15 @@ contract AlignedProofAggregationServiceDeployer is Script {
2831
ERC1967Proxy proxy = new ERC1967Proxy(
2932
address(alignedProofAggregationService),
3033
abi.encodeWithSignature(
31-
"initialize(address,address,address,address,bytes32,bytes32)",
34+
"initialize(address,address,address,address,address,bytes32,bytes32,bytes32)",
3235
ownerAddress,
3336
alignedAggregatorAddress,
3437
sp1VerifierAddress,
3538
risc0VerifierAddress,
39+
ziskVerifierAddress,
3640
risc0AggregationProgramImageId,
37-
sp1AggregationProgramVKHash
41+
sp1AggregationProgramVKHash,
42+
ziskAggregationProgramVKHash
3843
)
3944
);
4045

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
pragma solidity ^0.8.20;
3+
4+
import {Script} from "forge-std/Script.sol";
5+
import {console2} from "forge-std/console2.sol";
6+
import {ZiskVerifier} from "../../src/zisk/ZiskVerifier.sol";
7+
8+
contract ZiskVerifierDeployer is Script {
9+
function run() external {
10+
uint256 deployerKey = uint256(vm.envBytes32("DEPLOYER_PRIVATE_KEY"));
11+
bytes32 salt = vm.envOr("CREATE2_SALT", bytes32(uint256(0)));
12+
13+
vm.startBroadcast(deployerKey);
14+
15+
ZiskVerifier verifier;
16+
if (salt != bytes32(0)) {
17+
// Deploy with CREATE2 for deterministic address
18+
verifier = new ZiskVerifier{salt: salt}();
19+
} else {
20+
// Deploy without CREATE2
21+
verifier = new ZiskVerifier();
22+
}
23+
24+
vm.stopBroadcast();
25+
}
26+
}

contracts/script/deploy/config/devnet/proof-aggregator-service.devnet.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"address": {
33
"sp1VerifierAddress": "0x06530DD13aFB697B81E2d602a279EBAEC8Ca2E31",
44
"risc0VerifierAddress": "0x663F3ad617193148711d28f5334eE4Ed07016602",
5+
"ziskVerifierAddress": "",
56
"alignedAggregatorAddress": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
67
"alignedAggregatorAddressPrivateKey": "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"
78
},
89
"programs_id": {
910
"sp1AggregationProgramVKHash": "0x00d6e32a34f68ea643362b96615591c94ee0bf99ee871740ab2337966a4f77af",
10-
"risc0AggregationProgramImageId": "0x8908f01022827e80a5de71908c16ee44f4a467236df20f62e7c994491629d74c"
11+
"risc0AggregationProgramImageId": "0x8908f01022827e80a5de71908c16ee44f4a467236df20f62e7c994491629d74c",
12+
"ziskAggregationProgramVKHash": ""
1113
},
1214
"amounts": {
1315
"amountToPayInWei": 1000000000000000000,

contracts/script/deploy/config/devnet/proof-aggregator-service.devnet.mock.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
"address": {
33
"sp1VerifierAddress": "0x00000000000000000000000000000000000000FF",
44
"risc0VerifierAddress": "0x00000000000000000000000000000000000000FF",
5+
"ziskVerifierAddress": "0x00000000000000000000000000000000000000FF",
56
"alignedAggregatorAddress": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
67
"alignedAggregatorAddressPrivateKey": "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"
78
},
89
"programs_id": {
910
"sp1AggregationProgramVKHash": "0x00d6e32a34f68ea643362b96615591c94ee0bf99ee871740ab2337966a4f77af",
10-
"risc0AggregationProgramImageId": "0x8908f01022827e80a5de71908c16ee44f4a467236df20f62e7c994491629d74c"
11+
"risc0AggregationProgramImageId": "0x8908f01022827e80a5de71908c16ee44f4a467236df20f62e7c994491629d74c",
12+
"ziskAggregationProgramVKHash": ""
1113
},
1214
"permissions": {
1315
"owner": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955"

contracts/script/deploy/config/hoodi/proof-aggregator-service.hoodi.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"address": {
33
"sp1VerifierAddress": "0xe1D19B93F2052d42967bCe42e6d4125A31A0e9ef",
44
"risc0VerifierAddress": "0x32Db7dc407AC886807277636a1633A1381748DD8",
5+
"ziskVerifierAddress": "",
56
"alignedAggregatorAddress": "0x7EB3B63A4F3e7810Cc9bbc346749E2491Da4D7Cc"
67
},
78
"programs_id": {
89
"sp1AggregationProgramVKHash": "0x00d6e32a34f68ea643362b96615591c94ee0bf99ee871740ab2337966a4f77af",
9-
"risc0AggregationProgramImageId": "0x8908f01022827e80a5de71908c16ee44f4a467236df20f62e7c994491629d74c"
10+
"risc0AggregationProgramImageId": "0x8908f01022827e80a5de71908c16ee44f4a467236df20f62e7c994491629d74c",
11+
"ziskAggregationProgramVKHash": ""
1012
},
1113
"amounts": {
1214
"amountToPayInWei": 1000000000000000,

contracts/script/deploy/config/templates/proof-aggregator-service.template.config.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22
"address": {
33
"sp1VerifierAddress": "",
44
"risc0VerifierAddress": "",
5+
"ziskVerifierAddress": "",
56
"alignedAggregatorAddress": ""
67
},
78
"programs_id": {
89
"sp1AggregationProgramVKHash": "0x00a18429d092a8e1f58aea6ff650ad715ad4e6d7056600bb201d38460244507b",
9-
"risc0AggregationProgramImageId": "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97"
10+
"risc0AggregationProgramImageId": "0x4cc11a4ac146ce4fc71493d694a9707194316cbb609603a195ffbe0c4c099c97",
11+
"ziskAggregationProgramVKHash": ""
1012
},
1113
"permissions": {
1214
"owner": ""
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
#!/bin/bash
2+
3+
# cd to the directory of this script so that this can be run from anywhere
4+
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
5+
# At this point we are in scripts/anvil
6+
cd "$parent_path"
7+
8+
# Start an empty anvil chain in the background and dump its state to a json file upon exit
9+
anvil --load-state state/sp1-deployed-anvil-state.json --dump-state state/zisk-deployed-anvil-state.json &
10+
11+
# cd to /contracts
12+
cd ../../
13+
14+
sleep 1
15+
16+
export RPC_DEVNET='http://localhost:8545'
17+
18+
# Anvil account #2
19+
export DEPLOYER_PRIVATE_KEY='0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a'
20+
21+
# Salt for deterministic deployment with CREATE2
22+
export CREATE2_SALT='0x0000000000000000000000000000000000000000000000000000000000000001'
23+
24+
# Deploy Zisk verifier with CREATE2
25+
forge script script/deploy/ZiskVerifierDeployer.s.sol:ZiskVerifierDeployer \
26+
--rpc-url $RPC_DEVNET \
27+
--private-key $DEPLOYER_PRIVATE_KEY \
28+
--broadcast \
29+
--via-ir
30+
31+
# Kill the anvil process to save state
32+
pkill anvil

contracts/src/core/AlignedProofAggregationService.sol

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {UUPSUpgradeable} from "@openzeppelin-upgrades/contracts/proxy/utils/UUPS
77
import {IAlignedProofAggregationService} from "./IAlignedProofAggregationService.sol";
88
import {ISP1Verifier} from "@sp1-contracts/ISP1Verifier.sol";
99
import {IRiscZeroVerifier} from "@risc0-contracts/IRiscZeroVerifier.sol";
10+
import {IZiskVerifier} from "../zisk/IZiskVerifier.sol";
1011
import {MerkleProof} from "../../lib/openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol";
1112

1213
contract AlignedProofAggregationService is
@@ -33,12 +34,18 @@ contract AlignedProofAggregationService is
3334
/// https://dev.risczero.com/api/blockchain-integration/contracts/verifier#contract-addresses
3435
address public risc0VerifierAddress;
3536

37+
/// @notice The address of the Zisk verifier contract
38+
address public ziskVerifierAddress;
39+
3640
/// @notice Proving system ID for SP1
3741
uint8 public constant SP1_ID = 1;
3842

3943
/// @notice Proving system ID for RISC0
4044
uint8 public constant RISC0_ID = 2;
4145

46+
/// @notice Proving system ID for ZISK
47+
uint8 public constant ZISK_ID = 3;
48+
4249
/// @notice Maps allowed verifiers commitments to their proving system. If the verifier is not a valid one, it returns 0 and is considered invalid
4350
mapping(bytes32 => uint8) public allowedVerifiersProvingSystem;
4451

@@ -51,17 +58,21 @@ contract AlignedProofAggregationService is
5158
address _alignedAggregatorAddress,
5259
address _sp1VerifierAddress,
5360
address _risc0VerifierAddress,
61+
address _ziskVerifierAddress,
5462
bytes32 _risc0AggregatorProgramImageId,
55-
bytes32 _sp1AggregatorProgramVKHash
63+
bytes32 _sp1AggregatorProgramVKHash,
64+
bytes32 _ziskAggregatorProgramVKHash
5665
) public initializer {
5766
__Ownable_init();
5867
__UUPSUpgradeable_init();
5968
_transferOwnership(newOwner);
6069
alignedAggregatorAddress = _alignedAggregatorAddress;
6170
sp1VerifierAddress = _sp1VerifierAddress;
6271
risc0VerifierAddress = _risc0VerifierAddress;
72+
ziskVerifierAddress = _ziskVerifierAddress;
6373
allowedVerifiersProvingSystem[_risc0AggregatorProgramImageId] = RISC0_ID;
6474
allowedVerifiersProvingSystem[_sp1AggregatorProgramVKHash] = SP1_ID;
75+
allowedVerifiersProvingSystem[_ziskAggregatorProgramVKHash] = ZISK_ID;
6576
}
6677

6778
function verifyAggregationSP1(bytes32 blobVersionedHash, bytes calldata sp1PublicValues, bytes calldata sp1ProofBytes, bytes32 verifierProgramCommitment)
@@ -99,6 +110,22 @@ contract AlignedProofAggregationService is
99110
emit AggregatedProofVerified(merkleRoot, blobVersionedHash);
100111
}
101112

113+
function verifyAggregationZisk(bytes32 blobVersionedHash, uint64[4] calldata programVK, bytes calldata publicValues, bytes calldata proofBytes, bytes32 verifierProgramCommitment)
114+
public
115+
onlyAlignedAggregator
116+
{
117+
(bytes32 merkleRoot) = abi.decode(publicValues, (bytes32));
118+
119+
if (allowedVerifiersProvingSystem[verifierProgramCommitment] != ZISK_ID) {
120+
revert InvalidVerifyingProgram(verifierProgramCommitment, ZISK_ID, allowedVerifiersProvingSystem[verifierProgramCommitment]);
121+
}
122+
123+
IZiskVerifier(ziskVerifierAddress).verifySnarkProof(programVK, publicValues, proofBytes);
124+
125+
isMerkleRootVerified[merkleRoot] = true;
126+
emit AggregatedProofVerified(merkleRoot, blobVersionedHash);
127+
}
128+
102129
/// @notice Verifies the inclusion of proof in an aggregated proof via Merkle tree proof.
103130
///
104131
/// @dev
@@ -142,7 +169,8 @@ contract AlignedProofAggregationService is
142169
/// @notice Modifier to ensure the provided proving system ID is one of the valid values.
143170
modifier onValidProvingSystemId(uint8 provingSystemId) {
144171
if (provingSystemId != SP1_ID &&
145-
provingSystemId != RISC0_ID){
172+
provingSystemId != RISC0_ID &&
173+
provingSystemId != ZISK_ID){
146174
revert IAlignedProofAggregationService.InvalidProvingSystemId(provingSystemId);
147175
}
148176

@@ -163,6 +191,13 @@ contract AlignedProofAggregationService is
163191
emit SP1VerifierAddressUpdated(_sp1VerifierAddress);
164192
}
165193

194+
/// @notice Sets the address of the Zisk verifier contract
195+
/// @param _ziskVerifierAddress The new address for the Zisk verifier contract
196+
function setZiskVerifierAddress(address _ziskVerifierAddress) external onlyOwner {
197+
ziskVerifierAddress = _ziskVerifierAddress;
198+
emit ZiskVerifierAddressUpdated(_ziskVerifierAddress);
199+
}
200+
166201
/// @notice Allows a new verifying program commitment to the list of valid verifying programs.
167202
/// @param verifierProgramCommitment The verifying program commitment to allow (image ID for RISC0 or vk hash for SP1).
168203
/// @param provingSystemId The proving system ID associated with the verifying program.

contracts/src/core/IAlignedProofAggregationService.sol

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ interface IAlignedProofAggregationService {
99

1010
/// @notice Event emitted when the SP1 verifier address is updated
1111
event SP1VerifierAddressUpdated(address indexed newAddress);
12-
12+
13+
/// @notice Event emitted when the Zisk verifier address is updated
14+
event ZiskVerifierAddressUpdated(address indexed newAddress);
15+
1316
/// @notice Event emitted when a verifier program is allowed
1417
event VerifierProgramAllowed(bytes32 indexed verifierProgramCommitment, uint8 provingSystemId);
1518

@@ -29,6 +32,17 @@ interface IAlignedProofAggregationService {
2932
function verifyAggregationRisc0(bytes32 blobVersionedHash, bytes calldata risc0ReceiptSeal, bytes calldata risc0JournalBytes, bytes32 verifierProgramCommitment)
3033
external;
3134

35+
/// @notice Method to verify an aggregated proof from aligned using Zisk
36+
/// @dev This function is called by the aligned proof aggregator after collecting the proofs and aggregating them
37+
/// to be verified on-chain. We expect the blobTransactionHash to be called before
38+
/// @param blobVersionedHash the versioned hash of the blob transaction that contains the leaves that compose the merkle root.
39+
/// @param programVK The verification key for the RISC-V program
40+
/// @param publicValues The public values encoded as bytes
41+
/// @param proofBytes The proof of the program execution the Zisk zkVM encoded as bytes
42+
/// @param verifierProgramCommitment The chunk aggregator verifier program commitment against which the proof should be verified
43+
function verifyAggregationZisk(bytes32 blobVersionedHash, uint64[4] calldata programVK, bytes calldata publicValues, bytes calldata proofBytes, bytes32 verifierProgramCommitment)
44+
external;
45+
3246
function isProofVerified(
3347
bytes32[] calldata merklePath,
3448
uint16 provingSystemId,
@@ -44,14 +58,18 @@ interface IAlignedProofAggregationService {
4458
/// @param _sp1VerifierAddress The new address for the SP1 verifier contract
4559
function setSP1VerifierAddress(address _sp1VerifierAddress) external;
4660

61+
/// @notice Sets the address of the Zisk verifier contract
62+
/// @param _ziskVerifierAddress The new address for the Zisk verifier contract
63+
function setZiskVerifierAddress(address _ziskVerifierAddress) external;
64+
4765
/// @notice Allows a new verifier program commitment with its proving system ID
4866
/// @param verifierProgramCommitment The verifier program commitment to allow
49-
/// @param provingSystemId The proving system ID (1 for SP1, 2 for RISC0)
67+
/// @param provingSystemId The proving system ID (1 for SP1, 2 for RISC0, 3 for ZISK)
5068
function allowVerifyingProgram(bytes32 verifierProgramCommitment, uint8 provingSystemId) external;
5169

5270
/// @notice Disallows an existing verifier program commitment
5371
/// @param verifierProgramCommitment The verifier program commitment to disallow
54-
/// @param provingSystemId The proving system ID (1 for SP1, 2 for RISC0)
72+
/// @param provingSystemId The proving system ID (1 for SP1, 2 for RISC0, 3 for ZISK)
5573
function disallowVerifyingProgram(bytes32 verifierProgramCommitment, uint8 provingSystemId) external;
5674

5775
error OnlyAlignedAggregator(address sender);

0 commit comments

Comments
 (0)