Back to Blog
Engineering Architecture June 2026 7 min read

Why the VeilMesh Core Is Written in Rust

Why we wrote one memory-safe core in Rust for the cryptography and networking of the iOS, Android and desktop apps.

VeilMesh's routing and cryptography live in one engine, and we had to pick a language for it. We needed an engine that could run natively on iOS, Android, macOS, Windows, and Linux without rewriting the complex Double Ratchet and Proof-of-Work logic for every platform.

Separate code for each platform

Historically, building a mobile messenger meant maintaining two completely separate codebases (Swift for iOS, Kotlin/Java for Android). For a security product that is risky, because a cryptographic bug fixed on iOS can stay unfixed on Android.

React Native and Flutter are UI frameworks; they are not meant for low-level networking, Bluetooth LE state machines or cryptographic hashing, so the core needed a systems language.

Rust Unified Software Core Concept
Figure 1: A single Rust core compiling natively to dynamic libraries for all target platforms, wrapping complex cryptographic logic.

Why Not C++ or Go?

C++ has been the traditional choice for shared cross-platform libraries (used heavily by legacy commercial messengers). However, C++ requires manual memory management. In a networking protocol parsing raw bytes from potentially malicious peers, a single buffer overflow or use-after-free vulnerability can compromise the device.

Go (Golang) works well for backend servers, but it brings a heavy runtime and a Garbage Collector (GC). Running a GC language embedded within an iOS App or an Android App introduces unpredictable latency spikes and makes interoperability via C-FFI (Foreign Function Interface) awkward and adds overhead.

Limited hardware

In much of modern software engineering, if a backend application is slow or leaks memory, the usual response is to "scale up": add more RAM, raise Kubernetes limits, or add cloud instances on AWS or Azure. So a lot of code allocates freely and nobody notices.

An offline mesh network does not have this option. A phone has a fixed battery, a mesh gateway on an OpenWrt router may have 16MB of RAM, and BLE and sub-GHz Wi-Fi HaLow links have small MTUs. None of that can be bought more of, so the core has to be frugal with memory and CPU from the start.

Why Rust

We picked Rust for three reasons:

  1. Memory Safety without a Garbage Collector: Safe Rust rules out use-after-free and data races at compile time, and an out-of-bounds read in a packet parser becomes a checked error instead of memory corruption.
  2. Speed: Ed25519 signature verification and SHA-256 proof-of-work run about as fast as C, which matters for battery life.
  3. Generated FFI (Foreign Function Interface) bindings: uniffi generates Swift (iOS) and Kotlin (Android) bindings from the Rust core. UI developers call functions like mesh_core.send_message() as ordinary Swift or Kotlin code, without dealing with Rust directly.

One core for every platform

All protocol logic lives in veilmesh_core, so a routing bug fixed in Rust is fixed on every platform. It also means our small team reviews one implementation of the security code instead of several.