1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//! Persistent OpenMLS provider for the Ping SDK ([CR-4]).
//!
//! ## What this crate is
//!
//! The Ping SDK's [`MessagingClient`](::openmls) uses OpenMLS for the cryptographic
//! state machine, and OpenMLS owns its key material via an `OpenMlsProvider`. The
//! reference provider — [`openmls_rust_crypto::OpenMlsRustCrypto`] — keeps everything
//! in memory; on process exit, the state is gone. That breaks the **iOS NSE** and
//! **web Service Worker** cold-start paths, which spin up a *fresh* process expected
//! to decrypt a push payload.
//!
//! This crate adds a persistent provider:
//!
//! ```text
//! PersistentMlsProvider {
//! crypto: RustCrypto, // unchanged — RNG + signature + HPKE + KDF
//! storage: MemoryStorage, // in-process working set (openmls_memory_storage)
//! backend: StorageBackend, // where to flush MemoryStorage to disk
//! }
//! ```
//!
//! Reads hit the in-memory working set (fast). Writes are mediated by OpenMLS through
//! `MemoryStorage`; the provider exposes a [`checkpoint`](PersistentMlsProvider::checkpoint)
//! method the SDK calls after state-changing ops to flush the working set to disk.
//!
//! ## v0.1 serialization strategy
//!
//! For v0.1 we serialize the *entire* `MemoryStorage` HashMap as one CBOR blob per
//! checkpoint and write it to a single SQLite row. Pros: tiny diff against an
//! already-tested in-memory provider; no risk of mis-implementing OpenMLS's ~50-method
//! `StorageProvider<V>` trait. Cons: O(state) write cost per checkpoint. For the v1
//! profile (tens of groups, ~10-100 KB total state), this is fine. A future revision
//! can upgrade to per-row writes behind the same `StorageBackend` enum without
//! changing the public API. See [`docs/design/CR4_CR7_PERSISTENCE.md`] for the longer
//! discussion.
//!
//! ## At-rest encryption
//!
//! The SDK never derives its own key. `StorageBackend::Sqlite::encryption_key`, when
//! present, is passed through to SQLCipher's `PRAGMA key`. Hosts are expected to source
//! it from the OS keyring (Keychain on iOS, Keystore on Android, etc.) — matches the
//! documented split in `docs/architecture/crypto.md §Storage adapters`.
pub use ;
pub use StorageBackend;
pub use ;
pub use PersistentMlsProvider;