Skip to content

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.

Prints all arguments separated by spaces, followed by a newline. Returns nil.

print("hello", 42, true) // hello 42 true

Mode: VM only

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

Asserts that the condition is true. Returns nil on success, raises AssertionFailed on failure.

assert(1 + 1 == 2) // ok
assert(false) // error: AssertionFailed

Mode: Both (in circuits, emits 2 constraints: boolean enforcement + enforce = 1)

Returns the current time as milliseconds since the Unix epoch.

let t = time()
print(t) // 1740700800000

Mode: VM only

Returns a map with garbage collector statistics. See GC Statistics for details.

let stats = gc_stats()
print(stats["collections"]) // number of GC cycles
print(stats["bytes_freed"]) // cumulative bytes reclaimed
print(stats["peak_bytes"]) // maximum heap size reached
print(stats["gc_time_ms"]) // cumulative ms spent in GC
print(stats["bytes_allocated"]) // current live heap size

Mode: VM only

These functions extract components from a ProofObject returned by prove {}.

Returns the Groth16 proof as a JSON string.

let p = prove { ... }
print(proof_json(p)) // {"pi_a": [...], "pi_b": [...], ...}

Mode: VM only

Returns the public inputs as a JSON string.

print(proof_public(p)) // ["21888...", "17159..."]

Mode: VM only

Returns the verification key as a JSON string.

print(proof_vkey(p)) // {"protocol": "groth16", "curve": "bn128", ...}

Mode: VM only

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 element

Mode: Both (in circuits, emits 361 constraints)

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)

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) // true

Mode: VM only

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

Constructs a 512-bit unsigned integer. Same argument formats as bigint256.

let a = bigint512(42)
let b = bigint512("0xFF")

Mode: VM only

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

Parses a string as an integer. Errors if the string is not a valid number.

parse_int("42") // 42
parse_int("-7") // -7

Joins a list of strings with the given separator.

join(["a", "b", "c"], "-") // "a-b-c"
join(["hello"], " ") // "hello"
#FunctionArityModeReturns
0print(...)variadicVMnil
1typeof(x)1VMstring
2assert(x)1Bothnil
3time()0VMint
4gc_stats()0VMmap
5proof_json(p)1VMstring
6proof_public(p)1VMstring
7proof_vkey(p)1VMstring
8poseidon(a, b)2Bothfield
9poseidon_many(...)variadicBothfield
10verify_proof(p)1VMbool
11bigint256(x)1VMBigInt256
12bigint512(x)1VMBigInt512
13from_bits(bits, width)2VMBigInt
Standard Library
14parse_int(str)1VMint
15join(list, sep)2VMstring