Skip to main content
This tutorial builds a small eligibility-score computation. The goal is to model one client value as a share, compute over that share, and reconstruct the derived score explicitly.
This is a small local example. Use the same modeling steps with your own deployment and security validation when moving beyond the tutorial.
Campaign-style Stoffel architecture diagram showing how a StoffelLang program becomes app-prepared inputs, a build contract, and networked MPC runtime execution.

What you will use

  • The stoffel CLI.
  • The Rust SDK from crates.io when you run or adapt the Rust wrapper path.
  • A Share-based StoffelLang program.
Finish Installation before starting.

Create a project

Check the generated program first:

Replace src/main.stfl

Use this simple Share-based program:
The program keeps the input as a Share while it computes, then opens only the final eligibility score as the allowed tutorial output.

Validate and build

Inspect the bytecode if needed:
If your project name produces a different bytecode file name, list 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 slot 0 with the private input value:
The returned value is (42 + 25) * 2, not the raw client input.

Iterate in watch mode

For scripts, add --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 from src/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:
Create src/lib.rs:
Create src/app.rs for the ordinary application types:
Create 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.
Create 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.
Create src/bin/eligibility_client.rs as a command-line entry point for the client-handling code:
Run the local MPC owner in one terminal:
Then run the client handler from another terminal:
The important separation is that ordinary app logic stays in Rust, client handling lives in its own module, and the Stoffel program owns the private computation. In this local tutorial, 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 Share values while computing.
  • Use open() only for outputs you intentionally reveal.
  • For client-directed share outputs beyond this tutorial, prefer MpcOutput.send_to_client or Share.send_to_client.
  • Use stoffel check --print-ir, stoffel run --program-info, and bytecode disassembly when debugging.

Next steps