ERC-1078 ENS universal login and signup (Universal login / signup using ENS subdomains)

Stagnant · Accounts & wallets · created 2018-05-04

An approach in which, instead of a password or mnemonic, you log in via the identity contract that an ENS name points to, register only the necessary authority for a device-local key, and transact by signing.

Why it is needed

Under the existing approach, users must securely back up their wallet's mnemonic phrase themselves, and losing it means losing their entire assets. Also, having to create a new account or password for every app repeats the same hassle as logins that depend on a central server. Because the private key stored on a device directly holds asset access rights, losing or having the device hacked leaves no way to recover. From a dapp developer's perspective too, having to request a signature or transaction approval from the user every time meant even lightweight interactions like chatting or gaming had to use a heavy transaction flow. Without this standard, the login experience simultaneously bears both the inconvenience of password management and the fatal risk of key loss.

In depth

Identifier structure

A user's unique identifier is not a private key but a contract that implements both ERC-725 (identity) and ERC-1077 (signed message execution). Users don't need to know this contract's address directly; they only enter the ENS name that points to it. A locally generated private key doesn't hold assets directly; it is registered on the contract as a signer and serves only to sign messages expressing intent. These signatures are collected by a third party or a distributed network of relayers and executed against the contract. In other words, the Ethereum account is used not as the unique key but like an authentication token.

New signup procedure

If the user has no identity, the app performs the following in the background. It generates a private key on the device and stores it as securely as possible, creates or prepares an identity contract supporting ERC-725/1077, and registers that private key as the contract's sole manager key. At this point, no app-controlled key is added other than as a recovery option. It then registers the requested subdomain, transfers its ownership to the contract, and optionally registers a recovery method in case the key is lost. All of these steps can be designed as a single transaction, and the app may pass the signup cost on to the user or require anti-bot measures such as a captcha.

Pre-deployment to save gas

To save gas, the app can pre-deploy a small number of contracts when gas prices are low, filling all the main variables with 0xFFFF...FFFF to leave them in a 'vacant' state. When a user actually registers, filling in this vacant contract's storage earns a gas discount, while also giving the user the option to choose a contract address or icon.

Linking an existing account and authority levels

When a user who already has an identity connects to a new app, the required authority level is determined first. manager is the highest authority, able to sign transactions on the identity itself such as adding or removing keys, and should only be required by identity manager apps. action is authority to sign transactions that send funds or assets to another address, required by general-purpose wallets and browsers. encryption is the lowest authority, with no right to initiate on-chain transactions but able to represent the user via off-chain signed messages, suitable for games, chat, and social apps. After determining the authority level, the app generates a local key, looks up the identity address via ENS, builds the bytecode for an addKey(PUBLICKEY,LEVEL) call, and propagates it in order via a whisper channel, web3, an EIP-681 URI, and a QR code, to obtain the existing key owner's signature.

On-chain transaction request procedure

When it is determined that an actual on-chain transaction is needed, the app determines to, from, value, and data, and decides that level 1 (management) is required if to and from are the same contract, or level 2 (action) if they differ. It then calls the target contract's requiredSignatures(uint level) to check the number of signatures required, sets gasLimit by adding a margin (100,000 gas recommended) to the estimated gas cost, and sets gasToken and gasPrice considering network congestion and token prices (gasToken is 0 if paying in ether). It then builds an executable signed transaction using the ERC-1077 approach.

Using off-chain signatures

Not every transaction needs to be on-chain. A chat app can sign messages with the local key and send them to the counterparty, who can check against the identity contract whether the signature actually came from the user. Even a game with a stake only needs the identity to execute the first transaction that moves funds and opens the game; after that, the board state for each turn can be exchanged by signing its hash, with the final two moves determining the winner. Because a key can be revoked at any time, the app must account for this, for example by storing the list of keys at the time the game started. This kind of lightweight-use key is set at level 4 (encryption).

Signature distribution and result verification

If only one signature is required, the app provider can call the executeSigned function directly from the from address to deploy it. If more signatures are required or the app has no deployment server, the transaction is propagated to a distributed network such as a whisper channel; web3.eth.personal_sign is tried if web3 is available; and as a last resort a QR code containing the signed transaction and the data to be newly signed is shown. The goal is to keep propagating via whisper until a node willing to deploy once all signatures are collected appears. Afterward, the transaction pool for that address is watched: if the desired nonce shows up in the ExecutedSigned event of the identity contract, it is treated as a success, and if another transaction with the same or a higher nonce appears, it is treated as a failure and the process restarts.

Status

This proposal is in Stagnant status, and the source itself states that no working example of this implementation exists yet. In other words, the flow described here is a proposal that has not yet actually been implemented or had its adoption validated, and it may change or go no further.

Original ERC · ← ERCs