Skip to main content

Workspace

Struct Workspace 

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

Owns cryptographic state without exposing OpenMLS objects. Secret-bearing storage records are restricted to the trusted native persistence seam.

Implementations§

Source§

impl Workspace

Source

pub fn join_checkpoint(&self) -> Result<Vec<u8>, &'static str>

Public, signed MLS state containing the roster. Only distribute to authorized recipients; an invitation must bind its digest separately.

Source§

impl Workspace

Source

pub fn export_records(&self) -> Result<SecurityRecords, &'static str>

Local secret-bearing records. The storage adapter must atomically commit the complete change set with associated delivery state before adoption. No transport, database or host-language representation is selected here.

Source

pub fn restore_records( endpoint: [u8; 32], id: [u8; 32], records: &SecurityRecords, ) -> Result<Self, &'static str>

Restore only authenticated local records from the expected workspace and endpoint. This is not a decoder for unauthenticated peer-supplied state.

Source§

impl Workspace

Source

pub fn leave_action(&self) -> Result<ManagementAction, &'static str>

Sign a departure from this exact membership branch. Another admitted member must commit it; signing alone neither leaves nor changes keys.

Source

pub fn prepare_solo_leave(&self) -> Result<RemovedMembership, &'static str>

A one-member workspace has no peer to notify or remaining keys to rotate. Persist this terminal record before shutting down its local owner.

Source

pub fn provisional_copy(&self) -> Result<Workspace, &'static str>

Copy accepted state for one provisional operation without serializing it. Discard rejected candidates; persist an accepted candidate before adopting it or emitting its output. Never use copies as independent senders: their ratchets and counters start at the same position.

Source

pub fn prepare_management( &self, action: ManagementAction, ) -> Result<PreparedManagement, &'static str>

Source

pub fn prepare_management_update( &self, action: ManagementAction, commit: &[u8], ) -> Result<PreparedManagementUpdate, &'static str>

Stage verified management without changing this owner. Removal returns metadata without group keys, for replacement of the active saved record.

Source

pub fn verify_management( &self, action: ManagementAction, commit: &[u8], ) -> Result<(), &'static str>

Authenticate an exact public MLS management commit without changing this owner. The expected action is untrusted until it matches the signed commit. This checks one branch; it cannot establish global finality across partitions.

Source§

impl Workspace

Source

pub fn workspace_name(&self) -> Result<Option<String>, &'static str>

Source

pub fn workspace_name_head(&self) -> Result<[u8; 32], &'static str>

Source

pub fn workspace_name_revision(&self) -> Result<u64, &'static str>

Source

pub fn workspace_name_missing_history(&self) -> Result<u64, &'static str>

Source

pub fn prepare_workspace_name( &self, name: &str, ) -> Result<PreparedWorkspaceName, &'static str>

Source

pub fn sign_workspace_name_checkpoint(&self) -> Result<Vec<u8>, &'static str>

Source

pub fn workspace_name_checkpoint(&self) -> Result<Option<Vec<u8>>, &'static str>

Source

pub fn prepare_workspace_name_checkpoint( &self, checkpoint: &[u8], ) -> Result<PreparedWorkspaceNameCheckpoint, &'static str>

Source

pub fn prepare_workspace_name_update( &self, record: &[u8], ) -> Result<Workspace, &'static str>

Accept exactly the next name on this branch. No caller may install a peer’s checkpoint over existing accepted state; only a new join has that baseline.

Source

pub fn next_workspace_name( &self, after: [u8; 32], ) -> Result<Option<Vec<u8>>, &'static str>

One bounded next record, regardless of how many changes the workspace has made.

Source§

impl Workspace

Source

pub fn member_roster(&self) -> Result<Vec<MemberIdentity>, &'static str>

Source

pub fn sign_member_profile(&self) -> Result<Vec<u8>, &'static str>

A stable chosen name, shareable only within this workspace. Rename ordering is not implemented; a valid signature alone would not prove the latest name.

Source

pub fn sign_service_profile(&self) -> Result<Vec<u8>, &'static str>

Source

pub fn verify_member_profile( &self, bytes: &[u8], ) -> Result<MemberProfile, &'static str>

Source§

impl Workspace

Source

pub fn protect_application( &mut self, context: &[u8], payload: &[u8], ) -> Result<Vec<u8>, &'static str>

Advances the sender ratchet. The host must persist the updated workspace before sending the returned ciphertext or preparing another publication. On any error, close this owner and restore its last committed snapshot. Retrying delivery uses the SAME ciphertext, never re-encryption from old state.

Source

pub fn unprotect_application( &mut self, context: &[u8], ciphertext: &[u8], ) -> Result<ApplicationMessage, &'static str>

Authenticates an application message and advances replay/receive state. The host must persist before delivering the returned plaintext. On any error discard this owner and restore committed state: rejection can occur after the library has consumed a receive-ratchet generation. Context must be the canonical expected routing envelope, not an unchecked copy of the incoming message’s AAD. This does not grant topic permissions.

Source§

impl Workspace

Source

pub fn protect_object( &mut self, context: &[u8], payload: &[u8], ) -> Result<Vec<u8>, &'static str>

Host MUST durably save the resulting owner before releasing this object. Retries resend the exact object. Never restore an older committed sender state to retry encryption. On error discard the candidate, as with MLS.

Source

pub fn unprotect_object( &self, context: &[u8], object: &[u8], ) -> Result<AuthenticatedObject, &'static str>

Authenticate using the CURRENT accepted epoch/roster only. Does not import historical epochs, mutate a ratchet or suppress replay. The delivery layer must atomically record acceptance and pending application work before use.

Source§

impl Workspace

Source

pub fn sign_current_view( &self, context: &[u8], body: &[u8], ) -> Result<Vec<u8>, &'static str>

Sign current-view metadata without advancing application encryption state. The encrypted transport still controls who can obtain the statement.

Source

pub fn verify_current_view<'a>( &self, authority: [u8; 32], context: &[u8], signed: &'a [u8], ) -> Result<&'a [u8], &'static str>

Verify the statement against one current workspace member selected by the locally established query. Authorization to request it is checked outside.

Source

pub fn recovery_cutoff_request( &self, peer: [u8; 32], selection: [u8; 32], policy_revision: u64, ) -> Result<RecoveryCutoffRequest, &'static str>

Build a caller-owned discovery request from an accepted peer credential. Fresh randomness is generated locally; never accept a network-supplied nonce.

Source

pub fn member_id_for_endpoint( &self, peer: [u8; 32], ) -> Result<[u8; 32], &'static str>

Resolve a workspace-facing endpoint through the current accepted roster.

Source

pub fn sign_recovery_cutoff( &self, request: &RecoveryCutoffRequest, head: u64, ) -> Result<Vec<u8>, &'static str>

Caller authorizes the requester and reads the head from adopted retention state. A head identifies a cutoff only, never complete or available history.

Source

pub fn sign_recovery_window( &self, request: &RecoveryCutoffRequest, after: u64, head: u64, ) -> Result<Vec<u8>, &'static str>

Signed retention boundary for the requested selection, not delivery coverage.

Source

pub fn verify_recovery_cutoff( &self, expected: &RecoveryCutoffRequest, bytes: &[u8], ) -> Result<u64, &'static str>

Verify current membership, caller-held nonce/selection/policy and exact framing before exposing the head. The caller consumes its nonce once; replaying the same request cannot establish another freshness observation.

Source

pub fn verify_recovery_window( &self, expected: &RecoveryCutoffRequest, bytes: &[u8], ) -> Result<(u64, u64), &'static str>

Source

pub fn sign_recovery_offer( &self, request: &RecoveryRequest, packets: &[(&[u8], &[u8])], ) -> Result<Vec<u8>, &'static str>

Sign the exact packet set selected by this author’s retained index. The host must establish coverage independently; this method cannot infer it from ciphertext. No claim of current/latest coverage beyond the request. Offers expose metadata and require an authorized encrypted channel.

Source

pub fn verify_recovery_offer<'a>( &'a self, expected: &RecoveryRequest, bytes: &[u8], ) -> Result<VerifiedRecoveryOffer<'a>, &'static str>

Verify against current accepted membership and a locally established request. Signature checks do not authorize topic access or old epochs.

Source§

impl Workspace

Source

pub fn checkpoint_for_invitation( &self, requester: [u8; 32], responder: [u8; 32], request: &[u8], ) -> Result<Vec<u8>, &'static str>

Serve only the exact current checkpoint to a holder of this invitation.

Source

pub fn admission_history( &self, remote_endpoint: [u8; 32], request: &[u8], checkpoint: &[u8], ) -> Result<Vec<(AdmissionAuthorization, Vec<u8>)>, &'static str>

Verify the invitation holder and reconstruct the exact accepted branch from its pinned checkpoint before admitting or replying. Missing history is an error; it must not become a new Add with an unusable Welcome.

Source

pub fn check_membership_history( &self, remote_endpoint: [u8; 32], request: &[u8], checkpoint: &[u8], ) -> Result<(), &'static str>

Whether this admission’s pinned history can be served, without building the history. Admission intake only needs the answer; only the reply path needs the transitions, so intake does not pay to materialize and discard them.

Source

pub fn membership_history( &self, remote_endpoint: [u8; 32], request: &[u8], checkpoint: &[u8], ) -> Result<Vec<(MembershipAuthorization, Vec<u8>)>, &'static str>

Source

pub fn retained_admission( &self, remote_endpoint: [u8; 32], request: &[u8], ) -> Result<Option<AdmissionReply>, &'static str>

Look up a byte-identical retry from the authenticated endpoint. Only use this on the adopted, durably saved owner; this method does not perform I/O.

Source

pub fn issue_invitation(&self) -> Result<(Invitation, Vec<u8>), &'static str>

Returns a secret bearer token owner and the public checkpoint it pins. Checkpoint distribution/retention is part of invitation handoff.

Source

pub fn prepare_invitation( &self, expires_at: u64, personal: bool, automatic: bool, ) -> Result<(PreparedManagement, Invitation, Vec<u8>), &'static str>

Register a reusable link in shared policy before releasing its bearer token. The caller must persist the returned workspace before sharing.

Source

pub fn prepare_request_invitation( &self, expires_at: u64, ) -> Result<(PreparedManagement, Invitation, Vec<u8>), &'static str>

Source

pub fn retain_invitation_checkpoint( &mut self, action: ManagementAction, grant: &[u8], checkpoint: &[u8], ) -> Result<(), &'static str>

Retain one admin-signed public checkpoint carried with its authenticated invitation-management transition. The bearer secret is never retained.

Source

pub fn retained_invitation_checkpoint( &self, action: &ManagementAction, ) -> Option<(&[u8], &[u8])>

Source

pub fn prepare_invitation_approval( &self, bytes: &[u8], ) -> Result<PreparedManagement, &'static str>

Source

pub fn prepare_invitation_decline( &self, bytes: &[u8], ) -> Result<PreparedManagement, &'static str>

Source

pub fn membership_update_for( &self, endpoint: [u8; 32], after: u64, ) -> Result<Option<(MembershipAuthorization, Vec<u8>)>, &'static str>

remote_endpoint MUST come from authenticated transport, not request JSON. The original owner is unchanged on both success and rejection. One retained update for an authenticated endpoint. Current members may retrieve history; a former member may retrieve only its own exact removal from a parent state that proves its binding, never subsequent roster data.

Source

pub fn admission_update_after( &self, epoch: u64, ) -> Option<(MembershipAuthorization, Vec<u8>)>

Return the next locally retained admission for an existing member’s epoch. None means this owner has no such retained step, not that the requester is current. The host must authorize the requester before sharing workspace metadata.

Source

pub fn prepare_admission_update( &self, authorization: &AdmissionAuthorization, commit: &[u8], ) -> Result<Workspace, &'static str>

Prepare an existing member’s next epoch from an authorized ordinary-member Add. Leaves this owner unchanged on success or failure. The caller must save the returned owner before adoption and resolve old-epoch pending delivery explicitly. This is not a policy-change, removal or concurrent-branch merge operation.

Source

pub fn prepare_admission_batch_update( &self, authorizations: &[AdmissionAuthorization], commit: &[u8], ) -> Result<Workspace, &'static str>

Prepare an existing member’s next epoch from a bounded batch Add.

Source

pub fn assess_admission( &self, remote_endpoint: [u8; 32], bytes: &[u8], ) -> Result<AdmissionAssessment, &'static str>

Authenticate and classify a request without creating an MLS commit. Hosts can retain this result while an owner queues the transition.

Source

pub fn prepare_admission( &self, remote_endpoint: [u8; 32], bytes: &[u8], ) -> Result<PreparedAdmission, &'static str>

Source

pub fn prepare_validated_admission( &self, remote_endpoint: [u8; 32], bytes: &[u8], request: &ValidatedAdmission, ) -> Result<PreparedAdmission, &'static str>

Prepare the commit from a request already authenticated by Workspace::assess_admission. The current workspace policy is still checked because a queued invitation may expire or be consumed first.

Source

pub fn prepare_validated_admission_batch( &self, admissions: &[([u8; 32], &[u8], &ValidatedAdmission)], ) -> Result<PreparedAdmissionBatch, &'static str>

Prepare one bounded MLS transition for already authenticated requests. Authentication and policy checks happen once per request; MLS state is cloned and advanced once for the whole batch.

Source§

impl Workspace

Source

pub fn invitation_controls( &self, ) -> Result<(bool, Vec<InvitationControl>), &'static str>

Source§

impl Workspace

Source

pub fn seal_with_attachment( &self, key: &StorageKey, attachment: &[u8], ) -> Result<Vec<u8>, &'static str>

One authenticated host record for security state and opaque local state. Host must atomically replace it before adopting state or releasing packets. This binds the bytes together; it does not validate the attachment’s meaning or prevent rollback to an older authentic record.

Source

pub fn restore_with_attachment( key: &StorageKey, endpoint: [u8; 32], id: [u8; 32], sealed: &[u8], ) -> Result<(Self, Zeroizing<Vec<u8>>), &'static str>

Authenticate the whole record before exposing either component. The caller must validate the attachment against the restored owner before adoption.

Source

pub fn seal(&self, key: &StorageKey) -> Result<Vec<u8>, &'static str>

Source

pub fn restore( key: &StorageKey, endpoint: [u8; 32], id: [u8; 32], sealed: &[u8], ) -> Result<Self, &'static str>

Source§

impl Workspace

Source

pub fn memory_report(&self) -> MemoryReport

Source

pub fn create_named( endpoint: [u8; 32], display_name: &str, workspace_name: Option<&str>, ) -> Result<Self, &'static str>

Source

pub fn create( endpoint: [u8; 32], display_name: &str, ) -> Result<Self, &'static str>

Source

pub fn member(&self) -> Option<&MemberProfile>

None identifies a legacy snapshot without a chosen member profile.

Source

pub fn id(&self) -> [u8; 32]

Source

pub fn endpoint(&self) -> [u8; 32]

This owner’s workspace-scoped transport identity, not a device-global ID.

Source

pub fn epoch(&self) -> u64

Source

pub fn epoch_fingerprint(&self) -> [u8; 32]

Compare accepted epochs between already authenticated workspace members. Equality is not authority, global finality, or a branch-merge decision.

Source

pub fn member_endpoints(&self) -> Result<Vec<[u8; 32]>, &'static str>

Verified workspace-facing transport endpoints for a routing projection. This is membership, not topic permission or a global device directory.

Source

pub fn endpoints_for_members( &self, members: &[[u8; 32]], ) -> Result<Vec<[u8; 32]>, &'static str>

Resolve a canonical direct recipient scope through the accepted roster. Endpoint keys are a transport result, never caller supplied authority.

Source

pub fn member_count(&self) -> usize

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