This lib crate is a parser written to translate beetwen different cairo proof formats. It exports a function:
pub fn parse(input: String) -> anyhow::Result<Exprs>
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 with the -generate_annotations
flag. Currently only the recursive
and starknet
layouts are supported.
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.
An example usage:
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(())
}
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 crate enabling the cairo-args-runner
to pass multiple arrays correctly.