Overview
Address:0x000000000000000000000000000000000000000d
Introduced: Prague (EIP-2537)
EIP: EIP-2537
The BLS12-381 G1 MSM (Multi-Scalar Multiplication) precompile performs efficient batch scalar multiplication on the BLS12-381 curve’s G1 group. It computes the sum of multiple points each multiplied by their respective scalars: k1*P1 + k2*P2 + ... + kn*Pn. This operation is fundamental for BLS signature aggregation, zkSNARK verification, and efficient batch cryptographic operations.
MSM is significantly more efficient than performing individual multiplications and additions separately. The precompile uses optimized algorithms (like Pippenger’s algorithm) to compute batch operations with sublinear scaling.
EIP-2537 introduces BLS12-381 operations to enable efficient aggregate signatures used in Ethereum 2.0 consensus, where thousands of validator signatures must be verified together.
Gas Cost
Dynamic with discount:(BASE_GAS * k * discount) / 1000
- BASE_GAS: 12000
- k: Number of point-scalar pairs
- discount: Discount factor based on batch size (EIP-2537 table)
Discount Table
| Pairs (k) | Discount | Gas per pair |
|---|---|---|
| 1 | 1000 | 12000 |
| 2-3 | 820 | 9840 |
| 4-7 | 580 | 6960 |
| 8-15 | 430 | 5160 |
| 16-31 | 320 | 3840 |
| 32-63 | 250 | 3000 |
| 64-127 | 200 | 2400 |
| 128+ | 174 | 2088 |
(12000 * 32 * 250) / 1000 = 96000 gas
The discount reflects the efficiency gains from batch processing, making aggregate operations economical.
Input Format
160 * k bytes (must be exact multiple of 160)
Each point must satisfy the curve equation: y^2 = x^3 + 4 over BLS12-381 base field.
Point at infinity represented as all zeros (128 bytes).
Output Format
TypeScript Example
Zig Example
Error Conditions
- Out of gas: gasLimit < calculated gas cost
- Invalid input length: input.len % 160 != 0 or input.len == 0
- Invalid point: Any point doesn’t satisfy curve equation y² = x³ + 4
- Point not in subgroup: Any point not in correct subgroup
- Coordinate out of range: Any x or y >= field modulus
error.InvalidPoint.
MSM Properties
- Linearity: MSM(P, k) = k1P1 + k2P2 + … + kn*Pn
- Zero scalars: Points with k=0 contribute nothing to sum
- Point at infinity: Infinity points with any scalar contribute nothing
- Empty input: Returns error (must have at least one pair)
- Order independence: Result same regardless of pair order
Use Cases
- BLS signature aggregation: Aggregate thousands of validator signatures
- Batch verification: Verify multiple signatures simultaneously
- zkSNARK verification: Multi-scalar multiplications in proof verification
- Threshold signatures: Combine signature shares efficiently
- Polynomial commitments: KZG-style commitments on BLS12-381
- Consensus protocols: Ethereum 2.0 beacon chain signature aggregation
- Privacy protocols: Efficient batch operations in zk-Rollups
Implementation Details
- Zig: Uses blst library’s optimized MSM implementation
- TypeScript: Manual loop (naive implementation, less efficient)
- Algorithm: Pippenger’s algorithm for efficient batch processing
- Optimization: Exploits parallelism and precomputation
- Memory: Temporary storage proportional to number of pairs
Performance Characteristics
- Time complexity: O(k * log(k)) with Pippenger’s algorithm
- Gas discount: Increases with batch size (sublinear cost scaling)
- Break-even point: ~4 pairs more efficient than separate operations
- Maximum efficiency: Large batches (64+ pairs) get best discount
Gas Cost Comparison
Comparing MSM vs individual operations:Algorithm: Pippenger’s Method
Pippenger’s algorithm efficiently computes MSM by:- Bucketing: Group scalars by bit windows
- Bucket sums: Compute point sums for each bucket
- Window reduction: Combine buckets with doubling
- Final sum: Aggregate window results
Discount Rationale
EIP-2537 discount table reflects:- Algorithmic efficiency: Pippenger’s sublinear scaling
- Amortization: Fixed costs spread over more operations
- Hardware optimization: Better cache utilization with batches
- Incentive: Encourage batch operations for network efficiency
Security Considerations
- All points validated individually before processing
- Scalar range checked (any 256-bit value accepted)
- Constant-time operations prevent timing attacks
- Point at infinity handled correctly in accumulation
- Uses audited blst library for security-critical operations
Comparison with G1 Mul
| Operation | Single (Mul) | Batch (MSM) |
|---|---|---|
| Pairs (k) | 1 | 1-128+ |
| Base gas | 12000 | 12000 |
| Discount | None | 174-1000 |
| Algorithm | Double-and-add | Pippenger |
| Efficiency | O(log k) | O(k log log k) |

