Explaining the Portis encryption architecture… with cocktails! 🍹

The Portis whitepaper showcases how user accounts are generated, encrypted, and safely stored. Using key derivation and end-to-end encryption, your crypto wallet is always under your control, and the keys are only known to you and no one else. But the whitepaper is technical and complicated, so let’s simplify things the best way possible — with alcohol!

Jose J. Pérez Aguinaga
Portis
6 min readApr 7, 2021

--

Using cryptographically strong techniques, Portis creates a unique account and wallet for you, accessible to no one else, not even Portis. Photo by Artur Lysyuk on Unsplash.

The motto “not your keys, not your crypto” is one of the greatest maxims in the blockchain ecosystem. The challenge lies in the fact that by knowing the keys behind your crypto account, anyone can have access to your assets, and thus, your keys must be only known to you. Services that host your wallets for you are called “custodial” and have been prone to attacks from multiple hackers in the past, as they also hold the private keys for those wallets.

At the same time, your private keys are needed to manage your assets and create transactions. Since only transactions signed by your key are valid and let you move your crypto from one wallet to another, or to interact with smart contracts, you need to keep your private key with you at all times to conduct these transactions. This process can sometimes be cumbersome, not to mention that it relies on you to remember your private key without losing or mishandling it.

Portis solves both of these problems. First, it’s a self-custodial wallet, which means Portis is never in possession of your private key. At the same time, Portis allows you (and only you) to sign transactions online by using a familiar and simple email and password login mechanism.

So how does Portis accomplish this? Today, we’ll go over the Portis encryption architecture as defined in its whitepaper, simplify it for the non-technical reader and showcase how Portis can both keep your assets secure and give you an easy way to interact with the blockchain.

A taste of key derivation and end-to-end encryption

Two important concepts in understanding how Portis works are key derivation and end-to-end encryption. Although the math behind these strategies is cryptographically strong enough to back up hundreds of thousands of Portis users, the concepts are trivial: key derivation means obtaining something unique (a key) based on something secret, whereas end-to-end encryption means a key encrypts both ends of a communication channel. Only the owners of the keys can decrypt these contents, even if the communication channel is compromised.

Imagine a bar that lets you create your own private cocktail

It gives you a very long list of ingredients to choose from, and you can pick as many as you want and mix them in the quantities and order that you wish. To make things even more secure — each person gets a different list of ingredients to choose from!

Upon concocting your cocktail and taking a note of the ingredients used, quantities and order, you give it to an expert blind bartender who will taste it, and from that moment on, be able to uniquely recognize you based on that cocktail. For the sake of our analogy, let’s assume that this bartender has such absolute taste that he would easily detect even the smallest change in the cocktail.

What would you put in your secret cocktail? The more ingredients, the harder it will be for someone to replicate it — original photo by Clovis Wood Photography via Unsplash.

Now, imagine that the ingredients you used for your cocktail are your unique secrets, and the cocktail that resulted from mixing these ingredients is your unique key. A critical point to remember is that it's very easy to go from ingredients to cocktail, but impossible to go the other way around (from cocktail to ingredients).

Since you want to make sure the bartender correctly identifies you, and you want to make your cocktail memorable, you probably want to mix not two or three ingredients, but instead, ten or more. Perhaps not the most delicious cocktail, but definitely hard to replicate.

Your Portis account is like a secret cocktail: your password and email address are the specific ingredients you chose, and the mix of both is the key to your account. The Portis server is like the bartender that recognizes you based on the cocktail taste, as only you can remember how to produce your secret aperitif. This is a similar process many online websites use to recognize you: they don’t know your password, but they remember the fingerprint (hash) of the combination between both your username or email and password.

Your Portis account is like a secret cocktail: your password and email address are the ingredients, and the mix of both is the key to your account.

Artesanal wallets known only to you

Pushing the analogy a bit further, let’s imagine that upon sharing your secret cocktail, the bartender guides you to a secure locker room. The room is enormous, with what seems like an infinite amount of small lockers inside. These lockers, however, do not open or close with a key. Instead, the room has a small glass jar right at the entrance. The bartender pours your cocktail in there (oh the tragedy), and you hear a faint clicking sound — a specific locker has opened, and the bartender points it out to you, telling you that anything you put in there will be safely kept at the premises. However, to reopen it again, you will have to concoct the same secret cocktail you did in the first place, otherwise, your locker would not open again. Luckily, you wrote everything down and won’t have any trouble creating it again, but for someone else (including the bartender), this would be practically impossible.

Would you be able to produce a cocktail out of pure memory? Ounce by ounce? Passwords are the same. Original photo by Clovis Wood Photography via Unsplash.

In this case, the Portis database is like the lockers in the room. Without your secret key, Portis has no access to the contents of your locker. Your locker happens to contain the cryptographic material for your Ethereum and Bitcoin wallets, but to Portis, it’s just a “blob” of encrypted data (just a closed locker box). This is because your account key, the one created initially during your account process (the secret cocktail in our analogy), is known only to you and only you can access it.

Shaken, not stirred

To recap: when you create an account, Portis generates a random 64 bytes string in your browser called an encryptionKey — that’s the random list of ingredients in our example. It then uses your password and email (and a cryptographic function called scrypt) to encrypt that encryptionKey — that’s you choosing and mixing the specific cocktail ingredients from that list, creating an encryptedEncryptionKey, which Portis then stores on its servers

Afterward, your wallets’ private keys are safely created in your browser and then encrypted using this encryptionKey. Portis also stores the result of this process, internally called an encryptedMnemonicPhrase cipher, in our locker rooms (database), and gives you access to it via the Portis interface. At no point in time does Portis know what your encryptionKey looks like, i.e your unique list of ingredients.

Dutch courage at Portis

Portis’ confidence in our security model comes from the fact that we are never in contact with your private keys. Our solution has been battle-tested in hundreds of apps and within the ShapeShift ecosystem. We’ll toast to that — original photo by Clovis Wood Photography via Unsplash.

From day one, Portis has been transparent about its security architecture and approach for safekeeping wallets for users. Our self-custodial approach relies on key derivation and end-to-end encryption, which secures your wallet even from us, all while providing Dapp users with superb usability via our SDK.

Our next article will go over additional usability features (e.g., resetting your password) and the improvements made in our recent SDK releases.

--

--

Jose J. Pérez Aguinaga
Portis
Writer for

Cryptography enthusiast, educator, and engineer with executive expertise in the digital assets ecosystem | ex- @hoprnet , ex- @plaid