EIPs Explained

ERC-2386 · Stagnant · ERC · 2019-11-21

ERC-2386: Ethereum 2 Hierarchical Deterministic Walletstore

A JSON 'walletstore' format that saves an encrypted HD seed plus the next key index for Ethereum consensus-layer (BLS) keys, so validator wallets can move between tools.

What problem does it solve?

EIP-2335 standardised the keystore: an encrypted JSON file holding one BLS private key, as used by consensus-layer validators. But a hierarchical deterministic (HD) wallet does not store individual keys. It stores a seed and derives keys from it along a path. To create the next key without reusing an old one, the wallet also needs to remember which index it has reached.

Without a standard, each tool saved that seed and counter in its own way, so you could not move a wallet from one client or CLI to another. ERC-2386 defines a common JSON file for it, called a walletstore.

How it works

A walletstore is a JSON object with these fields:

Field Meaning
uuid Random version-4 UUID identifying the wallet
name Human-friendly name; must not start with _
version Always the integer 1
type The string "hierarchical deterministic"
crypto The encrypted seed, using exactly the EIP-2335 kdf / checksum / cipher structure
nextaccount Non-negative integer: the index to use for the next key

New keys are derived at path m/12381/60/<nextaccount>/0, following EIP-2334, with the key derivation itself defined in EIP-2333. After creating a key the wallet increments nextaccount so the same key is never generated twice.

Decryption works exactly like a keystore: run the KDF on the password, check the checksum, then decrypt the cipher.message to recover the seed.

Sample code

The shape of a walletstore (placeholder values shown; real files contain hex output from the KDF and cipher):

{
  "crypto": {
    "kdf": {
      "function": "pbkdf2",
      "params": { "c": 262144, "dklen": 32, "prf": "hmac-sha256", "salt": "<hex>" },
      "message": ""
    },
    "checksum": { "function": "sha256", "params": {}, "message": "<hex>" },
    "cipher": {
      "function": "aes-128-ctr",
      "params": { "iv": "<hex>" },
      "message": "<encrypted seed, hex>"
    }
  },
  "name": "Validator wallet",
  "nextaccount": 0,
  "type": "hierarchical deterministic",
  "uuid": "b74559b8-ed56-4841-b25c-dba1b7c9d9d5",
  "version": 1
}

Deriving the path for the next key:

function nextKeyPath(ws: { nextaccount: number }): string {
  return `m/12381/60/${ws.nextaccount}/0`;
}

Things to know

  • Status is Stagnant. The format has a Go implementation by the author, but it is not broadly adopted as a cross-client standard.
  • Security: the seed can regenerate every key on the path, so the walletstore is only as safe as its password and KDF settings. A leaked walletstore is worse than a leaked single keystore.
  • The spec suggests keeping the walletstore on an offline machine, generating individual EIP-2335 keystores there, and moving only those keystores to the online validator.
  • The JSON schema in the spec has a syntax slip (missing commas in the required list); follow the field descriptions above rather than copying it literally.

#wallet #keystore #validator #bls #json

Details

Authors
Jim McDonald <[email protected]>
Status
Stagnant
Type
Standards Track / ERC
Created
2019-11-21
Requires

Machine-readable: Markdown · JSON