---
eip: 3068
label: EIP-3068
title: Precompile for BN256 HashToCurve Algorithms
status: Stagnant
type: Standards Track
category: Core
created: 2020-10-23
requires: 198, 1108
official: https://eips.ethereum.org/EIPS/eip-3068
source: https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3068.md
canonical: https://eips.huatuo.xyz/eip-3068/
lang: en
tldr: "A stagnant proposal for precompiles that hash arbitrary messages onto the BN256 (alt_bn128) curve's G1 and G2 groups, which would make on-chain BLS signature verification cheap."
tags: [core, precompile, cryptography, bls, bn254, stagnant]
---

# EIP-3068: Precompile for BN256 HashToCurve Algorithms

> This EIP defines a hash-to-curve precompile for use in BN256 and would allow for cheaper BLS signature verification.

**TL;DR:** A stagnant proposal for precompiles that hash arbitrary messages onto the BN256 (alt_bn128) curve's G1 and G2 groups, which would make on-chain BLS signature verification cheap.

## What problem does it solve?

Ethereum already has precompiles for the BN256 curve (also called alt_bn128 or BN254): point addition, scalar multiplication ([EIP-196](/eip-196/)) and pairing checks ([EIP-197](/eip-197/)), made cheaper by [EIP-1108](/eip-1108/). These are enough to verify SNARKs.

To verify a **BLS signature over an arbitrary message**, though, you first need to map the message to a curve point (hash-to-curve). Without a precompile this must be done in Solidity, and according to the spec that costs about as much gas as the pairing check itself, even though it is an order of magnitude less computation. This blocked uses such as verifying group signatures from distributed key generation (the spec cites ETHDKG).

## How it works

The proposal specifies two deterministic functions:

- **`HashToG1(msg)`**
  1. `HashToBase` turns the message into a field element using two Keccak-256 hashes with domain-separation prefixes, combined modulo the field prime. This is done twice with different prefixes.
  2. `BaseToG1` maps each field element onto the curve using the Fouque–Tibouchi method (with modifications from Wahby–Boneh). It picks one of three candidate `x` values in a constant-time way and computes `y`.
  3. The two points are added; the sum is the result.
- **`HashToG2(msg)`** does the same over the quadratic extension field to land on the twist curve. It uses four field elements, adds the two twist points, then multiplies by the cofactor to reach G2.

Estimated gas, derived from benchmarks against the 6000-gas ECMUL price:

| Operation | Proposed gas |
| --- | --- |
| HashToG1 | `8500 + len(msg)` |
| HashToG2 | `80000 + 3 * len(msg)` |

## Sample code

Pseudocode of the hash-to-base step from the spec:

```python
def hash_to_base(msg: bytes, dsp1: int, dsp2: int, p: int) -> int:
    h0 = int.from_bytes(keccak256(bytes([dsp1]) + msg), "big")
    h1 = int.from_bytes(keccak256(bytes([dsp2]) + msg), "big")
    c = pow(2, 256, p)                 # 2^256 mod p
    return (h0 * c + h1) % p           # ~512-bit hash reduced mod p

def hash_to_g1(msg: bytes):
    t0 = hash_to_base(msg, 0x00, 0x01, P)
    t1 = hash_to_base(msg, 0x02, 0x03, P)
    return ec_add(base_to_g1(t0), base_to_g1(t1))
```

How BLS verification would then use the existing pairing precompile (`0x08`): check that `e(sig, g2) == e(HashToG1(msg), pubkey)`, which can be passed to the pairing precompile as `e(-sig, g2) * e(H(msg), pubkey) == 1`.

## Things to know

- Status: **Stagnant**. No addresses were assigned and the Test Cases and Implementation sections are "TBD".
- The spec warns that BN256's security has been reduced by newer number-field-sieve attacks. Estimates vary, with the more conservative one at around 100 bits instead of the original 128. This affects every pairing-based use of the curve, not just this EIP.
- The authors note that replacing `sign0` with `is_square` would match the original paper exactly; whether `sign0` preserves indifferentiability from a random oracle is not proven.
- For new designs needing BLS on Ethereum, [EIP-2537](/eip-2537/) adds BLS12-381 precompiles, including map-to-curve operations.
- The author disclosed an affiliation with MadHive, which motivated the proposal.


---

This is an unofficial plain-language summary. Read the full specification: https://eips.ethereum.org/EIPS/eip-3068
