Struct vodozemac::megolm::SessionKey
source · pub struct SessionKey { /* private fields */ }
Expand description
The session key, can be used to create a InboundGroupSession
.
Uses the session-sharing format described in the Olm spec.
+—+––+––––+––––+––––+––––+——+———–+ | V | i | R(i,0) | R(i,1) | R(i,2) | R(i,3) | Kpub | Signature | +—+––+––––+––––+––––+––––+——+———–+ 0 1 5 37 69 101 133 165 229 bytes
The version byte, V, is “\x02”. This is followed by the ratchet index, iii, which is encoded as a big-endian 32-bit integer; the 128 bytes of the ratchet; and the public part of the Ed25519 keypair.
The data is then signed using the Ed25519 key, and the 64-byte signature is appended.
Implementations§
source§impl SessionKey
impl SessionKey
sourcepub fn from_bytes(bytes: &[u8]) -> Result<Self, SessionKeyDecodeError>
pub fn from_bytes(bytes: &[u8]) -> Result<Self, SessionKeyDecodeError>
Deserialize the SessionKey
from a byte slice.
sourcepub fn to_base64(&self) -> String
pub fn to_base64(&self) -> String
Serialize the SessionKey
to a base64 encoded string.
This method will first use the SessionKey::to_bytes()
to
convert the session key to a byte vector and then encode the byte vector
to a string using unpadded base64 as the encoding.
sourcepub fn from_base64(key: &str) -> Result<Self, SessionKeyDecodeError>
pub fn from_base64(key: &str) -> Result<Self, SessionKeyDecodeError>
Deserialize the SessionKey
from base64 encoded string.