Meet Element R: our new unified crypto implementation

February 27, 2024
Security

Improved security performance across mobile and desktop

We’ve created a common cryptographic library implementation in Rust - codenamed Element R - for all our Element clients. With the latest release of Element Web and Desktop, the new implementation is now deployed across all of our mobile and desktop apps (iOS, Android, Windows, MacOS, Linux and Web) and means we can now start to realise its full potential. This is because until now not all users were relying on the new implementation, which is necessary to experience the full extent of the performance and reliability benefits.

This project has minimised the complexities associated with implementing E2EE. Many crypto issues/bugs from the legacy implementations are fixed now and there will be fewer instances where users are unable to decrypt messages. All of this work future-proofs our crypto and lays a strong foundation for our next-gen mobile app: Element X.

Moving to a common crypto implementation for all clients

The importance of cryptography

Given our software is a secure communications platform, a robust cryptographic implementation is central to our underlying architecture. It protects users, strengthens security and enables zero-trust decentralisation. Without the best cryptography, Element wouldn’t be working with multiple government agencies across the world. This includes three of our key German partners - the Ministry for the Interior (BMI) and the IT services providers BWI and Dataport - who we'd like to thank for their support on this project. Together, through our collaboration, we've covered tremendous ground and achieved great results within the timescale.

By converging our encryption on matrix-rust-sdk-crypto, we benefit significantly from Rust’s inherent memory safety, type safety, threading safety for fearless concurrency (whereas our old C++ libolm implementation was single threaded), and zero cost abstractions.  This also provides a single best-practice implementation of the higher level mechanisms for managing encryption in Matrix correctly - which previously were implemented entirely independently in each client.

For those looking for more technical details, and what this means for Matrix as a whole, check out the Vodozemac post on the Matrix blog. For everyone else, read on to understand what this work means within Element.

The key to efficient development

As our clients grew over time, our crypto implementations grew organically too. These

separate, legacy implementations caused inefficiency. A single universal crypto SDK helps us to fix bugs in one place, and accelerate our innovation with features like trust-on-first-use (TOFU), device dehydration, post quantum encryption, libsignal interoperability, and backup enhancements.

If you aren’t already aware, we’re in the process of launching our next-generation Matrix client: Element X Implementing our new Rust crypto libraries is a key part of our journey towards the best Matrix-based client in the world. Going forward our mobile apps are now built from the ground up using this new matrix-rust-sdk-crypto implementation, including Element X.

Locking in the advantages

It’s all about improving our security. Less complexity reduces potential implementation errors. Streamlining the development process enables efficient deployment, which means we progress faster. Security auditing is also simplified which saves time (and cost), given all the encryption is implemented in one place, in a single codebase. Ultimately, unified and strengthened cryptography is a win-win situation.

Our Rust crypto libraries out-perform our legacy libraries by a long, long way…

This test shows the new crypto implementation is up to 14 times faster when sharing a cryptographic key to 500 devices. The numbers speak for themselves!

Deciphering a secure future

We’re so excited to be sharing this news after working on such an ambitious project for the past two years. Achieving this milestone marks a significant moment for us, although our work is far from over. Now it’s time to move from delivering the universal crypto library to using it to our advantage and passing the benefits onto our users - you!

As we begin our final descent into Rust-land… please ensure your seatbelts are securely fastened and your belongings are in the overhead compartments. We thank you for choosing to fly Element. Enjoy your stay… 🛬


Related Posts

By the same author

Thanks for reading our blog— if you got this far, you should head toelement.ioto learn more!