A mobile-optimized Rust implementation of the Noise Protocol Framework, designed for iOS and Android integration in P2P messaging applications.
noise-mobile-rust provides FFI-safe bindings for the Noise Protocol, making it easy to integrate secure, end-to-end encrypted communication into mobile applications. Built on top of the excellent snow library, this crate adds mobile-specific optimizations and a clean FFI interface.
- π Noise Protocol XX - Mutual authentication pattern
- π± Mobile Optimized - Battery-efficient, background-task aware
- π Network Resilient - Handles connection interruptions gracefully
- π High Performance - < 10ms handshakes on mobile CPUs
- π‘οΈ Memory Safe - Rust's guarantees extend across FFI boundary
- π§ͺ Extensively Tested - Unit, integration, and device tests
βββββββββββββββββββ βββββββββββββββββββ
β iOS Swift β β Android Kotlin β
β App β β App β
ββββββββββ¬βββββββββ ββββββββββ¬βββββββββ
β FFI β JNI
βββββββββββββ¬ββββββββββββ€
β
βββββββββββββΌββββββββββββ
β noise-mobile-rust β
β (This Library) β
β β
β β’ C-compatible API β
β β’ Mobile optimizationsβ
β β’ Network resilience β
βββββββββββββ¬ββββββββββββ
β
βββββββββββββΌββββββββββββ
β snow library β
β (Noise Protocol impl) β
βββββββββββββββββββββββββ
use noise_mobile::{NoiseSession, NoiseMode};
// Initialize a session
let session = NoiseSession::new(NoiseMode::Initiator)?;
// Perform handshake
let handshake_msg = session.write_message(&[])?;
// Send handshake_msg to peer...
// After handshake completion
let encrypted = session.encrypt(b"Hello, secure world!")?;import NoiseMobile
let session = NoiseSession(mode: .initiator)
let handshakeData = try session.writeMessage(Data())
// Send to peer...import com.noise.mobile.NoiseSession
val session = NoiseSession(NoiseMode.INITIATOR)
val handshakeData = session.writeMessage(ByteArray(0))
// Send to peer...| Operation | Target | Actual |
|---|---|---|
| Handshake | < 10ms | TBD |
| Encrypt 1MB | < 100ms | TBD |
| Memory/Session | < 1KB | TBD |
- Rust 1.75+ (2021 edition)
- For iOS: Xcode 14+
- For Android: NDK r25+
# Debug build
cargo build
# Release build with optimizations
cargo build --release
# Run tests
cargo test
# Run benchmarks
cargo bench# iOS
cargo build --target aarch64-apple-ios --release
# Android
cargo build --target aarch64-linux-android --releaseWe prioritize testing on real devices:
# Unit tests
cargo test
# FFI boundary tests
cargo test --features ffi-tests
# Integration tests (requires device/simulator)
cargo test --features integration-tests
# Benchmarks
cargo benchnoise-mobile-rust/
βββ src/
β βββ core/ # Pure Rust implementation
β βββ ffi/ # FFI bindings
β βββ mobile/ # Mobile-specific features
βββ tests/ # Comprehensive test suite
βββ benches/ # Performance benchmarks
βββ examples/ # Integration examples
- All cryptographic operations via audited
snowlibrary - Zeroization of sensitive data
- Constant-time operations where required
- No runtime panics in FFI layer
Contributions are welcome! Please ensure:
- All tests pass
- No compiler warnings
- Code is formatted with
rustfmt - New features include tests
- FFI changes are documented
- P2P messaging apps (like BitChat)
- Secure file transfer
- IoT device communication
- Any app requiring end-to-end encryption
MIT OR Apache-2.0
Built on top of snow by @mcginty