Skip to main content
StoffelLang is the application language compiled by the 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 T annotations for share-typed private values.
  • Direct compilation to portable .stflb Stoffel VM bytecode.
  • Explicit share-oriented MPC APIs such as Share.*, ClientStore.*, Mpc.*, and MpcOutput.*, plus operator syntax for share arithmetic.
  • Host integration through the CLI and Rust SDK.

A minimal program

Compile and run it from a project or as a source file:

Variables and types

Use var for local bindings. Type annotations are optional when the compiler can infer the type.
Current primitive and runtime-facing types include:
  • signed integers: int8, int16, int32, int64
  • unsigned integers: uint8, uint16, uint32, uint64
  • bool
  • string
  • None / no-value returns
  • Share and secret T types such as secret int64 for MPC secret shares
  • list[T]
  • object and closure values used by the VM runtime
The 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:
Do not put secret before def or var; write var score: secret int64 = ..., not secret var score = ....

Functions

The CLI and SDK default to executing main, but most commands can select another entry function:

Control flow

Ranges and list iteration are supported:

Lists

MPC share APIs

StoffelLang models MPC values explicitly as share values. You can write those values with the generic Share 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.
Method-style calls are also available when you want to call a specific share builtin directly:
Boolean and fixed-point secret values use the same type-annotation pattern:

ClientStore inputs

ClientStore exposes local or network client input slots to the program:
When running locally through the CLI, provide client-slot inputs with --client-input:
With the Rust SDK, use .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 under crates/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.

Next steps