Friday, July 29, 2011

Bit Chat: A Peer-to-Peer Instant Messaging Concept Using BitTorrent Trackers

UPDATE: 5 Jan, 2015
Technitium Bit Chat (alpha version) is now available for download at https://bitchat.im

Bit Chat is a concept that I got while thinking about having a instant messaging (IM) system which would be completely decentralized, peer-to-peer and friend-to-friend and would provide confidentiality and optionally authentication. In this regards, BitChat can be considered a darknet system. BitChat takes many of the BitTorrent concepts and uses them to provide an instant messaging (IM) system instead of file sharing.

The classic problem faced in peer-to-peer system is to find IP address of peers who want to communicate together privately in a group. BitChat concept finds solution for it by using existing BitTorrent trackers and forming a peer-to-peer network by connecting to the nodes which are being tracked by the same infohash. DHT can also be used with trackers.

The current concept allows to use channels (similar to IRC channels) over which peers can communicate. Each channel has its own unique infohash. The topology currently thought is a full mesh network between small number of peers.

Each peer starts with a .chat file (just like a .torrent file) which contains infohash and tracker list. The file can be exchanged by email or any other way (even offline). BitChat client would use this file and get an IP address list of all the peers from the trackers mentioned in the file.

For providing privacy, BitChat would fake user agent info of popular BitTorrent clients so that even tracker servers dont know the intentions of the users. The client then maintains a peer list and connects to each of them in a full mesh.

Every connection to another peer is done with a brief handshake in which each peer exchange their identifiers, public keys and a list of peers that each one of them have (similar to peer exchange). Any new peer found from another peer is immediately connected in order to have a full mesh network. Each connection to a peer can be using TCP if directly feasible or UDP in case of client being behind NAT. UDP would punch holes in NAT allowing direct communication between peers possible. The client will have to implement a TCP like retransmission mechanism to solve problems with dropped UDP packets.

A client behind a http proxy can be supported such that it creates outbound connections to rest of the peers. Two peers behind http proxy will not have a direct link in such case and messages between them will have to be routed through other willing peers.

Authentication can be done with the help of public key cryptographic algorithms like RSA. The public key of peers can be exchanged online/offline and a small address book be maintained by BitChat clients to identify friends. The public key exchanged during peer-to-peer handshake will be matched with the address book to verify identity of known contacts.

A channel can be open ended or invite only. If the channel is only for closed group, the BitChat client can reject peer request from unknown contacts. In any case, only users who have the .chat file (or the infohash) can join the network in first place.

Confidentiality can be achieved by using public key cryptography. The public key of each peer will be used to do a key exchange for an agreed upon symmetric key algorithm. Each connection to a peer will have a separate key and it can be renewed with a handshake at regular intervals.

The system would allow for a common chat for all peers in a channel as well as private one-to-one chat. A group chat with only selected peers can be made with the group chat initiator deciding on whom to invite from the peers.

A simple client would implement text chat with a simple one-to-one file sharing. While, clients which can support voice and video chat can be developed.

Security issues which affect BitTorrent also apply to BitChat. The IP address of all peers is open to anyone knowing the infohash being used. Mitigation can be done by use of VPN or proxy services.

There are lot of peer-to-peer projects already being developed and used. BitChat concept is about using an existing infrastructure provided by BitTorrent and using it for a secure, private and user friendly instant messaging system.

A prototype or a working proof of concept client in .NET is being developed by Pratik Patil. The final client too will be made in .NET using .NET Framework 2.0 such that it would run on Mono Framework which supports Linux as well as MAC.

The protocol specification is under development and will be made public so that anyone can make their own BitChat client. Any inputs and queries are most welcomed. Post comments or send an email to me (shreyas at technitium dot com) or Pratik (pratik at technitium dot com).