{"eip":3068,"title":"Precompile for BN256 HashToCurve Algorithms","description":"This EIP defines a hash-to-curve precompile for use in BN256 and would allow for cheaper BLS signature verification.","authors":["Dr. Christopher Gorman (@chgormanMH)"],"status":"Stagnant","type":"Standards Track","category":"Core","created":"2020-10-23","requires":[198,1108],"discussionsTo":"https://ethereum-magicians.org/t/pre-compile-for-bls/3973","repo":"EIPs","label":"EIP-3068","officialUrl":"https://eips.ethereum.org/EIPS/eip-3068","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3068.md","url":"https://eips.huatuo.xyz/eip-3068/","tldr":{"en":"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.","ja":"任意のメッセージを BN256（alt_bn128）曲線の G1 と G2 の群にハッシュするプリコンパイルの、停滞中の提案。オンチェーンでの BLS 署名検証を低コストにする。","ko":"임의의 메시지를 BN256(alt_bn128) 곡선의 G1과 G2 군으로 해시하는 프리컴파일에 대한, 정체된 제안. 온체인 BLS 서명 검증을 저렴하게 만든다.","zh":"一项已停滞的提案：新增把任意消息哈希到 BN256（alt_bn128）曲线 G1 和 G2 群上的预编译，使链上 BLS 签名验证变得便宜。"},"tags":["core","precompile","cryptography","bls","bn254","stagnant"],"explainers":{"en":{"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"],"related":[196,197,1108,198,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-3068/","markdown":"## What problem does it solve?\n\nEthereum 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.\n\nTo 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).\n\n## How it works\n\nThe proposal specifies two deterministic functions:\n\n- **`HashToG1(msg)`**\n  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.\n  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`.\n  3. The two points are added; the sum is the result.\n- **`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.\n\nEstimated gas, derived from benchmarks against the 6000-gas ECMUL price:\n\n| Operation | Proposed gas |\n| --- | --- |\n| HashToG1 | `8500 + len(msg)` |\n| HashToG2 | `80000 + 3 * len(msg)` |\n\n## Sample code\n\nPseudocode of the hash-to-base step from the spec:\n\n```python\ndef hash_to_base(msg: bytes, dsp1: int, dsp2: int, p: int) -\u003e int:\n    h0 = int.from_bytes(keccak256(bytes([dsp1]) + msg), \"big\")\n    h1 = int.from_bytes(keccak256(bytes([dsp2]) + msg), \"big\")\n    c = pow(2, 256, p)                 # 2^256 mod p\n    return (h0 * c + h1) % p           # ~512-bit hash reduced mod p\n\ndef hash_to_g1(msg: bytes):\n    t0 = hash_to_base(msg, 0x00, 0x01, P)\n    t1 = hash_to_base(msg, 0x02, 0x03, P)\n    return ec_add(base_to_g1(t0), base_to_g1(t1))\n```\n\nHow 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`.\n\n## Things to know\n\n- Status: **Stagnant**. No addresses were assigned and the Test Cases and Implementation sections are \"TBD\".\n- 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.\n- 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.\n- For new designs needing BLS on Ethereum, [EIP-2537](/eip-2537/) adds BLS12-381 precompiles, including map-to-curve operations.\n- The author disclosed an affiliation with MadHive, which motivated the proposal.\n"},"ja":{"lang":"ja","tldr":"任意のメッセージを BN256（alt_bn128）曲線の G1 と G2 の群にハッシュするプリコンパイルの、停滞中の提案。オンチェーンでの BLS 署名検証を低コストにする。","tags":["core","precompile","cryptography","bls","bn254","stagnant"],"related":[196,197,1108,198,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-3068/","markdown":"## 何を解決するのか\n\nEthereum にはすでに BN256 曲線（alt_bn128 や BN254 とも呼ばれる）用のプリコンパイルがあります。点の加算とスカラー倍（[EIP-196](/eip-196/)）、ペアリングのチェック（[EIP-197](/eip-197/)）で、[EIP-1108](/eip-1108/) によってより安くなりました。これらは SNARK の検証には十分です。\n\nしかし、**任意のメッセージに対する BLS 署名**を検証するには、まずメッセージを曲線上の点に写像（hash-to-curve）する必要があります。プリコンパイルがないと、これは Solidity で行うことになり、仕様によれば、計算量は桁違いに少ないにもかかわらず、ペアリングチェックそのものと同程度のガスがかかります。このため、分散鍵生成による群署名の検証（仕様は ETHDKG を挙げています）のような用途が阻まれていました。\n\n## 仕組み\n\nこの提案は、2 つの決定論的な関数を規定します。\n\n- **`HashToG1(msg)`**\n  1. `HashToBase` が、ドメイン分離用のプレフィックスを付けた 2 つの Keccak-256 ハッシュを使ってメッセージを体の元に変換し、体の素数を法として組み合わせます。これを、異なるプレフィックスで 2 回行います。\n  2. `BaseToG1` が、Fouque–Tibouchi 法（Wahby–Boneh による修正を含む）で、各体の元を曲線上に写像します。3 つの候補の `x` 値から定数時間で 1 つを選び、`y` を計算します。\n  3. 2 つの点を加算し、その和が結果です。\n- **`HashToG2(msg)`** は、2 次拡大体上で同じことを行い、ツイスト曲線上に到達します。4 つの体の元を使い、2 つのツイスト点を加算してから、余因子を掛けて G2 に到達します。\n\n6000 ガスの ECMUL 価格に対するベンチマークから導いた推定ガス:\n\n| 演算 | 提案されているガス |\n| --- | --- |\n| HashToG1 | `8500 + len(msg)` |\n| HashToG2 | `80000 + 3 * len(msg)` |\n\n## サンプルコード\n\n仕様にある hash-to-base ステップの擬似コード:\n\n```python\ndef hash_to_base(msg: bytes, dsp1: int, dsp2: int, p: int) -\u003e int:\n    h0 = int.from_bytes(keccak256(bytes([dsp1]) + msg), \"big\")\n    h1 = int.from_bytes(keccak256(bytes([dsp2]) + msg), \"big\")\n    c = pow(2, 256, p)                 # 2^256 mod p\n    return (h0 * c + h1) % p           # ~512-bit hash reduced mod p\n\ndef hash_to_g1(msg: bytes):\n    t0 = hash_to_base(msg, 0x00, 0x01, P)\n    t1 = hash_to_base(msg, 0x02, 0x03, P)\n    return ec_add(base_to_g1(t0), base_to_g1(t1))\n```\n\nその後の BLS 検証が既存のペアリングプリコンパイル（`0x08`）をどう使うか: `e(sig, g2) == e(HashToG1(msg), pubkey)` を確認します。これは、ペアリングプリコンパイルには `e(-sig, g2) * e(H(msg), pubkey) == 1` として渡せます。\n\n## 知っておくべきこと\n\n- ステータス: **Stagnant**。アドレスは割り当てられず、Test Cases と Implementation のセクションは「TBD」です。\n- 仕様は、より新しい数体ふるい法による攻撃で BN256 の安全性が低下したと警告しています。推定値はさまざまで、より保守的なものでは当初の 128 ビットではなく約 100 ビットです。これはこの EIP に限らず、この曲線のペアリングベースのあらゆる用途に影響します。\n- 著者は、`sign0` を `is_square` に置き換えれば元の論文と完全に一致すると述べています。`sign0` がランダムオラクルとの識別不能性を保つかどうかは証明されていません。\n- Ethereum で BLS を必要とする新しい設計には、[EIP-2537](/eip-2537/) が、map-to-curve 演算を含む BLS12-381 のプリコンパイルを追加します。\n- 著者は、この提案の動機となった MadHive との関係を開示しています。\n"},"ko":{"lang":"ko","tldr":"임의의 메시지를 BN256(alt_bn128) 곡선의 G1과 G2 군으로 해시하는 프리컴파일에 대한, 정체된 제안. 온체인 BLS 서명 검증을 저렴하게 만든다.","tags":["core","precompile","cryptography","bls","bn254","stagnant"],"related":[196,197,1108,198,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-3068/","markdown":"## 어떤 문제를 해결하나요?\n\n이더리움에는 이미 BN256 곡선(alt_bn128 또는 BN254라고도 함)용 프리컴파일이 있습니다. 점 덧셈과 스칼라 곱([EIP-196](/eip-196/)), 페어링 검사([EIP-197](/eip-197/))이며, [EIP-1108](/eip-1108/)로 더 저렴해졌습니다. 이것만으로 SNARK를 검증하기에 충분합니다.\n\n하지만 **임의의 메시지에 대한 BLS 서명**을 검증하려면 먼저 메시지를 곡선 위의 점으로 매핑(hash-to-curve)해야 합니다. 프리컴파일이 없으면 이를 Solidity로 해야 하는데, 명세에 따르면 연산량은 한 자릿수 배 적은데도 페어링 검사 자체와 비슷한 가스가 듭니다. 이 때문에 분산 키 생성에서 나온 그룹 서명 검증(명세는 ETHDKG를 인용합니다) 같은 용도가 막혀 있었습니다.\n\n## 어떻게 동작하나요?\n\n이 제안은 결정론적 함수 두 개를 명시합니다.\n\n- **`HashToG1(msg)`**\n  1. `HashToBase`가 도메인 분리 접두사를 붙인 Keccak-256 해시 두 개로 메시지를 체의 원소로 바꾸고, 체의 소수를 법으로 결합합니다. 이를 서로 다른 접두사로 두 번 수행합니다.\n  2. `BaseToG1`이 Fouque–Tibouchi 방법(Wahby–Boneh의 수정 포함)으로 각 체 원소를 곡선 위에 매핑합니다. 후보 `x` 값 세 개 중 하나를 상수 시간 방식으로 고르고 `y`를 계산합니다.\n  3. 두 점을 더하며, 그 합이 결과입니다.\n- **`HashToG2(msg)`**는 이차 확대체에서 같은 일을 해 트위스트 곡선 위에 떨어집니다. 체 원소 네 개를 쓰고, 트위스트 점 두 개를 더한 다음 여인수를 곱해 G2에 도달합니다.\n\n6000 가스의 ECMUL 가격 대비 벤치마크에서 도출한 가스 추정치:\n\n| 연산 | 제안된 가스 |\n| --- | --- |\n| HashToG1 | `8500 + len(msg)` |\n| HashToG2 | `80000 + 3 * len(msg)` |\n\n## 샘플 코드\n\n명세에 있는 hash-to-base 단계의 의사 코드:\n\n```python\ndef hash_to_base(msg: bytes, dsp1: int, dsp2: int, p: int) -\u003e int:\n    h0 = int.from_bytes(keccak256(bytes([dsp1]) + msg), \"big\")\n    h1 = int.from_bytes(keccak256(bytes([dsp2]) + msg), \"big\")\n    c = pow(2, 256, p)                 # 2^256 mod p\n    return (h0 * c + h1) % p           # ~512-bit hash reduced mod p\n\ndef hash_to_g1(msg: bytes):\n    t0 = hash_to_base(msg, 0x00, 0x01, P)\n    t1 = hash_to_base(msg, 0x02, 0x03, P)\n    return ec_add(base_to_g1(t0), base_to_g1(t1))\n```\n\n이후 BLS 검증이 기존 페어링 프리컴파일(`0x08`)을 쓰는 방법: `e(sig, g2) == e(HashToG1(msg), pubkey)`를 확인하며, 이는 페어링 프리컴파일에 `e(-sig, g2) * e(H(msg), pubkey) == 1`로 전달할 수 있습니다.\n\n## 알아둘 점\n\n- 상태: **Stagnant**. 주소가 할당되지 않았고 Test Cases와 Implementation 섹션은 \"TBD\"입니다.\n- 명세는 더 새로운 수체 체(number-field-sieve) 공격으로 BN256의 보안이 낮아졌다고 경고합니다. 추정치는 다양하며, 더 보수적인 쪽은 원래의 128비트가 아닌 약 100비트입니다. 이는 이 EIP만이 아니라 이 곡선의 모든 페어링 기반 사용에 영향을 줍니다.\n- 저자들은 `sign0`을 `is_square`로 바꾸면 원 논문과 정확히 일치하게 된다고 언급합니다. `sign0`이 랜덤 오라클과의 구별 불가능성을 보존하는지는 증명되지 않았습니다.\n- 이더리움에서 BLS가 필요한 새 설계에는 [EIP-2537](/eip-2537/)이 map-to-curve 연산을 포함한 BLS12-381 프리컴파일을 추가합니다.\n- 저자는 이 제안의 동기가 된 MadHive와의 관계를 밝혔습니다.\n"},"zh":{"lang":"zh","tldr":"一项已停滞的提案：新增把任意消息哈希到 BN256（alt_bn128）曲线 G1 和 G2 群上的预编译，使链上 BLS 签名验证变得便宜。","tags":["core","precompile","cryptography","bls","bn254","stagnant"],"related":[196,197,1108,198,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-3068/","markdown":"## 它解决什么问题？\n\n以太坊已经有针对 BN256 曲线（也叫 alt_bn128 或 BN254）的预编译：点加法、标量乘法（[EIP-196](/eip-196/)）和配对检查（[EIP-197](/eip-197/)），并由 [EIP-1108](/eip-1108/) 降低了成本。这些足以验证 SNARK。\n\n然而，要验证**针对任意消息的 BLS 签名**，首先需要把消息映射到曲线上的一个点（hash-to-curve）。没有预编译的话，这只能用 Solidity 完成，而据规范所述，它消耗的 gas 与配对检查本身大致相当，尽管计算量要少一个数量级。这阻碍了例如验证分布式密钥生成所产生的群签名（规范以 ETHDKG 为例）等用途。\n\n## 它如何运作\n\n该提案规定了两个确定性函数：\n\n- **`HashToG1(msg)`**\n  1. `HashToBase` 使用两个带有域分隔前缀的 Keccak-256 哈希把消息转换为一个域元素，并对域的素数取模后合并。用不同的前缀这样做两次。\n  2. `BaseToG1` 使用 Fouque–Tibouchi 方法（含 Wahby–Boneh 的改进）把每个域元素映射到曲线上。它以常数时间的方式从三个候选的 `x` 值中选出一个，并计算 `y`。\n  3. 把两个点相加；其和即为结果。\n- **`HashToG2(msg)`** 在二次扩域上做同样的事情，落在扭曲曲线上。它使用四个域元素，把两个扭曲点相加，再乘以余因子到达 G2。\n\n根据与 6000 gas 的 ECMUL 价格对比的基准测试推算出的 gas 估算：\n\n| 运算 | 提议的 gas |\n| --- | --- |\n| HashToG1 | `8500 + len(msg)` |\n| HashToG2 | `80000 + 3 * len(msg)` |\n\n## 示例代码\n\n规范中 hash-to-base 步骤的伪代码：\n\n```python\ndef hash_to_base(msg: bytes, dsp1: int, dsp2: int, p: int) -\u003e int:\n    h0 = int.from_bytes(keccak256(bytes([dsp1]) + msg), \"big\")\n    h1 = int.from_bytes(keccak256(bytes([dsp2]) + msg), \"big\")\n    c = pow(2, 256, p)                 # 2^256 mod p\n    return (h0 * c + h1) % p           # ~512-bit hash reduced mod p\n\ndef hash_to_g1(msg: bytes):\n    t0 = hash_to_base(msg, 0x00, 0x01, P)\n    t1 = hash_to_base(msg, 0x02, 0x03, P)\n    return ec_add(base_to_g1(t0), base_to_g1(t1))\n```\n\n随后 BLS 验证如何使用现有的配对预编译（`0x08`）：检查 `e(sig, g2) == e(HashToG1(msg), pubkey)`，它可以作为 `e(-sig, g2) * e(H(msg), pubkey) == 1` 传给配对预编译。\n\n## 需要注意\n\n- 状态：**Stagnant**。没有分配地址，Test Cases 和 Implementation 部分均为\"TBD\"。\n- 规范警告说，BN256 的安全性因较新的数域筛攻击而降低。估算各不相同，较保守的估计约为 100 位，而不是原先的 128 位。这影响该曲线所有基于配对的用途，而不仅是这个 EIP。\n- 作者指出，把 `sign0` 替换为 `is_square` 将与原论文完全一致；`sign0` 是否保持与随机预言机的不可区分性尚未得到证明。\n- 对于需要在以太坊上使用 BLS 的新设计，[EIP-2537](/eip-2537/) 新增了 BLS12-381 预编译，其中包括 map-to-curve 运算。\n- 作者披露了其与 MadHive 的关联，这正是该提案的动机所在。\n"}}}
