Rust SDK Overview
The Stoffel Rust SDK provides a high-level API for building Multi-Party Computation (MPC) applications in Rust. It bridges the StoffelLang compiler, StoffelVM execution engine, and HoneyBadger MPC protocol into a cohesive, developer-friendly interface.Design Philosophy
The SDK is built around three core principles:Progressive Disclosure
Three API levels for different needs:- Simple API: Quick compilation and local testing
- Builder Pattern: Full MPC configuration
- Advanced API: Direct access to network and protocol layers
MPC-First Design
Programs are configured for MPC during compilation, ensuring all participants use consistent parameters.Clean Abstractions
The SDK hides cryptographic complexity while providing clear semantics for secret and public data.MPCaaS Architecture
The SDK implements an MPC-as-a-Service (MPCaaS) architecture that separates app developers from infrastructure operators:StoffelClient (For App Developers)
StoffelServer (For Infrastructure Operators)
QUIC Networking
All network communication uses QUIC for:- TLS 1.3 encryption: Secure by default
- Stream multiplexing: Efficient message handling
- Low latency: 0-RTT connection establishment
- Connection migration: Handles network changes
Quick Start
Simple Local Execution
MPC Configuration
Creating MPC Participants
Core Components
Stoffel Builder
The entry point for all SDK operations:StoffelRuntime
After building, provides access to:Program
Pure bytecode container with execution methods:MPC Participants
Three participant types for different roles:| Type | Provides Inputs | Computes | Receives Outputs |
|---|---|---|---|
| MPCClient | ✓ | ✗ | ✓ |
| MPCServer | ✗ | ✓ | ✗ |
| MPCNode | ✓ | ✓ | ✓ |
MPC Configuration
Protocol Parameters
Validation Rules
The SDK automatically validates MPC parameters:- HoneyBadger: Requires
n >= 3t + 1wheren= parties,t= threshold - Minimum 4 parties with threshold 1
- Common configurations:
- 4 parties, threshold 1:
4 >= 4✓ - 5 parties, threshold 1:
5 >= 4✓ (recommended default) - 7 parties, threshold 2:
7 >= 7✓
- 4 parties, threshold 1:
Error Handling
The SDK provides comprehensive error types:CompilationError: StoffelLang syntax or semantic errorsRuntimeError: VM execution failuresMPCError: Protocol-level errorsConfiguration: Invalid parametersNetwork: Connection failuresIoError: File operations
Network Configuration
Programmatic Configuration
TOML Configuration
Next Steps
- Installation: Set up the Rust SDK
- API Reference: Complete API documentation
- Examples: Working code examples
- StoffelLang: Learn the computation language