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 EIP-2537 (referred to as ERC2537 in the original Japanese article), which defines seven dedicated precompiles for efficient, gas-efficient cryptographic operations on the BLS12-381 curve in Ethereum.

The explanation below translates, summarizes, and expands on the original proposal.

I also cover a range of other EIPs.

Overview

EIP-2537 introduces precompiles for efficient operations on the pairing-friendly elliptic curve BLS12-381. Its main purpose is to make elliptic curve operations and multi-scalar multiplication (computing a sum of scalar multiples of points) used in BLS signature verification fast and economical.

Aggregating multiple BLS public keys or signatures can require many curve operations. Efficient implementations make practical applications more feasible.

What is MSM?

Multi-scalar multiplication (MSM) efficiently computes expressions of the following form.

text
r = s₁ * P₁ + s₂ * P₂ + ... + sₖ * Pₖ
  • P₁, P₂, ..., Pₖ are elliptic curve points in G1 or G2.
  • s₁, s₂, ..., sₖ are scalars (integers).
  • * represents scalar multiplication of an elliptic curve point, conceptually adding the point to itself repeatedly.
  • + represents point addition.

This operation frequently appears in BLS-related cryptographic computations and zero-knowledge proofs. Although the terms can be calculated separately, efficient algorithms such as Pippenger's algorithm compute them together. Ethereum therefore provides dedicated MSM precompiles.

  • BLS signature aggregation combines multiple signatures or public keys for verification.
  • When a protocol requires many scalar-point products, MSM can substantially reduce gas costs.
  • MSM is especially relevant to decentralized verification and zero-knowledge protocols.
text
MSM演算の流れ:

 [点P₁]    [点P₂]    [点P₃]       ← 楕円曲線上の点(公開鍵など)
   |         |         |
 [×s₁]     [×s₂]     [×s₃]         ← 各点に対してスカラー倍(整数の乗算)
   |         |         |
   +----+----+-----> 合計(加算)
                 ↓
               出力点(結果)

MSM computes multiple scalar-point products and sums them into a single point. This is more efficient than computing every term separately, especially in resource-constrained environments such as blockchains.

Motivation

Ethereum already had pairing precompiles for the BN254 curve (also known as Alt_bn128), but its estimated classical security level of approximately 80 bits raised concerns about long-term security.

BLS12-381 provides a higher classical security level (more than 120 bits), allowing stronger signature schemes. This makes it possible to use zero-knowledge proofs (ZKPs) and BLS-based authentication efficiently on-chain. Neither BN254 nor BLS12-381 is considered quantum-resistant.

These precompiles also reduce the gas costs of complex aggregation operations, supporting more scalable applications.

Specification

The specification defines seven precompiles for efficient BLS12-381 operations in Ethereum. They support basic curve arithmetic, multi-scalar multiplication, pairing checks, and mappings from field elements to curve points, as needed for cryptographic applications such as BLS verification and aggregation.

Precompile addresses and operations

Each operation is assigned the following address.

  • 0x0b
    • G1 point addition (BLS12_G1ADD)
  • 0x0c
    • G1 MSM (BLS12_G1MSM)
  • 0x0d
    • G2 point addition (BLS12_G2ADD)
  • 0x0e
    • G2 MSM (BLS12_G2MSM)
  • 0x0f
    • Pairing check (BLS12_PAIRING_CHECK)
  • 0x10
    • Mapping from Fp to G1 (BLS12_MAP_FP_TO_G1)
  • 0x11
    • Mapping from Fp2 to G2 (BLS12_MAP_FP2_TO_G2)

Elliptic curve and field definitions

  • Curve equation (G1)
    • Y^2 = X^3 + B (mod p), A=0
  • Base field (Fp)
    • p = 0x1a0111...aaab (381 bits)
  • Extension field (Fp2)
    • Fp2 = Fp[X]/(X² - nr2)

G1 is defined over Fp, while G2 is defined over Fp2. Both groups play important roles in signature verification.

Input and output encoding

  • Fp element
    • 64 bytes (big-endian, with the upper 16 bytes set to zero)
  • Fp2 element
    • 128 bytes (two concatenated Fp elements)
  • G1 point
    • 128 bytes, formed by concatenating the Fp values of x and y
  • G2 point
    • 256 bytes, formed by concatenating the Fp2 values of x and y
  • Scalar
    • A 32-byte big-endian integer

Although (0,0) is not an actual point on the curve, it is used by convention to encode the point at infinity.

ABI and error conditions for each operation

G1 addition (BLS12_G1ADD)

  • Input: Two G1 points (256 bytes)
  • Output: Their sum as a G1 point (128 bytes)
  • Errors: Invalid points, incorrect input length, and similar conditions

G1 MSM (BLS12_G1MSM)

  • Input: k pairs of a G1 point and a scalar (160k bytes)
  • Output: The MSM result as a G1 point (128 bytes)
  • Errors: Invalid points, points outside the required subgroup, incorrect input length, and similar conditions

G2 addition (BLS12_G2ADD)

  • Input: Two G2 points (512 bytes)
  • Output: Their sum as a G2 point (256 bytes)

G2 MSM (BLS12_G2MSM)

  • Input: k pairs of a G2 point and a scalar (288k bytes)
  • Output: The MSM result as a G2 point (256 bytes)

Pairing check (BLS12_PAIRING_CHECK)

  • Input: k pairs of G1 and G2 points (384k bytes)
  • Output: Boolean result (32 bytes, with the last byte equal to 0x00 or 0x01)
  • Condition: All points must belong to the required subgroup of order q

Fp-to-G1 mapping

  • Input: An Fp element (64 bytes)
  • Output: A G1 point (128 bytes)

Fp2-to-G2 mapping

  • Input: An Fp2 element (128 bytes)
  • Output: A G2 point (256 bytes)

Gas costs (indicative)

Operation Gas
G1 addition 375
G1 scalar multiplication 12000
G2 addition 600
G2 scalar multiplication 22500
Fp to G1 5500
Fp2 to G2 23800
Pairing check 32600 * k + 37700
G1 MSM Formula with a discount factor
G2 MSM Formula with a discount factor

MSM gas pricing accounts for efficient processing using algorithms such as Pippenger's algorithm, with discounts as the number of inputs increases.

Input lengths and error handling

  • Operations that accept variable-length input, such as MSM and pairing checks, must return an error if the input length is invalid.
  • Gas is charged even if the length is not a multiple of the required pair size and execution subsequently fails.

Behavior on errors

If a precompile encounters an error, all gas supplied to that call is consumed. This follows the design of existing Ethereum precompiles.

Rationale

Why MSM is a separate operation

The principal reason for providing a dedicated multi-scalar multiplication precompile is to reduce gas costs and execution time significantly. Two considerations are particularly important.

  • An efficient algorithm such as Pippenger's algorithm can compute multiplication and addition for 100 point-scalar pairs together.
  • Ethereum's CALL overhead can be substantial. The proposal estimates that making 100 individual scalar multiplication calls followed by 99 addition calls would incur roughly 138,600 gas in unnecessary overhead under the assumptions of that estimate.

A dedicated MSM precompile is therefore designed to be efficient in both processing time and gas consumption.

Why there is no dedicated multiplication precompile

An individual scalar multiplication, such as point × scalar (MUL), is a special case of MSM with k=1. The specification therefore adopts the following design.

  • No dedicated MUL precompile is defined.
  • For an MSM input containing only one pair (k=1), an implementation can fall back to ordinary scalar multiplication rather than using a more complex algorithm.

This allows a single ABI to support both individual multiplications and larger MSM computations, simplifying the specification and implementation.

Compatibility

Required subgroup checks

For MSM and pairing operations, implementations must verify that the supplied points belong to the correct subgroup.

A subgroup is a particular subset of elliptic curve points that forms a group under the curve's addition operation. Cryptographic protocols rely on points belonging to the intended subgroup. Using points from an incorrect subgroup may enable signature forgery or invalidate cryptographic computations.

Precompile implementations are encouraged to use optimized subgroup-checking methods described in the associated documentation. A failed check must return an error.

Endomorphism-based optimization

Endomorphism acceleration assumes that points belong to the correct subgroup, making subgroup checks essential. An endomorphism is a structure-preserving transformation that can be used to accelerate computation.

What is an endomorphism?

An endomorphism is a map from a mathematical structure to itself that preserves the relevant structure. For elliptic curves, it maps points to points in a manner consistent with the group addition law.

This property can be exploited to accelerate scalar multiplication.

Accelerating scalar multiplication with endomorphisms

Elliptic curve cryptography frequently uses scalar multiplication of the following form.

text
Q = k * P

Conceptually, this adds point P to itself k times. Large values of k make efficient computation particularly important.

An endomorphism can allow k to be decomposed into smaller coefficients, making it possible to compute the corresponding terms together or in parallel.

Example: the Gallant–Lambert–Vanstone (GLV) method

The GLV method decomposes the scalar k as follows.

text
k * P = k₁ * P + k₂ * φ(P)

Here, φ(P) is an endomorphism that maps the original point P to another point. With the appropriate scalar decomposition, the operation preserves the result. The original scalar multiplication can thus be replaced by computations involving two shorter scalars, improving performance.

Applications to BLS12-381

Pairing-friendly curves such as BLS12-381 have efficient endomorphisms that can accelerate scalar multiplication. To use these optimizations safely, the supplied points must belong to the correct subgroup.

Mapping field elements to curve points

Mapping elements of Fp or Fp2 to points in G1 or G2 uses the Shallue–van de Woestijne–Ulas (SWU) method. The detailed algorithms and parameters are defined in separate documentation.

Such mappings are used in cryptographic applications such as BLS signatures, where hashing to a curve is required. The emphasis is on correct and secure point mappings rather than on compatibility with arbitrary existing implementations.

Security considerations

Importance of conformance

The precompiles must implement BLS12-381 operations exactly as specified to preserve consensus and the expected cryptographic security properties. The older BN254 precompiles provide an estimated security level of approximately 80 bits, while BLS12-381 offers more than 120 bits of classical security.

Constant-time implementations

A constant-time implementation is designed to avoid execution-time variations that depend on secret information, helping prevent timing attacks. EIP-2537 explicitly states that constant-time execution is not mandatory for all operations. Constant-time implementations may be desirable when side-channel resistance is needed, but the specification does not require them for every precompile operation. Implementers should consider whether secret keys are involved, whether off-chain preprocessing is performed, and whether constant-time behavior is necessary for their use case.

Implementation best practices

  • Thorough subgroup checks Perform all required subgroup checks to prevent invalid points from being used in computations.
  • Strict input validation Return errors for invalid lengths or out-of-range values, consuming the supplied gas as specified.
  • Library selection When using open-source implementations, check whether they have undergone adequate security review, including timing resistance and formal verification where relevant.

Citation

Alex Vlasov (@shamatar), Kelly Olson (@ineffectualproperty), Alex Stokes (@ralexstokes), Antonio Sanso (@asanso), "EIP-2537: Precompile for BLS12-381 curve operations," Ethereum Improvement Proposals, no. 2537, February 2020. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-2537.

Conclusion

This article covered EIP-2537, which defines seven dedicated precompiles for fast, gas-efficient cryptographic operations on the BLS12-381 curve in Ethereum.

If you have questions, feel free to reach out via Twitter DM.

Twitter @cardene777

I also publish on the following platforms.

https://chaldene.net/