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
impl Workspace
Sourcepub fn export_records(&self) -> Result<SecurityRecords, &'static str>
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.
Sourcepub fn restore_records(
endpoint: [u8; 32],
id: [u8; 32],
records: &SecurityRecords,
) -> Result<Self, &'static str>
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
impl Workspace
Sourcepub fn leave_action(&self) -> Result<ManagementAction, &'static str>
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.
Sourcepub fn prepare_solo_leave(&self) -> Result<RemovedMembership, &'static str>
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.
Sourcepub fn provisional_copy(&self) -> Result<Workspace, &'static str>
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.
pub fn prepare_management( &self, action: ManagementAction, ) -> Result<PreparedManagement, &'static str>
Sourcepub fn prepare_management_update(
&self,
action: ManagementAction,
commit: &[u8],
) -> Result<PreparedManagementUpdate, &'static str>
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.
Sourcepub fn verify_management(
&self,
action: ManagementAction,
commit: &[u8],
) -> Result<(), &'static str>
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
impl Workspace
pub fn workspace_name(&self) -> Result<Option<String>, &'static str>
pub fn workspace_name_head(&self) -> Result<[u8; 32], &'static str>
pub fn workspace_name_revision(&self) -> Result<u64, &'static str>
pub fn workspace_name_missing_history(&self) -> Result<u64, &'static str>
pub fn prepare_workspace_name( &self, name: &str, ) -> Result<PreparedWorkspaceName, &'static str>
pub fn sign_workspace_name_checkpoint(&self) -> Result<Vec<u8>, &'static str>
pub fn workspace_name_checkpoint(&self) -> Result<Option<Vec<u8>>, &'static str>
pub fn prepare_workspace_name_checkpoint( &self, checkpoint: &[u8], ) -> Result<PreparedWorkspaceNameCheckpoint, &'static str>
Source§impl Workspace
impl Workspace
pub fn member_roster(&self) -> Result<Vec<MemberIdentity>, &'static str>
Sourcepub fn sign_member_profile(&self) -> Result<Vec<u8>, &'static str>
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.
pub fn sign_service_profile(&self) -> Result<Vec<u8>, &'static str>
pub fn verify_member_profile( &self, bytes: &[u8], ) -> Result<MemberProfile, &'static str>
Source§impl Workspace
impl Workspace
Sourcepub fn protect_application(
&mut self,
context: &[u8],
payload: &[u8],
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn unprotect_application(
&mut self,
context: &[u8],
ciphertext: &[u8],
) -> Result<ApplicationMessage, &'static str>
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
impl Workspace
Sourcepub fn protect_object(
&mut self,
context: &[u8],
payload: &[u8],
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn unprotect_object(
&self,
context: &[u8],
object: &[u8],
) -> Result<AuthenticatedObject, &'static str>
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
impl Workspace
Sourcepub fn sign_current_view(
&self,
context: &[u8],
body: &[u8],
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn verify_current_view<'a>(
&self,
authority: [u8; 32],
context: &[u8],
signed: &'a [u8],
) -> Result<&'a [u8], &'static str>
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.
Sourcepub fn recovery_cutoff_request(
&self,
peer: [u8; 32],
selection: [u8; 32],
policy_revision: u64,
) -> Result<RecoveryCutoffRequest, &'static str>
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.
Sourcepub fn member_id_for_endpoint(
&self,
peer: [u8; 32],
) -> Result<[u8; 32], &'static str>
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.
Sourcepub fn sign_recovery_cutoff(
&self,
request: &RecoveryCutoffRequest,
head: u64,
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn sign_recovery_window(
&self,
request: &RecoveryCutoffRequest,
after: u64,
head: u64,
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn verify_recovery_cutoff(
&self,
expected: &RecoveryCutoffRequest,
bytes: &[u8],
) -> Result<u64, &'static str>
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.
pub fn verify_recovery_window( &self, expected: &RecoveryCutoffRequest, bytes: &[u8], ) -> Result<(u64, u64), &'static str>
Sourcepub fn sign_recovery_offer(
&self,
request: &RecoveryRequest,
packets: &[(&[u8], &[u8])],
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn verify_recovery_offer<'a>(
&'a self,
expected: &RecoveryRequest,
bytes: &[u8],
) -> Result<VerifiedRecoveryOffer<'a>, &'static str>
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
impl Workspace
Sourcepub fn checkpoint_for_invitation(
&self,
requester: [u8; 32],
responder: [u8; 32],
request: &[u8],
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn admission_history(
&self,
remote_endpoint: [u8; 32],
request: &[u8],
checkpoint: &[u8],
) -> Result<Vec<(AdmissionAuthorization, Vec<u8>)>, &'static str>
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.
Sourcepub fn check_membership_history(
&self,
remote_endpoint: [u8; 32],
request: &[u8],
checkpoint: &[u8],
) -> Result<(), &'static str>
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.
pub fn membership_history( &self, remote_endpoint: [u8; 32], request: &[u8], checkpoint: &[u8], ) -> Result<Vec<(MembershipAuthorization, Vec<u8>)>, &'static str>
Sourcepub fn retained_admission(
&self,
remote_endpoint: [u8; 32],
request: &[u8],
) -> Result<Option<AdmissionReply>, &'static str>
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.
Sourcepub fn issue_invitation(&self) -> Result<(Invitation, Vec<u8>), &'static str>
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.
Sourcepub fn prepare_invitation(
&self,
expires_at: u64,
personal: bool,
automatic: bool,
) -> Result<(PreparedManagement, Invitation, Vec<u8>), &'static str>
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.
pub fn prepare_request_invitation( &self, expires_at: u64, ) -> Result<(PreparedManagement, Invitation, Vec<u8>), &'static str>
Sourcepub fn retain_invitation_checkpoint(
&mut self,
action: ManagementAction,
grant: &[u8],
checkpoint: &[u8],
) -> Result<(), &'static str>
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.
pub fn retained_invitation_checkpoint( &self, action: &ManagementAction, ) -> Option<(&[u8], &[u8])>
pub fn prepare_invitation_approval( &self, bytes: &[u8], ) -> Result<PreparedManagement, &'static str>
pub fn prepare_invitation_decline( &self, bytes: &[u8], ) -> Result<PreparedManagement, &'static str>
Sourcepub fn membership_update_for(
&self,
endpoint: [u8; 32],
after: u64,
) -> Result<Option<(MembershipAuthorization, Vec<u8>)>, &'static str>
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.
Sourcepub fn admission_update_after(
&self,
epoch: u64,
) -> Option<(MembershipAuthorization, Vec<u8>)>
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.
Sourcepub fn prepare_admission_update(
&self,
authorization: &AdmissionAuthorization,
commit: &[u8],
) -> Result<Workspace, &'static str>
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.
Sourcepub fn prepare_admission_batch_update(
&self,
authorizations: &[AdmissionAuthorization],
commit: &[u8],
) -> Result<Workspace, &'static str>
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.
Sourcepub fn assess_admission(
&self,
remote_endpoint: [u8; 32],
bytes: &[u8],
) -> Result<AdmissionAssessment, &'static str>
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.
pub fn prepare_admission( &self, remote_endpoint: [u8; 32], bytes: &[u8], ) -> Result<PreparedAdmission, &'static str>
Sourcepub fn prepare_validated_admission(
&self,
remote_endpoint: [u8; 32],
bytes: &[u8],
request: &ValidatedAdmission,
) -> Result<PreparedAdmission, &'static str>
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.
Sourcepub fn prepare_validated_admission_batch(
&self,
admissions: &[([u8; 32], &[u8], &ValidatedAdmission)],
) -> Result<PreparedAdmissionBatch, &'static str>
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
impl Workspace
pub fn invitation_controls( &self, ) -> Result<(bool, Vec<InvitationControl>), &'static str>
Source§impl Workspace
impl Workspace
Sourcepub fn seal_with_attachment(
&self,
key: &StorageKey,
attachment: &[u8],
) -> Result<Vec<u8>, &'static str>
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.
Sourcepub fn restore_with_attachment(
key: &StorageKey,
endpoint: [u8; 32],
id: [u8; 32],
sealed: &[u8],
) -> Result<(Self, Zeroizing<Vec<u8>>), &'static str>
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.
pub fn seal(&self, key: &StorageKey) -> Result<Vec<u8>, &'static str>
pub fn restore( key: &StorageKey, endpoint: [u8; 32], id: [u8; 32], sealed: &[u8], ) -> Result<Self, &'static str>
Source§impl Workspace
impl Workspace
pub fn memory_report(&self) -> MemoryReport
pub fn create_named( endpoint: [u8; 32], display_name: &str, workspace_name: Option<&str>, ) -> Result<Self, &'static str>
pub fn create( endpoint: [u8; 32], display_name: &str, ) -> Result<Self, &'static str>
Sourcepub fn member(&self) -> Option<&MemberProfile>
pub fn member(&self) -> Option<&MemberProfile>
None identifies a legacy snapshot without a chosen member profile.
pub fn id(&self) -> [u8; 32]
Sourcepub fn endpoint(&self) -> [u8; 32]
pub fn endpoint(&self) -> [u8; 32]
This owner’s workspace-scoped transport identity, not a device-global ID.
pub fn epoch(&self) -> u64
Sourcepub fn epoch_fingerprint(&self) -> [u8; 32]
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.
Sourcepub fn member_endpoints(&self) -> Result<Vec<[u8; 32]>, &'static str>
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.
Sourcepub fn endpoints_for_members(
&self,
members: &[[u8; 32]],
) -> Result<Vec<[u8; 32]>, &'static str>
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.
pub fn member_count(&self) -> usize
Auto Trait Implementations§
impl !Freeze for Workspace
impl Forget for Workspace
impl Move for Workspace
impl RefUnwindSafe for Workspace
impl Send for Workspace
impl Sync for Workspace
impl Unpin for Workspace
impl UnsafeUnpin for Workspace
impl UnwindSafe for Workspace
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> 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