From 9d03d9b59c0cdf5f4fd9d0bb6a94e1be0aa47f87 Mon Sep 17 00:00:00 2001 From: Scott Nonnenberg Date: Fri, 14 Jul 2023 12:18:32 -0700 Subject: [PATCH] Fix initial kyber key hydration; improve generation and logging --- ts/sql/Client.ts | 2 +- ts/textsecure/AccountManager.ts | 16 ++++++++++------ 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ts/sql/Client.ts b/ts/sql/Client.ts index bc16bddff859..318bbcff123e 100644 --- a/ts/sql/Client.ts +++ b/ts/sql/Client.ts @@ -281,7 +281,7 @@ async function bulkAddKyberPreKeys( await channels.bulkAddKyberPreKeys(updated); } async function getAllKyberPreKeys(): Promise> { - const keys = await channels.getAllPreKeys(); + const keys = await channels.getAllKyberPreKeys(); return keys.map(key => specToBytes(KYBER_PRE_KEY_SPEC, key)); } diff --git a/ts/textsecure/AccountManager.ts b/ts/textsecure/AccountManager.ts index 9df6ea85ca24..30553a138738 100644 --- a/ts/textsecure/AccountManager.ts +++ b/ts/textsecure/AccountManager.ts @@ -384,12 +384,12 @@ export default class AccountManager extends EventTarget { } catch (error) { const errorText = Errors.toLogFormat(error); throw new Error( - `generateNewKyberPreKeys: Failed to fetch identity key - ${errorText}` + `getIdentityKeyOrThrow: Failed to fetch identity key - ${errorText}` ); } if (!identityKey) { - throw new Error('generateNewKyberPreKeys: Missing identity key'); + throw new Error('getIdentityKeyOrThrow: Missing identity key'); } return identityKey; @@ -418,8 +418,10 @@ export default class AccountManager extends EventTarget { toSave.push(generatePreKey(keyId)); } - await store.storePreKeys(ourUuid, toSave); - await storage.put(PRE_KEY_ID_KEY[uuidKind], startId + count); + await Promise.all([ + store.storePreKeys(ourUuid, toSave), + storage.put(PRE_KEY_ID_KEY[uuidKind], startId + count), + ]); return toSave.map(key => ({ keyId: key.keyId, @@ -467,8 +469,10 @@ export default class AccountManager extends EventTarget { }); } - await store.storeKyberPreKeys(ourUuid, toSave); - await storage.put(KYBER_KEY_ID_KEY[uuidKind], startId + count); + await Promise.all([ + store.storeKyberPreKeys(ourUuid, toSave), + storage.put(KYBER_KEY_ID_KEY[uuidKind], startId + count), + ]); return toUpload; }