{"id":46027942,"url":"https://github.com/achronyme/achronyme","last_synced_at":"2026-04-01T17:10:45.415Z","repository":{"id":340193614,"uuid":"1163526264","full_name":"achronyme/achronyme","owner":"achronyme","description":"A programming language for zero-knowledge circuits with dual execution: full VM + optimized circuit compilation.","archived":false,"fork":false,"pushed_at":"2026-03-04T23:53:20.000Z","size":15362,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-03-05T05:02:36.920Z","etag":null,"topics":["compiler","cryptography","dsl","rust","zero-knowledge","zk"],"latest_commit_sha":null,"homepage":"https://achrony.me","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/achronyme.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":"audits/AUDIT-2026-02-21.md","citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-02-21T19:07:18.000Z","updated_at":"2026-03-04T23:53:23.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/achronyme/achronyme","commit_stats":null,"previous_names":["eddndev/achronyme"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/achronyme/achronyme","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achronyme%2Fachronyme","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achronyme%2Fachronyme/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achronyme%2Fachronyme/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achronyme%2Fachronyme/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/achronyme","download_url":"https://codeload.github.com/achronyme/achronyme/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achronyme%2Fachronyme/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30417686,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-12T06:40:58.731Z","status":"ssl_error","status_checked_at":"2026-03-12T06:40:40.296Z","response_time":114,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["compiler","cryptography","dsl","rust","zero-knowledge","zk"],"created_at":"2026-03-01T03:14:00.229Z","updated_at":"2026-04-01T17:10:45.408Z","avatar_url":"https://github.com/achronyme.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Achronyme\n\n[![CI](https://github.com/achronyme/achronyme/actions/workflows/ci.yml/badge.svg)](https://github.com/achronyme/achronyme/actions/workflows/ci.yml)\n\nA programming language for zero-knowledge circuits.\n\nWrite readable code. Decide what gets proven. Same language for general execution and ZK circuit compilation.\n\n## Install\n\n```bash\ncurl -fsSL https://achrony.me/install.sh | sh\n```\n\nThis installs the `ach` binary to `~/.local/bin`. Requires Linux or macOS (x86_64 or aarch64).\n\n### Build from source\n\n```bash\ngit clone https://github.com/achronyme/achronyme.git\ncd achronyme\ncargo build --release\ncargo test --workspace     # 2,000+ unit tests\nbash test/run_tests.sh     # 150+ integration tests\n```\n\n---\n\n## Quick Look\n\n### General-purpose execution\n\n```achronyme\nlet make_counter = fn(init) {\n    mut n = init\n    return fn() { n = n + 1; return n }\n}\nlet c = make_counter(0)\nprint(c())  // 1\nprint(c())  // 2\n```\n\n### ZK circuit\n\n```achronyme\npublic root\nwitness leaf\nwitness path[3]\nwitness indices[3]\n\nmerkle_verify(root, leaf, path, indices)\n```\n\n```bash\nach circuit merkle.ach --inputs \"root=...,leaf=42,path_0=...,path_1=...,path_2=...,indices_0=0,indices_1=1,indices_2=0\"\n# → circuit.r1cs + witness.wtns (snarkjs-compatible)\n```\n\n### Inline proof generation\n\n```achronyme\nlet secret = 0p42\nlet hash = 0p17159...  // poseidon(42, 0)\n\nlet p = prove {\n    witness secret\n    public hash\n    assert_eq(poseidon(secret, 0), hash)\n}\n\nprint(proof_json(p))  // Groth16 proof, verifiable on-chain\n```\n\n---\n\n## How It Works\n\nAchronyme has two execution modes from the same source:\n\n**VM mode** (`ach run`) — Full language: closures, recursion, GC, arrays, maps, strings, I/O. Code runs like any scripting language.\n\n**Circuit mode** (`ach circuit`) — Compiles to arithmetic constraints over BN254. No loops at runtime, no I/O — everything is unrolled and flattened into a constraint system for zero-knowledge proofs.\n\nThe `prove {}` block bridges both: it runs inside the VM, compiles its body as a circuit, generates a witness from captured variables, and produces a cryptographic proof — all in one expression.\n\n```\nSource (.ach)\n    │\n    ├─► Parser (Pratt) → AST\n    │       │\n    │       ├─► Bytecode → VM          (run mode)\n    │       │\n    │       └─► SSA IR → Optimize\n    │               │\n    │           ┌───┴───┐\n    │           ▼       ▼\n    │        R1CS    Plonkish\n    │      (Groth16) (KZG-PlonK)\n    │           │       │\n    │           ▼       ▼\n    │       .r1cs    Gates/Lookups\n    │       .wtns    Copy constraints\n    │           │       │\n    │           └───┬───┘\n    │               ▼\n    │         Native proof\n    │\n    └─► prove { } → compile + witness + verify + proof (inline)\n```\n\n---\n\n## Language\n\n### Types\n\n| Type | Examples |\n|------|---------|\n| Int | `42`, `-7` |\n| Bool | `true`, `false` |\n| String | `\"hello\"` |\n| List | `[1, 2, 3]` |\n| Map | `{\"a\": 1, \"b\": 2}` |\n| Field | `0p42`, `0pxFF`, `0pb1010` |\n| BigInt256 | `0i256xFF`, `0i256d42` |\n| BigInt512 | `0i512xFF`, `0i512d100` |\n| Function | `fn(x) { x + 1 }` |\n| Proof | result of `prove { }` |\n| Nil | `nil` |\n\n### Control Flow\n\n```achronyme\nif x \u003e 0 { print(\"positive\") } else { print(\"non-positive\") }\n\nwhile n \u003e 0 { n = n - 1 }\n\nfor item in list { print(item) }\n\nfor i in 0..10 { print(i) }\n```\n\n### Functions and Closures\n\n```achronyme\nlet add = fn(a, b) { a + b }\n\nlet fib = fn fib(n) {\n    if n \u003c 2 { return n }\n    return fib(n - 1) + fib(n - 2)\n}\n\n// Closures capture environment\nlet make_adder = fn(x) { fn(y) { x + y } }\nlet add5 = make_adder(5)\nprint(add5(3))  // 8\n```\n\n### Field Elements\n\nBN254 scalar field. Montgomery form internally. Created with the `0p` prefix:\n\n```achronyme\nlet a = 0p42\nlet b = 0pxFF\nlet c = 0pb1010\n\nlet sum = a + b\nlet prod = a * b\nlet inv = 0p1 / a\n```\n\n### BigInt (VM only)\n\nFixed-width unsigned integers (256-bit and 512-bit) for cryptographic operations:\n\n```achronyme\nlet a = 0i256xFF\nlet b = bigint256(42)\nlet bits = a.to_bits()\nlet masked = a.bit_and(b)\n```\n\n---\n\n## Circuit Features\n\n### Declarations\n\n```achronyme\npublic output          // public input (instance)\nwitness secret         // private input (witness)\nwitness arr[4]         // witness array (arr_0, arr_1, arr_2, arr_3)\n```\n\n### Builtins\n\n| Builtin | Description | R1CS cost | Plonkish cost |\n|---------|-------------|-----------|---------------|\n| `assert_eq(a, b)` | Enforce equality | 1 | 1 |\n| `assert(expr)` | Enforce boolean true | 2 | 2 |\n| `poseidon(a, b)` | Poseidon 2-to-1 hash | 361 | 361 |\n| `poseidon_many(a, b, c, ...)` | Left-fold Poseidon | 361*(n-1) | 361*(n-1) |\n| `mux(cond, a, b)` | Conditional select | 2 | 1 |\n| `range_check(x, bits)` | Value fits in N bits | bits+1 | 1 (lookup) |\n| `merkle_verify(root, leaf, path, indices)` | Merkle membership proof | ~1090/level | ~1090/level |\n| `len(arr)` | Compile-time array length | 0 | 0 |\n\n### Operators in Circuits\n\n| Operation | R1CS | Plonkish |\n|-----------|------|----------|\n| `+`, `-` | 0 | 0 |\n| `*` | 1 | 1 |\n| `/` | 2 | 2 |\n| `^` (constant exp) | O(log n) | O(log n) |\n| `==`, `!=` | 2 | 2 |\n| `\u003c`, `\u003c=`, `\u003e`, `\u003e=` | ~760 | ~760 |\n| `\u0026\u0026`, `\\|\\|` | 3 | 3 |\n| `!` | 1 | 1 |\n\n### Functions in Circuits\n\nFunctions are inlined at each call site. No dynamic dispatch, no recursion.\n\n```achronyme\nwitness a, b\npublic out\n\nfn hash_pair(x, y) { poseidon(x, y) }\n\nassert_eq(hash_pair(a, b), out)\n```\n\n### Control Flow in Circuits\n\n`if/else` compiles to `mux` (both branches are evaluated). `for` loops are statically unrolled. `while`, `break`, `continue` are rejected at compile time.\n\n```achronyme\nwitness vals[4]\npublic total\n\nlet sum = vals[0]\nlet sum = sum + vals[1]\nlet sum = sum + vals[2]\nlet sum = sum + vals[3]\nassert_eq(sum, total)\n```\n\n---\n\n## CLI\n\n```bash\n# Run a program\nach run script.ach\n\n# Run with PlonK prove backend\nach run script.ach --prove-backend plonkish\n\n# Compile circuit (in-source declarations)\nach circuit circuit.ach --inputs \"x=42,y=7\"\n\n# Compile circuit (CLI declarations)\nach circuit circuit.ach --public \"out\" --witness \"a,b\" --inputs \"out=42,a=6,b=7\"\n\n# Plonkish backend\nach circuit circuit.ach --backend plonkish --inputs \"x=42,y=7\"\n\n# Generate Plonkish proof\nach circuit circuit.ach --backend plonkish --inputs \"x=42\" --prove\n\n# Generate Solidity verifier contract\nach circuit circuit.ach --inputs \"x=42,y=7\" --solidity\n\n# Compile to bytecode\nach compile script.ach --output script.achb\n\n# Disassemble\nach disassemble script.ach\n```\n\nOutput `.r1cs` and `.wtns` files are compatible with snarkjs:\n\n```bash\nsnarkjs groth16 setup circuit.r1cs pot12_final.ptau circuit.zkey\nsnarkjs groth16 prove circuit.zkey witness.wtns proof.json public.json\nsnarkjs groth16 verify verification_key.json public.json proof.json\n```\n\n---\n\n## Prove Blocks\n\n`prove {}` compiles a circuit, captures variables from the enclosing scope, generates a witness, and returns a proof — all inline.\n\n```achronyme\nlet a = 0p6\nlet b = 0p7\nlet product = 0p42\n\nlet p = prove {\n    witness a\n    witness b\n    public product\n    assert_eq(a * b, product)\n}\n```\n\nVariable names inside `public`/`witness` declarations must match `let` bindings in the outer scope. Integer values are automatically promoted to field elements.\n\nThe result is a `Proof` object (Groth16 or PlonK depending on `--prove-backend`). Extract components with `proof_json(p)`, `proof_public(p)`, `proof_vkey(p)`. Verify with `verify_proof(p)`.\n\nIf no proving backend is available, the block still compiles the circuit, generates the witness, and verifies constraints locally (returns `nil`).\n\n---\n\n## Optimization Passes\n\nThe SSA IR runs four optimization passes before constraint generation:\n\n- **Constant folding** — Evaluates arithmetic on known constants at compile time\n- **Dead code elimination** — Removes unused instructions\n- **Boolean propagation** — Tracks proven-boolean variables, skips redundant enforcement\n- **Taint analysis** — Warns about under-constrained or unused inputs\n\nDisable with `--no-optimize`.\n\n---\n\n## Project Structure\n\n```\nachronyme/\n├── achronyme-parser/   Hand-written Pratt lexer + recursive descent parser\n├── ir/                 SSA intermediate representation, optimization passes\n├── compiler/           Bytecode compiler, R1CS backend, Plonkish backend\n├── vm/                 Register-based VM (37 opcodes, prototype method dispatch)\n├── memory/             Heap, GC, FieldElement\u003cF\u003e (BN254, BLS12-381, Goldilocks), BigInt\n├── constraints/        R1CS/Plonkish systems, Poseidon hash, binary export\n├── cli/                CLI, native Groth16 (ark-groth16) \u0026 PlonK (halo2-KZG)\n├── std/                Standard library (NativeModule: parse_int, join, I/O)\n├── ach-macros/         Proc-macros: #[ach_native], #[ach_module]\n├── docs/               Documentation site (Astro + Starlight, 83 pages, EN/ES)\n└── test/\n    ├── vm/             VM/interpreter integration tests\n    ├── circuit/        Circuit compilation tests\n    ├── prove/          Prove block tests\n    └── run_tests.sh    Integration test runner (158 tests)\n```\n\n---\n\n## Global Functions\n\n16 global functions are available without imports. Most operations now use [method syntax](#methods).\n\n| Function | Arity | Description |\n|----------|-------|-------------|\n| `print(...)` | variadic | Print values to stdout |\n| `typeof(x)` | 1 | Type name as String |\n| `assert(x)` | 1 | Runtime assertion |\n| `time()` | 0 | Unix timestamp (ms) |\n| `gc_stats()` | 0 | GC statistics as map |\n| `poseidon(a, b)` | 2 | Poseidon 2-to-1 hash (BN254) |\n| `poseidon_many(a, b, ...)` | variadic | Left-fold Poseidon hash |\n| `verify_proof(p)` | 1 | Verify a Groth16 proof |\n| `proof_json(p)` | 1 | Extract proof JSON |\n| `proof_public(p)` | 1 | Extract public inputs JSON |\n| `proof_vkey(p)` | 1 | Extract verifying key JSON |\n| `bigint256(x)` | 1 | Construct 256-bit unsigned integer |\n| `bigint512(x)` | 1 | Construct 512-bit unsigned integer |\n| `from_bits(bits, width)` | 2 | Bit list to BigInt |\n| `parse_int(str)` | 1 | Parse string to integer |\n| `join(list, sep)` | 2 | Join strings with separator |\n\n## Methods\n\nValues have type-specific methods called with dot syntax: `value.method(args)`.\n\n```achronyme\n// String methods\nlet upper = \"hello\".to_upper()          // \"HELLO\"\nlet words = \"a,b,c\".split(\",\")          // [\"a\", \"b\", \"c\"]\n\n// List methods\nlet doubled = [1, 2, 3].map(fn(n) { n * 2 })  // [2, 4, 6]\nlet evens = [1, 2, 3, 4].filter(fn(n) { n % 2 == 0 })  // [2, 4]\n\n// Map methods\nlet m = {name: \"Alice\", age: 30}\nassert(m.contains_key(\"name\"))\nm.set(\"city\", \"NYC\")\n\n// Int methods\nassert((-42).abs() == 42)\nassert(2.pow(10) == 1024)\n```\n\n**50 methods** across 6 types: Int (6), String (14), List (13), Map (8), Field (2), BigInt (7).\n\n**Static namespaces** provide type-level constants: `Int::MAX`, `Int::MIN`, `Field::ZERO`, `Field::ONE`, `Field::ORDER`, `BigInt::from_bits`.\n\n---\n\n## Status\n\n- 2,125+ unit tests + 158 integration tests\n- Cross-validated against snarkjs (independent constraint verification)\n- 2 ZK backends: R1CS/Groth16 + Plonkish/KZG-PlonK\n- Native in-process proof generation (no external tools)\n- snarkjs-compatible binary export\n- Solidity verifier contract generation\n- Poseidon hash compatible with circomlibjs\n- Runtime errors with source line numbers\n- [Documentation](https://docs.achrony.me)\n\n## License\n\nGPL-3.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachronyme%2Fachronyme","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fachronyme%2Fachronyme","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachronyme%2Fachronyme/lists"}