Native Functions
Achronyme provides 16 global functions: 14 built into the VM core, plus 2 from the standard library (achronyme-std). All are available as globals — no imports needed. Some are also available in circuit mode.
print(...values)
Section titled “print(...values)”Prints all arguments separated by spaces, followed by a newline. Returns nil.
print("hello", 42, true) // hello 42 trueMode: VM only
typeof(x)
Section titled “typeof(x)”Returns a string describing the type of the value: "Number", "String", "Bool", "Nil", "List", "Map", "Field", "BigInt256", "BigInt512", "Proof", "Function", "Native".
typeof(42) // "Number"typeof("hi") // "String"typeof(true) // "Bool"Mode: VM only
assert(condition)
Section titled “assert(condition)”Asserts that the condition is true. Returns nil on success, raises AssertionFailed on failure.
assert(1 + 1 == 2) // okassert(false) // error: AssertionFailedMode: Both (in circuits, emits 2 constraints: boolean enforcement + enforce = 1)
time()
Section titled “time()”Returns the current time as milliseconds since the Unix epoch.
let t = time()print(t) // 1740700800000Mode: VM only
gc_stats()
Section titled “gc_stats()”Returns a map with garbage collector statistics. See GC Statistics for details.
let stats = gc_stats()print(stats["collections"]) // number of GC cyclesprint(stats["bytes_freed"]) // cumulative bytes reclaimedprint(stats["peak_bytes"]) // maximum heap size reachedprint(stats["gc_time_ms"]) // cumulative ms spent in GCprint(stats["bytes_allocated"]) // current live heap sizeMode: VM only
Proof Inspection
Section titled “Proof Inspection”These functions extract components from a ProofObject returned by prove {}.
proof_json(proof)
Section titled “proof_json(proof)”Returns the Groth16 proof as a JSON string.
let p = prove { ... }print(proof_json(p)) // {"pi_a": [...], "pi_b": [...], ...}Mode: VM only
proof_public(proof)
Section titled “proof_public(proof)”Returns the public inputs as a JSON string.
print(proof_public(p)) // ["21888...", "17159..."]Mode: VM only
proof_vkey(proof)
Section titled “proof_vkey(proof)”Returns the verification key as a JSON string.
print(proof_vkey(p)) // {"protocol": "groth16", "curve": "bn128", ...}Mode: VM only
Cryptographic
Section titled “Cryptographic”poseidon(left, right)
Section titled “poseidon(left, right)”Computes the Poseidon 2-to-1 hash over BN254. Both arguments can be integers or field elements.
let h = poseidon(1, 2)print(h) // field elementMode: Both (in circuits, emits 361 constraints)
poseidon_many(a, b, ...)
Section titled “poseidon_many(a, b, ...)”Left-fold Poseidon hash: poseidon(poseidon(a, b), c) and so on. Requires at least 2 arguments.
let h = poseidon_many(1, 2, 3, 4)// equivalent to: poseidon(poseidon(poseidon(1, 2), 3), 4)Mode: Both (in circuits, emits 361 constraints per pair)
verify_proof(proof)
Section titled “verify_proof(proof)”Verifies a Groth16 proof. Returns true if valid, false otherwise. Requires a verify handler to be configured in the VM.
let p = prove { ... }let ok = verify_proof(p)print(ok) // trueMode: VM only
BigInt Constructors
Section titled “BigInt Constructors”bigint256(x)
Section titled “bigint256(x)”Constructs a 256-bit unsigned integer from an integer (>= 0) or string. Strings can use 0x (hex), 0b (binary), or decimal format.
let a = bigint256(42)let b = bigint256("0xFF")let c = bigint256("12345")Mode: VM only
bigint512(x)
Section titled “bigint512(x)”Constructs a 512-bit unsigned integer. Same argument formats as bigint256.
let a = bigint512(42)let b = bigint512("0xFF")Mode: VM only
from_bits(bits, width)
Section titled “from_bits(bits, width)”Constructs a BigInt from a list of 0/1 integers (LSB-first). Width must be 256 or 512.
let val = from_bits(bigint256(42).to_bits(), 256)assert(val == bigint256(42))Mode: VM only
Standard Library
Section titled “Standard Library”parse_int(str)
Section titled “parse_int(str)”Parses a string as an integer. Errors if the string is not a valid number.
parse_int("42") // 42parse_int("-7") // -7join(list, separator)
Section titled “join(list, separator)”Joins a list of strings with the given separator.
join(["a", "b", "c"], "-") // "a-b-c"join(["hello"], " ") // "hello"Summary Table
Section titled “Summary Table”| # | Function | Arity | Mode | Returns |
|---|---|---|---|---|
| 0 | print(...) | variadic | VM | nil |
| 1 | typeof(x) | 1 | VM | string |
| 2 | assert(x) | 1 | Both | nil |
| 3 | time() | 0 | VM | int |
| 4 | gc_stats() | 0 | VM | map |
| 5 | proof_json(p) | 1 | VM | string |
| 6 | proof_public(p) | 1 | VM | string |
| 7 | proof_vkey(p) | 1 | VM | string |
| 8 | poseidon(a, b) | 2 | Both | field |
| 9 | poseidon_many(...) | variadic | Both | field |
| 10 | verify_proof(p) | 1 | VM | bool |
| 11 | bigint256(x) | 1 | VM | BigInt256 |
| 12 | bigint512(x) | 1 | VM | BigInt512 |
| 13 | from_bits(bits, width) | 2 | VM | BigInt |
| Standard Library | ||||
| 14 | parse_int(str) | 1 | VM | int |
| 15 | join(list, sep) | 2 | VM | string |