Eliminate extra preKeys, fail early on key creation if no PNI identity key

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
Scott Nonnenberg 2023-08-21 13:15:10 -07:00 committed by GitHub
parent 0e19255256
commit 3339899684
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 444 additions and 6 deletions

View file

@ -489,6 +489,24 @@ export default class AccountManager extends EventTarget {
async maybeUpdateKeys(serviceIdKind: ServiceIdKind): Promise<void> {
const logId = `maybeUpdateKeys(${serviceIdKind})`;
await this.queueTask(async () => {
const { storage } = window.textsecure;
let identityKey: KeyPairType;
try {
const ourServiceId = storage.user.getCheckedServiceId(serviceIdKind);
identityKey = this.getIdentityKeyOrThrow(ourServiceId);
} catch (error) {
if (serviceIdKind === ServiceIdKind.PNI) {
log.info(
`${logId}: Not enough information to update PNI keys`,
Errors.toLogFormat(error)
);
return;
}
throw error;
}
const { count: preKeyCount, pqCount: kyberPreKeyCount } =
await this.server.getMyKeyCounts(serviceIdKind);
@ -544,9 +562,6 @@ export default class AccountManager extends EventTarget {
}
log.info(`${logId}: Uploading with ${keySummary.join(', ')}`);
const { storage } = window.textsecure;
const ourServiceId = storage.user.getCheckedServiceId(serviceIdKind);
const identityKey = this.getIdentityKeyOrThrow(ourServiceId);
const toUpload = {
identityKey: identityKey.pubKey,
preKeys,