Skip to main content

de_mls/
lib.rs

1//! # DE-MLS: Decentralized MLS Chat Protocol
2//!
3//! A library for building decentralized, end-to-end encrypted chat applications
4//! using the MLS (Messaging Layer Security) protocol with consensus-based membership management.
5//!
6//! ## Modules
7//!
8//! - **[`conversation`]** - The [`Conversation`] handle plus its
9//!   per-conversation state, state machine, and inbound dispatch
10//! - **[`consensus`]** - Consensus plug-in contract, outcome application, and voting
11//! - **[`peer_scoring`]** / **[`steward_list`]** / **[`freeze`]** - Protocol plug-ins
12//! - **[`mls_crypto`]** - MLS cryptographic operations (OpenMLS wrapper)
13//! - **[`protos`]** - Protobuf message definitions
14//!
15//! The library carries no transport. The reference delivery service (the
16//! `DeliveryService` trait + Waku implementation) lives in the `de-mls-ds`
17//! crate, and the reference integrator (`User`) in `de-mls-gateway`.
18//!
19//! ## Getting Started
20//!
21//! The library exposes the per-conversation [`Conversation`]
22//! handle. It carries no transport: it buffers outbound and consumes inbound
23//! payloads, and the integrator owns routing. A ready-to-use reference
24//! integrator (the multi-conversation `User` with registry + routing +
25//! lifecycle over a transport) lives in the `de-mls-gateway` crate.
26//!
27//! Integrators drain [`ConversationEvent`] from each conversation (for
28//! transport and UI delivery), feed inbound packets to the conversation, and
29//! dispatch the returned outcomes.
30//!
31//! ## Quick Example
32//!
33//! ```ignore
34//! use de_mls::Conversation;
35//!
36//! // Build a conversation from direct arguments: the OpenMLS provider,
37//! // credential + ciphersuite, the plug-in instances, and a consensus service.
38//! let mut conversation = Conversation::create(
39//!     "de-mls-test", provider, credential, ciphersuite, &signer,
40//!     scoring, steward, consensus, app_id, config, member_id,
41//! )?;
42//!
43//! // Send a chat message — buffered, never auto-sent.
44//! conversation.send_message(b"Hello, world!".to_vec(), &signer)?;
45//!
46//! // Drain outbound and publish it on your own transport.
47//! for out in conversation.drain_outbound() { /* publish */ }
48//! ```
49
50/// The [`Conversation`](conversation) handle, per-conversation
51/// state, state machine, and inbound dispatch.
52pub mod conversation;
53
54/// Consensus plug-in contract, outcome application, and voting.
55pub mod consensus;
56
57/// Peer-scoring plug-in: vocabulary, traits, and reference service.
58pub mod peer_scoring;
59
60/// Steward-list plug-in: deterministic roster and rotation queries.
61pub mod steward_list;
62
63/// Freeze round candidate processing, selection, and commit application.
64pub mod freeze;
65
66/// Conversation-event types produced for the integrator.
67pub mod events;
68
69/// [`ProcessResult`](process_result::ProcessResult) returned by inbound processing.
70pub mod process_result;
71
72/// Proposal classification.
73pub mod proposal_kind;
74
75/// Wall-clock anchor combined with the conversation state machine.
76pub mod phase_timer;
77
78/// Library error types.
79pub mod error;
80
81// Crate-root re-exports so flat-name imports resolve without the owning
82// module path.
83pub use conversation::*;
84pub use error::*;
85pub use events::*;
86pub use freeze::*;
87pub use peer_scoring::*;
88pub use process_result::*;
89pub use proposal_kind::*;
90pub use steward_list::*;
91
92// `consensus` and `phase_timer` are re-exported explicitly below to avoid glob
93// collisions with the conversation glob.
94pub use consensus::{
95    ConsensusApplyResult, ConsensusPlugin, ConsensusServiceFor, CreatorVote, SyncConsensusReceiver,
96    apply_consensus_result,
97};
98
99pub(crate) use phase_timer::PhaseTimer;
100
101/// MLS cryptographic operations: OpenMLS wrapper for encryption/decryption.
102pub mod mls_crypto;
103
104/// Reference implementations of the library's plug-in traits — in-memory
105/// MLS / peer-score storage, default consensus + per-conversation
106/// plug-in bundles, and a reference key-package provider. Production
107/// integrators swap one or more for their own implementations.
108pub mod defaults;
109
110#[cfg(test)]
111pub(crate) mod test_fixtures;
112
113pub mod protos;