polytune/lib.rs
1//! A Rust implementation of secure multi-party computation (MPC) based on the paper [Global-Scale
2//! Secure Multiparty Computation](https://dl.acm.org/doi/pdf/10.1145/3133956.3133979).
3//!
4//! This crate provides tools and protocols for performing secure computations across multiple
5//! parties without revealing private inputs to other participants. The implementation uses garbled
6//! circuits and other cryptographic primitives to ensure security.
7//!
8//! ## Features
9//!
10//! - Garbled circuit-based secure multi-party computation
11//! - Support for both trusted dealer and untrusted preprocessing
12//! - Efficient communication channels for distributed computation
13//! - Boolean circuit evaluation with privacy guarantees
14//!
15//! ## Main Components
16//!
17//! The crate is structured into several modules:
18//!
19//! * Top-level [`polytune`](`crate`): Contains the [`mpc`] function that executes the protocol for a party.
20//! * [`channel`]: Communication abstractions for exchanging data between parties.
21//!
22//! ## Basic Usage
23//!
24//! To run an MPC computation, each participating party needs to:
25//!
26//! 1. Set up communication channels with other parties
27//! 2. Create or load a circuit definition
28//! 3. Prepare private inputs
29//! 4. Call the [`mpc`] function with appropriate parameters
30//! 5. Process the resulting outputs
31//!
32//! ## Example
33//!
34//! ```ignore
35//! use polytune::{
36//! channel::SimpleChannel,
37//! garble_lang::circuit::Circuit,
38//! mpc,
39//! };
40//!
41//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
42//! // Set up a simple channel for communication
43//! let channel= /* ... */
44//!
45//! // Load or define a circuit
46//! let circuit = /* ... */
47//!
48//! // Define party roles and inputs
49//! let my_inputs = vec![true, false, true];
50//! let p_eval = 0; // Party 0 is the evaluator
51//! let p_own = 1; // This code is running as party 1
52//! let p_out = vec![0, 1]; // Parties 0 and 1 receive the output
53//!
54//! // Execute the MPC protocol
55//! let result = mpc(
56//! &channel,
57//! &circuit,
58//! &my_inputs,
59//! p_eval,
60//! p_own,
61//! &p_out,
62//! ).await?;
63//!
64//! println!("Computation result: {:?}", result);
65//! # Ok(())
66//! # }
67//! ```
68//!
69//! ## Security Properties
70//!
71//! This implementation provides security against malicious adversaries. The protocol ensures that
72//! no party learns anything beyond what can be inferred from their own inputs and the output of the
73//! computation.
74#![deny(missing_docs)]
75#![deny(rustdoc::broken_intra_doc_links)]
76#![deny(clippy::undocumented_unsafe_blocks)]
77
78pub use garble_lang;
79pub use mpc::protocol::{Error, MpcError, mpc};
80
81#[cfg(feature = "__bench")]
82#[doc(hidden)]
83pub mod bench_reexports;
84mod block;
85pub mod channel;
86mod ot;
87mod ot_core;
88mod transpose;
89// TODO remove this once OT implementations are refactored and we know
90// what parts we need and which not
91mod crypto;
92mod mpc;
93#[allow(dead_code)]
94mod utils;