How succinctlabs/sp1-project-template works
Project type and purpose
• This is a Rust-based end-to-end “SP1” proof generation template:
• It compiles and executes a RISC-V program (in program/)
• It generates zk-proofs (core, Groth16, PLONK) via CLI scripts (script/)
• It contains Solidity contracts (contracts/) to verify those proofs on EVM
• Use case: developers write RISC-V code, run it, generate proofs, and optionally verify on-chain.
File structure
• Top-level:
• program/ – the RISC-V application (Rust main.rs)
• lib/ – shared Rust library (lib.rs) used by both program/ and script/
• script/ – CLI entrypoints (build.rs, src/bin/*.rs) to drive execution and proof generation
• contracts/ – Solidity smart contracts, Foundry tests, and proof fixtures
• config: Cargo.toml files in each crate, Foundry config (foundry.toml), .env.example, GitHub workflows
• Patterns:
• Multi-crate workspace (Cargo workspaces)
• Clear separation: compute (program), proof API (script), on-chain verification (contracts)
Key insights from README
• Three execution modes via script CLI:
a. --execute – run the RISC-V program
b. --prove – generate an SP1 core proof
c. --bin evm – produce EVM-compatible proofs (Groth16/PLONK)
• Optionally emits JSON fixtures for Solidity tests and a verification key (vkey bin)
• Integration point: Succinct Prover Network (via env vars SP1_PROVER, NETWORK_PRIVATE_KEY)
Main components
a. RISC-V Program Component
• Contains program/src/main.rs
b. Shared Library Component
• Contains lib/src/lib.rs
c. CLI/Script Component
• builder (build.rs)
• executors (src/bin/main.rs)
• prover (src/bin/vkey.rs, src/bin/evm.rs)
d. Proof Engine
• Connection from CLI to SP1 core & backend proving libraries (external SP1 crates)
e. Smart Contracts Component
• Contains contracts/src/*.sol, contracts/test/*, Foundry config
f. External Services
g. Artifacts & Data Flows
• RISC-V binary
• Proof JSON fixtures (e.g. groth16-fixture.json)
• Verification key (programVKey)
Relationships and interactions
• “Program” → produces RISC-V binary
• “CLI Script”
• invokes build (runs build.rs), compiles program
• calls SP1 APIs in lib to execute or prove
• outputs proof artifacts → stored in script/target & contracts/src/fixtures
• “Solidity Contracts”
• import JSON fixtures
• Foundry tests verify proofs on local EVM
• “Succinct Prover Network”
• Optional remote prover for heavy proofs
• Controlled via environment (.env)
• “Ethereum/EVM”
• Deploy & verify the contract on-chain
Architectural patterns & design principles
• Modularity: separate crates for program, library, and CLI
• Reusability: lib/ is the core integration point with SP1
• Extensibility: add new CLI bins under script/src/bin/ or new proof systems
• CI/CD: GitHub workflows automate testing (foundry-test.yml) and on-chain proof CI (prove.yml)