Quick start
One minute quick start of writing a Pico program
This page shows you how to create and prove a Fibonacci program.
Start with the Fibonacci template
Create project
cargo pico new --template basic Fibonacci
Create a Fibonacci project template with the `basic` option.
Build program
# Build program in app folder
cd app
RUST_LOG=info cargo pico build
Build project with rust toolchain and generate RISC-V elf file in root/elf folder
Prove program with Pico
# Prove in prover folder
cd prover
RUST_LOG=info cargo pico prove --input "0x0A000000" --fast # input n = 10
In a production environment, you may require a Prover to generate proofs rather than relying on the CLI. In such a case, you can directly utilize the Pico-SDK tools to streamline the proof generation process.
# Prove in prover folder
cd prover
RUST_LOG=info cargo run --release
Project Layout
Fibonacci
|—— app
|—— src
|—— main.rs
|—— Cargo.toml
|—— elf
|—— riscv32im-pico-zkvm-elf
|—— lib
|—— src
|—— lib.rs
|—— Cargo.toml
|—— prover
|—— src
|—— main.rs
|—— Cargo.toml
|—— Cargo.toml
|—— Cargo.lock
|—— rust-toolchain
The template project includes 3 workspace members: app
, lib
and prover
app
: contains the program source code, which will be compiled to RiscV
lib
: contains components or utilities shared in multiple modules.
prover
: contains the scripts to prepare program input data and execute the proving process.
elf
: contains elf with RISC-V instructions.
Start with the EVM template
Minimum memory requirement: 32GB
Create and build the EVM Example Project
cargo pico new evm-example --template evm cd evm-example/app/ cargo pico build
Prove program to EVM
cd ../prover RUST_LOG=info cargo run --release
This step will locally set up the Groth16 Verifier contract and generate the Pico Groth16 proof. The files will be outputted to the
root/contracts/test_data
folder.Test EVM Proof
cd ../contracts mv -f ./test_data/Groth16Verifier.sol ./src/Groth16Verifier.sol forge test
The foundry test script will parse the proof generated in the previous step and interact with the Groth16 Verifier contract. With all tests passing, the EVM quick start is successful.
Last updated