Introduction
Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.
I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.
I also build and publish a variety of tools, libraries, and open-source projects.
This article examines EIP2333, which proposes a way to derive BLS12-381 keys securely in a tree structure.
This article translates, summarizes, and expands on the specification linked below. The original Mermaid diagrams are retained, including their Japanese labels.
I have also written about various other EIPs.
Overview
EIP2333 proposes a method for deriving BLS private keys in a tree structure from a single source of entropy (the input used to generate random values). It allows a practically unlimited number of keys to be derived hierarchically on the BLS12-381 curve, a type of elliptic curve used in cryptography. Deriving a child key requires only the parent key and the child index, making key management both flexible and secure.
BLS12-381 is an elliptic curve used in elliptic curve cryptography (ECC), particularly well suited to pairing-based cryptography. It is used in many blockchain projects, including Zcash and Ethereum 2.0.
BLS stands for Boneh–Lynn–Shacham, a digital signature scheme.
The 12 denotes an embedding degree of 12: computations can be performed over an extension field of degree 12.
The 381 refers to the approximate bit length of the curve's underlying field parameters.
Larger numbers generally provide greater security, all else being equal.
The curve supports efficient verification, short signatures, and signature aggregation, which combines multiple signatures into one.
The design also incorporates a post-quantum Lamport signature backup for each key in case quantum computers compromise the security of BLS12-381.
What is a Lamport signature?
Lamport signatures are among the simplest and oldest quantum-resistant signature schemes. They rely only on hash functions such as SHA256 to produce secure digital signatures.
- Generate random secret-key pairs (for example, two random values for each of 256 bit positions, giving 512 values).
- Hash each secret value to obtain the corresponding public-key component.
- To sign, reveal one of the two secret values for each message bit.
- To verify, compare the hashes of the revealed values with the corresponding public-key components.
This makes the scheme resistant to quantum attacks (Shor's algorithm does not apply), but it has some drawbacks.
- Large keys and signatures, typically several kilobytes or more.
- One-time use: a key must not be reused after signing.
EIP2333 uses Lamport signatures as an intermediate step, providing an emergency backup if quantum attacks break BLS12-381.
The specification was intended for use not only by Ethereum 2.0 but also by other ecosystems that use BLS signatures. At the time of the original proposal, a move to a neutral repository was planned.
Motivation
Problems with existing schemes
The key derivation scheme used in Ethereum 1.x (BIP32) is inefficient on BLS12-381. Approximately 54% or more of the keys generated using BIP32 would exceed the curve's order and be invalid, making the approach unsuitable in practice.
An elliptic curve private key must lie within the permitted scalar range (described here as 0 to r-1; zero is not a valid private key).
The value r is the order of the relevant group: repeatedly adding a point eventually returns to the identity.
BIP32 treats a random 32-byte number (approximately 2²⁵⁶ possibilities) as a private key.
However, the order r of BLS12-381 is slightly smaller than .
Consequently, approximately 54% of the keys generated using BIP32 fall outside the valid range (more than half of the generated values are greater than or equal to r) and are invalid.
Retrying invalid keys would make the process inefficient and impractical. A new derivation method for BLS12-381 is therefore needed, which is what this EIP proposes.
By contrast, on secp256k1 the probability of generating an invalid key is extremely low (less than one in 2 to the power of 127).
BIP32 (Bitcoin Improvement Proposal 32) defines a standard for hierarchical deterministic (HD) wallets.
It derives multiple private and public keys in a tree structure from a single master key, allowing users to separate wallets by child key (for payments, investments, or personal use, for example). Backups are straightforward because all keys can be regenerated from a single seed, the source of entropy. Ethereum, Bitcoin, and many other blockchain wallets use this approach. However, BIP32 was originally designed for the secp256k1 elliptic curve. Care is therefore required when applying it to other curves, such as BLS12-381.
Early standardization across chains
Establishing a standard before users generate their first keys allows them to share a common derivation method. This offers two advantages.
- A smoother transition to a quantum-resistant signature scheme in an emergency, with Lamport signatures acting as a bridge.
- Shared key-management tools across blockchains, simplifying operations.
Preparing for a post-quantum future
The derivation scheme generates a Lamport key pair as an intermediate step, which can be used for backup signatures. If BLS12-381 becomes insecure, Lamport signatures can enable migration to a more secure signature scheme. This provides an important safeguard against future advances in quantum computing.
Specification
The specification defines hierarchical derivation of BLS12-381 private keys. It first generates a master key from a single source of entropy (the seed), then derives child keys hierarchically. It also incorporates a Lamport signature backup in preparation for the quantum computing era.
Version information
EIP2333 follows version 4 of the CFRG draft for BLS signature standardization.
The EIP was updated on September 17, 2020, because an earlier implementation of hkdf_mod_r differed from the draft. Implementations should follow the latest version of the specification.
Key tree structure
Keys are organized in a tree, and each child key is derived from its parent key and child index.
Starting at the master key (the root), child nodes (m/0, m/1, ...) form successive levels of the hierarchy.
[m / 0] - [m / 0 / 0]
/ \
[m] --- [m / 0 / 1]
\
[m / 1] - [m / 1 / 0]This structure makes it possible to derive a practically unlimited number of keys from a single key and use different keys for different applications.
Key derivation at a glance
Key derivation consists of two steps.
- Generate the master (root) key.
- Derive a child key from its parent key.
In addition, each child key is derived through an intermediate Lamport key, which provides a post-quantum signature backup.
Functions
IKM_to_lamport_SK
sequenceDiagram
participant ユーザー入力 as IKMとsalt
participant 抽出器 as HKDF-Extract
participant 拡張器 as HKDF-Expand
participant 分割器 as bytes_split
participant 出力 as Lamport秘密鍵255個
ユーザー入力->>抽出器: IKMとsaltを渡す
抽出器->>抽出器: PRKを生成
抽出器->>拡張器: PRKを渡す
拡張器->>拡張器: OKM(8160バイト)を生成
拡張器->>分割器: OKMを渡す
分割器->>出力: 32バイト×255個に分割して出力
This function generates Lamport private keys from arbitrary secret input keying material (IKM) and a salt.
- Generate
PRKusing HKDF-Extract with the salt and IKM.- IKM
- The underlying secret, such as an entropy source or parent private key.
- salt
- Additional input to the derivation process, such as a child index.
- IKM
- Use PRK with HKDF-Expand to generate OKM (length = 255 × 32 bytes).
- Split OKM into 32-byte chunks to obtain 255 private values.
parent_SK_to_lamport_PK
sequenceDiagram
participant 入力 as 親秘密鍵と子インデックス
participant salt変換器 as インデックス → salt変換
participant IKM変換器 as 親鍵 → IKM変換
participant Lamport生成器 as IKM_to_lamport_SK
participant ハッシュ器 as SHA256ハッシュ処理
participant 出力 as 圧縮Lamport公開鍵
入力->>salt変換器: 子インデックスを渡す
salt変換器-->>IKM変換器: salt(4バイト)を出力
入力->>IKM変換器: 親秘密鍵を渡す
IKM変換器-->>Lamport生成器: IKM(ビッグエンディアン)を出力
Lamport生成器->>Lamport生成器: lamport_0 を生成
Lamport生成器->>Lamport生成器: IKMをビット反転し、lamport_1 を生成
Lamport生成器->>ハッシュ器: lamport_0[i], lamport_1[i] をSHA256でハッシュ
ハッシュ器->>ハッシュ器: ハッシュ結果をすべて連結
ハッシュ器->>出力: 全体をSHA256でまとめる
This function generates a Lamport public key from a parent node's private key and a child index.
- Convert the child index into a 4-byte salt.
- Encode the parent private key in big-endian byte order and generate a set of Lamport private keys (
lamport_0). - From the bitwise complement of the input (
not_IKM), generatelamport_1. - Hash each Lamport private value with SHA256 and concatenate the hashes.
- Hash the concatenated result with SHA256 to obtain the 32-byte compressed Lamport public key.
HKDF_mod_r
sequenceDiagram
participant 入力 as 入力IKM
participant ソルト初期化 as 初期ソルト設定
participant 抽出器 as HKDF-Extract
participant 拡張器 as HKDF-Expand
participant 整数変換器 as OKM → 整数変換
participant 出力判定 as SK判定
入入力->>ソルト初期化: "BLS-SIG-KEYGEN-SALT-" を使用
loop SKが0である限り繰り返す
ソルト初期化->>抽出器: salt, IKM || 0x00
抽出器->>拡張器: PRKを渡す
拡張器->>整数変換器: OKMを渡す(L = 48バイト)
整数変換器->>出力判定: SK = OKM mod r を計算
出力判定-->>ソルト初期化: SK == 0 の場合 salt をハッシュして再試行
end
出力判定->>入力: SK(BLS秘密鍵)を返す
This function converts an arbitrary byte string of at least 32 bytes into a BLS12-381 private key (0 <= SK < r, with zero rejected by the retry step).
- Use "BLS-SIG-KEYGEN-SALT-" as the initial salt.
- Obtain pseudorandom output with HKDF, convert it to an integer, and take the remainder modulo
ras the private key. - If the resulting key is zero, hash the salt and retry.
derive_child_SK
sequenceDiagram
participant 入力 as 親秘密鍵と子インデックス
participant Lamport公開鍵生成器 as parent_SK_to_lamport_PK
participant BLS鍵変換器 as HKDF_mod_r
participant 出力 as 子秘密鍵
入力->>Lamport公開鍵生成器: 親秘密鍵とインデックスを渡す
Lamport公開鍵生成器->>BLS鍵変換器: 圧縮Lamport公開鍵を渡す
BLS鍵変換器->>出力: BLS秘密鍵(子鍵)を返す
This function derives a child private key from its parent's private key and an index.
- Generate a compressed Lamport public key using
parent_SK_to_lamport_PK. - Convert the public key to a private key using
HKDF_mod_r. - The result is the child private key.
derive_master_SK
sequenceDiagram
participant 入力 as seed(エントロピーソース)
participant BLS鍵変換器 as HKDF_mod_r
participant 出力 as マスター秘密鍵(m)
入力->>BLS鍵変換器: seed を渡す
BLS鍵変換器->>出力: BLS秘密鍵(マスター鍵)を返す
This function generates the root (master) key. It normally uses a seed obtained from a BIP39 mnemonic or a similar source.
- Generate a private key from the seed using
HKDF_mod_r. - This becomes the master key (
m).
Additional notes
- Using Lamport signatures as an intermediate step provides a bridge to another secure signature scheme if quantum computers eventually break BLS12-381.
- The Lamport signature security guarantee is approximately 127.5 bits, given the design constraints of SHA256.
Design rationale
Why Lamport signatures?
Lamport signatures have a simple structure and are easy to implement compared with other quantum-resistant signature schemes. They require only a secure hash function rather than complex mathematical formulas or operations.
In EIP2333, Lamport signatures are reserved for backup use, so their large key sizes are not a significant concern.
Using the Lamport signature also exposes the associated BLS private key. In other words, the BLS key must no longer be trusted once the Lamport signature has been used; the backup is a one-time mechanism. This design avoids the need for additional backup storage alongside the BLS key.
The original explanation describes the Lamport key as having a 255-bit rather than a 256-bit parameter, reflecting the SHA256-based HKDF output limit of 255 blocks. The choice keeps the specification simple; the security guarantee discussed above is 127.5 bits.
Why SHA256?
EIP2333 uses SHA256 for all hashing. SHA256 is also used in the IETF's proposed BLS signature standard, so adopting it maintains consistency between the specifications.
Using multiple hash functions for different cryptographic operations would complicate implementations and could affect security. Choosing a single hash function is therefore beneficial for both simplicity and security.
The hkdf_mod_r() function
This function performs exactly the same operation as the KeyGen function defined in the IETF's proposed BLS standard.
In other words, KeyGen and hkdf_mod_r() produce the same private key from the same seed.
Using a standardized function allows implementations to reuse an established method that has undergone extensive security review. It also simplifies engineering reuse and interoperability.
The function does introduce a statistical deviation known as modulo bias. However, the effect is extremely small because the 48-byte output covers a range much larger than the curve's order, and it is considered negligible in practice.
Hardened keys only
Traditional HD wallet standards such as BIP32 and BIP44 support both hardened and non-hardened keys.
- Hardened keys
- Child keys cannot be computed without the parent private key.
- Non-hardened keys
- Child public keys can be derived using only the parent public key.
However, EIP2333 provides only hardened key derivation for security reasons.
Non-hardened keys are useful in UTXO-based systems such as Bitcoin, but they tend to complicate key management in account-based systems such as Ethereum. They also rely on group operations such as elliptic curve addition, which quantum computers can exploit, raising concerns about their security in a post-quantum era.
For these reasons, EIP2333 restricts key derivation to hardened keys from the outset.
Conclusion
This article has covered EIP2333, a proposal for securely deriving BLS12-381 keys in a tree structure. I hope it has clarified how the scheme works.
If you have questions, feel free to send me a direct message on Twitter.
I also publish on the following platforms.


