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

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 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 fn session_config(&self) -> SessionConfig

source

pub fn encrypt(&mut self, plaintext: impl AsRef<[u8]>) -> 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.

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>

Available on crate feature libolm-compat only.

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

§

type Output = T

Should always be Self
source§

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

§

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>,

§

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