Skip to main content

p2panda_encryption/two_party/
mod.rs

1// SPDX-License-Identifier: MIT OR Apache-2.0
2
3//! Protocols for secure key-agreement between two members ("two party").
4//!
5//! Group encryption is concerned around delivering a secure message from a single sender to a
6//! whole group with potentially many receivers. To achieve this "broadcast" topology of such
7//! system we need to establish secret key material with each member of the group before. This
8//! takes places in form of a pair-wise, secure key-agreement protocol between two members of the
9//! group.
10//!
11//! The "two party secure messaging" key-agreement protocol (2SM) is specified in the paper "Key
12//! Agreement for Decentralized Secure Group Messaging with Strong Security Guarantees" (2020).
13//!
14//! At its core, the 2SM protocol uses Public-Key Encryption (PKE) to encrypt messages, with
15//! frequent key rotation to provide PCS and FS. Initially, each party encrypts messages using the
16//! key-bundle input for X3DH. Afterwards, to achieve PCS, each time a party sends a message, it
17//! also updates its public key. Finally, to avoid reusing public keys (which would make FS
18//! impossible), whenever a party sends a message, it also updates the other party's public key. To
19//! do so, it sends a new secret key along with its message, then deletes its own copy, storing
20//! only the public key.
21//!
22//! <https://eprint.iacr.org/2020/1281.pdf>
23#[allow(clippy::module_inception)]
24mod two_party;
25mod x3dh;
26
27pub use two_party::{
28    LongTermTwoParty, OneTimeTwoParty, TwoParty, TwoPartyCiphertext, TwoPartyError,
29    TwoPartyMessage, TwoPartyState,
30};
31pub use x3dh::{X3dhCiphertext, X3dhError, x3dh_decrypt, x3dh_encrypt};