HashMesh is decentralized, and peer-to-peer messaging application designed for robust and private communication. Built with Rust for performance and security, HashMesh aims to provide a resilient communication network where users maintain control over their data, and share only what's needed.
HashMesh operates on a custom binary protocol over TCP, avoiding traditional HTTP/JSON overhead for efficiency and direct control over the communication stack.
- Custom Binary Protocol: Efficient, low-overhead communication using
rkyvfor zero-copy serialization/deserialization. - Peer-to-Peer (P2P) Architecture: Direct client-to-client connections for enhanced privacy and resilience.
- Out-of-band Security: End-to-end encryption and authentication is all trusted on the user, we don't take care of what you want to share and we don't track you. Out-of-band encryption mechanisms are central to the protocol design.
- Cross-Platform (Planned): Rust backend for core logic, Flutter frontend for desktop and mobile applications.
- Decentralized Discovery (Planned): Mechanisms for clients to discover each other without relying on a single central server.
- Message Routing: Intelligent routing of messages through connected peers to reach the intended recipient without sharing who.
The network consists of user devices and server nodes. Messages from a sender are routed through a server node to a destination. The server's role is to forward the message to either confirmed nodes that can reach the destination or to nodes that can help map the destination.
Servers establish connections through a handshake process. They exchange version and type information. A successful handshake results in an "ok" response. If there's a denial or failure, a reason or nothing is returned.
Server behavior can be configured using parameters such as:
rate_limit: The maximum operation rate in seconds.timeout: The duration after which an operation times out, in seconds.user_count: An optional parameter related to user counts.userid_format_rule: A regular expression for user ID format, defaulting to UUID V7.max_message_length: The maximum allowed length for messages.
All communication is encapsulated within a top-level Message enum, which can contain various sub-messages like ClientMessage, NodeMessage, HandshakeMessage, etc. Each message includes:
version: Protocol version for compatibility.own_uid: Sender's unique identifier (UUID).type: Indicates the message's purpose (e.g., "web", "p2p", "broadcast").encrypted_msg: The actual payload, encrypted for confidentiality.dest_uid: Recipient's unique identifier.ignore_uid_list: A list of UUIDs to avoid when routing, preventing loops.MAC: Message Authentication Code for integrity and authenticity.
Upon establishing a raw TCP connection, clients engage in a custom handshake process:
- Initial Exchange: Clients exchange their protocol
version,own_uid, and optionally a connectiontype. - Key Exchange: Securely establish a shared symmetric encryption key using a Diffie-Hellman-like key exchange.
- Authentication: Verify peer identity using digital signatures and public/private key pairs.
- Session Establishment: Confirm the secure channel is ready for application data.
This handshake ensures that all subsequent application data is encrypted and authenticated, providing end-to-end security. Please note that this project assumes that encrypted data can be decrypted by the recepient! Encryption keys are assumed to have been shared out of band, through a trusted channel!
Messages are routed through connected peers. If a message's dest_uid is not the current recipient,
the message is re-encrypted (if necessary) and forwarded to other connected peers, using the ignore_uid_list to prevent redundant forwarding.
- Rust (latest stable)
- Cargo (latest stable)
Navigate to the lib/ folder of the HashMesh repository and use Cargo:
cargo build --relaseThe lib Rust crate will be compiled as a native library (e.g., .so, .dylib, .dll) and linked into the Flutter application. Tools
like flutter_rust_bridge can simplify this process significantly.
Detailed instructions for running the Flutter application and setting up a local P2P network will be provided as the project develops.
We welcome contributions to HashMesh! Please refer to our CONTRIBUTING.md (to be created) for guidelines on how to get involved.
This project is licensed under the [GPLv3] - see the LICENSE file for details.