Helix is a framework for Multi-Party Computation (MPC) that provides a domain-specific language (DSL) for writing secure computation programs. The DSL compiles through multiple intermediate representations (IR) to gate-level circuits that can be executed by various MPC backends.
- DSL for MPC: Write secure computation programs in a high-level language
- Type System: Static type checking with support for public and secret values
- Two-Level IR: High-Level IR (HIR) for optimizations and Low-Level IR (LIR) for backend compilation
- Virtual Machine: Minimal instruction set for gate-level operations
- Backend Abstraction: Pluggable backends (currently includes a clear/non-cryptographic backend)
- Compiler Toolchain: Full compilation pipeline from source to executable circuits
helix/
├── crates/
│ ├── frontend/ # Parser, AST, type checker, and HIR codegen
│ ├── ir/ # HIR, LIR, and lowering passes
│ ├── backend/ # VM, backends, compiler, and executor
│ ├── common/ # Shared utilities
│ └── crypto/ # Cryptographic primitives (future)
├── bin/
│ └── compiler/ # Helix compiler CLI (helixc)
└── tests/
└── samples/ # Example MPC programs
- Rust 1.70+ (edition 2021)
- Cargo
# Clone the repository
git clone https://github.com/pop-eax/helix.git
cd helix
# Build the project
cargo build
# Build in release mode
cargo build --release# Or use directly
cargo run --bin helixc -- --helpCreate a file hello.mpc:
// Simple addition function
fn add(Public Field<64> a, Public Field<64> b) -> Field<64> {
return a + b;
}# Compile to IR
cargo run --bin helixc -- compile hello.mpc
# View AST
cargo run --bin helixc -- ast hello.mpc
# View HIR
cargo run --bin helixc -- hir hello.mpc
# View LIR
cargo run --bin helixc -- lir hello.mpc
# Compile to VM instructions
cargo run --bin helixc -- vm hello.mpc
# Execute with inputs
cargo run --bin helixc -- execute hello.mpc --inputs "5,10"- Field: Finite field element with N-bit size (e.g.,
Field<64>) - Visibility Modifiers:
Public: Value is known to all partiesSecret: Value is secret-shared or encrypted
fn function_name(Visibility Type param1, Visibility Type param2) -> ReturnType {
// function body
return expression;
}- Variable Declaration:
let Visibility Type name = expression; - Assignment:
lvalue = expression; - Return:
return expression; - Conditional:
if (condition) { ... } else { ... } - Loops:
for (let Visibility Type name = start; name < end; name = name + 1) { ... }
- Arithmetic:
+,-,*,/,% - Comparison:
==,!=,<,<=,>,>= - Boolean:
&&,||,! - Function Calls:
function_name(arg1, arg2)
fn add(Public Field<64> a, Public Field<64> b) -> Field<64> {
return a + b;
}fn multiply(Public Field<64> x, Secret Field<64> y) -> Field<64> {
return x * y;
}fn max(Public Field<64> a, Public Field<64> b) -> Field<64> {
if (a > b) {
return a;
} else {
return b;
}
}struct Point {
Public Field<64> x;
Public Field<64> y;
}
fn create_point(Public Field<64> x, Public Field<64> y) -> Point {
return Point { x: x, y: y };
}The helixc compiler provides several commands:
Compile MPC source file to IR (binary format)
helixc compile input.mpc [-o output.ir]Compile MPC source file to VM instructions (JSON format)
helixc vm input.mpc [-o output.vm.json]Execute MPC program with given inputs
helixc execute input.mpc --inputs "5,10,15"Display the Abstract Syntax Tree (JSON format)
helixc ast input.mpcDisplay the High-Level Intermediate Representation
helixc hir input.mpcDisplay the Low-Level Intermediate Representation
helixc lir input.mpcShow all intermediate representations (AST, HIR, LIR)
helixc debug input.mpcSource Code (.mpc)
↓
[Parser] → AST
↓
[Type Checker] → Validated AST
↓
[Codegen] → HIR (High-Level IR)
↓
[Lowering] → LIR (Low-Level IR)
↓
[VM Compiler] → VM Instructions
↓
[Backend] → Execution
- Parser: Pest-based parser for the MPC DSL
- AST: Abstract Syntax Tree representation
- Type Checker: Static type checking with visibility analysis
- Codegen: AST to HIR translation
- HIR: High-Level IR with SSA-like value representation and basic blocks
- LIR: Low-Level IR with gate-level circuit representation
- Lowering: HIR to LIR conversion pass
- VM: Virtual machine with minimal instruction set
- Clear Backend: Non-cryptographic backend for testing and debugging
- Compiler: LIR to VM instructions compilation
- Executor: Generic executor for running VM instructions
The VM provides a minimal set of gate instructions:
Boolean Gates:
And,Xor,Not(OR can be derived from these)
Arithmetic Gates:
Add,Mul,Sub,Div,Mod
Constants:
Constant { value, field_size }
Each instruction includes visibility information for MPC backends.
# Run all tests
cargo test
# Run tests for a specific crate
cargo test -p frontend
cargo test -p ir
cargo test -p backend
# Run integration tests
cargo test --test integration_testSample programs are located in tests/samples/:
add.mpc- Simple additionmultiply.mpc- Multiplication with secret inputarithmetic.mpc- Complex arithmetic operationscomparison.mpc- Comparison operationsconditional.mpc- Conditional logicloop.mpc- Loop constructsstruct.mpc- Struct definitions and usage
Party assignment is handled by the VM/executor at runtime, not during compilation. This allows:
- The same circuit to be executed with different party configurations
- Backend-agnostic LIR representation
- Flexible MPC protocol implementations
- HIR: Optimized for high-level transformations and optimizations
- LIR: Optimized for backend compilation and gate-level operations
Visibility (Public/Secret) is part of the type system, enabling:
- Static analysis of information flow
- Type checking for MPC correctness
- Clear separation between public and secret values
- Yao's Garbled Circuits backend
- BGW (Ben-Or, Goldwasser, Wigderson) arithmetic secret sharing backend
- More optimization passes (constant folding, dead code elimination, etc.)
- Array operations
- More complex control flow optimizations
- Cryptographic primitives integration
- Network protocol for distributed execution
MIT