# Cairo Proof Parser
This lib crate is a parser written to translate beetwen different cairo proof formats.
It exports a function:
```rust
pub fn parse(input: String) -> anyhow::Result<Exprs>
```
### Input
The input to the ```parse``` function is a proof in a json string format. The proof is expected to be generated by the [stone prover](https://github.com/starkware-libs/stone-prover) with the ```-generate_annotations``` flag. Currently only the ```recursive``` and ```starknet``` layouts are supported.
### Output
The output is the ```AST``` wchich can be deserialized to a string using ```Exprs::to_string(&self)``` method. This can than be serialized to the arguments expected by the cairo verifier, and run using [cairo args runner](https://crates.io/crates/cairo-args-runner).
### Example usage
An example usage:
```rust
use cairo_args_runner::{Arg, Felt252, VecFelt252};
use cairo_proof_parser::parse;
fn main() -> anyhow::Result<()> {
// Read the stone prover input
let input = std::fs::read_to_string("main_proof.json")?;
// Parse the input as an AST
let parsed = parse(input)?;
// Parse the AST as cairo arguments
let args: VecFelt252 = serde_json::from_str(
&parsed.to_string()
)?;
// Run the cairo verifier with the aruments
let result = cairo_args_runner::run(
"cairo_verifier.sierra.json",
"main",
&[Arg::Array(args.to_vec())],
)?;
println!("{result:?}");
Ok(())
}
```
### Roadmap
In the future we might parse directly to ```cairo-args-runner::Args``` to skip one parsing step. For now the current approach is absolutely sufficent and gives most flexibility. There were also some bug fixes in the [cairo-lang-runner](https://github.com/starkware-libs/cairo/blob/main/crates/cairo-lang-runner/README.md) crate enabling the ```cairo-args-runner``` to pass multiple arrays correctly.