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