Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Decentralised MLS proof-of-concept #3306

Draft
wants to merge 21 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"@babel/register": "^7.12.10",
"@casualbot/jest-sonar-reporter": "^2.2.5",
"@matrix-org/olm": "https://gitlab.matrix.org/api/v4/projects/27/packages/npm/@matrix-org/olm/-/@matrix-org/olm-3.2.14.tgz",
"@matrix-org/matrix-dmls-wasm": "https://gitlab.matrix.org/api/v4/projects/876/packages/npm/@matrix-org/matrix-dmls-wasm/-/@matrix-org/matrix-dmls-wasm-0.0.4.tgz",
"@types/bs58": "^4.0.1",
"@types/content-type": "^1.1.5",
"@types/debug": "^4.1.7",
Expand Down
9 changes: 5 additions & 4 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ limitations under the License.
import { Optional } from "matrix-events-sdk";

import type { IDeviceKeys, IMegolmSessionData, IOneTimeKey } from "./@types/crypto";
import type { IMlsSessionData } from "./crypto/algorithms/dmls";
import { ISyncStateData, SyncApi, SyncApiOptions, SyncState } from "./sync";
import {
EventStatus,
Expand Down Expand Up @@ -3105,7 +3106,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
*
* @returns a promise which resolves when the keys have been imported
*/
public importRoomKeys(keys: IMegolmSessionData[], opts?: IImportRoomKeysOpts): Promise<void> {
public importRoomKeys(keys: IMlsSessionData[], opts?: IImportRoomKeysOpts): Promise<void> {
if (!this.crypto) {
throw new Error("End-to-end encryption disabled");
}
Expand Down Expand Up @@ -3640,7 +3641,7 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
}

let totalKeyCount = 0;
let keys: IMegolmSessionData[] = [];
let keys: IMlsSessionData[] = [];

const path = this.makeKeyBackupPath(targetRoomId!, targetSessionId!, backupInfo.version);

Expand Down Expand Up @@ -3706,8 +3707,8 @@ export class MatrixClient extends TypedEventEmitter<EmittedEvents, ClientEventHa
const [key] = await algorithm.decryptSessions({
[targetSessionId!]: res as IKeyBackupSession,
});
key.room_id = targetRoomId!;
key.session_id = targetSessionId!;
const [epochNum, epochCreator] = targetSessionId!.split("|");
key.epoch = [parseInt(epochNum), epochCreator];
keys.push(key);
} catch (e) {
logger.log("Failed to decrypt megolm session from backup", e);
Expand Down
4 changes: 2 additions & 2 deletions src/crypto/algorithms/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ limitations under the License.
* Internal module. Defines the base classes of the encryption implementations
*/

import type { IMegolmSessionData } from "../../@types/crypto";
import type { IMlsSessionData } from "./dmls";
import { MatrixClient } from "../../client";
import { Room } from "../../models/room";
import { OlmDevice } from "../OlmDevice";
Expand Down Expand Up @@ -161,7 +161,7 @@ export abstract class DecryptionAlgorithm {
*
* @param opts - object
*/
public async importRoomKey(session: IMegolmSessionData, opts: object): Promise<void> {
public async importRoomKey(session: IMlsSessionData, opts: object): Promise<void> {
// ignore by default
}

Expand Down
Loading