Stoffel CLI Overview

The Stoffel CLI is a comprehensive command-line interface that provides everything you need to develop, build, test, and run privacy-preserving applications using secure Multi-Party Computation (MPC).

Design Philosophy

The Stoffel CLI is designed with the following principles:

  • Developer-Friendly: Intuitive commands that follow familiar patterns from tools like cargo and npm
  • Template-Driven: Project templates for different use cases and programming languages
  • Integrated Workflow: Seamless integration between development, compilation, and execution

Core Commands

Project Management

# Initialize new projects
stoffel init my-project                    # Default StoffelLang project
stoffel init my-project --template python  # Python SDK integration
stoffel init my-project --template rust    # Rust SDK integration
stoffel init my-project --lib              # Create a library project
stoffel init my-project --interactive      # Interactive project setup

Compilation

# Compile StoffelLang programs
stoffel compile                            # Compile all files in src/
stoffel compile src/main.stfl              # Compile specific file
stoffel compile --binary                   # Generate VM-compatible binaries (.stfb)
stoffel compile -O3                        # Maximum optimization (levels 0-3)
stoffel compile --disassemble program.stfb # Disassemble bytecode
stoffel compile --print-ir                 # Print intermediate representation

Building

# Build entire project
stoffel build                              # Debug build
stoffel build --release                    # Release build with optimizations
stoffel build -O2                          # Specific optimization level

Development

# Compile and run locally
stoffel dev                                # Default: 5 parties
stoffel dev --parties 7                    # Custom party count
stoffel dev --field bn254                  # Different cryptographic field

Execution

# Run compiled bytecode
stoffel run                                # Auto-discover in target/
stoffel run program.stfb                   # Run specific file
stoffel run --entry my_function            # Custom entry point

Testing

# Run project tests
stoffel test                               # Discover and run all tests
stoffel test --test specific_test          # Run specific test function
stoffel test --integration                 # Integration tests only
stoffel test --verbose                     # Detailed output

Available Templates

The CLI provides templates for different development scenarios:

Language-Specific Templates

TemplateDescriptionStatus
stoffelPure StoffelLang project (default)✅ Complete
pythonPython SDK integration with Poetry✅ Complete
rustRust SDK integration✅ Complete
typescriptTypeScript/Node.js integration⚠️ Skeleton (SDK pending)
solidity-foundrySolidity with Foundry framework✅ Complete
solidity-hardhatSolidity with Hardhat framework✅ Complete

Template Usage

stoffel init my-app                           # Default stoffel template
stoffel init my-app --template python         # Python project
stoffel init my-app --template rust           # Rust project
stoffel init my-app --template solidity-foundry  # Foundry project
stoffel init my-app --template solidity-hardhat  # Hardhat project

Project Structure

Pure StoffelLang Project

my-mpc-project/
├── Stoffel.toml              # Project configuration
├── src/                      # StoffelLang source files
│   └── main.stfl            # Main program entry point
├── tests/                   # Test files
│   └── integration.stfl     # Integration tests
└── README.md               # Project documentation

Python Template Structure

my-python-project/
├── pyproject.toml           # Poetry configuration
├── src/
│   └── my_python_project/
│       └── main.py         # Python entry point
├── stoffel/                 # Nested Stoffel project
│   ├── Stoffel.toml
│   └── src/
│       └── program.stfl    # StoffelLang program
├── tests/
│   └── test_main.py        # Python tests
└── README.md

Rust Template Structure

my-rust-project/
├── Cargo.toml               # Rust project config
├── src/
│   └── main.rs             # Rust entry point with SDK
├── stoffel/                 # Nested Stoffel project
│   ├── Stoffel.toml
│   └── src/
│       └── program.stfl    # StoffelLang program
└── README.md

Solidity Template Structure (Foundry)

my-solidity-project/
├── foundry.toml             # Foundry configuration
├── src/
│   └── MyMPCApp.sol        # Main contract
├── test/
│   └── MyMPCApp.t.sol      # Foundry tests
├── script/
│   └── Deploy.s.sol        # Deployment script
├── stoffel/                 # Nested Stoffel project
│   ├── Stoffel.toml
│   └── src/
│       └── program.stfl
└── README.md

Configuration

Stoffel.toml

The main configuration file for Stoffel projects:

[package]
name = "my-secure-app"
version = "0.1.0"
authors = ["Your Name <you@example.com>"]

[mpc]
protocol = "honeybadger"
parties = 5
threshold = 1
field = "bls12-381"

[build]
optimization_level = 2
output_dir = "target"

MPC Configuration

The CLI supports configurable MPC parameters:

  • Parties: Number of parties in the MPC computation (minimum 4 for HoneyBadger)
  • Threshold: Maximum number of corrupted parties tolerated
  • Constraint: parties >= 3 * threshold + 1
  • Cryptographic Fields: BLS12-381 (default), BN254, Secp256k1, Prime61

Valid Configurations

PartiesThresholdValid?
41✅ (4 >= 4)
51✅ (5 >= 4) - default
72✅ (7 >= 7)
31❌ (3 < 4)

Help System

The CLI provides comprehensive help for all commands:

stoffel --help                    # Main help
stoffel init --help               # Command-specific help
stoffel compile --help            # Compilation options
stoffel test --help               # Testing options

Command Status

Implemented Commands

CommandDescription
initProject initialization with templates
compileStoffelLang compilation
buildBuild entire project
devDevelopment mode (compile + run)
runExecute compiled bytecode
testTest discovery and execution

Planned Commands

CommandDescription
deployDeployment to MPC networks
addPackage dependency management
updateUpdate dependencies
publishPublish packages to registry
cleanRemove build artifacts

Examples

Quick Start

# Create and run a simple MPC project
stoffel init hello-mpc
cd hello-mpc
stoffel dev

Rust SDK Integration

# Create Rust project with SDK
stoffel init secure-compute --template rust
cd secure-compute
cargo build
cargo run

Solidity Integration

# Create Solidity project with Foundry
stoffel init my-contract --template solidity-foundry
cd my-contract
forge build
forge test

Next Steps