| Crates.io | air-codegen-winter |
| lib.rs | air-codegen-winter |
| version | 0.4.0 |
| created_at | 2022-11-10 22:23:30.208015+00 |
| updated_at | 2025-06-21 00:22:35.300082+00 |
| description | Winterfell code generator for the AirScript language |
| homepage | |
| repository | https://github.com/0xMiden/air-script |
| max_upload_size | |
| id | 712445 |
| size | 61,730 |
This crate contains a code generator targeting the Winterfell prover Rust library.
The purpose of this code generator is to convert a provided AirIR representation of an AIR into a custom Rust struct that implements Winterfell's Air trait. The generated code can be used instead of writing a custom Winterfell Air implementation directly in Rust.
Generate Rust code from an AirIR (AirScript's intermediate representation) by instantiating a new CodeGenerator with an AirScript AST (the output of the AirScript parser) and then calling generate. The generate method will return the Rust code implementation as a String.
Instantiating the CodeGenerator will add the required Winterfell imports, create a custom struct using the name defined for the AIR, then implement the Winterfell Air trait for the custom struct.
Example usage:
// parse the source string to a Result containing the AST or an Error
let ast = parse(source.as_str()).expect("Parsing failed");
// process the AST to get a Result containing the AirIR or an Error
let ir = AirIR::new(&ast).expect("AIR is invalid");
// generate Rust code targeting the Winterfell prover
let rust_code = CodeGenerator::new(&ir);
The following code is generated for the Winterfell Air trait implementation:
PublicInputs struct.Air trait:
AirContext creation in the new method:
get_periodic_column_values)get_assertions)get_aux_assertions)evaluate_transition)evaluate_aux_transition)