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§
source§impl GroupSession
impl GroupSession
sourcepub fn new(config: SessionConfig) -> Self
pub fn new(config: SessionConfig) -> 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 const fn message_index(&self) -> u32
pub const 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 const fn session_config(&self) -> SessionConfig
pub const fn session_config(&self) -> SessionConfig
Get the SessionConfig
that this GroupSession
is configured
to use.
sourcepub fn encrypt(&mut self, plaintext: impl AsRef<[u8]>) -> MegolmMessage
pub fn encrypt(&mut self, plaintext: impl AsRef<[u8]>) -> MegolmMessage
Encrypt the given 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
.
sourcepub fn from_libolm_pickle(
pickle: &str,
pickle_key: &[u8],
) -> Result<Self, LibolmPickleError>
pub fn from_libolm_pickle( pickle: &str, pickle_key: &[u8], ) -> Result<Self, LibolmPickleError>
Creates a GroupSession
object by unpickling a session in the legacy
libolm pickle format.
These pickles are encrypted and must be decrypted using the provided
pickle_key
.