From 2b59c8bb7c09301507ecf0289230b4a9e29238f4 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Sep 2020 10:52:02 +0200 Subject: [PATCH] store ed25519 key from olm event rather than one in m.room_key payload that's the docs/js-sdk do it, even though it probably doesn't matter much as we verify the key anyway --- src/matrix/e2ee/megolm/Decryption.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/matrix/e2ee/megolm/Decryption.js b/src/matrix/e2ee/megolm/Decryption.js index f1561a79..2a43c00b 100644 --- a/src/matrix/e2ee/megolm/Decryption.js +++ b/src/matrix/e2ee/megolm/Decryption.js @@ -109,9 +109,19 @@ export class Decryption { } } - async addRoomKeys(payloads, txn) { + /** + * @type {MegolmInboundSessionDescription} + * @property {string} senderKey the sender key of the session + * @property {string} sessionId the session identifier + * + * Adds room keys as inbound group sessions + * @param {Array} decryptionResults an array of m.room_key decryption results. + * @param {[type]} txn a storage transaction with read/write on inboundGroupSessions + * @return {Promise>} an array with the newly added sessions + */ + async addRoomKeys(decryptionResults, txn) { const newSessions = []; - for (const {senderKey, event} of payloads) { + for (const {senderCurve25519Key: senderKey, event, claimedEd25519Key} of decryptionResults) { const roomId = event.content?.["room_id"]; const sessionId = event.content?.["session_id"]; const sessionKey = event.content?.["session_key"]; @@ -136,7 +146,7 @@ export class Decryption { senderKey, sessionId, session: session.pickle(this._pickleKey), - claimedKeys: event.keys, + claimedKeys: {ed25519: claimedEd25519Key}, }; txn.inboundGroupSessions.set(sessionEntry); newSessions.push(sessionEntry);