Skip to content

Commit 86f0e3c

Browse files
committed
Improve docs about the Rust crypto integration
1 parent cd6078c commit 86f0e3c

File tree

2 files changed

+16
-41
lines changed

2 files changed

+16
-41
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ Note that if the templates are modified, the only things to do is to restart And
7070

7171
For now, the Matrix SDK and the Element application are in the same project. So there is no specific thing to do, this project should compile without any special action.
7272

73+
See [docs/rust_crypto_integration.md](./docs/rust_crypto_integration.md#testing-with-a-local-rust-aar) for notes on building against a custom version of the Rust `matrix-sdk-crypto`.
74+
7375
## I want to help translating Element
7476

7577
If you want to fix an issue with an English string, please submit a PR.

docs/rust_crypto_integration.md

Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,18 @@
11
## Overview
22

3-
Until the final migration to [rust crypto sdk](https://github.com/matrix-org/matrix-rust-components-kotlin), the Element Android project will support two
4-
different SDK as a product flavor.
5-
6-
The `matrix-sdk-android` module is defining a new flavor dimension `crypto`, with two flavors `kotlinCrypto` and `rustCrypto`.
7-
The crypto module cannot be changed at runtime, it's a build time configuration. The app supports migration from kotlinCrypto to rustCrypto but not the other
8-
way around.
9-
10-
The code that is not shared between the flavors is located in dedicated source sets (`src/kotlinCrypto/`, `src/rustCrypto/`). Some tests are also extracted
11-
in different source sets because they were accessing internal API and won't work with the rust crypto sdk.
12-
13-
## Noticeable changes
14-
15-
As a general rule, if you stick to the `kotlinCrypto` the app should behave as it was before the integration of favours.
16-
There is a noticeable exception though:
17-
In order to integrate the rust crypto several APIs had to be migrated from callback code to suspendable code. This change
18-
impacted a lot the key verification engine (user and device verification), so this part has been refactored for `kotlinCrypto`. The UI is also impacted,
19-
the verification flows now match the web experience.
20-
21-
TLDR; Verification UI and engine has been refactored.
3+
Element Android [now](https://github.com/element-hq/element-android/pull/8656) only supports the [rust crypto SDK](https://github.com/matrix-org/matrix-rust-sdk/tree/main/crates/matrix-sdk-crypto).
224

235
## Testing with a local rust aar
246

25-
In order to run a custom rust SDK branch you can follow the direction in the [bindings repository](https://github.com/matrix-org/matrix-rust-components-kotlin)
26-
in order to build the `matrix-rust-sdk-crypto.aar`.
7+
In order to run a custom rust SDK branch you can follow the directions in the
8+
[bindings repository](https://github.com/matrix-org/matrix-rust-components-kotlin?tab=readme-ov-file#testing-locally)
9+
in order to build the AAR for the crypto crate.
10+
11+
Install the resulting aar as `./library/rustCrypto/matrix-rust-sdk-crypto.aar`. For example:
2712

28-
Copy this lib in `library/rustCrypto/`, and rename it `matrix-rust-sdk-crypto.aar`.
13+
```sh
14+
ln -s <path_to_matrix-rust-components-kotlin>/crypto/crypto-android/build/outputs/aar/crypto-android-debug.aar ./library/rustCrypto/matrix-rust-sdk-crypto.aar
15+
```
2916

3017
Then go to `matrix-sdk-android/build.gradle` and toggle the comments between the following lines.
3118

@@ -34,30 +21,16 @@ Then go to `matrix-sdk-android/build.gradle` and toggle the comments between the
3421
// rustCryptoApi project(":library:rustCrypto")
3522
````
3623

37-
## Changes in CI
38-
39-
The workflow files have been updated to use the `kotlinCrypto` flavor, e.g
40-
41-
`assembleGplayNightly` => `assembleGplayKotlinCryptoNightly`
42-
43-
So building the unsigned release kotlin crypto apk is now:
44-
45-
`> ./gradlew assembleGplayKotlinCryptoRelease`
46-
47-
An additional workflow has been added to build the `rustCrypto` flavor (elementr.yml, ` Build debug APKs ER`).
48-
49-
5024
## Database migration from kotlin to rust
5125

52-
With the kotlin flavor, the crypto information are persisted in the crypto realm database.
53-
With the rust flavor, the crypto information are in a sqllite database.
26+
Crypto information is now persisted in a SQLite database.
5427

55-
The migration is handled when injecting `@SessionRustFilesDirectory` in the olmMachine.
28+
The migration from the old Realm database is handled when injecting `@SessionRustFilesDirectory` in the olmMachine.
5629
When launching the first time after migration, the app will detect that there is no rust data repository and it will
5730
create one. If there is an existing realm database, the data will then migrated to rust. See `ExtractMigrationDataUseCase`.
5831
This will extract your device keys, account secrets, active olm and megolm sessions.
5932

60-
There is no inverse migration for now, as there is not yet rust pickle to olm pickle support in the sdk.
61-
62-
If you migrate your app to rust, and want to revert to kotlin you have to logout then login again.
33+
There is no inverse migration. If you migrate to a version of the app that uses
34+
the Rust library, and want to revert to a Kotlin-crypto version, you will have
35+
to logout then login again.
6336

0 commit comments

Comments
 (0)