Expand description
Reference Rust SDK for building Stoffel MPC applications.
The SDK provides a small public entry point, Stoffel, for compiling
Stoffel-Lang programs, loading bytecode, configuring MPC runtime settings,
executing local development programs, and constructing client/server
participants.
use stoffel::prelude::*;
let result = Stoffel::compile(
"def main(a: int64, b: int64) -> int64:\n return a + b",
)?
.with_inputs(&[("a", 42_i64), ("b", 58_i64)])
.execute_clear()?;
assert_eq!(result[0].as_i64(), Some(100));Local MPC development uses the same builder, but delegates to
stoffel-vm’s real localhost coordinator runner and a built stoffel-run
binary instead of simulating the protocol in the SDK:
use stoffel::prelude::*;
let result = Stoffel::compile(
"def main() -> int64:\n var share = ClientStore.take_share(0, 0)\n return share.open()",
)?
.parties(5)
.threshold(1)
.with_client_input(0, &[42_i64])
.execute_local()
.await?;
assert_eq!(result[0].as_i64(), Some(42));Re-exports§
pub use backend::avss::AvssBackend;pub use backend::avss::AvssEngine;pub use backend::honeybadger::HoneyBadgerBackend;pub use backend::Backend;pub use backend::MpcBackend;pub use client::ClientBuilder;pub use client::ClientState;pub use client::ClientSummary;pub use client::ComputationHandle;pub use client::ComputationStatus;pub use client::ComputationSummary;pub use client::OffChainClientConfig;pub use client::OffChainClientConfigBuilder;pub use client::StoffelClient;pub use compiler::CompilationOptions;pub use config::Curve;pub use config::MpcConfig;pub use config::MpcConfigBuilder;pub use config::MpcConfigSummary;pub use config::MpcSection;pub use config::NetworkConfig;pub use config::NetworkConfigBuilder;pub use config::NetworkConfigSummary;pub use config::NetworkDeployment;pub use config::NetworkDeploymentBuilder;pub use config::NetworkSection;pub use config::PreprocessingConfig;pub use coordinator::OffChainCoordinator;pub use error::Error;pub use error::ErrorCategory;pub use error::Result;pub use input_file::load_client_inputs_file;pub use input_file::load_named_inputs_file;pub use observability::init_tracing;pub use observability::HealthStatus;pub use observability::OpenTelemetryGuard;pub use observability::ServerMetrics;pub use observability::ServerMetricsSnapshot;pub use observability::TracingConfig;pub use observability::TracingConfigBuilder;pub use observability::TracingConfigSummary;pub use program::BytecodeSummary;pub use program::ClientMetadata;pub use program::ClientMetadataSummary;pub use program::FunctionMetadata;pub use program::FunctionSummary;pub use program::Program;pub use program::ProgramSummary;pub use runtime::LocalNetworkBuilder;pub use runtime::RuntimeSummary;pub use runtime::StoffelRuntime;pub use server::OffChainServerConfig;pub use server::OffChainServerConfigBuilder;pub use server::ServerBuilder;pub use server::ServerState;pub use server::ServerSummary;pub use server::StoffelServer;pub use types::ClientId;pub use types::ClientInputValue;pub use types::ClientOutputValue;pub use types::ClientValueType;pub use types::FieldElement;pub use types::GeneratedProgramManifest;pub use types::GroupElement;pub use types::MaskIndex;pub use types::PartyId;pub use types::ProgramArgs;pub use types::PublicKey;pub use types::Round;pub use types::TypedClientInputs;pub use types::TypedClientOutputs;pub use types::Value;pub use types::ValueSummary;pub use vm::LocalClientOutput;
Modules§
- backend
- MPC backend selection and identity helpers.
- client
- Client-side builders and computation handles.
- compiler
- Stoffel-Lang compilation and bytecode loading helpers.
- config
- MPC and network configuration types.
- consensus
- Consensus types are owned by
stoffel-networking. - coordinator
- Coordinator surfaces and re-exports.
- docs
- Documentation model for Stoffel-Lang
"""docstrings"""(unstable). - error
- SDK error types and recovery metadata.
- input_
file - Helpers for loading SDK inputs from small data files.
- networking
- Networking re-exports from
stoffel-networking. - observability
- Observability helpers for tracing, health, and metrics.
- prelude
- Common imports for applications embedding the Stoffel Rust SDK.
- program
- Compiled program metadata and bytecode helpers.
- runtime
- Built runtime for a compiled or loaded Stoffel program.
- server
- Server-side builder, state, health, and metrics access.
- types
- Common SDK value and identifier types.
- vm
- StoffelVM execution integration.
Structs§
- Node
Public Key - Represents a node’s public key (DER-encoded SubjectPublicKeyInfo). Used for deterministic sender_id computation across all participants.
- OffChain
Coordinator Client - OffChain
Coordinator Server - The exterior wrapper of the server-side coordinator.
- Quic
Network Config - Configuration for the QUIC network manager.
- Quic
Network Manager - Stoffel
- SDK entry point and builder.
- Verified
Ordering - Verified canonical ordering of nodes and clients after consensus.
Enums§
- Consensus
Error - Error type for consensus protocol failures.
- Consensus
Gate - Drives the transparent gating of send/broadcast/send_to_client.
- Coordinator
Error - Function
Type - Network
Error - Error type for network related issues.
- Share
Type - Enum to represent the underlying type of a secret share
Traits§
- Coordinator
- Loadable
Program - Inputs accepted by
Stoffel::load_program. - Network
Manager - Share
Bound