Open personalizedrefrigerator opened 1 year ago
Do you know what part of the process makes it slow? Is it because we're decrypting all the master key in startup?
Do you know what part of the process makes it slow? Is it because we're decrypting all the master key in startup?
That seems to be the case. Applying this patch,
diff --git a/packages/lib/services/e2ee/utils.ts b/packages/lib/services/e2ee/utils.ts
index 38c04bc0c..cd145023a 100644
--- a/packages/lib/services/e2ee/utils.ts
+++ b/packages/lib/services/e2ee/utils.ts
@@ -141,6 +141,10 @@ export async function loadMasterKeysFromSettings(service: EncryptionService) {
for (let i = 0; i < masterKeys.length; i++) {
const mk = masterKeys[i];
if (service.isMasterKeyLoaded(mk)) continue;
+ if (!masterKeyEnabled(mk)) {
+ logger.info(`Skipping disabled master key.`);
+ continue;
+ }
const password = await findMasterKeyPassword(service, mk);
if (!password) continue;
then disabling most master keys (requires additional patching), seems to decrease startup time.
Another option might be to store unlocked master keys encrypted with a library like expo-secure-store.
Loading master keys from expo-secure-store
(or a similar library) may be faster than decrypting keys on each startup with sjcl
.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? If you require support or are requesting an enhancement or feature then please create a topic on the Joplin forum. This issue may be closed if no further activity occurs. You may comment on the issue and I will leave it open. Thank you for your contributions.
Operating system
Android
Joplin version
2.13.7
Desktop version info
No response
Current behaviour
Steps to reproduce:
Expected behaviour
Having a large number of master keys (particularly when unused) should not make Joplin slow to start.
On one Android simulator, each master key adds about half of a second to the startup time. On a physical Android device, each master key adds about three seconds to the startup time.
Logs
Below is a modified startup log, with the number of milliseconds since the last log included.
For example,
means that
Database was open successfully
was logged at14:14:36
, and 54 milliseconds after the previous log statement.The part of this relevant to master keys decryption: