Implementation Details
This page provides technical details about the HoneyBadger MPC protocol implementation in Stoffel, including message formats, state machines, and integration points.Architecture
Component Overview
HoneyBadger Engine
The core MPC engine (HoneyBadgerMpcEngine) manages:
- Secret share distribution
- Protocol message routing
- Beaver triple consumption
- Result reconstruction
Message Protocol
Wire Format
Messages are serialized usingbincode for efficient binary encoding:
NetEnvelope Wrapper
All network messages are wrapped in aNetEnvelope:
Message Flow
State Machines
Server State Machine
Client State Machine
Preprocessing Implementation
TripleGen Protocol
Beaver triple generation uses a specialized protocol with stricter requirements:- Random polynomial generation: Each party generates random degree-t polynomials
- Share exchange: Parties exchange evaluations at their indices
- Triple computation: Compute
c = a * busing Beaver’s protocol - Verification: Zero-knowledge proofs ensure correctness
Preprocessing Material
Secure Multiplication
Beaver Triple Protocol
When multiplying secret values[x] and [y]:
d and e are uniformly random (masked by a and b), revealing nothing about x or y.
Share Representation
Shamir Share Structure
Field Operations
All operations are performed in a finite field:Network Transport
QUIC Implementation
Connection Management
Synchronization Requirements
Critical Parameters
All servers in an MPC cluster must agree on:| Parameter | Description | Consequence of Mismatch |
|---|---|---|
instance_id | Unique computation identifier | Parties won’t recognize each other |
n_parties | Number of compute nodes | Protocol messages misrouted |
threshold | Byzantine fault tolerance | Security guarantees violated |
preprocessing_start_epoch | Unix timestamp for sync | Preprocessing fails |
Synchronization Protocol
FFI Exports
The MPC engine exports C-compatible functions for language bindings:Error Handling
Error Categories
Recovery Strategies
| Error | Recovery |
|---|---|
NetworkError | Retry with exponential backoff |
PreprocessingExhausted | Generate more triples, restart |
ProtocolViolation | Identify malicious party, exclude |
ThresholdExceeded | Cannot recover, abort computation |
Timeout | Increase timeout, check connectivity |
Performance Characteristics
Communication Complexity
| Operation | Messages | Rounds |
|---|---|---|
| Addition | 0 | 0 (local) |
| Multiplication | O(n) | 1 |
| Comparison | O(n log n) | O(log n) |
| Reconstruction | O(n) | 1 |
Latency Factors
- Network RTT: Dominates for small computations
- Triple generation: Pre-computed, amortized
- Reconstruction: Requires threshold+1 responses
- Computation: Linear in program complexity
Next Steps
- Protocol Overview: High-level protocol concepts
- Rust SDK API: Use these protocols in applications
- Solidity SDK: On-chain coordination