What we needed

AirSwap is a hybrid on-chain / off-chain protocol, which requires the coordination of off-chain peer-to-peer messages and on-chain identities (Ethereum addresses & private keys). If I’m chatting online with someone who claims to have control of an Ethereum address, I need to be able to cryptographically validate that they’re telling the truth.

We’ll call this first need off-chain/on-chain identity binding.

Secondly, since communication online is public by default, participants communicating with each other in a peer-to-peer network need to be able to hide their messages from everyone else, without trusting a central authority to coordinate encryption (public key registration).

We’ll call this need trustless end-to-end encryption.

Trustless end-to-end encryption enables another needed feature. If Alice is sending a message to Bob, and Bob is offline, Bob should be able to receive it when he comes back online, even if Alice no longer is. This means that a third party needs to be able to hold messages awaiting delivery in the interim. If the messages are encrypted, no one will be able to read them besides Bob and Alice, even if they are stored by a third party.

We’ll call this need encrypted offline delivery.

An industry standard for proving that you control an Ethereum address is to sign a challenge that someone sends you. Your signature can be used to prove ownership. However, if you’re communicating with many peers simultaneously (as is the design for the AirSwap protocol), this requires constant signatures, which is a tedious user experience when using a wallet like MetaMask, Ledger, or Trust Wallet. Messages can be signed programmatically when using a plaintext private key, but this exposes you to increased risk of being hacked. If we can keep our Ethereum private key secure inside of our wallet, and delegate only its ability to verify identity to another private key that can be stored in memory, we can automatically sign & decrypt messages without user interaction, and without exposing funds to increased risk.

We’ll call this needed functionality delegated programmatic authority

With the recent launch of AirSwap Spaces, we’ve put a system in production that not only fulfills all these needs but sets a new industry standard of what to expect from any messaging service with end-to-end encryption in terms of both security & convenience.

What we built

AirSwap KeySpace: trustless end-to-end encryption service

To illustrate the components involved in this system, I’ll show how they function together; both during key creation/recovery and during encrypted communication.