What this teaches
A lottery is a small version of a common product shape:Privacy boundary
The private computation can reveal the winner without giving the provider a board it can rerun, tune, export, or use to rank non-winners.
Code map
normal/lottery.rs: see what the trusted server can see and control.private/lottery.rs: see the authorized output model.src/client.rs: see each participant’s private eligibility payload.src/app.rs: see the Rust service compile, attach inputs, run local MPC, and map the winner index back to a participant.src/main.stfl: see private ticket generation, private comparison, private selection, and the single reveal.
Run it
From the tutorial repository root:What not to copy
Do not turn this into a global rule that every app should use lotteries or randomness. Copy the boundary pattern:- The product needs one opened decision.
- The private inputs and intermediate trace are not useful product surfaces.
- The app names the recipient of the opened result.
- Everything else stays inside the private computation.