Skip to main content

Overview

For example code of composition in action, please see the Proof Composition Example
Proof composition enables you to build upon existing proofs by verifying them within new zkVM guest programs. This is particularly useful when you want to prove a sequence of related statements without reproving each step. For example, let’s say you have:
  1. A proof that block n is valid
  2. You want to prove that both blocks n and n+1 are valid
Instead of reproving block n, you can:
  1. Use the existing proof of block n
  2. Prove only block n+1 under the assumption that n is valid
  3. Resolve this assumption by verifying the previous proof within your new proof
This approach is more efficient than reproving everything from scratch.

How Composition Works

Proof composition works by:
  1. Requesting a raw Groth16 proof from the Boundless Market
  2. Using this proof as input to a new zkVM guest program
  3. Verifying the proof within the guest program
  4. Building upon the verified result to prove new statements

Example: Composing Echo and Identity Proofs

The Proof Composition example demonstrates how to compose proofs using the Echo and Identity guest programs. First, we request a raw Groth16 proof from the Echo guest program:
We then use this proof as input to the Identity guest program:
Finally, we can use the composed proof to interact with a smart contract: