-
Notifications
You must be signed in to change notification settings - Fork 71
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
Query & claim needed keys before encrypting #270
Query & claim needed keys before encrypting #270
Conversation
Ensure that the bot has all keys needed for sharing a room key with recipients before encryping an event in that room. Signed-off-by: Andrew Ferrazzutti <[email protected]>
src/e2ee/RustEngine.ts
Outdated
@@ -106,6 +107,14 @@ export class RustEngine { | |||
settings.rotationPeriod = BigInt(encEv.rotationPeriodMs); | |||
settings.rotationPeriodMessages = BigInt(encEv.rotationPeriodMessages); | |||
|
|||
await this.run(RequestType.KeysQuery); |
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.
This doesn't appear to cause a query request to happen?
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.
It does, because by the time this is hit, the CryptoClient has updated the list of tracked users in the room, which queues outgoing key query requests in the crypto state machine.
Without this line, the first message a bot sends in an encrypted room with a user it hasn't seen before will be unencryptable by that user.
Otherwise, the SDK calls RustEngine.run
(and processes all outgoing requests, including key queries) after having already sent its first (encrypted) message, meaning it won't have the device key of new users & can't send them the to-device message containing the room key.
Ensure that the bot has all keys needed for sharing a room key with recipients before encryping an event in that room. Signed-off-by: Andrew Ferrazzutti <[email protected]>
Ensure that the bot has all keys needed for sharing a room key with recipients before encryping an event in that room. Signed-off-by: Andrew Ferrazzutti <[email protected]>
Ensure that the bot has all keys needed for sharing a room key with recipients before encryping an event in that room. Signed-off-by: Andrew Ferrazzutti <[email protected]>
Ensure that the bot has all keys needed for sharing a room key with recipients before encryping an event in that room. Signed-off-by: Andrew Ferrazzutti <[email protected]>
Ensure that the bot has all keys needed for sharing a room key with recipients before encryping an event in that room. Signed-off-by: Andrew Ferrazzutti <[email protected]>
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.
thanks :)
I've changed this slightly to match some desirables of the bot-sdk's public API, but generally lgtm
Ensure that the bot has all keys needed for sharing a room key with recipients before encryping an event in that room.
Signed-off-by: Andrew Ferrazzutti [email protected]
Checklist