Extract common crypto interface for all flavors #8470
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Type of change
Content
The full realmCrypto store API was still available in the rust flavor, it's problematic because several things have moved from realm and are now stored in the rust sdk.
As an example EventEditValidator was calling
deviceWithIdentityKey
from the legacy realm store on rust flavor, thus getting absent or outdated information.As a solution for that a IMXCommonCryptoStore interface has been extracted, that contains API that both falvors are still using. The RealmCryptoStore (IMXCryptoStore) full API has been moved to the kotlinCrypto flavor, and a RustCryptoStore has been introduced for the rustCryptoFalvor.
In a following PR we will see how to complitely remove the need for a realm crypto store, some changes are needed on the rust sdk in order to do it now (partial support is there, but not yet integrated, and some more might be needed).
One exception to that rule, the rust flavor is migrating megolm sessions lazyly, so it needs to access the legacy store for a moment.
Also added some defensive coding for some crash reported on sentry when trying to import megolm session from legacy store (added a log and tryOrNull in RequestSender for now).
The logic has changed in EventEditValidator because the rust-sdk doesn't have an API to get a device from a senderKey, you need to provide a userId as well in rust. Updated the test accordingly.
Motivation and context
Screenshots / GIFs
Tests
Tested devices
Checklist