Skip to content

Commit 32a9901

Browse files
committed
docs: match the SP1 proof aggregation documentation style
1 parent 7e98feb commit 32a9901

File tree

3 files changed

+65
-12
lines changed

3 files changed

+65
-12
lines changed

book/advanced/prove-scripts.md

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,26 @@
11
# Prove Scripts
22

3-
The prove scripts allow you to manually generate range and aggregation proofs for OP Succinct. These are useful for testing proof generation workflows and debugging.
3+
The prove scripts allow you to manually generate range and aggregation proofs for OP Succinct.
44

55
## Overview
66

7-
There are two main proving binaries:
8-
- **multi.rs**: Generates range proofs for multiple blocks
9-
- **agg.rs**: Aggregates multiple range proofs into a single aggregation proof
7+
OP Succinct uses a two-tier proving architecture:
8+
9+
1. **Range Proofs** (`multi.rs`): Generate compressed proofs for a range of L2 blocks. These proofs verify the state transition for a specific block range.
10+
11+
2. **Aggregation Proofs** (`agg.rs`): Combine multiple range proofs into a single aggregation proof. This reduces on-chain verification costs by verifying one proof instead of many.
1012

1113
Both binaries use the SP1 network prover by default.
1214

15+
### When to Use Aggregation
16+
17+
Aggregation is useful when you need to:
18+
- Reduce on-chain verification costs by combining multiple range proofs into one proof
19+
- Prove larger block ranges by aggregating individual range proofs from different time periods
20+
- Combine proofs from different proving sessions into a single proof for batch submission
21+
22+
> **Note:** All range proofs must be generated in compressed mode for aggregation. The prove scripts handle this automatically.
23+
1324
## Setup
1425

1526
### Environment Configuration
@@ -74,7 +85,7 @@ AGG_PROOF_MODE=plonk # Options: plonk, groth16
7485

7586
## Generating Range Proofs
7687

77-
The `multi.rs` binary generates range proofs for a specified block range.
88+
The `multi.rs` binary generates compressed range proofs for a specified block range. These proofs verify the state transition function for the L2 blocks in the range.
7889

7990
### Usage
8091

@@ -88,20 +99,29 @@ cargo run --bin multi --release -- \
8899
### Example
89100

90101
```bash
91-
# Generate a range proof for blocks 1000-1300
102+
# Generate a compressed range proof for blocks 1000-1300
92103
cargo run --bin multi --release -- \
93104
--start 1000 \
94105
--end 1300 \
95106
--prove
96107
```
97108

109+
The proof will be generated in compressed mode, which is required for aggregation.
110+
98111
### Output
99112

100113
Range proofs are saved to `data/{chain_id}/proofs/{start_block}-{end_block}.bin`
101114

102115
## Generating Aggregation Proofs
103116

104-
The `agg.rs` binary aggregates multiple range proofs into a single aggregation proof.
117+
The `agg.rs` binary aggregates multiple compressed range proofs into a single aggregation proof. This allows you to verify the state transition for a large block range with a single on-chain verification.
118+
119+
### How Aggregation Works
120+
121+
1. The binary loads the specified range proofs from `data/fetched_proofs/`
122+
2. Each range proof is verified to ensure validity
123+
3. The proofs are aggregated into a single proof that attests to the entire block range
124+
4. The aggregation proof can be submitted on-chain for efficient verification
105125

106126
### Usage
107127

@@ -115,27 +135,30 @@ cargo run --bin agg --release -- \
115135
### Example
116136

117137
```bash
118-
# Aggregate three range proofs
138+
# Aggregate three consecutive range proofs covering blocks 1000-1900
119139
cargo run --bin agg --release -- \
120140
--proofs 1000-1300,1300-1600,1600-1900 \
121141
--prover 0x1234567890abcdef1234567890abcdef12345678 \
122142
--prove
123143
```
124144

145+
This will generate a single aggregation proof that verifies the state transition from block 1000 to 1900.
146+
125147
### Parameters
126148

127149
| Parameter | Description | Required |
128150
|-----------|-------------|----------|
129151
| `--proofs` | Comma-separated list of proof names (without `.bin` extension) | Yes |
130-
| `--prover` | Prover wallet address | Yes |
131-
| `--prove` | Generate proof (omit to only execute) | No |
152+
| `--prover` | Prover wallet address included in the aggregation proof | Yes |
153+
| `--prove` | Generate proof (omit to only execute and verify inputs) | No |
132154
| `--env-file` | Path to environment file (default: `.env`) | No |
133155

134156
### Requirements
135157

136158
- Proof files must exist in `data/fetched_proofs/` directory
137159
- Proof names should match the range format: `{start_block}-{end_block}`
138-
- All range proofs must be verified before aggregation
160+
- Range proofs must be consecutive (e.g., 1000-1300, 1300-1600, 1600-1900)
161+
- All range proofs are automatically verified before aggregation
139162

140163
## Local Development
141164

contracts/foundry.lock

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"lib/forge-std": {
3+
"rev": "2b59872eee0b8088ddcade39fe8c041e17bb79c0"
4+
},
5+
"lib/lib-keccak": {
6+
"rev": "3b1e7bbb4cc23e9228097cfebe42aedaf3b8f2b9"
7+
},
8+
"lib/openzeppelin-contracts": {
9+
"rev": "ecd2ca2cd7cac116f7a37d0e474bbb3d7d5e1c4d"
10+
},
11+
"lib/openzeppelin-contracts-upgradeable": {
12+
"rev": "0a2cb9a445c365870ed7a8ab461b12acf3e27d63"
13+
},
14+
"lib/optimism": {
15+
"rev": "ef7a933ca7f3d27ac40406f87fea25e0c3ba2016"
16+
},
17+
"lib/solady": {
18+
"rev": "502cc1ea718e6fa73b380635ee0868b0740595f0"
19+
},
20+
"lib/sp1-contracts": {
21+
"rev": "90d99052cf7880fe521f5fb0974b9c51056f9619"
22+
}
23+
}

scripts/prove/bin/agg.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ fn load_aggregation_proof_data(
6767
(proofs, boot_infos)
6868
}
6969

70-
// Execute the OP Succinct program for a single block.
70+
/// Aggregates multiple range proofs into a single proof.
71+
///
72+
/// This binary takes multiple compressed range proofs and aggregates them into a single
73+
/// aggregation proof. This is useful for:
74+
/// - Reducing on-chain verification costs by combining multiple proofs into one
75+
/// - Proving larger block ranges by aggregating individual range proofs
76+
///
77+
/// Note: All input range proofs must be in compressed format for aggregation to work.
7178
#[tokio::main]
7279
async fn main() -> Result<()> {
7380
utils::setup_logger();

0 commit comments

Comments
 (0)