This repository is forked from gerlion/STARKs_for_Homomorphic_Tallying.
Install Cairo0 following the install page and activate the virtual environment. Clone the STONE prover project, build the docker image, and fetch the prover and verifier executables:
container_id=$(docker create prover)
docker cp -L ${container_id}:/bin/cpu_air_prover .
docker cp -L ${container_id}:/bin/cpu_air_verifier .Generate the input data for update circuit:
python generate_update_data.py 3 artifacts/update_input_3_example.jsonWithin a Cairo0 python virtual environment, compile the Cairo0 program:
cairo-compile src/update.cairo --output artifacts/update_compiled.json --proof_modeRun the Cairo0 program to generate the prover input files:
cairo-run --program=artifacts/update_compiled.json \
--layout=all_solidity \
--program_input=artifacts/update_input.json \
--air_public_input=artifacts/update_public_input.json \
--air_private_input=artifacts/update_private_input.json \
--trace_file=artifacts/update_trace.json \
--memory_file=artifacts/update_memory.json \
--print_output --proof_modeRun the STONE prover executable on the program data to generate a STARK proof:
./cpu_air_prover --out_file=artifacts/update_proof.json \
--private_input_file=artifacts/update_private_input.json \
--public_input_file=artifacts/update_public_input.json \
--prover_config_file=artifacts/cpu_air_prover_config.json \
--parameter_file=artifacts/cpu_air_params.jsonFinally, run the STONE verifier executable on the STARK proof and confirm verification:
./cpu_air_verifier --in_file=artifacts/update_proof.json && echo "Successfully verified proof."Similarly, use generate_accumulate_data.py to generate input data for accumulate.cairo, then replace update with accumulate in previous steps.
Use generate_full_data.py to simulate basic election where every voter submits one ballot. The script outputs set of inputs for the update circuit for each submission, and the accumulate circuit. Run bash prove_all_update.sh to automate previous steps for all update inputs.