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<SessionKey, SessionKeyDecodeError>
pub fn from_bytes(bytes: &[u8]) -> Result<SessionKey, 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<SessionKey, SessionKeyDecodeError>
pub fn from_base64(key: &str) -> Result<SessionKey, SessionKeyDecodeError>
Deserialize the SessionKey
from base64 encoded string.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SessionKey
impl<'de> Deserialize<'de> for SessionKey
Source§fn deserialize<D>(
deserializer: D,
) -> Result<SessionKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<SessionKey, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl Drop for SessionKey
impl Drop for SessionKey
Source§impl Serialize for SessionKey
impl Serialize for SessionKey
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl TryFrom<&[u8]> for SessionKey
impl TryFrom<&[u8]> for SessionKey
Source§type Error = SessionKeyDecodeError
type Error = SessionKeyDecodeError
Source§fn try_from(
value: &[u8],
) -> Result<SessionKey, <SessionKey as TryFrom<&[u8]>>::Error>
fn try_from( value: &[u8], ) -> Result<SessionKey, <SessionKey as TryFrom<&[u8]>>::Error>
Source§impl TryFrom<&str> for SessionKey
impl TryFrom<&str> for SessionKey
Source§type Error = SessionKeyDecodeError
type Error = SessionKeyDecodeError
Source§fn try_from(
value: &str,
) -> Result<SessionKey, <SessionKey as TryFrom<&str>>::Error>
fn try_from( value: &str, ) -> Result<SessionKey, <SessionKey as TryFrom<&str>>::Error>
Auto Trait Implementations§
impl Freeze for SessionKey
impl RefUnwindSafe for SessionKey
impl Send for SessionKey
impl Sync for SessionKey
impl Unpin for SessionKey
impl UnwindSafe for SessionKey
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more