// Copyright (c) 2024 Mozilla Corporation and contributors. // SPDX-License-Identifier: (Apache-2.0 OR MIT) /// /// Get the current epoch. /// pub type GroupContext = Vec; pub fn mls_group_context( _state: &PlatformState, _gid: &GroupId, _myself: &Identity, ) -> Result { unimplemented!() // return Json(GroupContext { // ... // }); } // TODO: Expose auditable pub struct PendingJoinState { identifier: Vec, } pub fn mls_group_process_welcome( pstate: &PlatformState, myself: &Identity, welcome: MlsMessage, ratchet_tree: Option>, ) -> Result { let client = pstate.client_default(myself)?; let (mut group, _info) = client.join_group(ratchet_tree, welcome)?; let gid = group.group_id().to_vec(); // Store the state group.write_to_storage()?; // Return the group identifier Ok(gid) } pub fn mls_group_inspect_welcome( pstate: &PlatformState, myself: &Identity, welcome: MlsMessage, ratchet_tree: Option>, ) -> Result { unimplemented!() } /// /// Leave a group. /// pub fn mls_group_propose_leave( pstate: PlatformState, gid: GroupId, myself: &Identity, ) -> Result { let mut group = pstate.client_default(myself)?.load_group(&gid)?; let self_index = group.current_member_index(); let proposal = group.propose_remove(self_index, vec![])?; Ok(proposal) } /// /// Import a group state into the storage /// pub fn mls_import_group_state( group_state: Vec, signature_key: SignatureKeypair, myself: SigningIdentity, ) -> Result<(), MlsError> { unimplemented!() // https://github.com/awslabs/mls-rs/blob/main/mls-rs/src/client.rs#L605 } /// /// Export a group state into the storage /// pub fn mls_export_group_state(gid: GroupId) -> Result, MlsError> { unimplemented!() } /// /// Validate a KeyPackage. /// pub fn validate_key_package(key_package: KeyPackage) -> Result<(), MlsError> { unimplemented!() } /// /// Extract Signing Identity from a KeyPackage. /// pub fn identity_from_key_package(key_package: KeyPackage) -> Result { unimplemented!() } /// Group configuration. /// /// This is more or less only for Ciphersuites and GroupContext extensions /// V8 - Update group context extensions /// Discuss: do we want to pass the version number explicitly to avoid compat problems with future versions ? (likely yes) /// /// # Parameters /// - `external_sender`: Availibility of the external sender extension /// - Default: None (We don't expose that) /// - `required_capabilities`: Needed to specify extensions /// - Option: None (Expose the ability to provide a 3-tuple of Vec) /// /// Note, external_sender is an Extension but other config options might be different pub fn mls_create_group_config( cs: CipherSuite, v: ProtocolVersion, options: ExtensionList, ) -> Result { Ok(GroupConfig { ciphersuite: cs, version: v, options, }) } /// Client configuration. /// /// V8 - We could require the library to update the client configuration at runtime /// Options: /// - WireFormatPolicy /// - Default: None (We don't expose that) /// - padding_size /// - Default: to some to complete the block to 64 bytes (pick a good value) /// - max_past_epochs /// - This is for application messages (cross-epoch) /// - Option: set the default some small value /// - number_of_resumption_psks /// - Default: 0 (We don't expose that) /// - use_ratchet_tree_extension /// - Option: default to true /// - out_of_order_tolerance /// - This is within an epoch /// - Option: set the default to small number /// - maximum_forward_distance /// - Maximum generation forward within an epoch from the same sender /// - Default: set to something like 1000 (Signal uses 2000) /// - Lifetime /// - Lifetime of a keypackage /// - This is to indicate the amount of time before which an update needs to happen pub struct ClientConfig { // Add fields as needed } // Question: should clients have consistent values for ratchet_tree_exrtensions pub fn mls_create_client_config( max_past_epoch: Option, use_ratchet_tree_extension: bool, out_of_order_tolerance: Option, maximum_forward_distance: Option, ) -> Result { unimplemented!() } // pub fn mls_group_propose_update( // _pstate: &mut PlatformState, // _gid: GroupId, // _myself: &Identity, // _signature_key: Option>, // // Below is client config // _group_context_extensions: Option, // _leaf_node_extensions: Option, // _leaf_node_capabilities: Option, // _lifetime: Option, // ) -> Result { // unimplemented!() // } /// /// TODO: Pending commit API /// // List pending // Apply pending // Discard pending