pub struct MlsClient { /* private fields */ }Expand description
One MLS identity + its groups. uniffi Object (Arc on the Kotlin/Swift side).
Implementations§
Source§impl MlsClient
impl MlsClient
Sourcepub fn sibling_sign(
&self,
gid: Vec<u8>,
primary_member_id: Vec<u8>,
device_member_id: Vec<u8>,
) -> Result<Vec<u8>, MlsError>
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.
Sourcepub 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>
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
impl MlsClient
Sourcepub fn new(identity: Vec<u8>) -> Result<Arc<MlsClient>, MlsError>
pub fn new(identity: Vec<u8>) -> Result<Arc<MlsClient>, MlsError>
Brand-new identity. identity = our stable per-group leaf id bytes (memberId).
Sourcepub fn from_state(blob: Vec<u8>) -> Result<Arc<MlsClient>, MlsError>
pub fn from_state(blob: Vec<u8>) -> Result<Arc<MlsClient>, MlsError>
Restore from a previously exported state blob (see [export_state]).
Sourcepub fn spawn_same_identity(&self) -> Result<Arc<MlsClient>, MlsError>
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.
Sourcepub fn export_state(&self) -> Result<Vec<u8>, MlsError>
pub fn export_state(&self) -> Result<Vec<u8>, MlsError>
Serialize the whole identity+groups for our SQLCipher store.
Sourcepub fn signature_public_key(&self) -> Vec<u8> ⓘ
pub fn signature_public_key(&self) -> Vec<u8> ⓘ
Our Ed25519 signature public key (identifies our leaf to peers).
Sourcepub fn generate_key_package(&self) -> Result<Vec<u8>, MlsError>
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.
Sourcepub fn generate_key_package_for(&self, suite: u16) -> Result<Vec<u8>, MlsError>
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.
Sourcepub fn group_ciphersuite(&self, gid: Vec<u8>) -> Result<u16, MlsError>
pub fn group_ciphersuite(&self, gid: Vec<u8>) -> Result<u16, MlsError>
Group suite (RFC 9420 code).
Sourcepub fn members_support(
&self,
gid: Vec<u8>,
suite: u16,
) -> Result<bool, MlsError>
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.
Sourcepub fn create_group(&self, gid: Vec<u8>) -> Result<(), MlsError>
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).
Sourcepub fn create_group_for(&self, gid: Vec<u8>, suite: u16) -> Result<(), MlsError>
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.
Sourcepub fn add_members(
&self,
gid: Vec<u8>,
key_packages: Vec<Vec<u8>>,
) -> Result<CommitBundle, MlsError>
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.
Sourcepub fn remove_members(
&self,
gid: Vec<u8>,
leaf_indices: Vec<u32>,
) -> Result<Vec<u8>, MlsError>
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.
Sourcepub fn update_keys(&self, gid: Vec<u8>) -> Result<Vec<u8>, MlsError>
pub fn update_keys(&self, gid: Vec<u8>) -> Result<Vec<u8>, MlsError>
Plain rekey (post-compromise security) with no membership change → Commit.
Sourcepub fn process_welcome(
&self,
welcome_bytes: Vec<u8>,
) -> Result<Vec<u8>, MlsError>
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.
Sourcepub fn encrypt(
&self,
gid: Vec<u8>,
plaintext: Vec<u8>,
) -> Result<Vec<u8>, MlsError>
pub fn encrypt( &self, gid: Vec<u8>, plaintext: Vec<u8>, ) -> Result<Vec<u8>, MlsError>
Encrypt an application payload (chat message / control) for the group.
Sourcepub fn process_incoming(
&self,
gid: Vec<u8>,
message: Vec<u8>,
) -> Result<Incoming, MlsError>
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.
Sourcepub fn process_incoming_with_sender(
&self,
gid: Vec<u8>,
message: Vec<u8>,
allowed_handshake_senders: Option<Vec<Vec<u8>>>,
) -> Result<IncomingWithSender, MlsError>
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).
Sourcepub fn export_secret(
&self,
gid: Vec<u8>,
label: String,
length: u32,
) -> Result<Vec<u8>, MlsError>
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.
Sourcepub fn epoch(&self, gid: Vec<u8>) -> Result<u64, MlsError>
pub fn epoch(&self, gid: Vec<u8>) -> Result<u64, MlsError>
Current epoch number (advances on every membership change / rekey).
Sourcepub fn members(&self, gid: Vec<u8>) -> Result<Vec<MemberInfo>, MlsError>
pub fn members(&self, gid: Vec<u8>) -> Result<Vec<MemberInfo>, MlsError>
Member identities (leaf credential bytes = memberIds) + their leaf indices.
Sourcepub fn leaf_limit(&self, gid: Vec<u8>) -> Result<u32, MlsError>
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.
Trait Implementations§
Source§impl<UT> LowerError<UT> for MlsClient
impl<UT> LowerError<UT> for MlsClient
Source§fn lower_error(obj: Self) -> RustBuffer
fn lower_error(obj: Self) -> RustBuffer
Source§impl<UT> LowerReturn<UT> for MlsClient
impl<UT> LowerReturn<UT> for MlsClient
Source§type ReturnType = <Arc<MlsClient> as LowerReturn<UniFfiTag>>::ReturnType
type ReturnType = <Arc<MlsClient> as LowerReturn<UniFfiTag>>::ReturnType
Source§fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
fn lower_return(obj: Self) -> Result<Self::ReturnType, RustCallError>
Source§fn handle_failed_lift(
error: LiftArgsError,
) -> Result<Self::ReturnType, RustCallError>
fn handle_failed_lift( error: LiftArgsError, ) -> Result<Self::ReturnType, RustCallError>
Auto Trait Implementations§
impl !Freeze for MlsClient
impl Forget for MlsClient
impl Move for MlsClient
impl RefUnwindSafe for MlsClient
impl Send for MlsClient
impl Sync for MlsClient
impl Unpin for MlsClient
impl UnsafeUnpin for MlsClient
impl UnwindSafe for MlsClient
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
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