Support for loading, storing, and using kyber keys in decryption
This commit is contained in:
parent
c1580a5eb3
commit
b6445a6af0
49 changed files with 2260 additions and 806 deletions
42
ts/sql/migrations/85-add-kyber-keys.ts
Normal file
42
ts/sql/migrations/85-add-kyber-keys.ts
Normal file
|
@ -0,0 +1,42 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Database } from '@signalapp/better-sqlite3';
|
||||
|
||||
import type { LoggerType } from '../../types/Logging';
|
||||
|
||||
export default function updateToSchemaVersion85(
|
||||
currentVersion: number,
|
||||
db: Database,
|
||||
logger: LoggerType
|
||||
): void {
|
||||
if (currentVersion >= 85) {
|
||||
return;
|
||||
}
|
||||
|
||||
db.transaction(() => {
|
||||
db.exec(
|
||||
`CREATE TABLE kyberPreKeys(
|
||||
id STRING PRIMARY KEY NOT NULL,
|
||||
json TEXT NOT NULL,
|
||||
ourUuid STRING
|
||||
GENERATED ALWAYS AS (json_extract(json, '$.ourUuid'))
|
||||
);`
|
||||
);
|
||||
|
||||
// To manage our ACI or PNI keys quickly
|
||||
db.exec('CREATE INDEX kyberPreKeys_ourUuid ON kyberPreKeys (ourUuid);');
|
||||
|
||||
// Add time to all existing preKeys to allow us to expire them
|
||||
const now = Date.now();
|
||||
db.exec(
|
||||
`UPDATE preKeys SET
|
||||
json = json_set(json, '$.createdAt', ${now});
|
||||
`
|
||||
);
|
||||
|
||||
db.pragma('user_version = 85');
|
||||
})();
|
||||
|
||||
logger.info('updateToSchemaVersion85: success!');
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue