AirAssembly: a low-level language for zk-STARKs

I’ve just released a new version of AirScript (v0.6) and genSTARK library (v0.7). The biggest thing is that now AirScript gets compiled into an AirAssembly module, and then genSTARK creates a STARK from this AirAssembly module.

In fact, genSTARK can now instantiate STARKs from either AirScript or AirAssembly source code. This will help with making AirScript modular/composable - which is what I’m planning to do next.

Other notable change is that now AirScript supports naming of input and readonly registers. So, for example, a MiMC STARK in AirScript can be written like this:

define MiMC over prime field (2^128 - 9 * 2^32 + 1) {
    const alpha: 3;
    
    // define cyclic readonly register
    static round_constant: cycle [42, 43, 170, 2209, 16426, 78087, 279978, 823517];

    // require a single secret input
    secret input start_value: element[1];

    // transition function definition
    transition 1 register {
        for each (start_value) {
            init { yield start_value; }
            for steps [1..8192] {
                yield $r0^3 + round_constant;
            }
        }
    }

    // transition constraint definition
    enforce 1 constraint {
        for all steps {
            enforce transition($r) = $n;
        }
    }
}

More sophisticated examples (hash functions, Merkle proofs) can be found here and here.

1 Like