Hello World
Create a project
Section titled “Create a project”The fastest way to get started is with ach init:
ach init hello --template vmcd helloach runThis 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.
General-Purpose Program
Section titled “General-Purpose Program”Create a file hello.ach:
print("Hello, world!")Run it:
ach run hello.achOutput:
Hello, world!A more interesting example
Section titled “A more interesting example”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))}Your First Circuit
Section titled “Your First Circuit”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:
ach circuit multiply.ach --inputs "product=42,a=6,b=7"This produces circuit.r1cs and witness.wtns, ready for snarkjs proof generation.
What just happened?
Section titled “What just happened?”- The parser read
multiply.achand built an AST with themultiplycircuit definition - The IR lowering phase converted it to SSA instructions
- The R1CS backend compiled the multiplication into a single constraint:
a * b = product - The witness generator filled in the concrete values:
a=6,b=7,product=42 - The exporter wrote snarkjs-compatible binary files
Inline Proof
Section titled “Inline Proof”You can also generate proofs directly from Achronyme code:
let a = 0p6let b = 0p7let 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.