AirAssembly: a low-level language for zk-STARKs

I’ve just released a JavaScript compiler/runtime for AirAssembly. The specs have changed a little as well since my last post.

The library is located here: https://github.com/GuildOfWeavers/AirAssembly
And the updated specs are here: https://github.com/GuildOfWeavers/AirAssembly/tree/master/specs

Here is a simple example of how the library can be used to generate an execution trace table and constraint evaluation table for a MiMC computation:

import { compile, instantiate } from '@guildofweavers/air-assembly';

const source = `
(module
    (field prime 4194304001)
    (const 
        (scalar 3))
    (static
        (cycle (prng sha256 0x4d694d43 64)))
    (transition
        (span 1) (result vector 1)
        (add 
            (exp (load.trace 0) (load.const 0))
            (get (load.static 0) 0)))
    (evaluation
        (span 2) (result vector 1)
        (sub
            (load.trace 1)
            (add
                (exp (load.trace 0) (load.const 0))
                (get (load.static 0) 0))))
    (export main (init seed) (steps 32)))`;

// instantiate AirModule object
const schema = compile(Buffer.from(source));
const air = instantiate(schema);

// generate execution trace table
const prover = air.createProver();
const trace = prover.generateExecutionTrace([3n]);

// generate constraint evaluation table
const tracePolys = air.field.interpolateRoots(prover.executionDomain, trace);
const constraintEvaluations = prover.evaluateTransitionConstraints(tracePolys);

A more sophisticated example of AirAssembly for Poseidon hash function can be found here.

Next, I’m planning to integrate the runtime into genSTARK.

One thing AirAssembly doesn’t yet support is “long-range” constraints. I’d love to add support for these as I think that opens up some interesting use cases. If anyone has any thoughts about long-range constraints (or any other aspect of AirAssembly), would love to hear them.

1 Like