Generating proofs
Aligned's Proof Aggregation Service currently accepts SP1 compressed proofs. This guide shows how to produce the files the Aggregation Mode CLI and SDK expect.
Dependencies
This guide assumes that:
The SP1 prover is installed (instructions)
You have an SP1 project to generate proofs from (instructions)
The Aggregation Mode CLI is installed (instructions)
Generating a compressed proof
In your SP1 script, generate the proof and write out the four files Aligned works with:
use sp1_sdk::{
include_elf, Elf, HashableKey, ProveRequest, Prover, ProverClient, ProvingKey, SP1Stdin,
};
const ELF: Elf = include_elf!("your-program");
#[tokio::main]
async fn main() {
let mut stdin = SP1Stdin::new();
// ...write your program inputs into `stdin`...
let client = ProverClient::from_env().await;
let pk = client.setup(ELF).await.expect("setup failed");
let vk = pk.verifying_key().clone();
// `.compressed()` is required — Aligned aggregates compressed proofs only.
let proof = client.prove(&pk, stdin).compressed().await.unwrap();
client.verify(&proof, &vk, None).expect("verification failed");
// 1. The proof itself — passed to `--proof` when submitting.
proof.save("./my_proof.proof").expect("saving proof failed");
// 2. The serialized verifying key — passed to `--vk` when submitting.
std::fs::write("./my_vk.bin", bincode::serialize(&vk).unwrap()).unwrap();
// 3. The verifying key hash (32 bytes) — passed to `--vk-hash` when verifying on-chain.
std::fs::write("./my_vk_hash.bin", vk.hash_bytes()).unwrap();
// 4. The public values — passed to `--public-inputs` when verifying on-chain.
std::fs::write("./my_public_inputs.bin", proof.public_values.clone()).unwrap();
}Then run it from your script directory:
A complete working example lives at scripts/test_files/sp1/fibonacci_proof_generator/, and the files it produces are checked into scripts/test_files/sp1/.
Which file goes where
my_proof.proof
proof.save(...)
agg_mode_cli submit sp1 --proof
my_vk.bin
bincode::serialize(&vk)
agg_mode_cli submit sp1 --vk
my_vk_hash.bin
vk.hash_bytes()
agg_mode_cli verify-on-chain --vk-hash
my_public_inputs.bin
proof.public_values
agg_mode_cli verify-on-chain --public-inputs
Submitting the proof to Aligned
Fund your submission quota first, then submit:
The command returns a task ID. Your proof is aggregated with others and settled on Ethereum within the aggregation window (24 hours by default).
Checking verification
Once the aggregated proof has been settled, check that yours was included:
See the Aggregation Mode CLI reference for every option, and the integration example for a full application walkthrough.
Last updated
Was this helpful?