From 9b724b76e0035a464216ac0dfcab412039013257 Mon Sep 17 00:00:00 2001 From: Mathieu Amiot Date: Tue, 13 Feb 2024 11:05:44 +0100 Subject: [PATCH] Appease rustfmt --- Cargo.toml | 4 +- openmls/Cargo.toml | 2 +- openmls/src/group/core_group/mod.rs | 46 +++++++++---------- openmls/src/group/core_group/staged_commit.rs | 35 ++++++++------ openmls/src/key_packages/key_package_in.rs | 4 +- rustfmt.toml | 4 +- 6 files changed, 49 insertions(+), 46 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 233786089f..09685d8235 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,9 +15,9 @@ resolver = "2" async-trait = "0.1" [workspace.dependencies.tls_codec] -version = "0.4.0" +version = "0.4" features = ["derive", "serde", "mls"] [workspace.dependencies.tls_codec_derive] -version = "0.4.0" +version = "0.4" features = ["derive", "serde", "mls"] diff --git a/openmls/Cargo.toml b/openmls/Cargo.toml index 6e0d6a0c7b..aec1c59f1c 100644 --- a/openmls/Cargo.toml +++ b/openmls/Cargo.toml @@ -24,7 +24,7 @@ x509-cert = "0.2" subtle = "2.5" fluvio-wasm-timer = "0.2" indexmap = "2.0" -itertools = "0.11" +itertools = "0.12" # Only required for tests. rand = { version = "0.8", optional = true, features = ["getrandom"] } diff --git a/openmls/src/group/core_group/mod.rs b/openmls/src/group/core_group/mod.rs index 9c8ff5ef06..8837eda493 100644 --- a/openmls/src/group/core_group/mod.rs +++ b/openmls/src/group/core_group/mod.rs @@ -243,7 +243,7 @@ impl CoreGroupBuilder { /// [`OpenMlsCryptoProvider`]. pub(crate) async fn build( self, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, signer: &impl Signer, ) -> Result> { let (public_group_builder, commit_secret, leaf_keypair) = @@ -270,7 +270,7 @@ impl CoreGroupBuilder { .map_err(LibraryError::unexpected_crypto_error)?, &serialized_group_context, ) - .map_err(LibraryError::unexpected_crypto_error)?; + .map_err(LibraryError::unexpected_crypto_error)?; // TODO(#1357) let resumption_psk_store = ResumptionPskStore::new(32); @@ -407,7 +407,7 @@ impl CoreGroup { self.context(), signer, ) - .map_err(ValidationError::LibraryError) + .map_err(ValidationError::LibraryError) } // 11.1.4. PreSharedKey @@ -437,7 +437,7 @@ impl CoreGroup { pub(crate) fn members_support_extensions<'a>( &self, extensions: &Extensions, - pending_proposals: impl Iterator, + pending_proposals: impl Iterator, ) -> Result<(), MemberExtensionValidationError> { let required_extension = extensions .iter() @@ -470,7 +470,7 @@ impl CoreGroup { &self, framing_parameters: FramingParameters, extensions: Extensions, - pending_proposals: impl Iterator, + pending_proposals: impl Iterator, signer: &impl Signer, ) -> Result { // Ensure that the group supports all the extensions that are wanted. @@ -485,7 +485,7 @@ impl CoreGroup { self.context(), signer, ) - .map_err(|e| e.into()) + .map_err(|e| e.into()) } /// Create a `ReInit` proposal pub(crate) fn create_reinit_proposal( @@ -512,7 +512,7 @@ impl CoreGroup { self.context(), signer, ) - .map_err(|e| e.into()) + .map_err(|e| e.into()) } // Create application message pub(crate) fn create_application_message( @@ -815,7 +815,7 @@ impl CoreGroup { /// Returns an error if access to the key store fails. pub(super) async fn store_epoch_keypairs( &self, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, epoch_encryption_keypair: EpochEncryptionKeyPair, ) -> Result<(), KeyStore::Error> { let k = EpochKeypairId::new( @@ -835,7 +835,7 @@ impl CoreGroup { /// Returns `None` if access to the key store fails. pub(super) async fn read_epoch_keypairs( &self, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, ) -> EpochEncryptionKeyPair { let k = EpochKeypairId::new( self.group_id(), @@ -855,7 +855,7 @@ impl CoreGroup { /// Returns an error if access to the key store fails. pub(super) async fn delete_previous_epoch_keypairs( &self, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, ) -> Result<(), KeyStore::Error> { let k = EpochKeypairId::new( self.group_id(), @@ -871,7 +871,7 @@ impl CoreGroup { pub(crate) async fn create_commit( &self, mut params: CreateCommitParams<'_>, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, signer: &impl Signer, ) -> Result> { let ciphersuite = self.ciphersuite(); @@ -890,15 +890,15 @@ impl CoreGroup { params.inline_proposals(), self.own_leaf_index(), ) - .map_err(|e| match e { - crate::group::errors::ProposalQueueError::LibraryError(e) => e.into(), - crate::group::errors::ProposalQueueError::ProposalNotFound => { - CreateCommitError::MissingProposal - } - crate::group::errors::ProposalQueueError::SenderError(_) => { - CreateCommitError::WrongProposalSenderType - } - })?; + .map_err(|e| match e { + crate::group::errors::ProposalQueueError::LibraryError(e) => e.into(), + crate::group::errors::ProposalQueueError::ProposalNotFound => { + CreateCommitError::MissingProposal + } + crate::group::errors::ProposalQueueError::SenderError(_) => { + CreateCommitError::WrongProposalSenderType + } + })?; // TODO: #581 Filter proposals by support // 11.2: @@ -1028,7 +1028,7 @@ impl CoreGroup { self.group_epoch_secrets().init_secret(), &serialized_provisional_group_context, ) - .map_err(LibraryError::unexpected_crypto_error)?; + .map_err(LibraryError::unexpected_crypto_error)?; // Prepare the PskSecret let psk_secret = { @@ -1037,7 +1037,7 @@ impl CoreGroup { &self.resumption_psk_store, &apply_proposals_values.presharedkeys, ) - .await?; + .await?; PskSecret::new(backend, ciphersuite, psks).await? }; @@ -1191,7 +1191,7 @@ impl MlsGroup { /// re-export pub async fn delete_previous_epoch_keypairs( &self, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, ) -> Result<(), KeyStore::Error> { self.group.delete_previous_epoch_keypairs(backend).await } diff --git a/openmls/src/group/core_group/staged_commit.rs b/openmls/src/group/core_group/staged_commit.rs index 8576d84d4c..2a4b9aa445 100644 --- a/openmls/src/group/core_group/staged_commit.rs +++ b/openmls/src/group/core_group/staged_commit.rs @@ -43,7 +43,7 @@ impl CoreGroup { &init_secret, serialized_provisional_group_context, ) - .map_err(LibraryError::unexpected_crypto_error)? + .map_err(LibraryError::unexpected_crypto_error)? } else { JoinerSecret::new( backend, @@ -51,7 +51,7 @@ impl CoreGroup { epoch_secrets.init_secret(), serialized_provisional_group_context, ) - .map_err(LibraryError::unexpected_crypto_error)? + .map_err(LibraryError::unexpected_crypto_error)? }; // Prepare the PskSecret @@ -61,7 +61,7 @@ impl CoreGroup { &self.resumption_psk_store, &apply_proposals_values.presharedkeys, ) - .await?; + .await?; PskSecret::new(backend, self.ciphersuite(), psks).await? }; @@ -201,7 +201,12 @@ impl CoreGroup { let update_path_leaf_node = Some(path.leaf_node().clone()); debug_assert_eq!(diff.leaf(sender_index), path.leaf_node().into()); - (commit_secret, new_keypairs, new_leaf_keypair_option, update_path_leaf_node) + ( + commit_secret, + new_keypairs, + new_leaf_keypair_option, + update_path_leaf_node, + ) } else { if apply_proposals_values.path_required { // ValSem201 @@ -285,7 +290,7 @@ impl CoreGroup { /// might throw a `LibraryError`. pub(crate) async fn merge_commit( &mut self, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, staged_commit: StagedCommit, ) -> Result, MergeCommitError> { // Get all keypairs from the old epoch, so we can later store the ones @@ -309,7 +314,7 @@ impl CoreGroup { async fn merge_member_commit( &mut self, - backend: &impl OpenMlsCryptoProvider, + backend: &impl OpenMlsCryptoProvider, mut old_epoch_keypairs: EpochEncryptionKeyPair, mut state: Box, is_member: bool, @@ -352,7 +357,7 @@ impl CoreGroup { return Err(LibraryError::custom( "We should have all the private key material we need.", ) - .into()); + .into()); } // Store the relevant keys under the new epoch @@ -399,7 +404,7 @@ impl CoreGroup { leaf_node_keypairs, backend, ) - .await + .await } } @@ -428,27 +433,27 @@ impl StagedCommit { } /// Returns the Add proposals that are covered by the Commit message as in iterator over [QueuedAddProposal]. - pub fn add_proposals(&self) -> impl Iterator { + pub fn add_proposals(&self) -> impl Iterator { self.staged_proposal_queue.add_proposals() } /// Returns the Remove proposals that are covered by the Commit message as in iterator over [QueuedRemoveProposal]. - pub fn remove_proposals(&self) -> impl Iterator { + pub fn remove_proposals(&self) -> impl Iterator { self.staged_proposal_queue.remove_proposals() } /// Returns the Update proposals that are covered by the Commit message as in iterator over [QueuedUpdateProposal]. - pub fn update_proposals(&self) -> impl Iterator { + pub fn update_proposals(&self) -> impl Iterator { self.staged_proposal_queue.update_proposals() } /// Returns the PresharedKey proposals that are covered by the Commit message as in iterator over [QueuedPskProposal]. - pub fn psk_proposals(&self) -> impl Iterator { + pub fn psk_proposals(&self) -> impl Iterator { self.staged_proposal_queue.psk_proposals() } /// Returns an interator over all [`QueuedProposal`]s - pub fn queued_proposals(&self) -> impl Iterator { + pub fn queued_proposals(&self) -> impl Iterator { self.staged_proposal_queue.queued_proposals() } @@ -479,12 +484,12 @@ impl StagedCommit { } } - /// Returns the leaf node of the (optional) update path. pub fn get_update_path_leaf_node(&self) -> Option<&LeafNode> { match self.state { StagedCommitState::PublicState(_) => None, - StagedCommitState::GroupMember(ref member) | StagedCommitState::ExternalMember(ref member) => { + StagedCommitState::GroupMember(ref member) + | StagedCommitState::ExternalMember(ref member) => { member.update_path_leaf_node.as_ref() } } diff --git a/openmls/src/key_packages/key_package_in.rs b/openmls/src/key_packages/key_package_in.rs index f03a7113aa..afb92282e3 100644 --- a/openmls/src/key_packages/key_package_in.rs +++ b/openmls/src/key_packages/key_package_in.rs @@ -74,7 +74,7 @@ mod private_mod { /// } KeyPackageTBS; /// ``` #[derive( -Debug, Clone, PartialEq, TlsSize, TlsSerialize, TlsDeserialize, Serialize, Deserialize, + Debug, Clone, PartialEq, TlsSize, TlsSerialize, TlsDeserialize, Serialize, Deserialize, )] struct KeyPackageTbsIn { protocol_version: ProtocolVersion, @@ -86,7 +86,7 @@ struct KeyPackageTbsIn { /// The key package struct. #[derive( -Debug, PartialEq, Clone, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize, + Debug, PartialEq, Clone, Serialize, Deserialize, TlsSerialize, TlsDeserialize, TlsSize, )] pub struct KeyPackageIn { payload: KeyPackageTbsIn, diff --git a/rustfmt.toml b/rustfmt.toml index bfe1bd58d6..3a26366d4d 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1,3 +1 @@ -wrap_comments = true -edition = "2018" -format_code_in_doc_comments = true +edition = "2021"