Struct matrix_sdk_crypto::ReadOnlyAccount
source · [−]pub struct ReadOnlyAccount {
pub user_id: Arc<UserId>,
pub device_id: Arc<DeviceId>,
pub identity_keys: Arc<IdentityKeys>,
/* private fields */
}
Expand description
Account holding identity keys for which sessions can be created.
An account is the central identity for encrypted communication between two devices.
Fields
user_id: Arc<UserId>
The user_id this account belongs to
device_id: Arc<DeviceId>
The device_id of this entry
identity_keys: Arc<IdentityKeys>
The associated identity keys
Implementations
sourceimpl ReadOnlyAccount
impl ReadOnlyAccount
sourcepub fn new(user_id: &UserId, device_id: &DeviceId) -> Self
pub fn new(user_id: &UserId, device_id: &DeviceId) -> Self
Create a fresh new account, this will generate the identity key-pair.
sourcepub fn identity_keys(&self) -> IdentityKeys
pub fn identity_keys(&self) -> IdentityKeys
Get the public parts of the identity keys for the account.
sourcepub fn signing_key_id(&self) -> OwnedDeviceKeyId
pub fn signing_key_id(&self) -> OwnedDeviceKeyId
Get the key ID of our Ed25519 signing key.
sourcepub fn update_uploaded_key_count(&self, new_count: u64)
pub fn update_uploaded_key_count(&self, new_count: u64)
sourcepub fn uploaded_key_count(&self) -> u64
pub fn uploaded_key_count(&self) -> u64
Get the currently known uploaded key count.
Has the account been shared with the server.
Mark the account as shared.
Messages shouldn’t be encrypted with the session before it has been shared.
sourcepub async fn one_time_keys(&self) -> HashMap<KeyId, Curve25519PublicKey>
pub async fn one_time_keys(&self) -> HashMap<KeyId, Curve25519PublicKey>
Get the one-time keys of the account.
This can be empty, keys need to be generated first.
sourcepub async fn generate_one_time_keys_helper(&self, count: usize)
pub async fn generate_one_time_keys_helper(&self, count: usize)
Generate count number of one-time keys.
sourcepub async fn max_one_time_keys(&self) -> usize
pub async fn max_one_time_keys(&self) -> usize
Get the maximum number of one-time keys the account can hold.
sourcepub async fn generate_one_time_keys(&self) -> Option<u64>
pub async fn generate_one_time_keys(&self) -> Option<u64>
Generate new one-time keys that need to be uploaded to the server.
Returns None if no keys need to be uploaded, otherwise the number of newly generated one-time keys. May return 0 if some one-time keys are already generated but weren’t uploaded.
Generally Some
means that keys should be uploaded, while None
means
that keys should not be uploaded.
sourcepub async fn keys_for_upload(
&self
) -> (Option<DeviceKeys>, BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>, BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>)
pub async fn keys_for_upload(
&self
) -> (Option<DeviceKeys>, BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>, BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>)
Get a tuple of device, one-time, and fallback keys that need to be uploaded.
If no keys need to be uploaded the DeviceKeys
will be None
and the
one-time and fallback keys maps will be empty.
sourcepub async fn mark_keys_as_published(&self)
pub async fn mark_keys_as_published(&self)
Mark the current set of one-time keys as being published.
sourcepub async fn sign(&self, string: &str) -> Ed25519Signature
pub async fn sign(&self, string: &str) -> Ed25519Signature
Sign the given string using the accounts signing key.
Returns the signature as a base64 encoded string.
sourcepub async fn pickle(&self) -> PickledAccount
pub async fn pickle(&self) -> PickledAccount
Get a serializeable version of the Account
so it can be persisted.
sourcepub fn from_pickle(pickle: PickledAccount) -> Result<Self, PickleError>
pub fn from_pickle(pickle: PickledAccount) -> Result<Self, PickleError>
Restore an account from a previously pickled one.
Arguments
-
pickle
- The pickled version of the Account. -
pickle_mode
- The mode that was used to pickle the account, either an unencrypted mode or an encrypted using passphrase.
sourcepub fn unsigned_device_keys(&self) -> DeviceKeys
pub fn unsigned_device_keys(&self) -> DeviceKeys
Generate the unsigned DeviceKeys
from this ReadOnlyAccount
sourcepub async fn device_keys(&self) -> DeviceKeys
pub async fn device_keys(&self) -> DeviceKeys
Sign the device keys of the account and return them so they can be uploaded.
sourcepub async fn bootstrap_cross_signing(
&self
) -> (PrivateCrossSigningIdentity, UploadSigningKeysRequest, SignatureUploadRequest)
pub async fn bootstrap_cross_signing(
&self
) -> (PrivateCrossSigningIdentity, UploadSigningKeysRequest, SignatureUploadRequest)
Bootstrap Cross-Signing
sourcepub async fn sign_cross_signing_key(
&self,
cross_signing_key: &mut CrossSigningKey
) -> Result<(), SignatureError>
pub async fn sign_cross_signing_key(
&self,
cross_signing_key: &mut CrossSigningKey
) -> Result<(), SignatureError>
Sign the given CrossSigning Key in place
sourcepub async fn sign_master_key(
&self,
master_key: MasterPubkey
) -> Result<SignatureUploadRequest, SignatureError>
pub async fn sign_master_key(
&self,
master_key: MasterPubkey
) -> Result<SignatureUploadRequest, SignatureError>
Sign the given Master Key
sourcepub async fn sign_json(
&self,
json: Value
) -> Result<Ed25519Signature, SignatureError>
pub async fn sign_json(
&self,
json: Value
) -> Result<Ed25519Signature, SignatureError>
Convert a JSON value to the canonical representation and sign the JSON string.
Arguments
json
- The value that should be converted into a canonical JSON string.
sourcepub async fn signed_one_time_keys(
&self
) -> BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>
pub async fn signed_one_time_keys(
&self
) -> BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>
Generate, sign and prepare one-time keys to be uploaded.
If no one-time keys need to be uploaded returns an empty BTreeMap.
sourcepub async fn signed_fallback_keys(
&self
) -> BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>
pub async fn signed_fallback_keys(
&self
) -> BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>
Sign and prepare fallback keys to be uploaded.
If no fallback keys need to be uploaded returns an empty BTreeMap.
sourcepub async fn create_outbound_session_helper(
&self,
identity_key: Curve25519PublicKey,
one_time_key: Curve25519PublicKey,
fallback_used: bool
) -> Session
pub async fn create_outbound_session_helper(
&self,
identity_key: Curve25519PublicKey,
one_time_key: Curve25519PublicKey,
fallback_used: bool
) -> Session
Create a new session with another account given a one-time key.
Returns the newly created session or a OlmSessionError
if creating a
session failed.
Arguments
-
their_identity_key
- The other account’s identity/curve25519 key. -
their_one_time_key
- A signed one-time key that the other account created and shared with us.
sourcepub async fn create_outbound_session(
&self,
device: ReadOnlyDevice,
key_map: &BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>
) -> Result<Session, SessionCreationError>
pub async fn create_outbound_session(
&self,
device: ReadOnlyDevice,
key_map: &BTreeMap<OwnedDeviceKeyId, Raw<OneTimeKey>>
) -> Result<Session, SessionCreationError>
Create a new session with another account given a one-time key and a device.
Returns the newly created session or a OlmSessionError
if creating a
session failed.
Arguments
-
device
- The other account’s device. -
key_map
- A map from the algorithm and device ID to the one-time key that the other account created and shared with us.
sourcepub async fn create_inbound_session(
&self,
their_identity_key: &str,
message: &PreKeyMessage
) -> Result<InboundCreationResult, SessionCreationError>
pub async fn create_inbound_session(
&self,
their_identity_key: &str,
message: &PreKeyMessage
) -> Result<InboundCreationResult, SessionCreationError>
Create a new session with another account given a pre-key Olm message.
Returns the newly created session or a OlmSessionError
if creating a
session failed.
Arguments
-
their_identity_key
- The other account’s identity/curve25519 key. -
message
- A pre-key Olm message that was sent to us by the other account.
sourcepub async fn create_group_session_pair(
&self,
room_id: &RoomId,
settings: EncryptionSettings
) -> Result<(OutboundGroupSession, InboundGroupSession), ()>
pub async fn create_group_session_pair(
&self,
room_id: &RoomId,
settings: EncryptionSettings
) -> Result<(OutboundGroupSession, InboundGroupSession), ()>
Create a group session pair.
This session pair can be used to encrypt and decrypt messages meant for a large group of participants.
The outbound session is used to encrypt messages while the inbound one is used to decrypt messages encrypted by the outbound one.
Arguments
-
room_id
- The ID of the room where the group session will be used. -
settings
- Settings determining the algorithm and rotation period of the outbound group session.
Trait Implementations
sourceimpl Clone for ReadOnlyAccount
impl Clone for ReadOnlyAccount
sourcefn clone(&self) -> ReadOnlyAccount
fn clone(&self) -> ReadOnlyAccount
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for ReadOnlyAccount
impl Debug for ReadOnlyAccount
Auto Trait Implementations
impl !RefUnwindSafe for ReadOnlyAccount
impl Send for ReadOnlyAccount
impl Sync for ReadOnlyAccount
impl Unpin for ReadOnlyAccount
impl !UnwindSafe for ReadOnlyAccount
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
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more