From 0002ea46abfa7811b649587f5b67a450cfd25299 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 10 Sep 2025 17:25:28 +0100 Subject: [PATCH] crypto: inline `PrivateCrossSigningIdentity::with_account` This was now only used in one place, and I think it makes more sense to inline it into olm::Account than leave it in `PrivateCrossSigningIdentity`. --- crates/matrix-sdk-crypto/src/olm/account.rs | 23 +++++++++++++++-- .../matrix-sdk-crypto/src/olm/signing/mod.rs | 25 ------------------- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/crates/matrix-sdk-crypto/src/olm/account.rs b/crates/matrix-sdk-crypto/src/olm/account.rs index 68387af31..f5bd2a60d 100644 --- a/crates/matrix-sdk-crypto/src/olm/account.rs +++ b/crates/matrix-sdk-crypto/src/olm/account.rs @@ -806,11 +806,30 @@ impl Account { device_keys } - /// Bootstrap Cross-Signing + /// Bootstraps cross-signing, generating new cross-signing keys and creating + /// the necessary upload and signature requests. + /// + /// # Returns + /// A tuple containing: + /// - [`PrivateCrossSigningIdentity`]: The newly-generated cross-signing + /// identity (including a signature from this device). + /// - [`UploadSigningKeysRequest`]: The request to upload the + /// newly-generated cross-signing keys to the server. + /// - [`SignatureUploadRequest`]: The request to upload the signature of + /// this device to the server. pub async fn bootstrap_cross_signing( &self, ) -> (PrivateCrossSigningIdentity, UploadSigningKeysRequest, SignatureUploadRequest) { - PrivateCrossSigningIdentity::with_account(self).await + let identity = PrivateCrossSigningIdentity::for_account(self); + + let signature_request = identity + .sign_account(self.static_data()) + .await + .expect("Can't sign own device with new cross signing keys"); + + let upload_request = identity.as_upload_request().await; + + (identity, upload_request, signature_request) } /// Sign the given CrossSigning Key in place diff --git a/crates/matrix-sdk-crypto/src/olm/signing/mod.rs b/crates/matrix-sdk-crypto/src/olm/signing/mod.rs index 50bf997b4..44af711fc 100644 --- a/crates/matrix-sdk-crypto/src/olm/signing/mod.rs +++ b/crates/matrix-sdk-crypto/src/olm/signing/mod.rs @@ -499,31 +499,6 @@ impl PrivateCrossSigningIdentity { .sign(message)) } - /// Create a new identity for the given Olm Account. - /// - /// Returns the new identity, the upload signing keys request and a - /// signature upload request that contains the signature of the account - /// signed by the self signing key. - /// - /// # Arguments - /// - /// * `account` - The Olm account that is creating the new identity. The - /// account will sign the master key and the self signing key will sign - /// the account. - pub(crate) async fn with_account( - account: &Account, - ) -> (Self, UploadSigningKeysRequest, SignatureUploadRequest) { - let identity = Self::for_account(account); - let signature_request = identity - .sign_account(account.static_data()) - .await - .expect("Can't sign own device with new cross signing keys"); - - let request = identity.as_upload_request().await; - - (identity, request, signature_request) - } - fn new_helper(user_id: &UserId, master: MasterSigning) -> Self { let (user, self_signing) = master.new_subkeys();