pub struct PreKeyMessage { /* private fields */ }
Expand description
Implementations§
Source§impl PreKeyMessage
impl PreKeyMessage
Sourcepub const fn one_time_key(&self) -> Curve25519PublicKey
pub const fn one_time_key(&self) -> Curve25519PublicKey
The single-use key that was uploaded to a public key directory by the
receiver of the message. Should be used to establish a Session
.
Sourcepub const fn base_key(&self) -> Curve25519PublicKey
pub const fn base_key(&self) -> Curve25519PublicKey
The base key, a single use key that was created just in time by the
sender of the message. Should be used to establish a Session
.
Sourcepub const fn identity_key(&self) -> Curve25519PublicKey
pub const fn identity_key(&self) -> Curve25519PublicKey
The long term identity key of the sender of the message. Should be used
to establish a Session
Sourcepub const fn session_keys(&self) -> SessionKeys
pub const fn session_keys(&self) -> SessionKeys
The collection of all keys required for establishing an Olm Session
from this pre-key message.
Other methods on this struct (like PreKeyMessage::identity_key()
)
can be used to retrieve individual keys from this collection.
Sourcepub fn session_id(&self) -> String
pub fn session_id(&self) -> String
Returns the globally unique session ID, in base64-encoded form.
This is a shorthand helper of the SessionKeys::session_id()
method.
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 Olm Message
.
The expected format of the byte array is described in the
PreKeyMessage::to_bytes()
method.
Sourcepub fn to_bytes(&self) -> Vec<u8> ⓘ
pub fn to_bytes(&self) -> Vec<u8> ⓘ
Encode the PreKeyMessage
as an array of bytes.
Olm PreKeyMessage
s consist of a one-byte version, followed by a
variable length payload.
+--------------+------------------------------------+
| Version Byte | Payload Bytes |
+--------------+------------------------------------+
The payload uses a format based on the Protocol Buffers encoding. It consists of the following key-value pairs:
Name | Tag | Type | Meaning |
---|---|---|---|
One-Time-Key | 0x0A | String | The public part of Bob’s single-use key |
Base-Key | 0x12 | String | The public part of Alice’s single-use key |
Identity-Key | 0x1A | String | The public part of Alice’s identity key |
Message | 0x22 | String | An embedded Olm message |
The last key/value pair in a PreKeyMessage
is a normal Olm
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 Olm PreKeyMessage
.
The string needs to be a base64 encoded byte array that follows the
format described in the PreKeyMessage::to_bytes()
method.
Sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Encode the PreKeyMessage
as a string.
This method first calls PreKeyMessage::to_bytes()
and then encodes
the resulting byte array as a string using base64 encoding.
Trait Implementations§
Source§impl Clone for PreKeyMessage
impl Clone for PreKeyMessage
Source§fn clone(&self) -> PreKeyMessage
fn clone(&self) -> PreKeyMessage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more