From 3e6f96cb7d64592c2d0810dd85a3d63b383a1de8 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 11 Jan 2024 13:10:46 -0800 Subject: [PATCH] Revert "Ability to add group context extensions" --- openmls/src/group/core_group/mod.rs | 8 --- openmls/src/group/mls_group/config.rs | 13 ---- openmls/src/group/mls_group/creation.rs | 1 - openmls/src/group/mls_group/test_mls_group.rs | 59 ------------------- openmls/src/group/public_group/builder.rs | 26 +++----- 5 files changed, 7 insertions(+), 100 deletions(-) diff --git a/openmls/src/group/core_group/mod.rs b/openmls/src/group/core_group/mod.rs index 7703260865..3983d127ab 100644 --- a/openmls/src/group/core_group/mod.rs +++ b/openmls/src/group/core_group/mod.rs @@ -211,14 +211,6 @@ impl CoreGroupBuilder { self } - /// Set the `group_context_extensions` of the [`CoreGroup`]. - pub fn with_group_context_extensions(mut self, extensions: Extensions) -> Self { - self.public_group_builder = self - .public_group_builder - .with_group_context_extensions(extensions); - self - } - /// Build the [`CoreGroup`]. /// Any values that haven't been set in the builder are set to their default /// values (which might be random). diff --git a/openmls/src/group/mls_group/config.rs b/openmls/src/group/mls_group/config.rs index ca2f00ea4e..a78c5e4ff6 100644 --- a/openmls/src/group/mls_group/config.rs +++ b/openmls/src/group/mls_group/config.rs @@ -60,8 +60,6 @@ pub struct MlsGroupConfig { pub(crate) lifetime: Lifetime, /// Ciphersuite and protocol version pub(crate) crypto_config: CryptoConfig, - // Other extensions - pub(crate) group_context_extensions: Extensions, } impl MlsGroupConfig { @@ -120,11 +118,6 @@ impl MlsGroupConfig { &self.crypto_config } - /// Set the `group_context_extensions` property of the MlsGroupConfig. - pub fn group_context_extensions(&self) -> &Extensions { - &self.group_context_extensions - } - #[cfg(any(feature = "test-utils", test))] pub fn test_default(ciphersuite: Ciphersuite) -> Self { Self::builder() @@ -227,12 +220,6 @@ impl MlsGroupConfigBuilder { self } - /// Sets the `group_context_extensions` property of the MlsGroupConfig. - pub fn group_context_extensions(mut self, extensions: Extensions) -> Self { - self.config.group_context_extensions = extensions; - self - } - /// Finalizes the builder and retursn an `[MlsGroupConfig`]. pub fn build(self) -> MlsGroupConfig { self.config diff --git a/openmls/src/group/mls_group/creation.rs b/openmls/src/group/mls_group/creation.rs index 91e94f486f..df2164bea4 100644 --- a/openmls/src/group/mls_group/creation.rs +++ b/openmls/src/group/mls_group/creation.rs @@ -57,7 +57,6 @@ impl MlsGroup { credential_with_key, ) .with_config(group_config) - .with_group_context_extensions(mls_group_config.group_context_extensions.clone()) .with_required_capabilities(mls_group_config.required_capabilities.clone()) .with_external_senders(mls_group_config.external_senders.clone()) .with_max_past_epoch_secrets(mls_group_config.max_past_epochs) diff --git a/openmls/src/group/mls_group/test_mls_group.rs b/openmls/src/group/mls_group/test_mls_group.rs index 20a04289b1..8cae8a6679 100644 --- a/openmls/src/group/mls_group/test_mls_group.rs +++ b/openmls/src/group/mls_group/test_mls_group.rs @@ -645,62 +645,3 @@ fn remove_prosposal_by_ref(ciphersuite: Ciphersuite, provider: &impl OpenMlsProv _ => unreachable!("Expected a StagedCommit."), } } - -#[apply(ciphersuites_and_providers)] -fn test_group_context_extensions(ciphersuite: Ciphersuite, provider: &impl OpenMlsProvider) { - let group_id = GroupId::from_slice(b"Test Group"); - let application_id = b"Test App ID"; - let metadata = vec![1, 2, 3]; - - let (alice_credential_with_key, _alice_kpb, alice_signer, _alice_pk) = - setup_client("Alice", ciphersuite, provider); - - // Define the MlsGroup configuration - let mls_group_config = MlsGroupConfig::builder() - .wire_format_policy(WireFormatPolicy::new( - OutgoingWireFormatPolicy::AlwaysPlaintext, - IncomingWireFormatPolicy::Mixed, - )) - .crypto_config(CryptoConfig::with_default_version(ciphersuite)) - .group_context_extensions(Extensions::single(Extension::ProtectedMetadata( - ProtectedMetadata::new( - &alice_signer, - application_id.to_vec(), - alice_credential_with_key.credential.clone(), - alice_credential_with_key.signature_key.as_slice().to_vec(), - metadata, - ) - .unwrap(), - ))) - .build(); - - // === Alice creates a group === - let mut alice_group = MlsGroup::new_with_group_id( - provider, - &alice_signer, - &mls_group_config, - group_id.clone(), - alice_credential_with_key, - ) - .expect("An unexpected error occurred."); - - assert!(alice_group - .export_group_context() - .extensions() - .contains(ExtensionType::ProtectedMetadata)); - - // Check the internal state has changed - assert_eq!(alice_group.state_changed(), InnerState::Changed); - - alice_group - .save(provider.key_store()) - .expect("Could not write group state to file"); - - let alice_group_deserialized = - MlsGroup::load(&group_id, provider.key_store()).expect("Could not deserialize MlsGroup"); - - assert!(alice_group_deserialized - .export_group_context() - .extensions() - .contains(ExtensionType::ProtectedMetadata)); -} diff --git a/openmls/src/group/public_group/builder.rs b/openmls/src/group/public_group/builder.rs index aeae7f9630..aac7ac329f 100644 --- a/openmls/src/group/public_group/builder.rs +++ b/openmls/src/group/public_group/builder.rs @@ -26,7 +26,6 @@ pub(crate) struct TempBuilderPG1 { required_capabilities: Option, external_senders: Option, leaf_extensions: Option, - group_context_extensions: Option, } impl TempBuilderPG1 { @@ -35,11 +34,6 @@ impl TempBuilderPG1 { self } - pub(crate) fn with_group_context_extensions(mut self, extensions: Extensions) -> Self { - self.group_context_extensions = Some(extensions); - self - } - pub(crate) fn with_required_capabilities( mut self, required_capabilities: RequiredCapabilitiesExtension, @@ -93,22 +87,17 @@ impl TempBuilderPG1 { _ => LibraryError::custom("Unexpected ExtensionError").into(), })?; let required_capabilities = Extension::RequiredCapabilities(required_capabilities); - - let mut extensions = Extensions::from_vec(vec![required_capabilities])?; - if let Some(ext_senders) = self.external_senders.map(Extension::ExternalSenders) { - extensions.add(ext_senders)?; - } - if let Some(group_context_extensions) = self.group_context_extensions { - for extension in group_context_extensions.iter() { - extensions.add(extension.clone())?; - } - } - + let extensions = + if let Some(ext_senders) = self.external_senders.map(Extension::ExternalSenders) { + vec![required_capabilities, ext_senders] + } else { + vec![required_capabilities] + }; let group_context = GroupContext::create_initial_group_context( self.crypto_config.ciphersuite, self.group_id, treesync.tree_hash().to_vec(), - extensions, + Extensions::from_vec(extensions)?, ); let next_builder = TempBuilderPG2 { treesync, @@ -183,7 +172,6 @@ impl PublicGroup { required_capabilities: None, external_senders: None, leaf_extensions: None, - group_context_extensions: None, } } }