Skip to main content

offline_protocol_mls/
lib.rs

1//! MLS (Message Layer Security) integration for the Offline Protocol SDK.
2//!
3//! This crate provides end-to-end encryption using the MLS protocol via OpenMLS.
4//! It supports both 1:1 encrypted messaging and group messaging with forward secrecy
5//! and post-compromise security.
6//!
7//! # Architecture
8//!
9//! The crate is designed with a storage-agnostic approach:
10//! - Apps implement the [`MlsStorage`] trait for platform-native secure storage
11//! - The [`MlsManager`] handles all MLS operations (key generation, encryption, decryption)
12//! - Groups are used for both 1:1 sessions (2-person groups) and multi-party chats
13//!
14//! # Example
15//!
16//! ```ignore
17//! use offline_protocol_mls::{MlsManager, MlsStorage};
18//!
19//! // Implement MlsStorage for your platform (iOS Keychain, Android Keystore, etc.)
20//! let storage = MyPlatformStorage::new();
21//!
22//! // Create the MLS manager
23//! let manager = MlsManager::new("user123", Box::new(storage))?;
24//!
25//! // Generate a key package to share with others
26//! let key_package = manager.generate_key_package()?;
27//!
28//! // Create a 1:1 session and send an encrypted message
29//! let ciphertext = manager.encrypt_for_user("bob", b"Hello, Bob!")?;
30//! ```
31
32#![deny(unsafe_code)]
33#![warn(missing_docs)]
34
35mod canonical;
36pub mod discovery;
37pub mod error;
38pub mod group;
39pub mod invite;
40pub mod manager;
41pub mod provider;
42pub mod session;
43pub mod storage;
44mod storage_adapter;
45pub mod types;
46
47// `LeafSource` rides here with `MlsError` because it is a public field type on
48// a public variant: matching on `LeafAddressMismatch { context, .. }` should not
49// need a deeper path than the error it came out of.
50pub use error::{LeafSource, MlsError, Result};
51pub use manager::{is_mls_framed, MlsManager, PushKeyPackage, MAX_PUSH_KEY_PACKAGES};
52pub use storage::{MlsStorage, StorageError};
53pub use types::{
54    EncryptedMessage, GroupId, GroupInfo, GroupMetadata, GroupRole, KeyPackageBundle,
55    MlsMessageType, ParseGroupRoleError, WelcomeMessage,
56};