Skip to main content
Stoffel VM registers standard runtime builtins and MPC-focused module-style builtins. In normal application code, prefer StoffelLang method/operator syntax where available; this page names the VM functions those features lower to.

General runtime builtins

The standard library includes object, array/list, closure, local storage, formatting, assertion, and output helpers.
Builtin groupNames
Objects and arrayscreate_object, create_array, get_field, get_or_create_array_field, set_field, array_length, array_push, array_concat, array_repeat, array_equals
List-style aliasesappend, extend, copy, count, index, pop, remove, insert, clear, reverse, sort, delete, len, range
Closures/upvaluescreate_closure, call_closure, get_upvalue, set_upvalue
Runtime helpersprint, type, to_string, slice, contains, assert
Local storageLocalStorage.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:
StoffelLang also supports typed secret values and operators. Prefer this shape in app examples when the scalar type is known:
Method/function forms remain useful when you want to call a specific builtin directly:
Opening or revealing a share reconstructs a clear value. Do this only at the point where the program intentionally discloses a result.

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.
BuiltinPurpose
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.
Example:
CLI local execution:
Rust SDK local execution:

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

Use MpcOutput.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:
ModulePurpose
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.
Treat these as lower-level integration surfaces. Prefer checked examples in crates/stoffel-lang/examples/ before documenting production-facing patterns around them. Current AVSS helper names:

See also