Skip to content

Hello World

The fastest way to get started is with ach init:

Terminal window
ach init hello --template vm
cd hello
ach run

This creates a project with an achronyme.toml and src/main.ach. See Project Configuration for details.

You can also create files manually — no project setup required.

Create a file hello.ach:

print("Hello, world!")

Run it:

Terminal window
ach run hello.ach

Output:

Hello, world!
let fib = fn fib(n) {
if n < 2 { return n }
return fib(n - 1) + fib(n - 2)
}
for i in 0..10 {
print(fib(i))
}

Create a file multiply.ach:

circuit multiply(product: Public, a: Witness, b: Witness) {
assert_eq(a * b, product)
}

This circuit proves that the prover knows two secret numbers a and b whose product equals the public value product.

Compile it:

Terminal window
ach circuit multiply.ach --inputs "product=42,a=6,b=7"

This produces circuit.r1cs and witness.wtns, ready for snarkjs proof generation.

  1. The parser read multiply.ach and built an AST with the multiply circuit definition
  2. The IR lowering phase converted it to SSA instructions
  3. The R1CS backend compiled the multiplication into a single constraint: a * b = product
  4. The witness generator filled in the concrete values: a=6, b=7, product=42
  5. The exporter wrote snarkjs-compatible binary files

You can also generate proofs directly from Achronyme code:

let a = 0p6
let b = 0p7
let product = 0p42
let p = prove(product: Public) {
assert_eq(a * b, product)
}

The prove {} block compiles the circuit, captures variables from the enclosing scope, generates a witness, verifies constraints, and — if a proving backend is available — returns a cryptographic proof.