EIPs Explained

ERC-2333 · Review · ERC · 2019-09-30

ERC-2333: BLS12-381 Key Generation

A deterministic way to derive a whole tree of BLS12-381 keys (as used by Ethereum validators) from one seed, with a built-in Lamport post-quantum fallback.

What problem does it solve?

Ethereum's consensus layer signs with BLS signatures over the BLS12-381 curve, not secp256k1. The usual way to derive many keys from one backup phrase, BIP32 ("HD wallets"), does not fit: because of the size of the BLS12-381 private-key group, more than half of BIP32 outputs would be invalid keys.

ERC-2333 defines a BLS-native key tree so that one seed (typically from a BIP-39 mnemonic) can produce any number of validator and withdrawal keys, and so that every tool derives the same keys from the same seed.

How it works

Keys form a tree. The root is the master key m; each node has children m / 0, m / 1, … up to index 2^32 - 1. A child is computed only from its parent's private key and the index, so all derivation is "hardened" — there is no public-key-only derivation as in BIP32.

  • Master key: derive_master_SK(seed) = HKDF_mod_r(seed), where the seed must be at least 256 bits.
  • Child key: the parent private key and index seed two sets of Lamport secret keys (one from the key, one from its bit-flipped form) via HKDF-SHA256. All of their hashes are concatenated and hashed again into a 32-byte compressed Lamport public key, which is then mapped into a BLS private key with HKDF_mod_r.
  • HKDF_mod_r hashes input keying material to an integer in [1, r), where r is the BLS12-381 group order. It matches the KeyGen function in the IETF BLS signature draft, so a library that implements KeyGen already has it.

The Lamport step is the clever part: every BLS key is the hash of a Lamport public key. If BLS12-381 is ever broken (for example by quantum computers), a holder can sign a one-time Lamport message proving ownership and migrate to a new scheme, without storing any extra backup key.

SHA-256 is the only hash used throughout, to keep the cryptographic surface small.

Sample code

Pseudocode for deriving a key at path m/12381/3600/0/0/0 (the validator signing-key path defined by the companion standard ERC-2334):

def derive_path(seed: bytes, path: str) -> int:
    parts = path.split("/")
    assert parts[0] == "m"
    sk = derive_master_SK(seed)               # HKDF_mod_r(seed)
    for p in parts[1:]:
        sk = derive_child_SK(sk, int(p))       # Lamport PK -> HKDF_mod_r
    return sk

def derive_child_SK(parent_sk: int, index: int) -> int:
    lamport_pk = parent_SK_to_lamport_PK(parent_sk, index)  # 32-byte hash
    return HKDF_mod_r(lamport_pk)

signing_sk = derive_path(seed, "m/12381/3600/0/0/0")

The spec's test case 0 lets you check an implementation: a given 64-byte seed must yield a specific master_SK and child_SK for index 0.

Things to know

  • Status is Review: the document is not finalized as an ERC, although the scheme is the one widely used by staking deposit tooling and validator clients.
  • The spec was changed in September 2020 to track the IETF KeyGen update. Implementations written against older versions produce different keys; make sure yours follows the current text and passes the test vectors.
  • Only hardened derivation exists, so BIP32/BIP44 paths and xpub-style watch-only derivation do not carry over.
  • Using the Lamport backup reveals the BLS private key, so it is a one-time migration tool, not a second everyday signature scheme. Its security is about 127.5 bits because HKDF can only stretch to 255 chunks.
  • Paths and keystores are defined separately in ERC-2334 and ERC-2335.

#bls #keys #validators #cryptography #wallets

Details

Authors
Carl Beekhuizen (@CarlBeek) <[email protected]>
Status
Review
Type
Standards Track / ERC
Created
2019-09-30
Required by

Machine-readable: Markdown · JSON