Rube Goldberg’s accounts system

Rube Goldberg’s accounts system

One of the first things a web developer learns how to do is make an account system: login and registration. In the old days, you had to set up a database yourself, making this marginally challenging (well, error-prone). These days, it is utterly trivial: use a plug-n-play OAuth implementation to let users login via Google, Facebook, Twitter, etc.

Given that this is a completely solved problem, why has Augur re-invented the wheel with its own (unusually complicated and inconvenient) accounts system? This post will attempt to explain how Augur accounts work and how they’re different from accounts on a “normal” website, why this creates a tricky account storage problem, and how we’re dealing with this problem.

First of all, I should clarify what I mean when I say “account”. Accounts in Augur are just Ethereum accounts. When you register a new account, the superbly-named Keythereum module creates an Ethereum wallet for you in the browser: it first generates a private key (a random 256-bit number), then it derives an encryption key from your password and uses this derived key to encrypt your private key. It’s easier to draw than to explain, so:

Registration

This is the same procedure followed by your local Ethereum node (such as geth or Parity) when it creates an account. The encrypted private key is now ready to be stored, together with the other cryptographic data needed to decrypt it when you supply your password. This data-that-needs-to-be-stored is small, about 500 bytes — the size of a short paragraph of text. Disk space is cheap and plentiful in today’s world, so it’s hardly a burden to store something so small! But, where exactly should we store it?

The first and most obvious option is to store it in a private database, controlled by us: you enter your username and password, the username is used to look up the encrypted key in the database, private key decryption is attempted using your password, and (if successful) you are “logged in” and your plaintext private key is available in your browser for use. At no point is the unauthenticated user presented with the text of the encrypted key. This is how our login/registration system initially worked. However, this system, while otherwise lovely, is centralized, and Augur is bound by an ironclad legal requirement to be decentralized. (We’re just writing software: we don’t create markets, we don’t operate markets, we don’t trade in the markets.)

A second option is to store it so that everyone sees it: put it directly on the Ethereum blockchain or some other distributed storage system, such as IPFS, Storj, or BigchainDB. For example, we might store the encrypted data on IPFS, and store the IPFS address (hash) on an Ethereum contract:

Encrypted key storage

However, if everyone can see your encrypted key, then your account is only as secure as your password, and most people are really bad at picking secure passwords. This sucks, and would lead to a lot of un-fun situations where users accounts would get hacked because they picked a shitty password, we would berate them for picking a shitty password, they would accuse us of blaming-the-victim, and the Augur community would inevitably collapse into bloodshed and chaos.

This leads us to door number three: store the encrypted account data in the user’s browser. (Also, make the user download the encrypted data and explain to them that if they lose that encrypted data file, all hope is lost and we cannot recover or reset their password.) This is both secure (only the user can access their browser’s local storage, and local storage is not shared between different websites) and decentralized, and so it is the option that the Augur app uses today.

However, there are significant drawbacks to this system. Because the data is stored in the browser, it does not automatically transfer across different browsers (or devices) that the user might use to access Augur. For example, if you register on your laptop using Chrome, your login will only work “as expected” on that laptop using Chrome. If you’re on Chrome on your desktop, or even on Firefox on your laptop, you won’t be able to login, because the encrypted account data isn’t there — it’s only available in Chrome on your laptop! You can import your account to other browsers/computers (using the downloaded account file), but this is not convenient, particularly if you’re moving from one computer to another: you have to manually transfer the file between computers.

We have a bunch of ideas for making account storage less bad, one of which looks especially promising. I’ll discuss these in a future post!

  • Thanks for post Jack, but I am wondering why you didn’t choose “Storj”? As far us I know they encrypt the data.

Comments are closed.