Skip to content

Latest commit

 

History

15 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ast-interpreter

A small Rust interpreter for Noir's monomorphized AST (noirc_frontend::monomorphization::ast).

It can run the same AST over bn254 or Goldilocks and compare field-independent values such as integers, booleans, arrays, tuples, and structs. Field values are deliberately never compared: a difference there is expected rather than a divergence. The default build uses Noir only.

Using it

[dependencies]
ast-interpreter = { git = "https://github.com/worldfnd/ast-interpreter.git", rev = "<rev>" }

Use interpret for self-checking programs with no inputs, or interpret_with_inputs when main takes arguments. For Prover.toml inputs, use inputs_from_prover_toml and expected_return_from_prover_toml.

Crates that pass Noir AST values into this interpreter must use the same pinned noirc_frontend and acvm sources, spelled the same way. Cargo keys a git dependency on the URL and the reference, so branch = "x" and rev = "<head of x>" are different sources: you get two FieldElement types and no error until the two halves meet. acvm::FieldElement is selected at compile time.

The mavros-oracle feature is a placeholder. Its mavros-compiler dependency is commented out, so enabling the feature fails the build with a compile_error! saying so.

Main exports: interpret, interpret_with_inputs, inputs_from_prover_toml, expected_return_from_prover_toml, Value, IntValue, DiffValue, DiffOutcome, FailureKind, values_equivalent, outcomes_equivalent, outcome_is_tolerated, and InterpretError.

InterpretError separates bad caller data (InvalidInput), runtime range errors (ValueOutOfRange), invalid AST value shapes (Type), and interpreter invariant failures (Internal). It and FailureKind are #[non_exhaustive].

Building and testing

Stable Rust. .cargo/config.toml raises RUST_MIN_STACK because Noir's frontend recurses past libtest's default; it applies only when cargo runs from this directory.

cargo build
cargo test
cargo test --features goldilocks

Ignored tests drive the cross-field differential and corpus surveys. They require either Noir's upstream corpus in a sibling ../noir checkout or field dumps generated by the dump test. Corpus smoke tests in the default suite self-skip when the sibling checkout is absent.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages