Skip to main content
Use the Rust SDK when Stoffel is part of an application rather than a standalone CLI run. The app keeps ordinary product logic in Rust and moves the privacy-sensitive computation into StoffelLang. If you want a complete minimal project before reading the pattern, run the Rust SDK quickstart. It is the smallest app-shaped Rust example before the larger tutorial apps. The shape to aim for is:
A small app-shaped project usually has:
The tutorial repository uses this structure in the Rust SDK quickstart, Private Lottery, Private Matchmaking, and N-party Battleship tutorials.

Service boundary responsibilities

src/app.rs should own the SDK handoff:
  1. Receive normal Rust domain input.
  2. Validate public application shape, such as participant count or slot layout.
  3. Keep each client payload attached to a client slot.
  4. Compile src/main.stfl or load built .stflb bytecode.
  5. Configure local MPC settings such as parties, threshold, backend, and timeout.
  6. Attach private inputs with .with_client_input(slot, values).
  7. Build the runtime and validate client inputs.
  8. Run local MPC for the tutorial/dev smoke test.
  9. Decode the opened result into a Rust domain type.
  10. Keep ordinary policy decisions, persistence, display names, and routing in Rust when they do not need private computation.

Minimal pattern

This pattern is for local development. It runs several MPC nodes/processes locally on your machine. A deployed network uses the same program boundary but different server/client configuration.

Client payloads

Give each logical participant a Rust type that owns its private payload:
Then attach the payload at the service boundary:
Prefer one client slot per logical participant when the product has distinct participants. That keeps ownership clear and makes the privacy boundary easier to explain.

StoffelLang boundary

The Stoffel program should load only the private values it needs:
The host app can apply ordinary public policy afterward, such as yes_votes >= approvals_required.

Compile source or load bytecode

For development tutorials, compiling source keeps the example easy to read:
For application builds, use the CLI to build bytecode and load the artifact:
Generated bindings can carry program metadata into the Rust app. Regenerate or update them when the ClientStore input/output shape changes.

Verification loop

Use both Rust and Stoffel checks:
Then run the tutorial’s exact local MPC command. If the tutorial uses newer StoffelLang helpers than your installed CLI supports, use the CLI version named by the tutorial repository until those APIs are in the default installer.

Next steps