Skip to main content

MlsClient

Struct MlsClient 

Source
pub struct MlsClient { /* private fields */ }
Expand description

One MLS identity + its groups. uniffi Object (Arc on the Kotlin/Swift side).

Implementations§

Source§

impl MlsClient

Source

pub fn sibling_sign( &self, gid: Vec<u8>, primary_member_id: Vec<u8>, device_member_id: Vec<u8>, ) -> Result<Vec<u8>, MlsError>

Sign the “sibling” link with our own leaf key. Our memberId must be one of the two (the phone signs as primary, the desktop as device). Group membership is not required: the desktop signs before joining; an MlsClient has one leaf key for its whole lifetime.

Source

pub fn sibling_verify( &self, gid: Vec<u8>, primary_member_id: Vec<u8>, device_member_id: Vec<u8>, primary_sig: Vec<u8>, device_sig: Vec<u8>, ) -> Result<bool, MlsError>

Verify the link against leaf keys in the CURRENT group tree: both leaves exist, carry these memberIds, and both signatures are valid.

Source§

impl MlsClient

Source

pub fn new(identity: Vec<u8>) -> Result<Arc<MlsClient>, MlsError>

Brand-new identity. identity = our stable per-group leaf id bytes (memberId).

Source

pub fn from_state(blob: Vec<u8>) -> Result<Arc<MlsClient>, MlsError>

Restore from a previously exported state blob (see [export_state]).

Source

pub fn spawn_same_identity(&self) -> Result<Arc<MlsClient>, MlsError>

Same leaf (memberId and Ed25519 signing key), but without groups or packages: for moving a group to another suite. The signing key is unchanged, so device-link (sibling) signatures still verify against the leaf keys of the new tree.

Source

pub fn export_state(&self) -> Result<Vec<u8>, MlsError>

Serialize the whole identity+groups for our SQLCipher store.

Source

pub fn signature_public_key(&self) -> Vec<u8> ⓘ

Our Ed25519 signature public key (identifies our leaf to peers).

Source

pub fn generate_key_package(&self) -> Result<Vec<u8>, MlsError>

Produce a fresh KeyPackage (serialized) to hand to whoever will add us to a group.

Source

pub fn generate_key_package_for(&self, suite: u16) -> Result<Vec<u8>, MlsError>

Key package in suite [suite] (mls_suite_legacy or mls_suite_xwing). The same leaf (memberId and signing key) can issue packages in both suites: the inviter picks the one that fits the group.

Source

pub fn group_ciphersuite(&self, gid: Vec<u8>) -> Result<u16, MlsError>

Group suite (RFC 9420 code).

Source

pub fn members_support( &self, gid: Vec<u8>, suite: u16, ) -> Result<bool, MlsError>

Whether all leaves of the group advertise support for [suite] (i.e. every member runs a core that supports it). The app uses this to decide whether the group can be moved to X-Wing.

Source

pub fn create_group(&self, gid: Vec<u8>) -> Result<(), MlsError>

Create a new group with our chosen 32-byte group id (gid). We become the single initial member (admin handled at the app layer, not by MLS).

Source

pub fn create_group_for(&self, gid: Vec<u8>, suite: u16) -> Result<(), MlsError>

New group in suite [suite]. No state may exist under the same gid in this client.

Source

pub fn add_members( &self, gid: Vec<u8>, key_packages: Vec<Vec<u8>>, ) -> Result<CommitBundle, MlsError>

Add members by their serialized KeyPackages → returns Commit (for existing members) + Welcome (for the new ones). We merge our own commit immediately.

Source

pub fn remove_members( &self, gid: Vec<u8>, leaf_indices: Vec<u32>, ) -> Result<Vec<u8>, MlsError>

Remove members by leaf index → Commit to fan out. We merge our own commit.

Source

pub fn update_keys(&self, gid: Vec<u8>) -> Result<Vec<u8>, MlsError>

Plain rekey (post-compromise security) with no membership change → Commit.

Source

pub fn process_welcome( &self, welcome_bytes: Vec<u8>, ) -> Result<Vec<u8>, MlsError>

Join a group from a Welcome we received → returns the group id we joined.

Source

pub fn encrypt( &self, gid: Vec<u8>, plaintext: Vec<u8>, ) -> Result<Vec<u8>, MlsError>

Encrypt an application payload (chat message / control) for the group.

Source

pub fn process_incoming( &self, gid: Vec<u8>, message: Vec<u8>, ) -> Result<Incoming, MlsError>

Feed an inbound MLS message to a group: decrypts application payloads and applies membership Commits. Classifies the outcome.

Source

pub fn process_incoming_with_sender( &self, gid: Vec<u8>, message: Vec<u8>, allowed_handshake_senders: Option<Vec<Vec<u8>>>, ) -> Result<IncomingWithSender, MlsError>

Same as process_incoming, plus the sender’s leaf (Application, Commit, Proposal from a member; None — external sender or the frame was not processed).

allowed_handshake_senders: if set, a Commit/Proposal is accepted only when the credential of the sender’s leaf (verified by OpenMLS) is in this list. Otherwise the Commit is NOT merged (the epoch does not advance) — CommitRejected, a Proposal — Ignored. This lets the app bind a Commit to the ML-DSA signer of the envelope: a member with a valid PQ signature of their own cannot push through another leaf’s Commit. None — no check, as before. Application messages are not restricted by this list (their leaf is checked by the app).

Source

pub fn export_secret( &self, gid: Vec<u8>, label: String, length: u32, ) -> Result<Vec<u8>, MlsError>

Derive a fresh symmetric secret bound to the current epoch (e.g. a conference media key). Rotates automatically every time the group rekeys.

Source

pub fn epoch(&self, gid: Vec<u8>) -> Result<u64, MlsError>

Current epoch number (advances on every membership change / rekey).

Source

pub fn members(&self, gid: Vec<u8>) -> Result<Vec<MemberInfo>, MlsError>

Member identities (leaf credential bytes = memberIds) + their leaf indices.

Source

pub fn leaf_limit(&self, gid: Vec<u8>) -> Result<u32, MlsError>

How many leaves the group may have right now: 100 if all leaves run the new core (the MULTI_DEVICE_CAPABILITY marker), otherwise 20. The app uses this to decide whether desktops can be added: if they do not fit into 20 leaves and someone is still on an old version, wait.

Source

pub fn own_leaf_marked(&self, gid: Vec<u8>) -> Result<bool, MlsError>

Whether our leaf carries the new-core marker. If not, run update_keys (rekey) and send the Commit: after it the leaf advertises the marker.

Trait Implementations§

Source§

impl<UT> LiftRef<UT> for MlsClient

Source§

impl<UT> LowerError<UT> for MlsClient

Source§

fn lower_error(obj: Self) -> RustBuffer

Lower this value for scaffolding function return Read more
Source§

impl<UT> LowerReturn<UT> for MlsClient

Source§

type ReturnType = <Arc<MlsClient> as LowerReturn<UniFfiTag>>::ReturnType

The type that should be returned by scaffolding functions for this type. Read more
Source§

fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>

Lower the return value from an scaffolding call Read more
Source§

fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>

Lower the return value for failed argument lifts Read more
Source§

impl<UT> TypeId<UT> for MlsClient

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

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

Create a new handle for an Arc value Read more
Source§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
Source§

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

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

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

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

Source§

fn vzip(self) -> V