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 group chat applications
4//! using the MLS (Messaging Layer Security) protocol with consensus-based membership management.
5//!
6//! ## Architecture
7//!
8//! ```text
9//! ┌─────────────────────────────────────────────────────────────────────┐
10//! │                         Your Application                            │
11//! └───────────────────────────────┬─────────────────────────────────────┘
12//!                                 │
13//!         ┌───────────────────────┼───────────────────────┐
14//!         ▼                       ▼                       ▼
15//! ┌───────────────┐      ┌───────────────┐      ┌───────────────┐
16//! │     core      │      │   mls_crypto  │      │      ds       │
17//! │  (protocol)   │      │ (encryption)  │      │ (transport)   │
18//! └───────────────┘      └───────────────┘      └───────────────┘
19//!         │                       │                       │
20//!         └───────────────────────┼───────────────────────┘
21//!                                 ▼
22//!                        ┌───────────────┐
23//!                        │      app      │
24//!                        │ (reference)   │
25//!                        └───────────────┘
26//! ```
27//!
28//! ## Modules
29//!
30//! - **[`core`]** - Protocol implementation (message processing, consensus integration)
31//! - **[`mls_crypto`]** - MLS cryptographic operations (OpenMLS wrapper)
32//! - **[`ds`]** - Delivery service abstraction (Waku transport)
33//! - **[`app`]** - Reference application layer (multi-group management, state machine)
34//! - **[`protos`]** - Protobuf message definitions
35//!
36//! ## Getting Started
37//!
38//! Most developers should start with the [`core`] module documentation, which explains:
39//! - What traits you need to implement ([`core::GroupEventHandler`])
40//! - Core operations (create group, join, send messages)
41//! - The ProcessResult → DispatchAction flow
42//!
43//! If you want a ready-to-use solution, see [`app::User`] which provides complete
44//! group management with state machine and epoch handling.
45//!
46//! ## Quick Example
47//!
48//! ```ignore
49//! use de_mls::core::{DefaultProvider, GroupEventHandler};
50//! use de_mls::app::User;
51//!
52//! // Create a user with an Ethereum private key
53//! let user: User<DefaultProvider> = User::with_private_key(
54//!     "0xac0974...",  // Private key
55//!     consensus,      // Consensus service
56//!     handler,        // Your GroupEventHandler implementation
57//! )?;
58//!
59//! // Create a group (as steward)
60//! user.create_group("my-group", true).await?;
61//!
62//! // Send a message
63//! user.send_message("my-group", b"Hello, world!").await?;
64//! ```
65
66/// Protocol implementation: message processing, consensus, and group operations.
67pub mod core;
68
69/// Reference application layer: multi-group management and state machine.
70pub mod app;
71
72/// Delivery service: transport-agnostic messaging.
73/// Enable the **`waku`** feature for the Waku relay implementation.
74pub mod ds;
75
76/// MLS cryptographic operations: OpenMLS wrapper for encryption/decryption.
77pub mod mls_crypto;
78
79/// Protobuf message definitions.
80pub mod protos {
81    /// Re-exported consensus protocol messages.
82    pub mod hashgraph_like_consensus {
83        pub mod v1 {
84            pub use ::hashgraph_like_consensus::protos::consensus::v1::*;
85        }
86    }
87
88    /// DE-MLS application-level messages.
89    pub mod de_mls {
90        pub mod messages {
91            pub mod v1 {
92                include!(concat!(env!("OUT_DIR"), "/de_mls.messages.v1.rs"));
93            }
94        }
95    }
96}