#air #stark #zero-knowledge #zkp

bin+lib air-script

AirScript language compiler

1 unstable release

Uses new Rust 2021

0.1.0 Nov 10, 2022

#949 in Cryptography

24 downloads per month

MIT license


AirScript Compiler

This crate aggregates all components of the AirScript compiler into a single place. Specifically, it re-exports functionality from the parser, ir, and winterfell code generator crates. Additionally, when compiled as an executable, this crate can be used via a CLI to transpile AIRs defined in AirScript to a specified target language.

Basic Usage

An in-depth description of AirScript is available in the full AirScript documentation.

The compiler has three stages, which can be imported and used independently or together.

  1. Parser: scans and parses AirScript files and builds an AST
  2. IR: produces an intermediate representation from an AirScript AST
  3. Code generation: translate an AirIR into a specific target language

Example usage:

use air_script::{parse, AirIR, CodeGenerator};

// 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::from_source(&ast).expect("AIR is invalid");

// generate Rust code targeting the Winterfell prover
let rust_code = CodeGenerator::new(&ir);

There are several example .air files written in AirScript which can be found in the examples/ directory.

To run the full transpilation pipeline, the CLI can be used for convenience.

Command-Line Interface (CLI)

There is a command-line interface available for transpiling AirScript files. Currently, the only available target is Rust code for use with the Winterfell STARK prover library.

To use the CLI, first run:

cargo build --release

Then, run the airc target with the transpile option and specify your input file with -i. For example:

./target/release/airc transpile -i examples/system.air

When no output destination is specified, the output file will use the path and name of the input file, replacing the .air extension with .rs. For the above example, examples/system.rs will contain the generated output.

You can use the help option to see other available options.

./target/release/airc transpile --help


~116K SLoC