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

Process received room key requests #449

Merged
merged 4 commits into from
Jun 6, 2017

Conversation

richvdh
Copy link
Member

@richvdh richvdh commented Jun 1, 2017

Doesn't actually do any of the crypto magic yet.

* Determine if we have the keys necessary to respond to a room key request
*
* @param {module:crypto#RoomKeyRequest} keyRequest
* @return {boolean} true if we have the keys and could (theoretically) share
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll probably be querying indexeddb to get the answer right? Probably want this to be a Promise then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well, not currently - the relevant info is in localstorage. Admittedly we'd probably like it to move to indexeddb, but that's a whole separate project

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's in local storage, won't we hit size limits again? It's pretty easy to convert this to be q(bool) right? I would prefer if we did an async design up-front, as it's often a pain to turn a synchronous API into an async one retrospectively.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the relevant info is already in localstorage.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

// list of IncomingRoomKeyRequests/IncomingRoomKeyRequestCancellations
// we received in the current sync.
this._receivedRoomKeyRequests = [];
this._receivedRoomKeyRequestCancellations = [];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storing them like this means we lose ordering information from /sync. Is this a problem?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

E.g if I send a key request then immediately cancel it, currently we will process the key request due to how _processReceivedRoomKeyRequests is currently implemented.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well now.

AFAIK there is no guarantee in the protocol that the ordering of to-device messages is preserved anyway, so this whole thing is a steaming pile of fragility.

That said - in the case you mention, we will process the key request, and then process the cancellation. Which is considerably better than processing (and, presumably, ignoring) the cancellation and then the request.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we will process the key request, and then process the cancellation.

Doesn't that race? We should at least mention the ordering concerns and decisions / things we've punted on for now somewhere.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, of course it races:

AFAIK there is no guarantee in the protocol that the ordering of to-device messages is preserved anyway, so this whole thing is a steaming pile of fragility.

the order in which requests and cancellations order are, tbh, the least of my concerns here. I want to ship it and iterate it rather than think through the edge cases any more. This work has taken weeks already.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

continue;
}

req._shareCallback = () => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like that Crypto is clobbering an _ variable on a different class (IncomingRoomKeyRequest) like this. Please either make a public function to do this, or don't pretend that this is private. Just because both classes are in the same 1300 line file is not a good enough reason to gut wrench.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fair. Hopefully fixed in 1664312.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

WFM!

@kegsay
Copy link
Member

kegsay commented Jun 5, 2017

Otherwise LGTM.

@kegsay kegsay assigned richvdh and unassigned kegsay Jun 5, 2017
Avoid gut-wrenching properties on IncomingRoomKeyRequest.
@kegsay
Copy link
Member

kegsay commented Jun 6, 2017

LGTM

@richvdh richvdh changed the base branch from develop to room_key_sharing June 6, 2017 13:27
@richvdh richvdh merged commit 1c66524 into room_key_sharing Jun 6, 2017
@richvdh richvdh deleted the rav/handle_room_key_requests branch June 6, 2017 13:31
ylecollen pushed a commit to matrix-org/matrix-android-sdk that referenced this pull request Oct 25, 2017
manuroe added a commit to matrix-org/matrix-ios-sdk that referenced this pull request Nov 3, 2017
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.

None yet

2 participants