Struct core_crypto::prelude::Client

source ·
pub struct Client { /* private fields */ }
Expand description

Represents a MLS client which in our case is the equivalent of a device.

It can be the Android, iOS, web or desktop application which the authenticated user is using. A user has many client, a client has only one user. A client can belong to many MLS groups

It is cheap to clone a Client because everything heavy is wrapped inside an Arc.

Implementations§

source§

impl Client

source

pub async fn generate_one_keypackage_from_credential_bundle( &self, backend: &MlsCryptoProvider, cs: MlsCiphersuite, cb: &CredentialBundle, ) -> CryptoResult<KeyPackage>

Generates a single new keypackage

§Arguments
  • backend - the KeyStorage to load the keypackages from
§Errors

KeyStore and OpenMls errors

source

pub async fn request_key_packages( &self, count: usize, ciphersuite: MlsCiphersuite, credential_type: MlsCredentialType, backend: &MlsCryptoProvider, ) -> CryptoResult<Vec<KeyPackage>>

Requests count keying material to be present and returns a reference to it for the consumer to copy/clone.

§Arguments
§Errors

KeyStore and OpenMls errors

source

pub async fn valid_keypackages_count( &self, backend: &MlsCryptoProvider, ciphersuite: MlsCiphersuite, credential_type: MlsCredentialType, ) -> CryptoResult<usize>

Returns the count of valid, non-expired, unclaimed keypackages in store

source

pub async fn prune_keypackages( &self, backend: &MlsCryptoProvider, refs: &[KeyPackageRef], ) -> CryptoResult<()>

Prune the provided KeyPackageRefs from the keystore

Warning: Despite this API being public, the caller should know what they’re doing. Provided KeypackageRefs will be purged regardless of their expiration state, so please be wary of what you are doing if you directly call this API. This could result in still valid, uploaded keypackages being pruned from the system and thus being impossible to find when referenced in a future Welcome message.

source§

impl Client

source

pub async fn init( &self, identifier: ClientIdentifier, ciphersuites: &[MlsCiphersuite], backend: &MlsCryptoProvider, nb_key_package: usize, ) -> CryptoResult<()>

Initializes the client. If the client’s cryptographic material is already stored in the keystore, it loads it Otherwise, it is being created.

§Arguments
  • identifier - client identifier ; either a ClientId or a x509 certificate chain
  • ciphersuites - all ciphersuites this client is supposed to support
  • backend - the KeyStore and crypto provider to read identities from
§Errors

KeyStore and OpenMls errors can happen

source

pub async fn generate_raw_keypairs( &self, ciphersuites: &[MlsCiphersuite], backend: &MlsCryptoProvider, ) -> CryptoResult<Vec<ClientId>>

Initializes a raw MLS keypair without an associated client ID Returns a random ClientId to bind later in Client::init_with_external_client_id

§Arguments
  • ciphersuites - all ciphersuites this client is supposed to support
  • backend - the KeyStore and crypto provider to read identities from
§Errors

KeyStore and OpenMls errors can happen

source

pub async fn init_with_external_client_id( &self, client_id: ClientId, tmp_ids: Vec<ClientId>, ciphersuites: &[MlsCiphersuite], backend: &MlsCryptoProvider, ) -> CryptoResult<()>

Finalizes initialization using a 2-step process of uploading first a public key and then associating a new Client ID to that keypair

§Arguments
  • client_id - The client ID you have fetched from the MLS Authentication Service
  • tmp_ids - The temporary random client ids generated in the previous step Client::generate_raw_keypairs
  • ciphersuites - To initialize the Client with
  • backend - the KeyStore and crypto provider to read identities from

WARNING: You have absolutely NO reason to call this if you didn’t call Client::generate_raw_keypairs first. You have been warned!

source

pub async fn id(&self) -> CryptoResult<ClientId>

Retrieves the client’s client id. This is free-form and not inspected.

source

pub async fn is_e2ei_capable(&self) -> bool

Returns whether this client is E2EI capable

Trait Implementations§

source§

impl Clone for Client

source§

fn clone(&self) -> Client

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Client

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Client

source§

fn default() -> Client

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

source§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V