zuring-lang

Status: experimental, and not published yet. zuring-lang and .zl are working names.

A small typed language for the virtual machine. A program is Rust-like functions over field, bool, the integers u8 to u64, and arrays of them:

static PRICES: [u64; 8] = [120, 75, 300, 42, 90, 15, 250, 60];

fn main() {
    let budget = input() as u64;
    let mut spent: u64 = 0;
    for i in 0..8 {
        if spent + PRICES[i] <= budget {
            spent = spent + PRICES[i];
        }
    }
    output(spent);
}

Integers are checked: an operation whose result leaves its type fails the run.

Built-inWhat it does
input()The step's input word
page()The page cell
secret()A private word, which the prover gives with the step's input word
hint(e)e's value, computed outside the proof: the program has to check it
output(e)Sets the output word
assert(e)Fails the run unless e holds
wait()Ends the step: the run goes on with the next step's input word

An integer / or % takes its quotient and remainder as hints, so a run's hints are its hints, its secrets and its divisions, in order.

Running it

The interpreter is the language's reference. It gives a run's output, or the check that failed and its line, and the hints the compiled code will take. The compiler turns a program into the machine's assembly, and vm checks that the compiled program, run with those hints, agrees with the interpreter.

CommandWhat it does
zuring-lang check <file>Parses and checks the program
zuring-lang run <file>Runs it on the interpreter
zuring-lang asm <file>Compiles it, and prints the assembly
zuring-lang vm <file>Compiles it, and runs it on the machine
zuring-lang prove <file>Compiles it, and proves its run
zuring-lang play <file>Runs a program that waits a step at a time, reading each step's input word and private words from the terminal. With --prove, it proves each step before the next.

--x sets the input word and --secret gives the next private word, once per word. --fuel bounds the statements and loop iterations a run may take, --depth the calls at once, and --steps the steps vm runs.