Skip to main content

OpenMlsAuthority

Struct OpenMlsAuthority 

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

An AlbumAuthority backed by a live OpenMLS group pinned to PINNED_CIPHERSUITE.

One instance owns one album’s group as seen by one device. Its epoch ledger is produced by real MLS commits (self-update, add, remove) and Welcome processing; every verify_asset answer is read from live MLS state, never a server assertion.

Implementations§

Source§

impl OpenMlsAuthority

Source

pub fn reconcile_with_server( &mut self, view: ServerChainView, ) -> Result<ReconcileOutcome, OpenMlsAuthorityError>

Bring this member current against the server-authoritative chain, reporting what happened as a ReconcileOutcome. The single reconciliation entry point (not a per-failure-mode call):

  • UpToDate — nothing to do;
  • Reconciled — the member was behind and replayed the missed commits (the server-authoritative state);
  • Diverged — the member is ahead with an honestly-lost commit (surfaced to the user; the LostCommitTracker drives the actual re-submit), never silently merged;
  • Unrecoverable — a provable fork, or a missed commit that will not apply (e.g. this member was removed) — re-bootstrap.
Source

pub fn rekey_group( &mut self, ids: IdSource<'_>, reason: RekeyReason, ) -> Result<RekeyOutcome, OpenMlsAuthorityError>

The full group re-keying ceremony (mls-resilience.md § Group re-keying ceremony): mint a fresh epoch (new AMK + write-tier key) for the whole group as one intent_id-keyed operation, and prepare the fresh epoch’s broadcast. Epoch rotation is the primitive; this is the doc-specified orchestration. Assets are not re-encrypted (content-addressed; prior AMKs are retained for reading history) — the ceremony re-attests the fresh epoch’s write-tier and re-broadcasts the fresh AMK, which is what makes pre-compromise keys useless post-rekey.

Source

pub fn begin_rekey( &mut self, ids: IdSource<'_>, reason: RekeyReason, ) -> Result<(Uuid, MlsMessageOut), OpenMlsAuthorityError>

Phase 1 of the re-key: mint the fresh epoch via a self-update commit (fresh epoch secrets ⇒ fresh AMK, fresh minted write-tier), record the resume state, and return the commit for the other members. The single commit is the atomic cutover — until a member applies it, the album stays on the prior epoch, so a partial run never leaves two live write-tier keys.

Source

pub fn finish_rekey( &mut self, ) -> Result<Vec<MlsMessageOut>, OpenMlsAuthorityError>

Phase 2 of the re-key: broadcast the fresh epoch’s AMK + write-tier private half and clear the resume state. Idempotent — resuming after the intent already completed is a no-op returning no messages. The commit is not re-produced here (it merged in phase 1), so a resume after a crash never advances the epoch a second time.

Source

pub fn resume_rekey( &mut self, ) -> Result<Option<Vec<MlsMessageOut>>, OpenMlsAuthorityError>

Resume an interrupted re-key on restart (crash-resume): if a re-key was mid-flight (begin_rekey ran but finish_rekey did not), complete phase 2; otherwise None. The intent_id guarantees the epoch is never advanced a second time.

Source

pub fn rekey_in_progress(&self) -> bool

Whether a re-key is mid-flight (its commit merged but its broadcast not yet sent).

Source§

impl OpenMlsAuthority

Source

pub fn propose_upgrade( &mut self, ids: IdSource<'_>, from_protocol_version: impl Into<String>, from_suite_id: u16, to_protocol_version: impl Into<String>, to_suite_id: u16, deadline: SignedDuration, ) -> Result<UpgradeProposal, OpenMlsAuthorityError>

Step 1 (admin). Issue a hybrid-signed UpgradeIntent and enter upgrade quiescence. The intent_id is minted here, a UUIDv7 from ids. Returns the signed intent + the MLS application message to broadcast to the other members. Refused if the album is already tombstoned or already quiescing under another intent.

Source

pub fn receive_upgrade_intent( &mut self, message: MlsMessageIn, directory: &DeviceDirectory, ) -> Result<SignedUpgradeIntent, OpenMlsAuthorityError>

Step 1/2 (member). Process a broadcast UpgradeIntent: verify the proposer’s DSK hybrid signature against directory, then enter quiescence. Rejects a different intent while one is already in flight (only one upgrade per album); a re-receipt of the same intent is idempotent. Returns the verified signed intent.

Source

pub fn queue_pending_write( &mut self, encoded_write: Vec<u8>, ) -> Result<(), OpenMlsAuthorityError>

Queue a write locally during upgrade quiescence (pending_until_upgrade). The caller owns the opaque encoding; the writes are handed back by take_pending_writes after cutover for re-encoding against the fork’s to_version. Refused if not quiescing.

Source

pub fn take_pending_writes(&mut self) -> Vec<Vec<u8>>

Drain the locally-queued pending_until_upgrade writes (for replay into the fork). Draining is the caller’s cue to re-encode each against the fork’s to_version and replay it.

Source

pub fn frozen_state_hash( &self, summary: &AlbumStateSummary, ) -> Result<Hash32, OpenMlsAuthorityError>

The album’s frozen_state_hash over its full state: the album id, the sorted member list (from live MLS group state), and the caller’s AlbumStateSummary. Suite-fixed SHA-256.

Source

pub fn commit_tombstone( &mut self, summary: &AlbumStateSummary, ) -> Result<TombstoneOutcome, OpenMlsAuthorityError>

Step 4 (admin). Freeze the album with an AlbumTombstone commit: compute the frozen_state_hash over summary, attach it (with the terminal epoch’s write-tier attestation) to the commit’s authenticated data, advance the group one terminal epoch, and mark the album tombstoned. Requires an in-flight quiescence (propose_upgrade).

Source

pub fn process_tombstone( &mut self, message: MlsMessageIn, summary: &AlbumStateSummary, ) -> Result<(), OpenMlsAuthorityError>

Step 4 (member). Process a received AlbumTombstone commit: recompute frozen_state_hash over this member’s own summary and compare it to the committed mark. On mismatch the upgrade aborts cleanly — the staged commit is dropped, the album stays at its prior epoch and normal operation (FrozenStateMismatch). On match, the freeze is adopted (album tombstoned). Idempotent for a re-delivered tombstone of an already-frozen album.

Source

pub fn fork_upgrade( admin_identity: MlsDeviceIdentity, new_album_id: Uuid, lineage: UpgradeLineage, history_policy: HistoryPolicy, ) -> Result<OpenMlsAuthority, OpenMlsAuthorityError>

Step 5. Found the fork: a fresh MLS album group at new_album_id and the target version, minting AMK_v1 + a fresh write-tier key (via create_album), and recording the upgraded_from continuity pointer. Members are then migrated with the standard add_member / join_via_welcome flow. Assets are not re-encrypted — the fork references the existing ciphertext by content hash.

Source

pub fn is_tombstoned(&self) -> Option<Uuid>

The upgrade intent_id this album was tombstoned under, or None if it is live.

Source

pub fn upgraded_from(&self) -> Option<&UpgradeLineage>

The upgraded_from continuity pointer, if this album is a fork produced by an upgrade.

Source

pub fn quiescing_intent(&self) -> Option<Uuid>

The intent_id of an in-flight upgrade quiescence, or None.

Source

pub fn has_completed_intent(&self, intent_id: Uuid) -> bool

Whether a ceremony intent_id has already completed on this authority (idempotency ledger).

Source§

impl OpenMlsAuthority

Source

pub fn create_album( identity: MlsDeviceIdentity, album_id: Uuid, history_policy: HistoryPolicy, ) -> Result<Self, OpenMlsAuthorityError>

Found a new album: create the MLS group for album_id with identity as its first (admin) member, at the pinned X-Wing ciphersuite, and attest the genesis epoch (amk_version = 1, MLS epoch 0). Mints the epoch-1 write-tier key and AMK; the AMK is held locally (the founder authored the epoch). history_policy is fixed for the album here.

Source

pub fn create_self_group( ids: IdSource<'_>, album_id: Uuid, ) -> Result<Self, OpenMlsAuthorityError>

Create a fresh single-member (self) album group with a freshly-generated device identity and the default HistoryPolicy::Full. This is the single-member entry point, kept for the offline/parity surface; multi-member ceremonies use create_album with an explicit MlsDeviceIdentity. The identity’s user and device ids are UUIDv7s minted from ids.

Source

pub fn add_member( &mut self, key_package: KeyPackage, joiner_directory: &DeviceDirectory, ) -> Result<AddOutcome, OpenMlsAuthorityError>

Add a device (a new user’s device, or an existing user’s new device) to the album.

Verifies the KeyPackage’s hybrid LeafNode identity binding against joiner_directory first — a leaf whose Ed25519 MLS key is not covered by the device DSK’s Ed25519 and ML-DSA identity signature is rejected before any group mutation. Then runs the MLS Add proposal + Commit, advancing to a fresh epoch, and prepares the in-band key delivery: the new epoch’s AMK for existing members, and the joiner’s history batch per the album’s fixed HistoryPolicy (never a per-add choice — SSoT: MLS § History Delivery).

Source

pub fn remove_member( &mut self, leaf: LeafNodeIndex, ) -> Result<RemoveOutcome, OpenMlsAuthorityError>

Remove a device from the album by its leaf index and re-key: the MLS Remove + Commit advances to a fresh epoch whose new AMK and write-tier key the removed device does not hold, so it cannot read or write future epochs. The removed device cannot even process the commit (it is evicted). Prepares the fresh AMK’s AlbumKeyDistribution for the remaining members (SSoT: MLS § Remove user).

Source

pub fn leaf_index_of_device(&self, device_id: Uuid) -> Option<LeafNodeIndex>

The leaf index of the member whose LeafNode binding names device_id, or None. Convenience for driving a remove_member by device rather than by raw leaf index.

Source

pub fn leaf_indices_of_user(&self, user_id: Uuid) -> Vec<LeafNodeIndex>

Every leaf index whose LeafNode binding names user_id — a user’s whole device set in this album, which is the unit a per-user block removes. Sorted, so the removal is deterministic; empty when the user is not a member.

Reads the same hybrid identity binding leaf_index_of_device does, so a leaf that never passed verify_leaf_binding cannot smuggle in a user_id.

Source

pub fn block_user( &mut self, user_id: Uuid, ) -> Result<BlockOutcome, OpenMlsAuthorityError>

Block a user from this album: remove all of their devices in one MLS Remove + Commit and bump the AMK epoch, so the blocked user loses read access to every future epoch and their write-tier capability is rotated out from under them.

This is the crypto half of the moderation doc’s per-user block; the server-visible half (revoking the blocker’s album_share rows) is enforced independently, so a block is complete only when both have run. Per the design, prior epochs’ keys the blocked user already holds are not clawed back — assets they could already read stay readable, which is the same removal semantics as any remove_member.

Blocking a user who is not a member is a no-op, not an error: it reports BlockOutcome::already_absent with the unchanged epoch and no commit. That makes the ceremony idempotent, which matters because the server-side block row is itself idempotent and a retry must not burn an epoch (and a spurious epoch bump would strand every honest concurrent uploader in the pending window for nothing).

Refuses to block the local user: a device cannot evict itself from its own group, and silently succeeding would leave the caller believing a block took effect.

Source

pub fn advance_epoch( &mut self, amk_present: bool, ) -> Result<AmkVersion, OpenMlsAuthorityError>

Advance to a fresh epoch via a self-update commit (the scheduled-rotation ceremony): the RFC 9420 ratchet moves forward (new epoch secrets ⇒ new AMK + write-tier key), the ceiling bumps by one. amk_present records whether this epoch’s AMK is locally delivered — true in the committer’s own view. Returns the new amk_version.

This is the single-member rotation. For the multi-member rotation that also broadcasts the fresh AMK to the other members, use rotate_epoch.

Source

pub fn rotate_epoch(&mut self) -> Result<RemoveOutcome, OpenMlsAuthorityError>

Scheduled rotation as a ceremony: advance_epoch(true) plus the commit and the fresh epoch’s AlbumKeyDistribution for the other members.

Source

pub fn stage_self_update( &mut self, ) -> Result<MlsMessageOut, OpenMlsAuthorityError>

Stage a self-update commit without merging it, returning the commit for the other members. Mints (and stashes) the prospective epoch’s write-tier keypair; the group holds the pending commit until merge_pending (won) or discard_pending_and_process (lost — the stashed keypair is dropped with the commit).

Source

pub fn merge_pending(&mut self) -> Result<AmkVersion, OpenMlsAuthorityError>

Merge this member’s own staged pending commit — the “my commit won” path. Advances the epoch, holds the fresh AMK, and installs the write-tier keypair minted at staging.

Source

pub fn discard_pending_and_process( &mut self, winning_commit: MlsMessageIn, ) -> Result<AmkVersion, OpenMlsAuthorityError>

Discard this member’s own staged pending commit and process the winning peer’s commit instead — the “my commit lost, rebase” path. Leaves this member converged on the peer’s epoch with no divergence; the write-tier keypair minted at staging is dropped (its epoch never existed on the chain).

Source

pub fn process_commit( &mut self, message: MlsMessageIn, ) -> Result<AmkVersion, OpenMlsAuthorityError>

Process a peer’s commit (add / remove / self-update) delivered over the group channel: merge it, advancing this member’s view to the new epoch. The commit’s authenticated AAD attests the fresh epoch’s write-tier public key (installed immediately, so verify_asset can check the epoch’s manifests); the AMK and the write-tier private half are both pending until their AlbumKeyDistribution / WriteTierDistribution deliveries arrive via process_key_delivery. Returns the new amk_version.

A member removed by this commit is evicted: OpenMLS marks the group inactive and this returns the merged (now-inactive) state.

Source

pub fn process_key_delivery( &mut self, message: MlsMessageIn, ) -> Result<(), OpenMlsAuthorityError>

Apply an in-band key-delivery application message — an AlbumKeyDistribution (a single epoch’s AMK, flipping it from pending to present), a WriteTierDistribution (the epoch’s write-tier private half, granting signing capability), or an AlbumHistoryBundle (a joiner’s prior-epoch batch). This is the vehicle that closes the pending windows.

Source

pub fn join_via_welcome( identity: MlsDeviceIdentity, welcome_message: MlsMessageIn, history_messages: Vec<MlsMessageIn>, history_policy: HistoryPolicy, ) -> Result<Self, OpenMlsAuthorityError>

Join an album as a new member by processing a Welcome. Adopts the group, learns the album’s current epoch as its monotonic ceiling from the commit chain (never the server), derives + holds the current epoch’s AMK, then applies the committer’s history_messages (the AlbumHistoryBundle and current-epoch AlbumKeyDistribution) to populate the prior epochs its HistoryPolicy entitles it to.

history_policy is the album’s fixed policy, communicated to the joiner with the invite; binding it into the group’s context extension so it is cryptographically album-fixed (not merely conveyed) is a follow-up (see module docs).

Source

pub fn export_current_amk(&self) -> Result<[u8; 32], OpenMlsAuthorityError>

Export the AMK content key for the group’s current epoch from the RFC 9420 exporter. Deterministic for a fixed epoch; the album id is the exporter context so two albums never collide at the same epoch.

Source

pub fn identity(&self) -> &MlsDeviceIdentity

This device’s MLS participation identity.

Source

pub fn history_policy(&self) -> HistoryPolicy

The album’s fixed history policy.

Source

pub fn member_count(&self) -> usize

The number of members currently in the group.

Source

pub fn writers(&self) -> Vec<LeafNodeIndex>

The epoch’s writer set — the recipients of a WriteTierDistribution.

Roles seam: core has no roles model yet, so every member is a writer and this returns all leaves — which is what makes the group-encrypted application channel a faithful “writers-only” delivery today. When the roles model lands, this filter narrows to the role-holding leaves and build_write_tier_distribution’s send-path switches to per-writer delivery (the group channel is readable by every member, so a proper subset cannot ride it).

Source

pub fn amk(&self, epoch: AmkVersion) -> Option<[u8; 32]>

The cached AMK content key for epoch, or None if this member holds no state for it.

Source

pub fn mark_amk_present(&mut self, epoch: AmkVersion)

Mark an epoch’s AMK content key as locally delivered — mirrors ReferenceAuthority::mark_amk_present.

Source

pub fn write_tier_signing_key( &self, epoch: AmkVersion, ) -> Option<&HybridSigningKey>

The write-tier signing key for epoch — the private half a writer signs manifests with. None unless this member minted the key (committer) or received the epoch’s WriteTierDistribution: signing capability is never derivable from group state — no distribution, no sign-capable handle. Also None for a read-only prior epoch delivered through a join-time history bundle.

Source

pub fn current_write_tier(&self) -> &HybridSigningKey

The current (ceiling) epoch’s write-tier signing key — the one new writes are signed under.

Panics if this member holds no signing capability for the current epoch (its WriteTierDistribution has not arrived) — committer-side convenience; a receive-side caller must use write_tier_signing_key and treat None as “cannot write yet” (pending, analogous to has_amk).

Source

pub fn mls_epoch(&self) -> u64

The live MLS group epoch (u64). amk_version is always this plus one.

Source

pub fn ciphersuite(&self) -> Ciphersuite

The ciphersuite the group is actually running — asserted == PINNED_CIPHERSUITE in tests.

Source

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

Export the full durable group state to a self-contained byte blob: the OpenMLS storage keyspace (ratchet tree, epoch secrets, queued proposals, the leaf signer, key-package bundles) plus Capsule’s epoch ledger and this device’s identity. Round-trips through import_state. Where the blob is stored (a library.sqlite row, a file) is the caller’s lifecycle concern.

Source

pub fn import_state(bytes: &[u8]) -> Result<Self, OpenMlsAuthorityError>

Reconstruct an authority from an export_state blob.

Trait Implementations§

Source§

impl AlbumAuthority for OpenMlsAuthority

Source§

fn album_id(&self) -> Uuid

The album this authority speaks for.
Source§

fn epoch_ceiling(&self) -> AmkVersion

The monotonic epoch ceiling: the highest amk_version the admin chain attests. A manifest claiming a higher epoch is terminal-rejected (the server cannot fabricate a future epoch a client will honor).
Source§

fn write_tier_pubkey(&self, epoch: AmkVersion) -> Option<HybridVerifyingKey>

The write-tier public key for epoch, or None if the chain attests no such epoch. verify_asset checks the manifest’s write_sig against this key.
Source§

fn has_amk(&self, epoch: AmkVersion) -> bool

Whether the AMK content key for epoch is held locally. When an epoch is within the attested range but its AMK has not yet arrived over MLS, the asset is pending, not forged.
Source§

fn admin_chain_verifies(&self) -> bool

Whether the admin-signed attestation chain itself verifies. If this is false, the authority is untrusted and verify_asset must terminal-reject everything — an implementation must never trust an unsigned or forged ledger.
Source§

impl From<OpenMlsAuthority> for Authority

Available on crate feature mls only.
Source§

fn from(a: OpenMlsAuthority) -> Self

Converts to this type from the input type.

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
§

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

§

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.

§

impl<T> Instrument for T

§

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

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

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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

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 = 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

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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