|
| 1 | +# stwo_run_and_prove |
| 2 | + |
| 3 | +Runs a compiled Cairo program and generates a Stwo proof for it. Optionally verifies the proof. |
| 4 | +Saves the proof to the given path with the requested format, and optionally saves the program output and data for debugging. |
| 5 | + |
| 6 | +Entry point: `crates/stwo_run_and_prove/src/main.rs` |
| 7 | + |
| 8 | + |
| 9 | +## Build & run |
| 10 | + |
| 11 | +cargo run -p stwo_run_and_prove -- --help |
| 12 | + |
| 13 | + |
| 14 | +## Basic usage |
| 15 | + |
| 16 | +Required arguments: |
| 17 | +- `--program <PathBuf>`: Absolute path to the compiled Cairo program. |
| 18 | +- `--proof_path <PathBuf>`: Absolute path where the generated proof will be saved. |
| 19 | + |
| 20 | +Basic Example: |
| 21 | +cargo run -p stwo_run_and_prove -- \ |
| 22 | + --program path/to/compiled_program.json \ |
| 23 | + --proof_path proof.json |
| 24 | + |
| 25 | +Optional arguments: |
| 26 | +- `--program_input <PathBuf>`: Absolute path to the program input file. |
| 27 | +- `--program_output <PathBuf>`: Absolute path where the program's output will be saved. |
| 28 | +- `--prover_params_json <PathBuf>`: Absolute path to the JSON file containing the prover parameters. |
| 29 | +- `--proof_format <ProofFormat>`: Proof format (Json or CairoSerde. default: CairoSerde). |
| 30 | +- `--verify`: Verifies the generated proof. |
| 31 | +- `--save_debug_data`: Saves the ProverInput to a file in `debug_data_dir` for both success and failure. |
| 32 | +- `--debug_data_dir <PathBuf>`: Absolute path to the output directory where the ProverInput will be saved in the |
| 33 | + case of a proving error, or when the save_debug_data flag is enabled. |
| 34 | + |
| 35 | +Example with verification and debug data: |
| 36 | +cargo run -p stwo_run_and_prove -- \ |
| 37 | + --program path/to/compiled_program.json \ |
| 38 | + --program_input path/to/program_input.json \ |
| 39 | + --proof_path path/to/proof.json \ |
| 40 | + --verify \ |
| 41 | + --debug_data_dir path/to/debug_output \ |
| 42 | + --save_debug_data |
| 43 | + |
| 44 | + |
| 45 | +## What it does |
| 46 | + |
| 47 | +1. Runs the given Cairo program with cairo-vm. |
| 48 | +2. Calls `stwo_cairo_adapter::adapter::adapt(&cairo_runner)` to produce `ProverInput`. |
| 49 | +3. Proves the program, and optionally verifies it. |
| 50 | +4. Saves the proof, and optionally the program's output and the debug data, to the given paths. |
| 51 | + |
| 52 | + |
| 53 | +## Outputs |
| 54 | + |
| 55 | +- Proof (`--proof_path`): Stwo proof file in the specified format. |
| 56 | +- Program output (`--program_output`): JSON array of program output felts (if specified). |
| 57 | +- Debug data: ProverInput JSON saved to `debug_data_dir` (when `--save_debug_data` is enabled or on proving failure). |
0 commit comments