This is a small local example. Use the same modeling steps with your own deployment and security validation when moving beyond the tutorial.

What you will use
- The
stoffelCLI. - The Rust SDK from crates.io when you run or adapt the Rust wrapper path.
- A
Share-based StoffelLang program.
Create a project
Replace src/main.stfl
Use this simple Share-based program:
Share while it computes, then opens only the final eligibility score as the allowed tutorial output.
Validate and build
target/debug and use that path.
Run locally with a client input
Run the project through local MPC. This starts several MPC nodes/processes locally on your machine and feeds client slot0 with the private input value:
(42 + 25) * 2, not the raw client input.
Iterate in watch mode
--once.
Run the same idea from Rust
The Rust SDK is the primary application API for embedding Stoffel programs in Rust apps. Use the bytecode you already built fromsrc/main.stfl instead of embedding a second sample program in Rust. In this example, .execute_local().await? performs local MPC testing by spawning several MPC nodes/processes on your machine:
Shape it like an app integration
A larger app usually separates the code that owns the MPC network from the code that handles user/client requests. MPC nodes run away from input and output clients; the client-facing app identifies the private portion of a request and hands that portion to the Stoffel-backed workflow. For this tutorial, keep everything on your development machine but split the project like an app would be split:src/lib.rs:
src/app.rs for the ordinary application types:
src/bin/main.rs. This is the local development network owner: it loads the bytecode built from src/main.stfl, waits for client requests, and runs each private score through local MPC. Stop it with Ctrl-C when you are done.
src/client.rs. This file is the client-handling boundary: it accepts an application request, sends only the private score to the local MPC side, then combines the returned score with ordinary app fields.
src/bin/eligibility_client.rs as a command-line entry point for the client-handling code:
main.rs starts local MPC nodes on the same development machine. In a deployed setup, that network would run elsewhere, and the client-handling side would connect to it instead of using this local file-based handoff.
Want to deploy MPC apps instead of running local development networks? Sign up for Stoffel updates to hear when we launch the platform for deploying MPC apps.
Design notes
- Identify which input is secret-shared, which policy logic is public, and which computed result should be reconstructed.
- Keep sensitive values as
Sharevalues while computing. - Use
open()only for outputs you intentionally reveal. - For client-directed share outputs beyond this tutorial, prefer
MpcOutput.send_to_clientorShare.send_to_client. - Use
stoffel check --print-ir,stoffel run --program-info, and bytecode disassembly when debugging.