General runtime builtins
The standard library includes object, array/list, closure, local storage, formatting, assertion, and output helpers.| Builtin group | Names |
|---|---|
| Objects and arrays | create_object, create_array, get_field, get_or_create_array_field, set_field, array_length, array_push, array_concat, array_repeat, array_equals |
| List-style aliases | append, extend, copy, count, index, pop, remove, insert, clear, reverse, sort, delete, len, range |
| Closures/upvalues | create_closure, call_closure, get_upvalue, set_upvalue |
| Runtime helpers | print, type, to_string, slice, contains, assert |
| Local storage | LocalStorage.store, LocalStorage.load, LocalStorage.retrieve, LocalStorage.delete, LocalStorage.exists |
print is variadic: it formats arguments, joins them with spaces, and writes one line through the VM’s configured output sink.
In StoffelLang, prefer method syntax where the language exposes it:
Share builtins
Share values represent MPC secret shares. The VM exposes these canonical share operations:
Batch operations
Use batch operations when a program naturally computes or returns several shares.Share.batch_mul is the VM builtin for batched share multiplication; use it when the algorithm already has aligned share arrays and should consume MPC multiplication material in batch form.
ClientStore builtins
ClientStore bridges external client input material into a Stoffel program. VM-level client slots are ordinal positions in the configured/sorted client roster, not necessarily raw network client IDs.
| Builtin | Purpose |
|---|---|
ClientStore.get_number_clients() | Total known client slots. |
ClientStore.get_number_input_clients() | Number of clients with input material. |
ClientStore.get_number_output_clients() | Number of output-capable client slots. |
ClientStore.take_share(client_slot, input_index) | Load a default integer share from a client slot. |
ClientStore.take_share_bool(client_slot, input_index) | Load a one-bit boolean share from a client slot. |
ClientStore.take_share_fixed(client_slot, input_index) | Load a fixed-point share from a client slot. |
Mpc builtins
Mpc exposes runtime metadata, readiness, capabilities, and public randomness helpers.
Mpc.rand and Mpc.rand_int produce local public randomness. For jointly generated secret-shared randomness, use Share.random or Share.random_int.
Capability names include:
Mpc.has_capability(...) accepts common aliases such as mul, rbc, open-exp, and preproc-store.
Example:
MpcOutput builtins
UseMpcOutput.send_to_client when a program should deliver share outputs to client slots through the coordinator/output path.
It accepts a client slot and either a single share or a non-empty homogeneous array/list of shares:
Share.send_to_client(client_slot) is also available for single-share output flows.
Lower-level protocol helper modules
The VM also registers module-style helpers used by advanced protocol and cryptographic examples:| Module | Purpose |
|---|---|
Bytes.* | Byte-array construction, concatenation, conversion, slicing, and length helpers. |
Crypto.* | Hashing and signature-related helper functions used by protocol examples. |
Field.* | Field-oriented helper functions. |
Rbc.* | Reliable broadcast helpers. |
Avss.* | AVSS share inspection helpers for commitments and key names. See AVSS. |
crates/stoffel-lang/examples/ before documenting production-facing patterns around them.
Current AVSS helper names: