pub struct MegolmMessage { /* private fields */ }
Expand description
An encrypted Megolm message.
Contains metadata that is required to find the correct ratchet state of a
InboundGroupSession
necessary to decrypt the message.
Implementations§
Source§impl MegolmMessage
impl MegolmMessage
Sourcepub fn ciphertext(&self) -> &[u8] ⓘ
pub fn ciphertext(&self) -> &[u8] ⓘ
The actual ciphertext of the message.
Sourcepub const fn message_index(&self) -> u32
pub const fn message_index(&self) -> u32
The index of the message that was used when the message was encrypted.
Sourcepub const fn signature(&self) -> &Ed25519Signature
pub const fn signature(&self) -> &Ed25519Signature
Get a reference to the megolm message’s signature.
Sourcepub fn from_bytes(message: &[u8]) -> Result<Self, DecodeError>
pub fn from_bytes(message: &[u8]) -> Result<Self, DecodeError>
Try to decode the given byte slice as a MegolmMessage
.
The expected format of the byte array is described in the
MegolmMessage::to_bytes()
method.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Encode the MegolmMessage
as an array of bytes.
Megolm messages consist of a one byte version, followed by a variable length payload, a fixed length message authentication code, and a fixed length signature.
+---+------------------------------------+-----------+------------------+
| V | Payload Bytes | MAC Bytes | Signature Bytes |
+---+------------------------------------+-----------+------------------+
0 1 N N+8 N+72 bytes
The payload uses a format based on the Protocol Buffers encoding. It consists of the following key-value pairs:
Name | Tag | Type | Meaning |
---|---|---|---|
Message-Index | 0x08 | Integer | The index of the ratchet, i |
Cipher-Text | 0x12 | String | The cipher-text, Xi, of the message |
Sourcepub fn from_base64(message: &str) -> Result<Self, DecodeError>
pub fn from_base64(message: &str) -> Result<Self, DecodeError>
Try to decode the given string as a MegolmMessage
.
The string needs to be a base64 encoded byte array that follows the
format described in the MegolmMessage::to_bytes()
method.
Sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode the MegolmMessage
as a string.
This method first calls MegolmMessage::to_bytes()
and then encodes
the resulting byte array as a string using base64 encoding.
Trait Implementations§
Source§impl Clone for MegolmMessage
impl Clone for MegolmMessage
Source§fn clone(&self) -> MegolmMessage
fn clone(&self) -> MegolmMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more