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
sourceimpl SessionKey
impl SessionKey
sourcepub fn to_bytes(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn to_bytes(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
Serialize the SessionKey
to a byte vector.
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.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for SessionKey
impl<'de> Deserialize<'de> for SessionKey
sourcefn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl Serialize for SessionKey
impl Serialize for SessionKey
sourceimpl TryFrom<&[u8]> for SessionKey
impl TryFrom<&[u8]> for SessionKey
Auto Trait Implementations
impl RefUnwindSafe for SessionKey
impl Send for SessionKey
impl Sync for SessionKey
impl Unpin for SessionKey
impl UnwindSafe for SessionKey
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more