vodozemac::megolm

Struct 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

Source

pub fn new(config: SessionConfig) -> Self

Construct a new group session, with a random ratchet state and signing key pair.

Source

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.

Source

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.

Source

pub const fn session_config(&self) -> SessionConfig

Get the SessionConfig that this GroupSession is configured to use.

Source

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.

Source

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.

Source

pub fn pickle(&self) -> GroupSessionPickle

Convert the group session into a struct which implements serde::Serialize and serde::Deserialize.

Source

pub fn from_pickle(pickle: GroupSessionPickle) -> Self

Restore a GroupSession from a previously saved GroupSessionPickle.

Source

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.

Trait Implementations§

Source§

impl Default for GroupSession

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl From<&GroupSession> for InboundGroupSession

Source§

fn from(session: &GroupSession) -> Self

Converts to this type from the input type.
Source§

impl From<GroupSessionPickle> for GroupSession

Source§

fn from(pickle: GroupSessionPickle) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V