Ever since Google hangouts broke XMPP federation (messages are just dropped!) I've been thinking about an alternative. I've always been a little uncomfortable with how my conversations with others are readable by the user's service provider.
As I have been working on the clearskies project, I have seen some ways that it'd be possible use it to create a friend-to-friend chat program. I am not the first to have the idea of peer-to-peer chat, but I think I have some ideas that might improve upon existing systems.
While I'll talk about chat, these same concepts would apply to any cloud service that is used for friend-to-friend or small group communication. For example, a location sharing application (like google latitude), a private photo sharing app (like snapchat), a family-oriented social network (like path), and email.
One of the big problems with P2P systems is spam. Without a central provider, there is no way to protect yourself from unwanted messages if your address gets leaked.
Clearskies (and its inspiration, BitTorrent Sync) work by creating "pairings" between devices. The pairing isn't really just a pair, as there can be three or more devices involved, but it's conceptually similar to pairing with bluetooth.
To avoid spam, friend-to-friend systems shouldn't have a public address. Instead, a pairing should be created between the two friends, using an out-of-band method, such as IM, facebook, or in person.
In other words, the software wouldn't have "friend requests" or "approve new buddy" popups.
One clear advantage to this system is that it also works better with strangers. For example, if you were at your job and a temporary contractor needed a way to contact you or send you files, you could pair with him and then break the pairing later on.
I will talk about how to implement this on top of btsync, since that's a system I believe most of the readers here will be familiar with. btsync isn't ideal for real-time communication, since it doesn't notice file changes quickly enough, but it serves to demonstrate the point.
The first thing that needs to be created is a folder that is only used to keep data in sync between multiple devices that the person owns. For example, Amy installs the chat software on her laptop and her cell phone. She pairs the app on her cell phone with the software on her laptop using the full-access secret for that folder. This would be done through the chat software itself, not btsync, meaning that she doesn't need to even know that btsync is involved under the hood.
When Amy wants to chat with Betty, she clicks to add a new buddy in the chat program on her laptop. The software creates a new folder for Betty and gives Amy its full-access secret. Amy sends this to Betty out-of-band, perhaps via facebook or SMS. Betty then clicks to add a new buddy and pastes the secret into her software.
The software will store the Amy-Betty secret into Amy's main folder so that the secret will propagate to Amy's cell phone. Her cell phone then creates the corresponding folder.
Amy and Betty are now connected and can chat. There would be a file per each of Amy and Betty's devices in the Amy-Betty folder that would be appended to whenever a new message is written.
In addition to file sync, the vision with clearskies is to provide a platform that makes it easier to add friend-to-friend services to existing programs. See my previous post for more information.
Further discussion can be found on the mailing list.