Skip to content

Throw a specific error when the backup decryption key does not match the public backup#5202

Merged
andybalaam merged 1 commit intodevelopfrom
andybalaam/fix-backup-when-decryption-key-is-wrong-31793
Mar 2, 2026
Merged

Throw a specific error when the backup decryption key does not match the public backup#5202
andybalaam merged 1 commit intodevelopfrom
andybalaam/fix-backup-when-decryption-key-is-wrong-31793

Conversation

@andybalaam
Copy link
Copy Markdown
Member

@andybalaam andybalaam commented Feb 27, 2026

Part of element-hq/element-web#31793

We need to be able to detect when the private and public keys for key backup (key storage) are mismatched, so this change throws a specific error type when that happens.

element-hq/element-web#32668 detects this condition in Element Web and handles it by creating a new key backup, extracting the user from this nasty predicament.

andybalaam added a commit to element-hq/element-web that referenced this pull request Feb 27, 2026
…ryption key

Fixes #31793

Depends on matrix-org/matrix-js-sdk#5202

When we try to load the key storage decryption key from Recovery, but we
find that it does not match the public key of the current key storage
backup, create a new key storage backup.
@andybalaam andybalaam marked this pull request as ready for review February 27, 2026 15:40
@andybalaam andybalaam requested review from a team as code owners February 27, 2026 15:40
@andybalaam andybalaam enabled auto-merge March 2, 2026 13:24
Copy link
Copy Markdown
Contributor

@kaylendog kaylendog left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, although something like DecryptionKeyMismatchError would tickle my brain more than DecryptionKeyDoesNotMatchError.

@andybalaam andybalaam added this pull request to the merge queue Mar 2, 2026
andybalaam added a commit to element-hq/element-web that referenced this pull request Mar 2, 2026
…ryption key

Fixes #31793

Depends on matrix-org/matrix-js-sdk#5202

When we try to load the key storage decryption key from Recovery, but we
find that it does not match the public key of the current key storage
backup, create a new key storage backup.
Merged via the queue into develop with commit 0966330 Mar 2, 2026
40 of 41 checks passed
@andybalaam andybalaam deleted the andybalaam/fix-backup-when-decryption-key-is-wrong-31793 branch March 2, 2026 14:15
andybalaam added a commit to element-hq/element-web that referenced this pull request Mar 2, 2026
…ryption key

Fixes #31793

Depends on matrix-org/matrix-js-sdk#5202

When we try to load the key storage decryption key from Recovery, but we
find that it does not match the public key of the current key storage
backup, create a new key storage backup.
andybalaam added a commit to element-hq/element-web that referenced this pull request Mar 2, 2026
…ryption key

Fixes #31793

Depends on matrix-org/matrix-js-sdk#5202

When we try to load the key storage decryption key from Recovery, but we
find that it does not match the public key of the current key storage
backup, create a new key storage backup.
andybalaam added a commit to element-hq/element-web that referenced this pull request Mar 5, 2026
…ryption key

Fixes #31793

Depends on matrix-org/matrix-js-sdk#5202

When we try to load the key storage decryption key from Recovery, but we
find that it does not match the public key of the current key storage
backup, create a new key storage backup.
github-merge-queue bot pushed a commit to element-hq/element-web that referenced this pull request Mar 5, 2026
…ryption key (#32668)

* Set up the MatrixClient before each RecoveryPanelOutOfSync test

Without this, we can't override MatrixClient methods until we've called
`renderComponent`, which is awkward.

* Actually test that we load the decryption key in RecoveryPanelOutOfSync

It turns out the existing test didn't actually go down the expected code
path and call loadSessionBackupPrivateKeyFromSecretStorage.

* Reset key storage if restoring from Recovery encounters the wrong decryption key

Fixes #31793

Depends on matrix-org/matrix-js-sdk#5202

When we try to load the key storage decryption key from Recovery, but we
find that it does not match the public key of the current key storage
backup, create a new key storage backup.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants