Cipher: An End-to-End Encrypted Peer-to-Peer Instant Mobile Messaging System
Abstract
Most instant messaging applications rely on a centralized client-server architecture, which entails systemic risks such as data privacy concerns, censorship, and single points of failure. This study designs and implements Cipher, a peer-to-peer mobile instant messaging system that communicates without transmitting message content to a central server in plain text. The network and cryptography core was developed in Go using hexagonal architecture; Android and iOS clients were built with Flutter and integrated via the Gomobile bridge. Security employs RSA-4096 identity keys, HMAC-SHA256-based deterministic session key derivation, and AES-256-GCM authenticated encryption. A composite transport layer combines UDP, a WebRTC data channel, ICE with STUN/TURN, and an encrypted Firebase relay fallback. Field tests showed a connection success rate above 95%, an average 30% latency increase in relay mode versus direct P2P, reliable large-file transfer over UDP through fragmentation and rate limiting, and application startup reduced from 5 s to under 1 s. The findings indicate that a mobile-first, secure, and usable decentralized communication prototype is feasible with appropriate architectural choices.