Fix initial kyber key hydration; improve generation and logging
This commit is contained in:

committed by
Fedor Indutnyy

parent
3f399b1329
commit
9d03d9b59c
@@ -281,7 +281,7 @@ async function bulkAddKyberPreKeys(
|
|||||||
await channels.bulkAddKyberPreKeys(updated);
|
await channels.bulkAddKyberPreKeys(updated);
|
||||||
}
|
}
|
||||||
async function getAllKyberPreKeys(): Promise<Array<KyberPreKeyType>> {
|
async function getAllKyberPreKeys(): Promise<Array<KyberPreKeyType>> {
|
||||||
const keys = await channels.getAllPreKeys();
|
const keys = await channels.getAllKyberPreKeys();
|
||||||
|
|
||||||
return keys.map(key => specToBytes(KYBER_PRE_KEY_SPEC, key));
|
return keys.map(key => specToBytes(KYBER_PRE_KEY_SPEC, key));
|
||||||
}
|
}
|
||||||
|
@@ -384,12 +384,12 @@ export default class AccountManager extends EventTarget {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorText = Errors.toLogFormat(error);
|
const errorText = Errors.toLogFormat(error);
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`generateNewKyberPreKeys: Failed to fetch identity key - ${errorText}`
|
`getIdentityKeyOrThrow: Failed to fetch identity key - ${errorText}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!identityKey) {
|
if (!identityKey) {
|
||||||
throw new Error('generateNewKyberPreKeys: Missing identity key');
|
throw new Error('getIdentityKeyOrThrow: Missing identity key');
|
||||||
}
|
}
|
||||||
|
|
||||||
return identityKey;
|
return identityKey;
|
||||||
@@ -418,8 +418,10 @@ export default class AccountManager extends EventTarget {
|
|||||||
toSave.push(generatePreKey(keyId));
|
toSave.push(generatePreKey(keyId));
|
||||||
}
|
}
|
||||||
|
|
||||||
await store.storePreKeys(ourUuid, toSave);
|
await Promise.all([
|
||||||
await storage.put(PRE_KEY_ID_KEY[uuidKind], startId + count);
|
store.storePreKeys(ourUuid, toSave),
|
||||||
|
storage.put(PRE_KEY_ID_KEY[uuidKind], startId + count),
|
||||||
|
]);
|
||||||
|
|
||||||
return toSave.map(key => ({
|
return toSave.map(key => ({
|
||||||
keyId: key.keyId,
|
keyId: key.keyId,
|
||||||
@@ -467,8 +469,10 @@ export default class AccountManager extends EventTarget {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
await store.storeKyberPreKeys(ourUuid, toSave);
|
await Promise.all([
|
||||||
await storage.put(KYBER_KEY_ID_KEY[uuidKind], startId + count);
|
store.storeKyberPreKeys(ourUuid, toSave),
|
||||||
|
storage.put(KYBER_KEY_ID_KEY[uuidKind], startId + count),
|
||||||
|
]);
|
||||||
|
|
||||||
return toUpload;
|
return toUpload;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user