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

Rust crypto: support migration to Rust crypto #3964

Closed
richvdh opened this issue Dec 15, 2023 · 1 comment · Fixed by #3978
Closed

Rust crypto: support migration to Rust crypto #3964

richvdh opened this issue Dec 15, 2023 · 1 comment · Fixed by #3978
Assignees
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust Z-Labs

Comments

@richvdh
Copy link
Member

richvdh commented Dec 15, 2023

Part of support for migration to Rust Crypto. Depends on matrix-org/matrix-rust-sdk-crypto-wasm#78 and #3963.

Add a new migrateFromLegacyCrypto(legacyStore) method to js-sdk/src/rust-crypto, and call it in MatrixClient.initRustCrypto, before calling RustCrypto.initRustCrypto. First, it needs to check if there might be data to migrate:

  • Call CryptoStore.containsData and skip out if no data.
  • Call CryptoStore.startup.
  • Call CryptoStore.getMigrationState and skip any steps below that are done. Otherwise:
  • Extract the following and send to the rust layer:
    • (Pickled) account.
    • Private cross-signing keys (via CryptoStore.getSecretStorePrivateKey("master") etc)
    • Encrypted rooms (via CryptoStore.getEndToEndRooms)
    • Backup decryption key (via CryptoStore.getSecretStorePrivateKey("m.megolm_backup.v1"))
    • Backup version: we'll have to fetch this from the server (and check the key matches the above).
      Afterwards, call CryptoStore.setMigrationState to flag that this initial import has been done.
  • Then, migrate the Olm and Megolm sessions, in batches.

We need to emit some sort of progress indication, so that the app can give feedback. Probably something as simple as a crypto.dataMigrationProgress event, whose payload includes two numbers including a total number of steps, and a number of steps so far. We can wire this into the progress_listener callback of the rust migration functions.

@richvdh
Copy link
Member Author

richvdh commented Dec 15, 2023

We are ignoring:

  • Tracked users - I think the rust layer can figure this out for itself
  • Outgoing room key requests - hopefully we won't do these in ER anyway
  • session_problems - stores Olm sessions with decryption problems, for unwedging. We can let the Rust layer figure this out.

Stuff we may need to figure out how to import later:

  • List of withheld inbound group sessions
  • parked_shared_history and shared_history_inbound_group_sessons - something to do with history-share-on-invite, which we don't support in ER yet?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Element-R Issues affecting the port of Element's crypto layer to Rust Z-Labs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant