Skip to content

Commit 775b295

Browse files
authored
feat: verifiable binaries (#146)
1 parent 343e01d commit 775b295

File tree

4 files changed

+62
-15
lines changed

4 files changed

+62
-15
lines changed

book/SUMMARY.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@
99
- [Configuration](./getting-started/configuration.md)
1010
- [Cost Estimator CLI Tool](./cost-estimator.md)
1111
- [L2 Node Setup](./node-setup.md)
12+
- [Appendix](./advanced/intro.md)

book/advanced/intro.md

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Advanced
2+
3+
When deploying OP Succinct in production, it's important to ensure that the SP1 programs used when generating proofs are reproducible.
4+
5+
## Verify the OP Succinct binaries
6+
7+
### Introduction
8+
9+
There are two programs used in OP Succinct:
10+
- `range`: Proves the correctness of an OP Stack derivation + STF for a range of blocks.
11+
- `aggregation`: Aggregates multiple range proofs into a single proof. This is the proof that lands on-chain. The aggregation proof ensures that all `range` proofs in a given block range are linked and use the `rangeVkeyCommitment` from the `L2OutputOracleProxy` as the verification key.
12+
13+
### Prerequisites
14+
15+
To reproduce the OP Succinct program binaries, you first need to install the [cargo prove](https://docs.succinct.xyz/getting-started/install.html#option-1-prebuilt-binaries-recommended) toolchain.
16+
17+
Ensure that you have the latest version of the toolchain by running:
18+
19+
```bash
20+
sp1up
21+
```
22+
23+
Confirm that you have the toolchain installed by running:
24+
25+
```bash
26+
cargo prove --version
27+
```
28+
29+
### Verify the SP1 binaries
30+
31+
To build the SP1 binaries, first ensure that Docker is running.
32+
33+
```bash
34+
docker ps
35+
```
36+
37+
Then build the binaries:
38+
39+
```bash
40+
cd programs/range
41+
# Build the range-elf
42+
cargo prove build --elf range-elf --docker
43+
44+
cd ../aggregation
45+
# Build the aggregation-elf
46+
cargo prove build --elf aggregation-elf --docker
47+
```
48+
49+
Now, verify the binaries by confirming the output of `vkey` matches the vkeys on the contract. The `vkey` program outputs the verification keys
50+
based on the ELFs in `/elf`.
51+
52+
```bash
53+
cargo run --bin vkey --release
54+
```

elf/range-elf

1.66 KB
Binary file not shown.

scripts/utils/bin/vkey.rs

+7-15
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use alloy::sol;
2-
use alloy_primitives::{hex, keccak256, B256};
2+
use alloy_primitives::B256;
33
use anyhow::Result;
4-
use log::info;
54
use op_succinct_client_utils::types::u32_to_u8;
65
use sp1_sdk::{utils, HashableKey, ProverClient};
76

@@ -38,24 +37,17 @@ async fn main() -> Result<()> {
3837

3938
let prover = ProverClient::new();
4039

41-
let (_, vkey) = prover.setup(MULTI_BLOCK_ELF);
42-
43-
let program_hash = keccak256(MULTI_BLOCK_ELF);
44-
info!("Program Hash [view on Explorer]:");
45-
info!("0x{}", hex::encode(program_hash));
46-
47-
println!(
48-
"Range ELF Verification Key U32 Hash: {:?}",
49-
vkey.vk.hash_u32()
50-
);
40+
let (_, range_vk) = prover.setup(MULTI_BLOCK_ELF);
5141

5242
// Get the 32 byte commitment to the vkey from vkey.vk.hash_u32()
53-
let multi_block_vkey_u8 = u32_to_u8(vkey.vk.hash_u32());
43+
let multi_block_vkey_u8 = u32_to_u8(range_vk.vk.hash_u32());
5444
let multi_block_vkey_b256 = B256::from(multi_block_vkey_u8);
55-
println!("Range ELF Verification Key B256: {}", multi_block_vkey_b256);
45+
println!(
46+
"Range ELF Verification Key Commitment: {}",
47+
multi_block_vkey_b256
48+
);
5649

5750
let (_, agg_vk) = prover.setup(AGG_ELF);
58-
info!("Aggregation ELF Verification Key: {}", agg_vk.bytes32());
5951
println!("Aggregation ELF Verification Key: {}", agg_vk.bytes32());
6052

6153
Ok(())

0 commit comments

Comments
 (0)