Documentation Index
Fetch the complete documentation index at: https://mintlify.com/risc0/risc0/llms.txt
Use this file to discover all available pages before exploring further.
Recursive Proving
RISC Zero’s zkVM uses recursive proving to achieve:- Unbounded computation size through continuations
- Constant proof size regardless of program complexity
- Proof aggregation combining multiple proofs
- Proof composition for modular verification
Overview
Recursive proving allows the zkVM to prove that it correctly verified another proof. This enables:- Breaking large computations into segments
- Verifying each segment independently
- Combining segment proofs into a single proof
- Compressing the final proof for efficient on-chain verification
The
Prover::prove_with_opts method allows choosing between composite, succinct, or Groth16 receipts.Recursive Proving Process
The end-to-end proving process consists of several stages:The program executes in the zkVM, producing a collection of Segments. Programs are automatically split into segments if they exceed the segment size limit.
Each segment is proven independently, generating a SegmentReceipt. This uses the RISC-V circuit to prove correct execution.
Each SegmentReceipt is lifted to the recursion circuit, producing a SuccinctReceipt. This is the first recursion step.
Pairs of SuccinctReceipts are joined together repeatedly until only one SuccinctReceipt remains. This aggregates all segments into a single proof.
The final SuccinctReceipt is passed through identity_p254, which prepares it for Groth16 proving using the Poseidon254 hash function.
Circuit Architecture
RISC Zero’s zkVM consists of three circuits:1. RISC-V Circuit
A STARK circuit that proves correct execution of RISC-V programs. This is the main circuit that executes your guest code.2. Recursion Circuit
A separate STARK circuit optimized for:- Verifying other STARK proofs
- Cryptographic operations
- Integrating custom accelerator circuits
- Fewer columns than the RISC-V circuit
- Instruction set optimized for cryptography
- Same underlying proof system as RISC-V circuit
3. STARK-to-SNARK Circuit
An R1CS circuit (Groth16) that verifies proofs from the Recursion Circuit, producing tiny proofs suitable for blockchain verification.Recursion Programs
The Recursion Circuit supports several programs used internally:Lift
Verifies a STARK proof from the RISC-V circuit using the Recursion circuit. This produces a proof with constant verification time regardless of the original segment length.Join
Verifies two STARK proofs from the Recursion circuit, combining them into one. By repeated application, any number of receipts can be compressed into a single receipt.Identity_p254
Verifies a STARK proof using the Poseidon254 hash function. This is the last step before Groth16 proving, ensuring compatibility with the SNARK circuit.Resolve
Used for proof composition to remove assumptions from receipt claims, enabling modular proof verification.Receipt Types
CompositeReceipt
Contains all segment receipts without any recursion. Fastest to generate but largest in size.- Size: ~200 KB per segment
- Use case: Development, local testing
- Verification: Verify each segment independently
SuccinctReceipt
Fully recursed STARK proof, constant size regardless of program complexity.- Size: ~200 KB (constant)
- Use case: Off-chain verification, proof aggregation
- Verification: Single constant-time verification
Groth16Receipt
SNARK proof suitable for on-chain verification.- Size: ~200 bytes
- Use case: Blockchain verification
- Verification: Verify on-chain via RISC Zero verifier contract
Practical Examples
Basic Recursive Proving
Aggregating Multiple Proofs
Controlling Segment Size
- Smaller segments: More segments, more join operations, slower overall
- Larger segments: Fewer segments, higher memory usage, may exceed GPU memory
Performance Considerations
Proving Time Breakdown
For a typical program with 4 segments:| Stage | Time (relative) | Notes |
|---|---|---|
| Execution | 1x | Fast, single-threaded |
| Segment proving | 40x | Parallelizable, benefits from GPU |
| Lifting | 4x | One per segment |
| Joining | 6x | Log(N) joins needed |
| Identity_p254 | 4x | Required for Groth16 |
| Groth16 compress | 60x | Only if on-chain verification needed |
With GPU acceleration, segment proving time can be reduced by 10-20x. See GPU Acceleration.
Optimization Strategies
- Optimize guest code first: See Optimization Guide
- Use GPU acceleration: 10-20x speedup for proving
- Skip Groth16 compression: Use SuccinctReceipts for off-chain verification
- Parallelize segment proving: Segments can be proven concurrently
- Cache receipts: Reuse proofs for identical computations
Continuations
Continuations allow programs to run indefinitely by splitting execution into segments:- Saves state when segment limit is reached
- Creates a continuation point
- Resumes execution in the next segment
- Joins segment proofs together
Advanced: Custom Recursion
For advanced use cases, you can use the recursion circuit directly:Next Steps
- Learn about GPU Acceleration to speed up proving
- Explore Performance Optimization for guest code
- Understand Proof Composition for modular proofs
- Read about On-chain Verification with Groth16