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

Decrypt initial message after joining new DM #151

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

codemonium
Copy link
Contributor

Suppose that Alice logs in using Element. Before this change, when Bob would send a DM to Alice through Pantalaimon, Alice would not be able to decrypt Bob's initial message. Instead, she would see

Unable to decrypt: The sender's device has not sent us the keys for this message.

and Pantalaimon's olmsessions table would have no associated records. Any future messages would be visible however. On the other hand, when Alice (using Element) is the one to send the first DM to Bob, he can decrypt the initial message.

For Pantalaimon to execute /keys/claim, get_missing_sessions must return the invitee's device (and log Missing session for device). If Pantalaimon calls this method too soon, then self.device_store will not have the device. To populate self.device_store before Pantalaimon calls get_missing_sessions, it must execute /keys/query (and invoke _handle_key_query) earlier, during the /createRoom request. Pantalaimon does execute the /keys/query request during a sync after the server finishes creating the DM (and logs Adding new device to the device store for user), but only after checking unsuccessfully for the device in self.device_store.

After this change, Pantalaimon executes /keys/claim, there is one record in olmsessions, and Alice can decrypt Bob's initial message.

Suppose that Alice logs in using Element. Before this change, when Bob
would send a DM to Alice through Pantalaimon, Alice would not be able to
decrypt Bob's initial message. Instead, she would see "Unable to
decrypt: The sender's device has not sent us the keys for this message."
and Pantalaimon's olmsessions table would have no associated records.
Any future messages would be visible however. On the other hand, when
Alice (using Element) is the one to send the first DM to Bob, he can
decrypt the initial message.

For Pantalaimon to execute /keys/claim, get_missing_sessions must return
the invitee's device (and log "Missing session for device"). If
Pantalaimon calls this method too soon, then self.device_store will not
have the device. To populate self.device_store before Pantalaimon calls
get_missing_sessions, it must execute /keys/query (and invoke
_handle_key_query) earlier, during the /createRoom request. Pantalaimon
does execute the /keys/query request during a sync after the server
finishes creating the DM (and logs "Adding new device to the device
store for user"), but only after checking unsuccessfully for the device
in self.device_store.

After this change, Pantalaimon executes /keys/claim, there is one record
in olmsessions, and Alice can decrypt Bob's initial message.
@chookity-pokk
Copy link
Collaborator

This is a few years late but @codemonium if you want to rebase this on master I'd like to merge it.

@chookity-pokk chookity-pokk merged commit a2a2d70 into matrix-org:master Oct 30, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants