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
59
60
61
62
63
64
65
66
67
68
69
70
71
// SPDX-License-Identifier: AGPL-3.0-or-later
//! Create and moderate large secret groups to maintain key material for secure messaging.
//!
//! p2panda uses the [MLS] (Messaging Layer Security) protocol for group key negotiation to
//! establish secrets in a group of users for _Sender Ratchet Secrets_ or _Long Term Secrets_. Both
//! settings give confidentiality, authenticity and post-compromise security, while the sender
//! ratchet scheme also gives forward secrecy.
//!
//! A group of users sharing that secret state is called a _secret group_ in p2panda. Sender
//! ratchet encryption is interesting for applications with high security standards where every
//! message is individually protected with an ephemeral key, whereas long-term secret encryption is
//! useful for building application where keys material is reused for multiple messages over longer
//! time, so past data can still be decrypted, even when a member joins the secret group later.
//!
//! [MLS]: https://messaginglayersecurity.rocks
//!
//! ## Example
//!
//! ```
//! # extern crate p2panda_rs;
//! # fn main() -> Result<(), Box<dyn std::error::Error>> {
//! # use std::convert::TryFrom;
//! # use p2panda_rs::hash::Hash;
//! # use p2panda_rs::identity::KeyPair;
//! # use p2panda_rs::secret_group::{SecretGroup, SecretGroupMember, MlsProvider};
//! # let group_instance_id = Hash::new_from_bytes(vec![1, 2, 3])?;
//! // Define provider for cryptographic methods and key storage
//! let provider = MlsProvider::new();
//!
//! // Generate new Ed25519 key pair
//! let key_pair = KeyPair::new();
//!
//! // Create new group member based on p2panda key pair
//! let member = SecretGroupMember::new(&provider, &key_pair)?;
//!
//! // Create a secret group with member as the owner
//! let mut group = SecretGroup::new(&provider, &group_instance_id, &member)?;
//!
//! // Encrypt message
//! let ciphertext = group.encrypt(&provider, b"Secret Message")?;
//! # Ok(())
//! # }
//! ```
//!
//! This module also provides lower-level methods to maintain MLS (Messaging Layer Security) group
//! state for secure group messaging in p2panda as well as Structs and methods to handle p2panda
//! Long Term Secrets.
//!
//! Long Term Secrets contain symmetric AEAD keys which are used to en- & decrypt data over longer
//! periods of time, spanning over multiple MLS group epochs.
//!
//! See: <https://openmls.tech> for more information.
pub use SecretGroupCommit;
pub use SecretGroupError;
pub use SecretGroup;
pub use SecretGroupMember;
pub use SecretGroupMessage;
// @TODO: This will be removed as soon as we have our own provider
pub use MlsProvider;