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//! - [`storage_conformance::run`] is the gate an implementation has to pass
12//! - The [`MlsManager`] handles all MLS operations (key generation, encryption, decryption)
13//! - Groups are used for both 1:1 sessions (2-person groups) and multi-party chats
14//!
15//! # Example
16//!
17//! ```ignore
18//! use offline_protocol_mls::{MlsManager, MlsStorage};
19//!
20//! // Implement MlsStorage for your platform (iOS Keychain, Android Keystore, etc.)
21//! let storage = MyPlatformStorage::new();
22//!
23//! // Create the MLS manager
24//! let manager = MlsManager::new("user123", Box::new(storage))?;
25//!
26//! // Generate a key package to share with others
27//! let key_package = manager.generate_key_package()?;
28//!
29//! // Create a 1:1 session and send an encrypted message
30//! let ciphertext = manager.encrypt_for_user("bob", b"Hello, Bob!")?;
31//! ```
32
33#![deny(unsafe_code)]
34#![warn(missing_docs)]
35
36pub mod discovery;
37pub mod error;
38pub mod group;
39pub mod identity_assertion;
40pub mod invite;
41pub mod manager;
42pub mod provider;
43pub mod session;
44pub mod storage;
45mod storage_adapter;
46pub mod storage_conformance;
47pub mod types;
48
49// `LeafSource` rides here with `MlsError` because it is a public field type on
50// a public variant: matching on `LeafAddressMismatch { context, .. }` should not
51// need a deeper path than the error it came out of.
52pub use error::{LeafSource, MlsError, Result};
53pub use identity_assertion::verify_identity_assertion;
54pub use manager::{is_mls_framed, MlsManager, PushKeyPackage, MAX_PUSH_KEY_PACKAGES};
55pub use session::SealMark;
56pub use storage::{MlsStorage, StorageError};
57pub use types::{
58    EncryptedMessage, GroupId, GroupInfo, GroupMetadata, GroupRole, KeyPackageBundle,
59    MlsMessageType, ParseGroupRoleError, WelcomeMessage,
60};