To build the Cairo Verifier, follow these steps:
- Build the project by running the following command in your terminal:
scarb build
- (Optional) Test the project to ensure everything works correctly:
scarb test
For local proof verification, follow these steps:
- Run the verifier locally on example proof using the following command:
cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/example_proof.json
To verify proofs on Starknet, proceed with the following steps:
- Prepare calldata of example proof for sncast:
cargo run --release --bin snfoundry_proof_serializer < examples/proofs/example_proof.json > examples/starknet/calldata
- Call the function with calldata on the Starknet contract:
cd examples/starknet
./call_contract.sh calldata
To create a proof, perform the following steps:
- Install stone-prover (restart your shell after installation):
git clone --recurse-submodules https://github.com/Moonsong-Labs/stone-prover-sdk.git
cd stone-prover-sdk
bash scripts/install-stone.sh
- Install cairo-lang:
pip install cairo-lang==0.12.0
- Compile a Cairo program, for example, the Fibonacci program:
cd examples/prover
cairo-compile fibonacci.cairo --output fibonacci_compiled.json --proof_mode
- Run the Cairo program:
cairo-run \
--program=fibonacci_compiled.json \
--layout=recursive \
--program_input=fibonacci_input.json \
--air_public_input=fibonacci_public_input.json \
--air_private_input=fibonacci_private_input.json \
--trace_file=fibonacci_trace.bin \
--memory_file=fibonacci_memory.bin \
--print_output \
--proof_mode
- Prove the Cairo program:
cpu_air_prover \
--out_file=../proofs/fibonacci_proof.json \
--private_input_file=fibonacci_private_input.json \
--public_input_file=fibonacci_public_input.json \
--prover_config_file=cpu_air_prover_config.json \
--parameter_file=cpu_air_params.json \
--generate_annotations
You can verify
this the proof locally
or on the Starknet Cairo verifier
contract by specifying the path examples/proofs/fibonacci_proof.json
to the newly generated proof.
By default, the verifier uses Pedersen for verifier-friendly layers and Keccak for unfriendly layers. To change the hasher for unfriendly layers, use the provided Python script:
To change the hasher for unfriendly layers to Blake2s, run the following command:
python3 change_hasher.py -t blake
To change the hasher for unfriendly layers to Keccak256, run the following command:
python3 change_hasher.py -t keccak