ERC-4527 QR code data transfer protocol for wallets (QR Code transmission protocol for wallets)

Stagnant · Accounts & wallets · created 2021-12-07

Defines a standard data format for offline signers (cold wallets) and watch-only wallets to exchange public keys, signing requests, and signing results via QR codes.

Why it is needed

Offline signers (hardware wallets, phones in airplane mode, etc.) are not connected to the network, so they cannot construct transactions themselves. They must receive the data to be signed from a watch-only wallet, sign it, and return it. Methods such as USB, Bluetooth, or file transfer have a wide attack surface, break easily with software changes, and make it hard for users to transparently verify what they are signing. QR codes let users decode and verify the content directly with a tool, offering high transparency, security, and compatibility, but until now there was no standard for what data to encode and how to exchange it via QR code between offline signers and watch-only wallets.

In depth

The four-step process between offline signers and watch-only wallets

The original text defines a four-step workflow between the offline signer (a device that holds the private key and is not connected to the network) and the watch-only wallet (a wallet connected to the network that interacts with Ethereum). First, the offline signer passes public key information to the watch-only wallet via QR code so it can generate addresses and sync balances. Next, the watch-only wallet builds unsigned data, such as a transaction or typed data, and sends it to the offline signer via QR code. The offline signer signs it and returns the signature via QR code, and finally the watch-only wallet receives the signature, assembles the signed transaction, and performs tasks such as broadcasting it.

Animated QR codes and UR/CBOR encoding

Because the data a single QR code can hold is limited, this standard extends Uniform Resources (UR), created by BlockchainCommons, to transmit data via animated QR codes. Binary data is encoded in CBOR (Concise Binary Object Representation), and its structure is expressed in CDDL (Concise Data Definition Language).

Derivation paths expressed with crypto-keypath

crypto-keypath is a structure representing a key's derivation path, consisting of components (each step of the path and whether it is hardened), source-fingerprint (the fingerprint of the path's ancestor key or master key), and depth (the number of derivation steps). If components is empty, source-fingerprint must be the fingerprint of the master key. Each path-component consists of one of a child index (child-index), an index range, or a wildcard range, together with whether it is hardened (is-hardened).

Extended public keys conveyed via crypto-hdkey

The hd-key that the offline signer passes to the watch-only wallet consists of a derived-key, containing key-data (a 33-byte public key), chain-code (32 bytes, used for deriving child keys, omitted if no further derivation is possible), origin (the derivation path expressed as crypto-keypath), name (a short name for the key), and source (a description such as device information). If chain-code is absent, the key is a standalone key, and origin can convey only the derivation path. To pass multiple public keys at once, the crypto-account type can be used.

Signing requests sent via eth-sign-request

The newly defined eth-sign-request contains sign-data (the bytes to be signed), data-type (the kind of data to be signed), chain-id (default 1), derivation-path (the path of the private key to use for signing), and optionally request-id (a UUID identifying the request), address (the Ethereum address for verification), and origin (the name of the wallet that sent the request, etc.). data-type 1 means the RLP encoding of a legacy transaction, 2 means EIP-712 typed signing data, 3 means a raw message such as EIP-191 personal_sign, and 4 means an EIP-2718 typed transaction.

Signing results returned via eth-signature

Once the offline signer finishes signing, it returns the result as an eth-signature type. This includes request-id (the UUID identifying the request), a 65-byte signature (made up of r, s, and v), and optionally origin, which conveys information about the device that provided the signature.

Why UR was chosen

The original text gives three reasons for choosing UR. It uses the alphanumeric QR code mode for efficiency, and each part includes a CRC32 checksum of the entire message so that it can be verified whether the fragments were correctly reassembled, and it uses Fountain Codes, which can handle both finite and infinite-length data fragments, making it easier for the recipient to recover the data. It also cites that existing UR types such as crypto-keypath and crypto-hdkey already exist, making it easy to add new types, and that the air-gapped wallet community continues to develop UR further.

A proposal in Stagnant status

This ERC is currently in Stagnant status, meaning it is no longer actively discussed or revised and has stalled. The original text notes that an actual implementation can be found in the form of test cases and a reference implementation in the ur-registry-eth package released by the Keystone team, but the standard itself may not be further changed or updated.

Things to watch out for

Original ERC · ← ERCs