Back to Blog
Engineering Architecture June 2026 7 min read

Why Rust? Building a Unified Cross-Platform Core

We didn't choose Rust because it was trendy. We chose it because it was the only language capable of powering a unified, memory-safe cryptographic engine across iOS, Android, and Desktop simultaneously.

When starting VeilMesh, one of the most critical architectural decisions was choosing the language for our core routing and cryptographic engine. 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.

The Cross-Platform Dilemma

Historically, building a mobile messenger meant maintaining two completely separate codebases (Swift for iOS, Kotlin/Java for Android). This is a nightmare for a security product. A cryptographic bug fixed on iOS might be missed on Android.

Cross-platform UI frameworks like React Native or Flutter are excellent for painting pixels, but they are absolutely the wrong tool for heavy, low-level networking, Bluetooth LE state machines, and cryptographic hashing. We needed a true 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 is catastrophic.

Go (Golang) is fantastic 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) clumsy and bloated.

The "Infinite Resource" Trap

In modern software engineering, there is a common pattern: if a backend application is slow or leaks memory, the default response is to "scale up"—adding more RAM, increasing Kubernetes limits, or scaling cloud instances on AWS or Azure. This cloud-centric luxury often breeds a habit of writing highly allocate-heavy, resource-insensitive code that generates millions of temporary objects under the hood.

In an offline-first mesh network, this luxury vanishes. A smartphone battery cannot be scaled up in the cloud. A local mesh gateway running on a rugged OpenWrt router has a fixed, unexpandable 16MB of RAM. A sub-GHz Wi-Fi HaLow link or a BLE advertiser has rigid physical MTU limits that cannot be expanded with a subscription. Under these severe constraints, resource efficiency is not a micro-optimization; it is a prerequisite for survival. This is why standard enterprise runtimes fail in mesh environments—they are architecturally unfit for zero-trust, resource-constrained hardware.

The Rust Advantage

Rust hit the perfect sweet spot for VeilMesh, providing three non-negotiable guarantees:

  1. Memory Safety without a Garbage Collector: Rust's ownership model guarantees at compile-time that our packet parsers won't suffer from buffer overflows or data races, completely eliminating entire classes of zero-day vulnerabilities.
  2. Zero-Cost Abstractions: The Ed25519 signature verification and SHA-256 Proof-of-Work routines execute with the same raw C-level performance required to prevent battery drain on mobile devices.
  3. Seamless FFI (Foreign Function Interface): Using tools like uniffi, our Rust core automatically generates safe bindings for Swift (iOS) and Kotlin (Android). The UI developers simply call functions like mesh_core.send_message() without ever knowing they are interacting with Rust.

A Single Source of Truth

By centralizing the protocol logic in veilmesh_core, we guarantee that all platforms behave identically. A routing bug fixed once in Rust is instantly fixed across the entire ecosystem. This "Unified Core" architecture allows our small engineering team to move incredibly fast while maintaining military-grade security standards.