Skip to content

Enhance vault encryption performance with caching #3582

@mikesposito

Description

@mikesposito

We have a couple of opportunities for optimizing the performance of vault encryption, specifically within the EthKeyringController and the KeyringController setup:

1. Improve Key Caching in EthKeyringController:

The EthKeyringController is currently set up to derive a new encryption key from the user's password for every keychain operation. This approach is inefficient as it unnecessarily repeats the key derivation process.

We should amend the EthKeyringController to prioritize the use of a cached encryption key rather than re-deriving it from the password. This would only apply in instances where the cached encryption key is still in memory, and it would significantly reduce the processing time by avoiding redundant derivations.

2. Initialize KeyringController with Caching Enabled (in the extension):

As a separate but related improvement, when initializing KeyringController in the extension, we should enable the cacheEncryptionKey option by default (instead of MV3-only). This adjustment would ensure that the KeyringController itself utilizes the performance benefits of key caching.

3. Replace updateVault with isVaultUpdated:

The EthKeyringController currently uses the updateVault function from browser-passworder for a simple comparison with the existing vault, which leads to needless re-encryption.

We should export isVaultUpdated from browser-passworder, and use it in the EthKeyringController. This function would allow us to check if the vault is updated by analyzing its metadata, which is far more efficient than performing a full derivation -> decryption -> derivation -> encryption operation.

Metadata

Metadata

Assignees

Labels

team-wallet-frameworkDeprecated: Please use `team-core-platform` instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions