This guide provides step-by-step instructions for working with the Stone Prover Docker container and compiling, running, and verifying Cairo code. Ensure Docker is installed and running on your machine before proceeding.
cd stone-prover
docker build --tag prover .
docker run -it prover bashfor Mac
docker build --tag prover . --build-arg CMAKE_ARGS=-DNO_AVX=1
docker run -it prover bashCan also copy out the executable stone prover file to the linux system
container_id=$(docker create prover)
docker cp -L ${container_id}:/bin/cpu_air_prover .
docker cp -L ${container_id}:/bin/cpu_air_verifier .To start, you need to copy the Cairo code into the Stone Prover Docker container. Execute the following commands in your terminal:
# Find the container ID for the 'prover' container
CONTAINER_ID=$(docker ps -aqf "name=^prover$")
# Copy the 'mapper/' directory to the '/app/' directory in the 'prover' container
docker cp mapper/ $CONTAINER_ID:/app/Once the code is in the container, follow these steps to compile and execute it.
cairo-compile mapper.cairo --output mapper_compiled.json --proof_mode --no debug_infocairo-run \
--program=mapper_compiled.json \
--layout=recursive \
--air_public_input=mapper_public_input.json \
--air_private_input=mapper_private_input.json \
--trace_file=mapper_trace.json \
--memory_file=mapper_memory.json \
--print_output \
--proof_mode
Remember to check the public input for the number of steps to configure the FRI step list in cpu_air_params.json FRI steps should typically be in the range 2-4; the degree bound should be in the range 4-7. The following equation should be satisfied
log₂(last_layer_degree_bound) + ∑fri_step_list = log₂(#steps) + 4cpu_air_prover --out_file=mapper_proof.json --private_input_file=mapper_private_input.json --public_input_file=mapper_public_input.json --prover_config_file=cpu_air_prover_config.json --parameter_file=cpu_air_params.json --generate_annotations# Find the container ID for the 'prover' container
CONTAINER_ID=$(docker ps -aqf "name=^prover$")
# Copy the 'mapper/' directory to the '/app/' directory in the 'prover' container
docker cp $CONTAINER_ID:/app/mapper/ cairo_programs/macOS
brew install pyenv pyenv-virtualenvAdd the following to your .zshrc or .bashrc:
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"pyenv install 3.9
pyenv virtualenv 3.9 stone-prover-cairo0-verifier2pyenv activate stone-prover-cairo0-verifier2If jq is not installed:
brew install jqNavigate to the cairo-lang directory and execute:
jq '{ proof: . }' ../../cairo_programs/mapper/mapper_proof.json > cairo_verifier_input.json
cairo-compile --cairo_path=./src src/starkware/cairo/cairo_verifier/layouts/all_cairo/cairo_verifier.cairo --output cairo_verifier.json --no_debug_info
cairo-run \
--program=cairo_verifier.json \
--layout=recursive \
--program_input=cairo_verifier_input.json \
--trace_file=cairo_verifier_trace.json \
--memory_file=cairo_verifier_memory.json \
--print_outputAssuming one proof is in folder mapper and the other in foler mapper2
jq -s '{ proof1: .[0], proof2: .[1] }' ../../cairo_programs/mapper/mapper_proof.json ../../cairo_programs/mapper/mapper_proof.json > combined_verifier_input.json
cairo-compile --cairo_path=./src src/starkware/cairo/cairo_verifier/layouts/all_cairo/merge_cairo_verifier.cairo --output merge_cairo_verifier.json --no_debug_info
cairo-run \
--program=merge_cairo_verifier.json \
--layout=recursive \
--program_input=combined_verifier_input.json \
--trace_file=cairo_combined_verifier_trace.json \
--memory_file=cairo_combined_verifier_memory.json \
--print_output