Skip to main content

Quickstart

In this section, we will show you how to get started with SP1 by compiling, executing and proving a simple Fibonacci program.

Create an SP1 Project

After installing the cargo-prove CLI, you can create and navigate to a new project with the following commands:

cargo prove new --bare fibonacci
cd fibonacci

This command will create a new folder in your current directory which includes a basic SP1 project for zkVM programs.

note

If you use the --evm option instead of --bare, you will need to install Foundry to compile the Solidity contracts for on-chain verification. Please follow the instructions on the official Foundry docs.

After installation, run forge install in the contracts directory to install the necessary dependencies.

Project Overview

Your new project will have the following structure:

.
├── program
│   ├── Cargo.lock
│   ├── Cargo.toml
│   └── src
│   └── main.rs
├── rust-toolchain
└── script
├── Cargo.lock
├── Cargo.toml
├── build.rs
└── src
└── bin
├── prove.rs
└── vkey.rs

6 directories, 4 files

There are 2 directories (each a crate) in the project:

  • program: the source code that will be proven inside the zkVM.
  • script: code that contains proof generation and verification code.

We recommend you install the rust-analyzer extension. Note that if you use cargo prove new inside a monorepo, you will need to add the manifest file to rust-analyzer.linkedProjects to get full IDE support.

Build

Before we can run the program inside the zkVM, it must be compiled to a RISC-V executable using the succinct Rust toolchain. This is called an ELF (Executable and Linkable Format). To compile the program, you can run the following command:

cd program && cargo prove build

This will generate an ELF file in the target/elf-compilation directory.

note

The build.rs file in the script directory will use run the above command automatically to build the ELF, so you won't need to manually run cargo prove build every time you make a change to the program.

Execute

To test your program, you can first execute it without generating a proof. Executing the program is helpful for verifying your program's correctness without generating a proof, which is helpful for debugging and speeds up development.

cd ../script
RUST_LOG=info cargo run --release -- --execute

The output should show something like this:

n: 20
Program executed successfully.
n: 20
a: 6765
b: 10946
Values are correct!
Number of cycles: 9198
note

For larger programs (>1M cycles), skip proof generation during development. Instead, just execute the program with the RISC-V runtime to verify the public_values match the expected output. This is much faster for testing.

Prove

When you are ready to generate a proof, you should run the script with the --prove flag that will generate a proof.

cd ../script
RUST_LOG=info cargo run --release -- --prove

The output should show something like this:

2025-04-03T00:42:32.165860Z  WARN SP1_PROVER environment variable not set, defaulting to 'cpu'
n: 20
2025-04-03T00:42:35.634237Z INFO prove_core: clk = 0 pc = 0x2013c4
2025-04-03T00:42:35.637007Z INFO prove_core: clk = 0 pc = 0x2013c4
2025-04-03T00:42:35.760049Z INFO prove_core:generate main traces: close time.busy=112ms time.idle=1.50µs index=0
2025-04-03T00:42:41.208307Z INFO prove_core: close time.busy=5.45s time.idle=126ms
Successfully generated proof!
2025-04-03T00:42:41.360538Z INFO verify: close time.busy=151ms time.idle=1.29µs
Successfully verified proof!

The Fibonacci program is quite small by default, so proof generation will only take a few seconds locally. After proof generation, the proof is verified for correctness.

Note: When benchmarking proof generation times locally, it is important to note that there is a fixed overhead for proving. Concretely, proof generation time for small programs is not representative of the performance on larger programs. Larger programs will have better performance characteristics as the fixed overhead is amortized across more work.

Project Template

Alternatively, you can start by cloning the SP1 Project Template. This template contains an SP1 program, a script to generate proofs, and a Solidity contract that can verify SP1 proofs on any EVM chain.

Please see the Recommended Workflow section for more details on how to develop your SP1 program and generate proofs.

We strongly recommend that developers who want to use SP1 for non-trivial programs generate proofs on the Succinct Prover Network. The Succinct Prover Network generates SP1 proofs across multiple machines, reducing latency and also runs SP1 on optimized hardware instances for better proof generation performance and cheaper proofs.

We recommend using the prover network to estimate latency and costs of proof generation for production benchmarking. We also would love to chat with your team directly to help you get started with the prover network--please fill out this form.