One of the defining principles behind web technologies is building things once and making them available everywhere regardless of the device or platform. This inspired us to build a web version of Wire that anyone could use in a WebRTC-enabled browser.

However, there’s one major challenge with web applications. JavaScript, the web’s programming language, was built for programmer productivity at the expense of performance efficiency. It was the right decision by Brendan Eich when he created JavaScript in 1995 to make interactive websites a reality.

But the internet has evolved since then, and so have the expectations of users and web developers. Hardware access, offline operation, and real-time communication are the new norm for developers, and JavaScript serves as the foundation for these technologies.

Since JavaScript is an interpreted language, code compilation is done at runtime. This requires extra computational time during program execution compared to compiled programming languages. The impact depends on the application — the speed difference is not very noticeable when displaying static images or text, but can have a significant effect during cryptographic calculations.

Wire’s end-to-end encryption protocol Proteus, originally written in Rust, makes use of cryptographic primitives from the implementations of HMAC-SHA256, Curve25519 and HKDF. These algorithms are essential for everything that happens in Wire and are provided by the Sodium crypto library.

The Sodium library is available for numerous platforms — a native version written in C (libsodium), bindings for Rust (rust_sodium) and a pure JavaScript version (libsodium.js), which has been compiled using Emscripten.

The Rust version of Proteus is tightly integrated in our mobile apps and uses the Rust bindings to libsodium, which are significantly faster than their JavaScript counterparts: