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

Crypto SDK usage in React Native #4453

Closed
flyingleafe opened this issue Dec 23, 2024 · 3 comments
Closed

Crypto SDK usage in React Native #4453

flyingleafe opened this issue Dec 23, 2024 · 3 comments

Comments

@flyingleafe
Copy link

Hello. We are developing an application with end-to-end encrypted chat functionality in React Native, and intend to use Matrix codebase for that purpose.

We initially planned to simply use matrix-js-sdk, doing basically the same which was started in matrix-rn-sdk, but never quite finished. We reused the CryptoStore implementation from this repository, but as it turned out, Rust Crypto API exposed by matrix-js-sdk never uses the provided CryptoStore implementation for anything except from old data migration to the new storage. The new (actual) storage could only be backed by IndexedDB (https://github.com/matrix-org/matrix-rust-sdk-crypto-wasm), which is unavailable in React Native environment

Currently, I see two possible paths forward for us:

  • Use matrix-sdk-crypto bindings for Android and iOS as native modules in React Native, and redefine the crypto module in matrix-js-sdk in some sort of way which will be reusing those native modules in the same manner the matrix-sdk-crypto WASM module is used;

  • Inside matrix-rust-sdk-crypto-wasm, make the crypto storage implementation based on some abstract key-value storage trait, and let JS code provide the storage implementation specific to the platform, and run all that through react-native-webassembly.

I am ready to partake in either endeavour and share the results with the comminity. However, I am not sure what will be easier and what will be more in line with the general direction of Matrix codebase development.

Any help regarding that would be much appreciated.

@zzorba
Copy link
Contributor

zzorba commented Dec 23, 2024

@flyingleafe today is your lucky day.

There is a newer open-sourced set of bindings for RN built using uniffi directly that you can find here: https://github.com/unomed-dev/react-native-matrix-sdk. It is built using the https://github.com/jhugman/uniffi-bindgen-react-native project which allows for direct usage of any uniffi enabled rust library in react-native.

It currently supports all features of the matrix-sdk-ffi crate for iOS and Android. The maintainers of both libraries hang out in this chat room https://matrix.to/#/#uniffi-bindgen-js:matrix.org, if you run into any issues.

@flyingleafe
Copy link
Author

@zzorba wow, that seemingly simplifies things a lot! Thank you very much for this info, Google was much less helpful in discovering those recent projects.

@bnjbvr
Copy link
Member

bnjbvr commented Jan 6, 2025

Closing, as it seems the uniffi react-native bindings are sufficient to address this; feel free to reopen if you think it's not the case.

@bnjbvr bnjbvr closed this as not planned Won't fix, can't repro, duplicate, stale Jan 6, 2025
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

No branches or pull requests

3 participants