Skip to main content

MlsService

Struct MlsService 

Source
pub struct MlsService<S: DeMlsStorage> { /* private fields */ }
Expand description

Main MLS service - unified API for all MLS operations.

Groups are managed internally by group ID string. The service handles:

  • Identity initialization and management
  • Key package generation
  • Group creation and joining
  • Message encryption and decryption
  • Steward commit operations

Implementations§

Source§

impl<S> MlsService<S>
where S: DeMlsStorage<MlsStorage = MemoryStorage>,

Source

pub fn new(storage: S) -> Self

Create a new MLS service with the given storage backend.

Source

pub fn init(&self, wallet: Address) -> Result<()>

Initialize identity from wallet address.

Creates MLS credentials and signing keys from the wallet address. Call this once before using any other methods.

Source

pub fn wallet_hex(&self) -> String

Get the wallet address as a checksummed hex string (“0x…”).

Source

pub fn generate_key_package(&self) -> Result<KeyPackageBytes>

Generate a key package for joining a group.

Key packages are single-use and should be regenerated after each join.

Source

pub fn create_group(&self, group_id: &str) -> Result<()>

Create a new MLS group.

The group name becomes the MLS group ID. The creator becomes the only member and is typically the steward.

Source

pub fn join_group(&self, welcome_bytes: &[u8]) -> Result<String>

Join a group from a welcome message.

Returns the group ID on success. The welcome must be for us (contain one of our key package references).

Source

pub fn is_welcome_for_us(&self, welcome_bytes: &[u8]) -> Result<bool>

Check if a welcome message is for us (without joining).

Returns true if the welcome contains one of our key package references.

Source

pub fn members(&self, group_id: &str) -> Result<Vec<Vec<u8>>>

Get all current group members as wallet addresses.

Source

pub fn encrypt(&self, group_id: &str, plaintext: &[u8]) -> Result<Vec<u8>>

Encrypt an application message for the group.

Returns MLS ciphertext that only group members can decrypt.

Source

pub fn decrypt( &self, group_id: &str, ciphertext: &[u8], ) -> Result<DecryptResult>

Decrypt/process an inbound MLS message.

Handles application messages, proposals, and commits.

Source

pub fn commit( &self, group_id: &str, updates: &[GroupUpdate], ) -> Result<CommitResult>

Create proposals for membership changes and commit them.

This is the core steward operation: takes a list of add/remove operations, creates MLS proposals, and commits them in a batch.

Auto Trait Implementations§

§

impl<S> !Freeze for MlsService<S>

§

impl<S> RefUnwindSafe for MlsService<S>
where S: RefUnwindSafe,

§

impl<S> Send for MlsService<S>

§

impl<S> Sync for MlsService<S>

§

impl<S> Unpin for MlsService<S>
where S: Unpin,

§

impl<S> UnwindSafe for MlsService<S>
where S: UnwindSafe,

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

Source§

type Classified = T

Source§

fn classify(self) -> T

Source§

impl<T> Declassify for T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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 = 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.
Source§

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

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more