stoffellang crate in the stoffel repository. It uses Python-like indentation, def functions, var bindings, static type annotations, lists, objects, closures, and explicit MPC share APIs.
Prefer examples from crates/stoffel-lang/examples/, the generated project template, and the Rust SDK examples over older syntax outside the documented def/var/.stflb workflow. Use the runnable examples guide to choose examples by task.
Design goals
- Familiar Python-style control flow and indentation.
- Static types with inference for local development ergonomics, including
secret Tannotations for share-typed private values. - Direct compilation to portable
.stflbStoffel VM bytecode. - Explicit share-oriented MPC APIs such as
Share.*,ClientStore.*,Mpc.*, andMpcOutput.*, plus operator syntax for share arithmetic. - Host integration through the CLI and Rust SDK.
A minimal program
Variables and types
Usevar for local bindings. Type annotations are optional when the compiler can infer the type.
- signed integers:
int8,int16,int32,int64 - unsigned integers:
uint8,uint16,uint32,uint64 boolstringNone/ no-value returnsShareandsecret Ttypes such assecret int64for MPC secret shareslist[T]- object and closure values used by the VM runtime
secret keyword is part of type annotations. Use it on parameters, return types, local variables, list elements, and object fields when a value is represented as an MPC share:
secret before def or var; write var score: secret int64 = ..., not secret var score = ....
Functions
main, but most commands can select another entry function:
Control flow
Lists
MPC share APIs
StoffelLang models MPC values explicitly as share values. You can write those values with the genericShare type or with typed secret annotations such as secret int64, secret bool, or secret fix64. Use ClientStore to read client-provided shares, regular operators such as +, -, *, and / for arithmetic when they fit the value shape, and reveal(), Share.open(...), or MpcOutput.send_to_client where your program intentionally reconstructs or delivers a result.
ClientStore inputs
ClientStore exposes local or network client input slots to the program:
--client-input:
.with_client_input(0, &[42_i64]).
Runtime metadata
MPC programs can query runtime metadata and capabilities:Compilation outputs
The current bytecode extension is.stflb:
stoffel build writes project bytecode under target/debug or target/release depending on the selected profile.
Examples in the repository
Runnable examples live undercrates/stoffel-lang/examples/. Start with the examples guide when you want source-level patterns for clear StoffelLang, client-provided private inputs, share arithmetic, reusable MPC building blocks, or larger private workflows.