Struct vodozemac::megolm::GroupSession
source · [−]pub struct GroupSession { /* private fields */ }
Expand description
A Megolm group session represents a single sending participant in an encrypted group communication context containing multiple receiving parties.
A group session consists of a ratchet, used for encryption, and an Ed25519 signing key pair, used for authenticity.
A group session containing the signing key pair is also known as an “outbound” group session. We differentiate this from an inbound group session where this key pair has been removed and which can be used solely for receipt and decryption of messages.
Such an inbound group session is typically sent by the outbound group session owner to each of the receiving parties via a secure peer-to-peer channel (e.g. an Olm channel).
Implementations
sourceimpl GroupSession
impl GroupSession
sourcepub fn new() -> Self
pub fn new() -> Self
Construct a new group session, with a random ratchet state and signing key pair.
sourcepub fn session_id(&self) -> String
pub fn session_id(&self) -> String
Returns the globally unique session ID, in base64-encoded form.
A session ID is the public part of the Ed25519 key pair associated with the group session. Due to the construction, every session ID is (probabilistically) globally unique.
sourcepub fn message_index(&self) -> u32
pub fn message_index(&self) -> u32
Return the current message index.
The message index is incremented each time a message is encrypted with the group session.
sourcepub fn encrypt(&mut self, plaintext: &str) -> MegolmMessage
pub fn encrypt(&mut self, plaintext: &str) -> MegolmMessage
Encrypt the plaintext
with the group session.
The resulting ciphertext is MAC-ed, then signed with the group session’s Ed25519 key pair and finally base64-encoded.
sourcepub fn session_key(&self) -> SessionKey
pub fn session_key(&self) -> SessionKey
Export the group session into a session key.
The session key contains the key version constant, the current message index, the ratchet state and the public part of the signing key pair. It is signed by the signing key pair for authenticity.
The session key is in a portable format, suitable for sending over the network. It is typically sent to other group participants so that they can reconstruct an inbound group session in order to decrypt messages sent by this group session.
sourcepub fn pickle(&self) -> GroupSessionPickle
pub fn pickle(&self) -> GroupSessionPickle
Convert the group session into a struct which implements
serde::Serialize
and serde::Deserialize
.
sourcepub fn from_pickle(pickle: GroupSessionPickle) -> Self
pub fn from_pickle(pickle: GroupSessionPickle) -> Self
Restore a GroupSession
from a previously saved
GroupSessionPickle
.
Trait Implementations
sourceimpl Default for GroupSession
impl Default for GroupSession
sourceimpl From<&GroupSession> for InboundGroupSession
impl From<&GroupSession> for InboundGroupSession
sourcefn from(session: &GroupSession) -> Self
fn from(session: &GroupSession) -> Self
Converts to this type from the input type.
sourceimpl From<GroupSessionPickle> for GroupSession
impl From<GroupSessionPickle> for GroupSession
sourcefn from(pickle: GroupSessionPickle) -> Self
fn from(pickle: GroupSessionPickle) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for GroupSession
impl Send for GroupSession
impl Sync for GroupSession
impl Unpin for GroupSession
impl UnwindSafe for GroupSession
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more