{"eip":197,"title":"Precompiled contracts for optimal ate pairing check on the elliptic curve alt_bn128","description":"Precompiled contracts for elliptic curve pairing operations are required in order to perform zkSNARK verification within the block gas limit.","authors":["Vitalik Buterin \u003cvitalik@ethereum.org\u003e","Christian Reitwiessner \u003cchris@ethereum.org\u003e"],"status":"Final","type":"Standards Track","category":"Core","created":"2017-02-06","repo":"EIPs","label":"EIP-197","officialUrl":"https://eips.ethereum.org/EIPS/eip-197","sourceUrl":"https://github.com/ethereum/EIPs/blob/master/EIPS/eip-197.md","url":"https://eips.huatuo.xyz/eip-197/","tldr":{"en":"Added a precompile at address 0x08 that checks elliptic-curve pairings on alt_bn128, making on-chain zkSNARK verification affordable.","ja":"アドレス 0x08 にプリコンパイルを追加し、alt_bn128 上の楕円曲線ペアリングを検証できるようにした。これによりオンチェーンでの zkSNARK 検証が現実的なコストになった。","ko":"주소 0x08에 alt_bn128의 타원곡선 페어링을 검사하는 프리컴파일을 추가해, 온체인 zkSNARK 검증을 감당할 만한 비용으로 만들었다.","zh":"在地址 0x08 新增预编译合约，用于检查 alt_bn128 上的椭圆曲线配对，使链上验证 zkSNARK 的成本变得可承受。"},"tags":["precompile","cryptography","zksnark","pairing","byzantium"],"explainers":{"en":{"lang":"en","tldr":"Added a precompile at address 0x08 that checks elliptic-curve pairings on alt_bn128, making on-chain zkSNARK verification affordable.","tags":["precompile","cryptography","zksnark","pairing","byzantium"],"related":[196,1108,609,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/eip-197/","markdown":"## What problem does it solve?\n\nzkSNARKs let someone prove a statement is true without revealing why, using a proof that is small and quick to check. That helps with privacy, because data can stay hidden, and with scaling, because a large computation can be checked cheaply. Verifying a SNARK, however, needs **pairing operations** on an elliptic curve. Written in plain EVM code, these were far too expensive to fit in a block.\n\nEIP-197 adds a native precompiled contract for this check. Together with [EIP-196](/eip-196/), which adds point addition and scalar multiplication on the same curve, it makes zkSNARK verification practical inside smart contracts.\n\n## How it works\n\n- **Address:** `0x08`, active from the Byzantium fork.\n- **Curve:** alt_bn128 (also called BN254). G1 lies on `y² = x³ + 3` over a prime field. G2 lies on a twist of that curve over a quadratic extension field. The spec chose this curve because it suits SNARKs and lets Ethereum reuse components and artifacts from Zcash.\n- **Input:** `k` pairs `(a_i, b_i)`, with each `a_i` in G1 and each `b_i` in G2. Each pair is 192 bytes: G1 is two 32-byte coordinates, and G2 is two `F_p²` coordinates, each 2×32 bytes. The input length must be a multiple of 192. An empty input is valid and returns 1.\n- **Output:** 32 bytes. The value is `1` if `e(a1, b1) · e(a2, b2) · … · e(ak, bk) = 1`, and `0` otherwise. The call **fails** if the input is malformed or a point is not on the curve or not in the correct subgroup.\n- **Encoding:** big-endian 32-byte field elements. The point at infinity is `(0, 0)`. An `F_p²` element `a·i + b` is encoded as `(a, b)`, with the imaginary part first.\n\nThe precompile does not return a pairing value. It only checks whether a product of pairings equals 1. All known SNARK verifiers need only this check, and it avoids having to encode values from the complex target group.\n\n**Gas:** originally `80,000 · k + 100,000`.\n\n## Sample code\n\nCalling the precompile from Solidity. Groth16 verifiers generated by common SNARK toolchains contain a routine like this:\n\n```solidity\nfunction pairingCheck(uint256[] memory input) internal view returns (bool) {\n    require(input.length % 6 == 0, \"bad input\"); // 6 words = 192 bytes per pair\n    uint256[1] memory out;\n    bool ok;\n    assembly {\n        ok := staticcall(gas(), 0x08, add(input, 0x20), mul(mload(input), 0x20), out, 0x20)\n    }\n    require(ok, \"pairing failed\");\n    return out[0] == 1;\n}\n```\n\nLayout of one pair (192 bytes):\n\n```\n[ a.x (32) | a.y (32) | b.x_imag (32) | b.x_real (32) | b.y_imag (32) | b.y_real (32) ]\n```\n\n## Things to know\n\n- Gas was reduced in Istanbul by [EIP-1108](/eip-1108/) to `34,000 · k + 45,000`, which is the price today.\n- The ordering of `F_p²` coordinates (imaginary part first) is a common source of bugs when hand-encoding G2 points.\n- Later research lowered alt_bn128's estimated security below the 128 bits originally assumed. Newer designs often use BLS12-381, available through [EIP-2537](/eip-2537/).\n- Shipped in Byzantium ([EIP-609](/eip-609/)).\n"},"ja":{"lang":"ja","tldr":"アドレス 0x08 にプリコンパイルを追加し、alt_bn128 上の楕円曲線ペアリングを検証できるようにした。これによりオンチェーンでの zkSNARK 検証が現実的なコストになった。","tags":["precompile","cryptography","zksnark","pairing","byzantium"],"related":[196,1108,609,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ja/eip-197/","markdown":"## 何を解決するのか\n\nzkSNARK を使うと、小さく素早く検証できる証明によって、理由を明かさずに主張が真であることを示せます。データを秘匿できるのでプライバシーに役立ち、大規模な計算を安価に検証できるのでスケーリングにも役立ちます。ただし、SNARK の検証には楕円曲線上の**ペアリング演算**が必要です。通常の EVM コードで書くと、ブロックに収まらないほど高価でした。\n\nEIP-197 は、この検証のためのネイティブなプリコンパイルドコントラクトを追加します。同じ曲線上の点の加算とスカラー倍を追加する [EIP-196](/eip-196/) と合わせて、スマートコントラクト内での zkSNARK 検証が実用的になります。\n\n## 仕組み\n\n- **アドレス:** `0x08`。Byzantium フォークから有効です。\n- **曲線:** alt_bn128（BN254 とも呼ばれます）。G1 は素体上の `y² = x³ + 3` 上にあります。G2 は 2 次拡大体上のその曲線のツイスト上にあります。仕様がこの曲線を選んだのは、SNARK に適しており、Ethereum が Zcash の部品や成果物を再利用できるためです。\n- **入力:** `k` 個のペア `(a_i, b_i)`。各 `a_i` は G1 の点、各 `b_i` は G2 の点です。1 ペアは 192 バイトです。G1 は 32 バイトの座標が 2 つ、G2 は `F_p²` の座標が 2 つで、それぞれ 2×32 バイトです。入力長は 192 の倍数でなければなりません。空の入力は有効で、1 を返します。\n- **出力:** 32 バイト。`e(a1, b1) · e(a2, b2) · … · e(ak, bk) = 1` なら `1`、そうでなければ `0` です。入力の形式が不正な場合、点が曲線上にない場合、または正しい部分群に属さない場合、呼び出しは**失敗**します。\n- **エンコード:** ビッグエンディアンの 32 バイトの体の元。無限遠点は `(0, 0)` です。`F_p²` の元 `a·i + b` は `(a, b)` とエンコードされ、虚部が先です。\n\nこのプリコンパイルはペアリングの値を返しません。ペアリングの積が 1 に等しいかどうかを確認するだけです。既知のすべての SNARK 検証器に必要なのはこの確認だけで、複雑なターゲット群の値をエンコードする必要もなくなります。\n\n**Gas:** 当初は `80,000 · k + 100,000` でした。\n\n## サンプルコード\n\nSolidity からプリコンパイルを呼び出す例です。一般的な SNARK ツールチェーンが生成する Groth16 検証器には、このようなルーチンが含まれています。\n\n```solidity\nfunction pairingCheck(uint256[] memory input) internal view returns (bool) {\n    require(input.length % 6 == 0, \"bad input\"); // 6 words = 192 bytes per pair\n    uint256[1] memory out;\n    bool ok;\n    assembly {\n        ok := staticcall(gas(), 0x08, add(input, 0x20), mul(mload(input), 0x20), out, 0x20)\n    }\n    require(ok, \"pairing failed\");\n    return out[0] == 1;\n}\n```\n\n1 ペア（192 バイト）のレイアウト:\n\n```\n[ a.x (32) | a.y (32) | b.x_imag (32) | b.x_real (32) | b.y_imag (32) | b.y_real (32) ]\n```\n\n## 知っておくべきこと\n\n- Gas は Istanbul で [EIP-1108](/eip-1108/) により `34,000 · k + 45,000` に引き下げられ、これが現在の価格です。\n- `F_p²` 座標の順序（虚部が先）は、G2 の点を手作業でエンコードするときのバグの典型的な原因です。\n- その後の研究で、alt_bn128 の推定セキュリティは当初想定された 128 ビットを下回りました。新しい設計では、[EIP-2537](/eip-2537/) で利用できる BLS12-381 が使われることが多くなっています。\n- Byzantium（[EIP-609](/eip-609/)）で実装されました。\n"},"ko":{"lang":"ko","tldr":"주소 0x08에 alt_bn128의 타원곡선 페어링을 검사하는 프리컴파일을 추가해, 온체인 zkSNARK 검증을 감당할 만한 비용으로 만들었다.","tags":["precompile","cryptography","zksnark","pairing","byzantium"],"related":[196,1108,609,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/ko/eip-197/","markdown":"## 어떤 문제를 해결하나요?\n\nzkSNARK를 쓰면 작고 빠르게 확인할 수 있는 증명으로, 이유를 드러내지 않고 어떤 주장이 참임을 보일 수 있습니다. 데이터를 숨길 수 있어 프라이버시에 도움이 되고, 큰 연산을 저렴하게 검증할 수 있어 확장성에도 도움이 됩니다. 그런데 SNARK를 검증하려면 타원곡선 위의 **페어링 연산**이 필요합니다. 일반 EVM 코드로 작성하면 블록에 담기에는 너무 비쌌습니다.\n\nEIP-197은 이 검증을 위한 네이티브 프리컴파일 컨트랙트를 추가합니다. 같은 곡선에서 점 덧셈과 스칼라 곱셈을 추가하는 [EIP-196](/eip-196/)과 함께 스마트 컨트랙트 안에서 zkSNARK 검증을 현실적으로 만듭니다.\n\n## 어떻게 동작하나요?\n\n- **주소:** `0x08`, Byzantium 포크부터 활성화됩니다.\n- **곡선:** alt_bn128(BN254라고도 부릅니다). G1은 소수체 위의 `y² = x³ + 3` 위에 있습니다. G2는 이차 확대체 위에서 그 곡선의 트위스트 위에 있습니다. 명세가 이 곡선을 고른 것은 SNARK에 적합하고 이더리움이 Zcash의 구성 요소와 산출물을 재사용할 수 있기 때문입니다.\n- **입력:** `k`개의 쌍 `(a_i, b_i)`이며, 각 `a_i`는 G1, 각 `b_i`는 G2에 속합니다. 한 쌍은 192바이트입니다. G1은 32바이트 좌표 두 개이고, G2는 `F_p²` 좌표 두 개로 각각 2×32바이트입니다. 입력 길이는 192의 배수여야 합니다. 빈 입력은 유효하며 1을 반환합니다.\n- **출력:** 32바이트. `e(a1, b1) · e(a2, b2) · … · e(ak, bk) = 1`이면 `1`, 아니면 `0`입니다. 입력 형식이 잘못되었거나 점이 곡선 위에 없거나 올바른 부분군에 속하지 않으면 호출이 **실패**합니다.\n- **인코딩:** 빅엔디언 32바이트 체 원소. 무한원점은 `(0, 0)`입니다. `F_p²` 원소 `a·i + b`는 `(a, b)`로 인코딩되며 허수부가 먼저 옵니다.\n\n이 프리컴파일은 페어링 값을 반환하지 않습니다. 페어링의 곱이 1과 같은지만 확인합니다. 알려진 모든 SNARK 검증기에는 이 검사만 있으면 되고, 복잡한 타깃 군의 값을 인코딩할 필요도 없어집니다.\n\n**Gas:** 처음에는 `80,000 · k + 100,000`이었습니다.\n\n## 샘플 코드\n\nSolidity에서 프리컴파일을 호출하는 예입니다. 일반적인 SNARK 툴체인이 생성하는 Groth16 검증기에는 이와 같은 루틴이 들어 있습니다.\n\n```solidity\nfunction pairingCheck(uint256[] memory input) internal view returns (bool) {\n    require(input.length % 6 == 0, \"bad input\"); // 6 words = 192 bytes per pair\n    uint256[1] memory out;\n    bool ok;\n    assembly {\n        ok := staticcall(gas(), 0x08, add(input, 0x20), mul(mload(input), 0x20), out, 0x20)\n    }\n    require(ok, \"pairing failed\");\n    return out[0] == 1;\n}\n```\n\n한 쌍(192바이트)의 레이아웃:\n\n```\n[ a.x (32) | a.y (32) | b.x_imag (32) | b.x_real (32) | b.y_imag (32) | b.y_real (32) ]\n```\n\n## 알아둘 점\n\n- Gas는 Istanbul에서 [EIP-1108](/eip-1108/)에 의해 `34,000 · k + 45,000`으로 낮아졌으며, 현재 가격입니다.\n- `F_p²` 좌표의 순서(허수부가 먼저)는 G2 점을 직접 인코딩할 때 흔한 버그의 원인입니다.\n- 이후 연구에서 alt_bn128의 추정 보안 수준이 처음 가정한 128비트보다 낮아졌습니다. 최신 설계는 [EIP-2537](/eip-2537/)로 쓸 수 있는 BLS12-381을 쓰는 경우가 많습니다.\n- Byzantium([EIP-609](/eip-609/))에서 적용되었습니다.\n"},"zh":{"lang":"zh","tldr":"在地址 0x08 新增预编译合约，用于检查 alt_bn128 上的椭圆曲线配对，使链上验证 zkSNARK 的成本变得可承受。","tags":["precompile","cryptography","zksnark","pairing","byzantium"],"related":[196,1108,609,2537],"updated":"2026-10-19","url":"https://eips.huatuo.xyz/zh/eip-197/","markdown":"## 它解决什么问题？\n\nzkSNARK 让人可以在不透露原因的情况下证明某个陈述为真，所用的证明体积小、验证快。这有助于隐私（数据可以保持隐藏），也有助于扩容（大规模计算可以被廉价地验证）。然而，验证 SNARK 需要在椭圆曲线上进行**配对运算**。用普通 EVM 代码来写，成本高到无法放进一个区块。\n\nEIP-197 为这项检查新增了原生预编译合约。它与 [EIP-196](/eip-196/)（在同一条曲线上新增点加法和标量乘法）配合，使在智能合约中验证 zkSNARK 变得切实可行。\n\n## 它如何运作\n\n- **地址：** `0x08`，自 Byzantium 分叉起启用。\n- **曲线：** alt_bn128（也叫 BN254）。G1 位于素域上的 `y² = x³ + 3` 上。G2 位于该曲线在二次扩域上的扭曲曲线上。规范选择这条曲线，是因为它适合 SNARK，并且能让以太坊复用 Zcash 的组件和产物。\n- **输入：** `k` 对 `(a_i, b_i)`，每个 `a_i` 属于 G1，每个 `b_i` 属于 G2。每一对占 192 字节：G1 是两个 32 字节的坐标，G2 是两个 `F_p²` 坐标，每个为 2×32 字节。输入长度必须是 192 的倍数。空输入有效，返回 1。\n- **输出：** 32 字节。若 `e(a1, b1) · e(a2, b2) · … · e(ak, bk) = 1`，值为 `1`，否则为 `0`。如果输入格式错误，或某个点不在曲线上、不在正确的子群中，调用会**失败**。\n- **编码：** 大端序 32 字节域元素。无穷远点为 `(0, 0)`。`F_p²` 元素 `a·i + b` 编码为 `(a, b)`，虚部在前。\n\n该预编译不返回配对值，只检查一组配对的乘积是否等于 1。所有已知的 SNARK 验证器只需要这一项检查，这样也避免了对复杂的目标群取值进行编码。\n\n**Gas：** 最初为 `80,000 · k + 100,000`。\n\n## 示例代码\n\n在 Solidity 中调用该预编译。常见 SNARK 工具链生成的 Groth16 验证器都包含类似这样的例程：\n\n```solidity\nfunction pairingCheck(uint256[] memory input) internal view returns (bool) {\n    require(input.length % 6 == 0, \"bad input\"); // 6 words = 192 bytes per pair\n    uint256[1] memory out;\n    bool ok;\n    assembly {\n        ok := staticcall(gas(), 0x08, add(input, 0x20), mul(mload(input), 0x20), out, 0x20)\n    }\n    require(ok, \"pairing failed\");\n    return out[0] == 1;\n}\n```\n\n一对数据（192 字节）的布局：\n\n```\n[ a.x (32) | a.y (32) | b.x_imag (32) | b.x_real (32) | b.y_imag (32) | b.y_real (32) ]\n```\n\n## 需要注意\n\n- Gas 在 Istanbul 中被 [EIP-1108](/eip-1108/) 降低为 `34,000 · k + 45,000`，这也是现行价格。\n- `F_p²` 坐标的顺序（虚部在前）是手工编码 G2 点时常见的 bug 来源。\n- 后来的研究把 alt_bn128 的估计安全强度降到了最初假设的 128 位以下。较新的设计常使用 BLS12-381，可通过 [EIP-2537](/eip-2537/) 使用。\n- 随 Byzantium 上线（[EIP-609](/eip-609/)）。\n"}},"requiredBy":[609,1108,1922,1923]}
