p2panda_encryption/lib.rs
1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! `p2panda-encryption` provides decentralized, secure data- and message encryption for groups
4//! with post-compromise security and optional forward secrecy.
5//!
6//! The crate implements two different group key-agreement and encryption schemes for a whole range
7//! of use cases for applications which can't rely on a stable network connection or centralised
8//! coordination.
9//!
10//! The first scheme we simply call [**"Data Encryption"**](data_scheme), allowing peers to encrypt any data with
11//! a secret, symmetric key for a group (using XChaCha20-Poly1305). This will be useful for building
12//! applications where users who enter a group late will still have access to previously-created
13//! content, for example knowledge databases, wiki applications or a booking tool for rehearsal
14//! rooms.
15//!
16//! A member will not learn about any newly-created data after they are removed from the group,
17//! since the key gets rotated on member removal. This should accommodate for many use-cases in p2p
18//! applications which rely on basic group encryption with post-compromise security (PCS) and
19//! forward secrecy (FS) during key agreement. Applications can optionally choose to remove
20//! encryption keys for forward secrecy if they so desire.
21//!
22//! The second scheme is [**"Message Encryption"**](message_scheme), offering a forward secure (FS)
23//! messaging ratchet, similar to Signal's [Double Ratchet
24//! algorithm](https://en.wikipedia.org/wiki/Double_Ratchet_Algorithm). Since secret keys are
25//! always generated for each message, a user can not easily learn about previously-created
26//! messages when getting hold of such a key. We believe that the latter scheme will be used in
27//! more specialised applications, for example p2p group chats, as strong forward secrecy comes
28//! with it's own UX requirements. We are nonetheless excited to offer a solution for both worlds,
29//! depending on the application's needs.
30//!
31//! More detail about the particular implementation and design choices of `p2panda-encryption` can
32//! be found in our [in-depth blog post](https://p2panda.org/2025/02/24/group-encryption.html) and
33//! [README](https://github.com/p2panda/p2panda/blob/main/p2panda-encryption/README.md).
34pub mod crypto;
35#[cfg(any(test, feature = "data_scheme"))]
36pub mod data_scheme;
37pub mod key_bundle;
38pub mod key_manager;
39pub mod key_registry;
40#[cfg(any(test, feature = "message_scheme"))]
41pub mod message_scheme;
42#[cfg(any(test, feature = "test_utils"))]
43mod ordering;
44#[cfg(any(test, feature = "test_utils"))]
45pub mod test_utils;
46pub mod traits;
47pub mod two_party;
48
49pub use crypto::{Rng, RngError};