diff --git a/src/@types/matrix-sdk-crypto-wasm.d.ts b/src/@types/matrix-sdk-crypto-wasm.d.ts index c7504a3484..10c20924dc 100644 --- a/src/@types/matrix-sdk-crypto-wasm.d.ts +++ b/src/@types/matrix-sdk-crypto-wasm.d.ts @@ -20,6 +20,11 @@ declare module "@matrix-org/matrix-sdk-crypto-wasm" { interface OlmMachine { importSecretsBundle(bundle: RustSdkCryptoJs.SecretsBundle): Promise; exportSecretsBundle(): Promise; + importCrossSigningKeys( + master_key?: string, + self_signing_key?: string, + user_signing_key?: string, + ): Promise; } interface SecretsBundle { diff --git a/src/rust-crypto/CrossSigningIdentity.ts b/src/rust-crypto/CrossSigningIdentity.ts index a7218d4837..0dccbb17dc 100644 --- a/src/rust-crypto/CrossSigningIdentity.ts +++ b/src/rust-crypto/CrossSigningIdentity.ts @@ -87,12 +87,18 @@ export class CrossSigningIdentity { "bootstrapCrossSigning: Cross-signing private keys not found locally, but they are available " + "in secret storage, reading storage and caching locally", ); - await this.olmMachine.importCrossSigningKeys( + const status = await this.olmMachine.importCrossSigningKeys( masterKeyFromSecretStorage, selfSigningKeyFromSecretStorage, userSigningKeyFromSecretStorage, ); + // Check that `importCrossSigningKeys` worked correctly (for example, it will fail silently if the + // public keys are not available). + if (!status.hasMaster || !status.hasSelfSigning || !status.hasUserSigning) { + throw new Error("importCrossSigningKeys failed to import the keys"); + } + // Get the current device const device: RustSdkCryptoJs.Device = await this.olmMachine.getDevice( this.olmMachine.userId,