Skip to content

kacperkozi/integrity

 
 

Repository files navigation

Cairo Verifier

Cairo Verifier

Continuous Integration - tests

Continuous Integration - proof verification tests

Building the Verifier

To build the Cairo Verifier, follow these steps:

  1. Build the project by running the following command in your terminal:
scarb build
  1. (Optional) Test the project to ensure everything works correctly:
scarb test

Running the Verifier on Example Proof

Local Proof Verification

For local proof verification, follow these steps:

  1. Run the verifier locally on example proof using the following command:
cargo run --release --bin runner -- target/dev/cairo_verifier.sierra.json < examples/proofs/recursive/example_proof.json

Starknet Proof Verification

To verify proofs on Starknet, proceed with the following steps:

  1. Prepare calldata of example proof for sncast:
cargo run --release --bin snfoundry_proof_serializer < examples/proofs/recursive/example_proof.json > examples/starknet/calldata
  1. Call the function with calldata on the Starknet contract:
cd examples/starknet
./1-verify-proof.sh 0x487810706cc0dfdba0c82403d98e9d32dc36793ed2b731231e5ea19f00c5861 calldata

List of deployed Verifier Contracts

Configure Verifier

By default, the verifier is configured for recursive layout and keccak hash for verifier unfriendly commitment layers. You can easily change that by using the configure python script (this script is in Experimental stage):

python configure.py -l recursive -s keccak

layout types: [dex, recursive, recursive_with_poseidon, small, starknet, starknet_with_keccak]
hash types: [keccak, blake2s]

Creating a Proof

To create a proof, perform the following steps:

  1. Install stone-prover (restart your shell after installation):
git clone https://github.com/starkware-libs/stone-prover.git
cd stone-prover
docker build --tag prover .
container_id=$(docker create prover)
docker cp -L ${container_id}:/bin/cpu_air_prover ../examples/prover
docker cp -L ${container_id}:/bin/cpu_air_verifier ../examples/prover
  1. Install cairo-lang:
pip install cairo-lang==0.12.0
  1. Compile a Cairo program, for example, the Fibonacci program:
cd examples/prover
cairo-compile fibonacci.cairo --output fibonacci_compiled.json --proof_mode
  1. 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
  1. Prove the Cairo program:
./cpu_air_prover \
    --out_file=../proofs/recursive/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 proof locally or on the Starknet Cairo verifier contract by specifying the path examples/proofs/recursive/fibonacci_proof.json to the newly generated proof.

Benchmarking

In order to launch benchmarking, just run this (it requires recursive layout configuration):

cargo run --release --bin benches -- target/dev/cairo_verifier.sierra.json

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Cairo 99.5%
  • Other 0.5%