matrix-rust-sdk icon indicating copy to clipboard operation
matrix-rust-sdk copied to clipboard

Refactor the verification handling in the crypto crate

Open poljar opened this issue 4 years ago • 4 comments

The verification logic has a bunch of layers, the bottom layer is a type-safe state machine. We should be able to simplify this, at least for the SAS verification types.

poljar avatar Nov 09 '21 14:11 poljar

One thing that would help out immensely for the type-safe state machine is the type-changing struct update syntax.

Has been in development for some while though: https://github.com/rust-lang/rust/issues/86555.

poljar avatar Oct 26 '22 11:10 poljar

It's also a bit magical how the crypto crates handles verification events. For example in rooms, it handles it because we try to decrypt the event (there is no receive room event call similar to to_device). As a consequence verification in a clear room won't work.

BillCarsonFr avatar Nov 28 '22 21:11 BillCarsonFr

It's also a bit magical how the crypto crates handles verification events. For example in rooms, it handles it because we try to decrypt the event (there is no receive room event call similar to to_device). As a consequence verification in a clear room won't work.

Oh I see there is a call for that receiveUnencryptedVerificationEvent()

BillCarsonFr avatar Nov 29 '22 08:11 BillCarsonFr

Oh I see there is a call for that receiveUnencryptedVerificationEvent()

There is, but you also seem to have missed some conversation in chat:

how about we remove the implicit handling of verification events when you decrypt, deprecate the receive_unencrypted_verification_event method and instead add a receive_verification_events() method; this method takes all the verification events we received in a particular sync and we fire out the signals when this method is gone through all events?

Perhaps we'll end up with just a single method that you need to call explicitly.

poljar avatar Nov 29 '22 08:11 poljar