Skip to content

Commit 4f778ad

Browse files
committed
Merge branch 'staging' into feat/aggregate-proofs-in-chunks
2 parents 618688f + b31292e commit 4f778ad

File tree

7 files changed

+101
-18
lines changed

7 files changed

+101
-18
lines changed

Makefile

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,30 @@ start_proof_aggregator: is_aggregator_set ## Starts proof aggregator with provin
175175
start_proof_aggregator_gpu: is_aggregator_set ## Starts proof aggregator with proving + GPU acceleration (CUDA)
176176
AGGREGATOR=$(AGGREGATOR) SP1_PROVER=cuda cargo run --manifest-path ./aggregation_mode/Cargo.toml --release --features prove,gpu -- config-files/config-proof-aggregator.yaml
177177

178+
verify_aggregated_proof_sp1_holesky_stage:
179+
@echo "Verifying SP1 in aggregated proofs on holesky..."
180+
@cd batcher/aligned/ && \
181+
cargo run verify-agg-proof \
182+
--network holesky-stage \
183+
--from-block $(FROM_BLOCK) \
184+
--proving_system SP1 \
185+
--public_input ../../scripts/test_files/sp1/sp1_fibonacci_4_1_3.pub \
186+
--program-id-file ../../scripts/test_files/sp1/sp1_fibonacci_4_1_3.vk \
187+
--beacon_url $(BEACON_URL) \
188+
--rpc_url https://ethereum-holesky-rpc.publicnode.com
189+
190+
verify_aggregated_proof_risc0_holesky_stage:
191+
@echo "Verifying RISC0 in aggregated proofs on holesky..."
192+
@cd batcher/aligned/ && \
193+
cargo run verify-agg-proof \
194+
--network holesky-stage \
195+
--from-block $(FROM_BLOCK) \
196+
--proving_system Risc0 \
197+
--program-id-file ../../scripts/test_files/risc_zero/fibonacci_proof_generator/fibonacci_id_2_0.bin \
198+
--public_input ../../scripts/test_files/risc_zero/fibonacci_proof_generator/risc_zero_fibonacci_2_0.pub \
199+
--beacon_url $(BEACON_URL) \
200+
--rpc_url https://ethereum-holesky-rpc.publicnode.com
201+
178202
install_aggregation_mode: ## Install the aggregation mode with proving enabled
179203
cargo install --path aggregation_mode --features prove
180204

batcher/aligned-sdk/src/sdk/aggregation.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ pub enum AggregationModeVerificationData {
1818
vk: [u8; 32],
1919
public_inputs: Vec<u8>,
2020
},
21+
Risc0 {
22+
image_id: [u8; 32],
23+
public_inputs: Vec<u8>,
24+
},
2125
}
2226

2327
impl AggregationModeVerificationData {
@@ -29,6 +33,15 @@ impl AggregationModeVerificationData {
2933
hasher.update(public_inputs);
3034
hasher.finalize().into()
3135
}
36+
AggregationModeVerificationData::Risc0 {
37+
image_id,
38+
public_inputs,
39+
} => {
40+
let mut hasher = Keccak256::new();
41+
hasher.update(image_id);
42+
hasher.update(public_inputs);
43+
hasher.finalize().into()
44+
}
3245
}
3346
}
3447
}

batcher/aligned/src/main.rs

Lines changed: 23 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -325,8 +325,12 @@ pub struct VerifyProofInAggModeArgs {
325325
proving_system: ProvingSystemArg,
326326
#[arg(name = "Public input file name", long = "public_input")]
327327
pub_input_file_name: Option<PathBuf>,
328-
#[arg(name = "Verification key hash", long = "vk", required = true)]
329-
verification_key_hash: PathBuf,
328+
#[arg(
329+
name = "Verification key hash",
330+
long = "program-id-file",
331+
required = true
332+
)]
333+
program_id_file: PathBuf,
330334
}
331335

332336
#[derive(Args, Debug)]
@@ -790,20 +794,25 @@ async fn main() -> Result<(), AlignedError> {
790794
return Ok(());
791795
}
792796
AlignedCommands::VerifyProofInAggMode(args) => {
793-
let proof_data = match args.proving_system {
794-
ProvingSystemArg::SP1 => {
795-
let vk = read_file(args.verification_key_hash)?
796-
.try_into()
797-
.expect("Invalid hexadecimal encoded vk hash");
797+
let program_id_key = read_file(args.program_id_file)?
798+
.try_into()
799+
.expect("Invalid hexadecimal encoded vk hash");
798800

799-
let Some(pub_inputs_file_name) = args.pub_input_file_name else {
800-
error!("Public input file not provided");
801-
return Ok(());
802-
};
803-
let public_inputs = read_file(pub_inputs_file_name)?;
801+
let Some(pub_inputs_file_name) = args.pub_input_file_name else {
802+
error!("Public input file not provided");
803+
return Ok(());
804+
};
805+
let public_inputs = read_file(pub_inputs_file_name)?;
804806

805-
AggregationModeVerificationData::SP1 { vk, public_inputs }
806-
}
807+
let proof_data = match args.proving_system {
808+
ProvingSystemArg::SP1 => AggregationModeVerificationData::SP1 {
809+
vk: program_id_key,
810+
public_inputs,
811+
},
812+
ProvingSystemArg::Risc0 => AggregationModeVerificationData::Risc0 {
813+
image_id: program_id_key,
814+
public_inputs,
815+
},
807816
_ => {
808817
error!("Proving system not supported in aggregation mode");
809818
return Ok(());

contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

contracts/src/core/AlignedLayerServiceManager.sol

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,27 @@ contract AlignedLayerServiceManager is
301301
);
302302
}
303303

304+
function verifyBatchInclusion(
305+
bytes32 proofCommitment,
306+
bytes32 pubInputCommitment,
307+
bytes32 provingSystemAuxDataCommitment,
308+
bytes20 proofGeneratorAddr,
309+
bytes32 batchMerkleRoot,
310+
bytes memory merkleProof,
311+
uint256 verificationDataBatchIndex
312+
) external view onlyWhenNotPaused(2) returns (bool) {
313+
return this.verifyBatchInclusion(
314+
proofCommitment,
315+
pubInputCommitment,
316+
provingSystemAuxDataCommitment,
317+
proofGeneratorAddr,
318+
batchMerkleRoot,
319+
merkleProof,
320+
verificationDataBatchIndex,
321+
address(0)
322+
);
323+
}
324+
304325

305326
function setAggregator(address _alignedAggregator) public onlyOwner {
306327
alignedAggregator = _alignedAggregator;

contracts/src/core/AlignedProofAggregationService.sol

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ contract AlignedProofAggregationService is
2424
/// https://docs.succinct.xyz/onchain-verification/contract-addresses
2525
address public sp1VerifierAddress;
2626

27+
/// @notice The address of the Wallet that is allowed to call the verify function.
28+
address public alignedAggregatorAddress;
29+
2730
/// @notice The address of the Risc0 verifier contract
2831
/// @dev See supported verifier here:
2932
/// https://dev.risczero.com/api/blockchain-integration/contracts/verifier#contract-addresses
3033
address public risc0VerifierAddress;
3134

32-
/// @notice The address of the Wallet that is allowed to call the verify function.
33-
address public alignedAggregatorAddress;
34-
3535
/// @notice whether we are in dev mode or not
3636
/// if the sp1 verifier address is set to this address, then we skip verification
3737
address public constant VERIFIER_MOCK_ADDRESS = address(0xFF);
@@ -109,4 +109,10 @@ contract AlignedProofAggregationService is
109109
}
110110
_;
111111
}
112+
113+
/// @notice Sets the address of the Risc0 verifier contract
114+
/// @param _risc0VerifierAddress The new address for the Risc0 verifier contract
115+
function setRisc0VerifierAddress(address _risc0VerifierAddress) external onlyOwner {
116+
risc0VerifierAddress = _risc0VerifierAddress;
117+
}
112118
}

contracts/src/core/IAlignedLayerServiceManager.sol

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,16 @@ interface IAlignedLayerServiceManager {
6161
address senderAddress
6262
) external view returns (bool);
6363

64+
function verifyBatchInclusion(
65+
bytes32 proofCommitment,
66+
bytes32 pubInputCommitment,
67+
bytes32 provingSystemAuxDataCommitment,
68+
bytes20 proofGeneratorAddr,
69+
bytes32 batchMerkleRoot,
70+
bytes memory merkleProof,
71+
uint256 verificationDataBatchIndex
72+
) external view returns (bool);
73+
6474
function balanceOf(address account) external view returns (uint256);
6575

6676
function setAggregator(address _aggregator) external;

0 commit comments

Comments
 (0)