The Friends Messenger
A unique completely decentralized messenger that doesn’t use any centralised servers to establish a direct p2p communication between friends.
Features
The Friends Chat Application enables direct peer-to-peer communication between users via WebRTC.
The Handshake to exchange Peer Info doesn’t rely on a classic Server but utilizes the Autonomi Network as handshake server (to be more precise Scratchpads on the autonomi network) for this.
To sign up, create an account and start chatting with a friend you can see the flow in this little demo:
planned Features:
- easier theming
- plugins (through JS Webcomponents loaded from immutable chunks on Autonomi)
- multi-user chat
- optionally persisting chat history
- sending offline messages => encrypted to a friend-specific scratchpad
- more extensive profile pages
- better status (more options even when online)
- App as JS Webcomponent (usable by other Autonomi Apps)
- App as Native App for all OSes and mobile
Security Aspects
The Friends Messenger ensures secure communication through multiple layers:
- End-to-End Encryption: All peer-to-peer communication is secured via WebRTC’s built-in DTLS (Datagram Transport Layer Security) and SRTP (Secure Real-time Transport Protocol)
- Cryptographic Identity: Each user has a unique cryptographic profile ID (96-character hex string) derived from their account creation process
- Decentralized Handshake: No central server stores or has access to user data - the Autonomi Network facilitates the initial peer discovery
- Perfect Forward Secrecy: Each WebRTC session establishes new encryption keys, ensuring past communications remain secure even if keys are compromised
- No Data Persistence: Messages are not stored on any server - they exist only during the active peer-to-peer session
Installation & Start
To start the P2P chat application, you first need to install the dweb
command line tool (after installing rustup if you don’t have that; description and link in the troubleshooting section at the bottom):
cargo install --locked dweb-cli
and then you need to make sure to include a private key holding some Eth(Arb) and ANT in your environment variables to enable dweb to pay for the needed Account Setup (one digit USD worth of Eth and 1 ANT are enough for everything needed as of now)
easiest is to include this export in your ~/.bashrc (or other terminal init file)
export SECRET_KEY=0x1111111111111111111111111111111111111111111111111111111111111111
After installation, you can start the dweb server with:
(blocks one terminal session)
dweb serve
and then you can open friends from a 2nd terminal with
dweb open friends
For more detailed instructions regarding dweb, please visit the dweb repository.
Technical Details:
Unique Public Identifier
The Friends Messenger uses a sophisticated cryptographic identity system:
- Profile ID Generation: When a user creates an account, a unique 96-character hexadecimal Profile ID is generated and used as their cryptographic identity
- Public Scratchpad: This Profile ID becomes the address of a public scratchpad on the Autonomi Network containing the user’s profile information (display name, profile image, friend request details)
- Public Identifier (Optional): Users can create human-readable public names (like usernames) that point to their Profile ID via cryptographic pointers
- Searchable Identity: Friends can find each other either by the full 96-character Profile ID or by the optional public identifier
Friendship Requests
The friendship system works through a simple scratchpad-based messaging system where the communication partners tell each other where they expect the messages and check that location in intervals:
-
Profile Discovery: Each user’s profile is stored in a public scratchpad at their Profile ID address, containing their display name, profile image, and most importantly, the access credentials for their friend request scratchpad
-
Friend Request Scratchpad: Each user has a private scratchpad where friend requests are received. The profile contains the private key needed to write to this scratchpad. Since the private key to this Friend Request Scratchpad this will be changeable in future upgrades => to mess it up repeatedly would be costly because then the requester would need to pay for it.
-
Request Process: When Alice wants to add Bob as a friend:
- Alice looks up Bob’s Profile ID (either full 96-char ID or via public identifier)
- Alice reads Bob’s public profile to get his friend request scratchpad details
- Alice posts a friend request containing her own response scratchpad address
-
Response Process: Bob periodically checks his friend request scratchpad:
- When Bob sees Alice’s request, he can choose to approve or deny
- If approved, Bob posts his response to Alice’s specified response address
- Alice polls her response scratchpad and receives Bob’s approval
-
Connection Establishment: Once both parties have exchanged scratchpad addresses, they can establish a direct WebRTC connection for real-time communication
This decentralized approach ensures no central server ever sees or stores the friend relationships - everything is mediated through the Autonomi Network’s scratchpad system.
Architecture & Technologies
The Friends Messenger is built using modern web technologies:
- Frontend: Svelte/SvelteKit for reactive user interface
- WebRTC: Direct peer-to-peer communication with automatic NAT traversal
- Autonomi Network: Decentralized storage network for profile and friend request data
- Scratchpads: Autonomi’s mutable storage system for user profiles and to facilitate peer discovery
- Smokesigns Library: WebRTC abstraction layer for simplified peer connections
- Cryptographic Security: SHA256 hashing and hex-based addressing for secure identity management
Development Features
- Multi-language Support: UI available in English and German. Other languages will follow soonish
- File Sharing: Support for sending images, videos, and files through WebRTC data channels
- Theme Support: Customizable UI themes
- Real-time Status: Connection status indicators
Troubleshooting
I recommend installing dweb via cargo after installing rustup (the rust development environment)
e.g. on Linux/MacOS:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
(after that you need to close and open the terminal again)
then the
cargo install --locked dweb-cli
Error scenarios
in case you see errors with the dweb install you may need to:
sudo apt-get update && sudo apt-get install libssl-dev pkg-config