round_based/lib.rs
1//! 
2//! [](https://docs.rs/round-based)
3//! [](https://crates.io/crates/round-based)
4//! [](https://discordapp.com/channels/905194001349627914/1285268686147424388)
5//!
6//! An MPC framework that unifies and simplifies the way of developing and working with
7//! multiparty protocols (e.g. threshold signing, random beacons, etc.).
8//!
9//! ## Goals
10//!
11//! * Async friendly \
12//! Async is the most simple and efficient way of doing networking in Rust
13//! * Simple, configurable \
14//! Protocol can be carried out in a few lines of code: check out examples.
15//! * Independent of networking layer \
16//! We use abstractions [`Stream`] and [`Sink`] to receive and send messages.
17//!
18//! ## Networking
19//!
20//! In order to run an MPC protocol, transport layer needs to be defined. All you have to do is to
21//! implement [`Delivery`] trait which is basically a stream and a sink for receiving and sending messages.
22//!
23//! Message delivery should meet certain criterias that differ from protocol to protocol (refer to
24//! the documentation of the protocol you're using), but usually they are:
25//!
26//! * Messages should be authenticated \
27//! Each message should be signed with identity key of the sender. This implies having Public Key
28//! Infrastructure.
29//! * P2P messages should be encrypted \
30//! Only recipient should be able to learn the content of p2p message
31//! * Broadcast channel should be reliable \
32//! Some protocols may require broadcast channel to be reliable. Simply saying, when party receives a
33//! broadcast message over reliable channel it should be ensured that everybody else received the same
34//! message.
35//!
36//! ## Features
37//!
38//! * `sim` enables protocol execution simulation, see [`sim`] module
39//! * `sim-async` enables protocol execution simulation with tokio runtime, see [`sim::async_env`]
40//! module
41//! * `state-machine` provides ability to carry out the protocol, defined as async function, via Sync
42//! API, see [`state_machine`] module
43//! * `derive` is needed to use [`ProtocolMessage`](macro@ProtocolMessage) proc macro
44//! * `runtime-tokio` enables [tokio]-specific implementation of [async runtime](runtime)
45//!
46//! ## Join us in Discord!
47//! Feel free to reach out to us [in Discord](https://discordapp.com/channels/905194001349627914/1285268686147424388)!
48
49#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg, doc_cfg_hide))]
50#![forbid(unused_crate_dependencies, missing_docs)]
51#![no_std]
52
53extern crate alloc;
54
55#[doc(no_inline)]
56pub use futures_util::{Sink, SinkExt, Stream, StreamExt};
57
58/// Fixes false-positive of `unused_crate_dependencies` lint that only occur in the tests
59#[cfg(test)]
60mod false_positives {
61 use anyhow as _;
62 use futures as _;
63 use trybuild as _;
64
65 use {hex as _, rand as _, rand_dev as _};
66}
67
68mod delivery;
69pub mod party;
70pub mod rounds_router;
71pub mod runtime;
72#[cfg(feature = "state-machine")]
73pub mod state_machine;
74
75#[cfg(feature = "sim")]
76pub mod sim;
77
78pub use self::delivery::*;
79#[doc(no_inline)]
80pub use self::{
81 party::{Mpc, MpcParty},
82 rounds_router::{ProtocolMessage, RoundMessage},
83};
84
85#[doc(hidden)]
86pub mod _docs;
87
88/// Derives [`ProtocolMessage`] and [`RoundMessage`] traits
89///
90/// See [`ProtocolMessage`] docs for more details
91#[cfg(feature = "derive")]
92pub use round_based_derive::ProtocolMessage;