hydrogen-web/src/matrix/e2ee/megolm/decryption
2022-02-15 18:20:14 +01:00
..
DecryptionChanges.js comment to explain replay attack better 2021-03-02 19:39:04 +01:00
DecryptionPreparation.js Convert mergeMap.js to ts 2021-11-17 20:28:44 +05:30
KeyLoader.ts store key source in inbound session 2022-01-28 10:03:30 +01:00
README.md split up megolm decryption so it can happen in multiple steps,see README 2020-09-10 12:05:53 +02:00
ReplayDetectionEntry.ts convert ReplayDetectionEntry to typescript 2021-10-22 17:47:29 +02:00
RoomKey.ts some more typing 2022-01-28 13:14:38 +01:00
SessionDecryption.ts convert DecryptionResult 2022-02-15 18:20:14 +01:00
utils.ts convert groupby and megolm decryption utils to typescript 2021-10-21 14:40:51 +02:00

Lots of classes here. The complexity comes from needing to offload decryption to a webworker, mainly for IE11. We can't keep a idb transaction open while waiting for the response from the worker, so need to batch decryption of multiple events and do decryption in multiple steps:

  1. Read all used inbound sessions for the batch of events, requires a read txn. This happens in Decryption. Sessions are loaded into SessionInfo objects, which are also kept in a SessionCache to prevent having to read and unpickle them all the time.
  2. Actually decrypt. No txn can stay open during this step, as it can be offloaded to a worker and is thus async. This happens in DecryptionPreparation, which delegates to SessionDecryption per session.
  3. Read and write for the replay detection, requires a read/write txn. This happens in DecryptionChanges
  4. Return the decrypted entries, and errors if any