pub struct Account { /* private fields */ }
Expand description
An Olm account manages all cryptographic keys used on a device.
Implementations
sourceimpl Account
impl Account
sourcepub fn identity_keys(&self) -> IdentityKeys
pub fn identity_keys(&self) -> IdentityKeys
Get the IdentityKeys of this Account
sourcepub fn ed25519_key(&self) -> Ed25519PublicKey
pub fn ed25519_key(&self) -> Ed25519PublicKey
Get a reference to the account’s public Ed25519 key
sourcepub fn curve25519_key(&self) -> Curve25519PublicKey
pub fn curve25519_key(&self) -> Curve25519PublicKey
Get a reference to the account’s public Curve25519 key
sourcepub fn sign(&self, message: &str) -> Ed25519Signature
pub fn sign(&self, message: &str) -> Ed25519Signature
Sign the given message using our Ed25519 fingerprint key.
sourcepub fn max_number_of_one_time_keys(&self) -> usize
pub fn max_number_of_one_time_keys(&self) -> usize
Get the maximum number of one-time keys the client should keep on the server.
Note: this differs from the libolm method of the same name, the
libolm method returned the maximum amount of one-time keys the Account
could hold and only half of those should be uploaded.
sourcepub fn create_outbound_session(
&self,
identity_key: Curve25519PublicKey,
one_time_key: Curve25519PublicKey
) -> Session
pub fn create_outbound_session(
&self,
identity_key: Curve25519PublicKey,
one_time_key: Curve25519PublicKey
) -> Session
Create a Session
with the given identity key and one-time key.
sourcepub fn remove_one_time_key(
&mut self,
public_key: &Curve25519PublicKey
) -> Option<Curve25519SecretKey>
pub fn remove_one_time_key(
&mut self,
public_key: &Curve25519PublicKey
) -> Option<Curve25519SecretKey>
Remove a one-time key that has previously been published but not yet used.
Note: This function is only rarely useful and you’ll know if you
need it. Notably, you do not need to call it manually when using up
a key via Account::create_inbound_session
since the key is
automatically removed in that case.
sourcepub fn create_inbound_session(
&mut self,
their_identity_key: Curve25519PublicKey,
pre_key_message: &PreKeyMessage
) -> Result<InboundCreationResult, SessionCreationError>
pub fn create_inbound_session(
&mut self,
their_identity_key: Curve25519PublicKey,
pre_key_message: &PreKeyMessage
) -> Result<InboundCreationResult, SessionCreationError>
Create a Session
from the given pre-key message and identity key
sourcepub fn generate_one_time_keys(&mut self, count: usize)
pub fn generate_one_time_keys(&mut self, count: usize)
Generates the supplied number of one time keys.
sourcepub fn one_time_keys(&self) -> HashMap<KeyId, Curve25519PublicKey>
pub fn one_time_keys(&self) -> HashMap<KeyId, Curve25519PublicKey>
Get the currently unpublished one-time keys.
The one-time keys should be published to a server and marked as
published using the mark_keys_as_published()
method.
sourcepub fn generate_fallback_key(&mut self)
pub fn generate_fallback_key(&mut self)
Generate a single new fallback key.
The fallback key will be used by other users to establish a Session
if
all the one-time keys on the server have been used up.
sourcepub fn fallback_key(&self) -> HashMap<KeyId, Curve25519PublicKey>
pub fn fallback_key(&self) -> HashMap<KeyId, Curve25519PublicKey>
Get the currently unpublished fallback key.
The fallback key should be published just like the one-time keys, after
it has been successfully published it needs to be marked as published
using the mark_keys_as_published()
method as well.
sourcepub fn forget_fallback_key(&mut self) -> bool
pub fn forget_fallback_key(&mut self) -> bool
The Account
stores at most two private parts of the fallback key. This
method lets us forget the previously used fallback key.
sourcepub fn mark_keys_as_published(&mut self)
pub fn mark_keys_as_published(&mut self)
Mark all currently unpublished one-time and fallback keys as published.
sourcepub fn pickle(&self) -> AccountPickle
pub fn pickle(&self) -> AccountPickle
Convert the account into a struct which implements serde::Serialize
and serde::Deserialize
.
sourcepub fn from_pickle(pickle: AccountPickle) -> Self
pub fn from_pickle(pickle: AccountPickle) -> Self
Restore an Account
from a previously saved AccountPickle
.
sourcepub fn from_libolm_pickle(
pickle: &str,
pickle_key: &[u8]
) -> Result<Self, LibolmPickleError>
pub fn from_libolm_pickle(
pickle: &str,
pickle_key: &[u8]
) -> Result<Self, LibolmPickleError>
Create an Account
object by unpickling an account pickle in libolm
legacy pickle format.
Such pickles are encrypted and need to first be decrypted using
pickle_key
.
Trait Implementations
sourceimpl From<AccountPickle> for Account
impl From<AccountPickle> for Account
sourcefn from(pickle: AccountPickle) -> Self
fn from(pickle: AccountPickle) -> Self
Converts to this type from the input type.
Auto Trait Implementations
impl RefUnwindSafe for Account
impl Send for Account
impl Sync for Account
impl Unpin for Account
impl UnwindSafe for Account
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