-
Notifications
You must be signed in to change notification settings - Fork 731
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
Ensure OTKs are uploaded when the session is created #3724
Conversation
The sync response can omit the field device_one_time_keys_count.signed_curve25519 and the SDK was waiting to know this value to upload the OTK. Now the SDK uploads the OTK when it uploads the device keys.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Only issue is that existing devices impacted won't recover the missing sessionIds (even key request should fail with withheld I think).
Only option could be to do a megolm key import on background (if there is a backup and the keys were uploaded by another session)
I think we might need to force to upload new OTK with this patch |
Done, see commit 0598810 |
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OneTimeKeysUploader.kt
Outdated
Show resolved
Hide resolved
matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/OneTimeKeysUploader.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a bit of logging for errors?
You are already uploading one time keys here if Considering that you already upload keys when the subfield is null, why not do so, when deviceOneTimeKeysCount is null? Then you don't need to force an OTK upload after the upgrade and the logic would work fine with the synapse changes. Yes, the spec isn't clear here, but you are already depending on the subfield to not be null. I think you can extend the requirement to the whole parent object. |
I'm not sure to follow you. In our case |
Instead of
do:
The difference is minimal. Now you also update OTKs, if the field is ompletely missing instead of just the signedCurve25519 field being missing. Since you already interpret missing fields as being 0, this should not really be a change from the spec side, even if that spec is unclear if the field can be missing, when nothing changed. And it fixes it even on synapses that leave out the field completely without any need for migration, I think. (I am not familiar with kotlin or the codebase though) Or in other words, |
@deepbluev7 if |
@bmarty Why does |
definitly Empirically, when Synapse sends We keep the nullability everywhere because of optionality, and multiple server implementation / changes, so it always a bit painful to deal with such fallback. |
The sync response can omit the field
device_one_time_keys_count.signed_curve25519
and the SDK was waiting to know this value to eventually upload some OTKs, even after a session creation.Now the SDK uploads the OTK when it uploads the device keys.
This is due to recent change on Synapse sync response: https://github.com/matrix-org/synapse/pull/10214/files/7978990f5139067e1868d100d223e28e4447d2fb#diff-70f29654c1c37fb886340dc6f22a99571503f4a54dc46942ca6028b8896b00b7L254