# Revisiting the Proofs Behind Pairing Checks

- **Authors**: Hao Pham, Kobi Gurkan
- **Date**: November 30, 2026
- **Tags**: cryptography, pairings
In [our previous post](https://blog.zksecurity.xyz/posts/openvm-bugs/), we described a soundness bug that our AI experiment found in a pairing precompile. That investigation sent us back to [*On Proving Pairings*](https://eprint.iacr.org/2024/640.pdf), the paper by Andrija Novakovic and Liam Eagen behind the technique.

The earlier experiment had taken the paper as its ground truth.
But why don't we move a step deeper: try to break the paper?
The initial thought is that if we can break it, or at least spot an ambiguity in its description, then we can "farm" a lot of bugs across many implementations.

Things like that have happened in the past. We can name a few:

- 
An ambiguous description of how the "transcript" was derived in an early version of the PlonK paper made popular implementations such as SnarkJS suffer from the now well-known Frozen Heart attack, found by the Trail of Bits team.[2](#fn:tob)

  An ambiguous description of how the "transcript" was derived in an early version of the PlonK paper made popular implementations such as SnarkJS suffer from the now well-known Frozen Heart attack, found by the Trail of Bits team.[2](#fn:tob)
- 
An oversight around identity-element checks and the semantics of aggregate verification in early versions of [the IRTF draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-bls-signature-04) led to a family of zero-related bugs in several implementations (py_ecc, blst, milagro_bls, etc.), found by Nguyen Thoi Minh Quan.[3](#fn:quan)

  An oversight around identity-element checks and the semantics of aggregate verification in early versions of [the IRTF draft](https://datatracker.ietf.org/doc/html/draft-irtf-cfrg-bls-signature-04) led to a family of zero-related bugs in several implementations (py_ecc, blst, milagro_bls, etc.), found by Nguyen Thoi Minh Quan.[3](#fn:quan)

We wanted to try something similar: revisit the paper's arguments and check whether their assumptions hold across different parameters.
In other words, we wanted to break the paper!

We didn't break the intended BN254 construction!
But in discussions with Andrija, we (and our LLMs, of course) identified a few places where the proofs and statements in the paper could be clarified or generalized better.

The intended BN254 construction remains valid.
Our aim here is to restate the three theorems and explain the necessary preconditions in a common cyclic-group framework.

Before we get back to the pairing problem, let's review a few facts about cyclic groups and introduce the notation we'll need.

# Some background on cyclic group

We will use some facts about (finite) cyclic groups. Let $q$ be a prime power, let $k$ be a positive integer, and let $r$ be a prime dividing $q^k-1$. Set $h=(q^k-1)/r$. The nonzero elements of the extension field $\mathbb F_{q^k}$ form a cyclic multiplicative group:

$$
G=\mathbb F_{q^k}^{*}=\langle g\rangle,\qquad N=|G|=q^k-1=rh.
$$

The cyclic allows you to treat every element in the group as $g^a$ for some number $a$ (even if we don't know $a$), where $g$ is called group generator. It makes life much easier.

Next, raising elements to a positive integer power $b$ gives the subgroup $G^b$[5](#fn:r-residue):

$$
G^b:={z^b:z\in G}
=\langle g^{\gcd(b,N)}\rangle,
\qquad |G^b|=\frac{N}{\gcd(b,N)}.
$$

The order (number of elements) of a subgroup is determined by $N/\gcd(b, N)$. 
As a result, if you choose $b$ to be coprime with $N$, you just obtain a permutation of the original group. 

> [!NOTE]
> For example, take a cyclic group of order 12 with generator $g$.
> The squares form $G^2={1,g^2,g^4,\ldots,g^{10}}$, while the fourth powers form the smaller subgroup $G^4={1,g^4,g^8}$.
> Eighth powers give $G^8={1,g^8,g^{16}}$, which is actually the same subgroup as $G^4$, since $g^{16}=g^4$.
> So the exponent doesn't have to divide the group order: what matters is the gcd, and $\gcd(8,12)=\gcd(4,12)=4$.

A cyclic group has **exactly one** subgroup of each order dividing $N$. As you can see above, $G^4$ and $G^8$ have order 3, and their elements are identical!
So if we want to check if two subgroups of a cyclic group are equal of not, we just need to calculate their orders.

Consequently, for subgroups $A,B\le G$, their product

$$
AB={ab:a\in A,\ b\in B}
$$

is a subgroup of order $\operatorname{lcm}(|A|,|B|)$. This follows either by writing both subgroups as powers of $g$ or from $|AB|=|A||B|/|A\cap B|$.

In our context, we use $q$ to define a finite field $\mathbb{F}_q$,
then construct an elliptic curve $E(\mathbb{F}_q)$ over this field.
The prime $r$ is chosen such that $r | #E(\mathbb{F}_q)$ and $r^2 \nmid #E(\mathbb{F}_q)$, while $k$ is the smallest positive integer such that $r | q^k - 1$ (i.e., $k$ is the embedding degree).

# Recall the problem

In case you didn't have time to read [the previous blog](https://blog.zksecurity.xyz/posts/openvm-bugs/),
a pairing verifier often needs to check that a product of pairings is one:

$$
\prod_i e(P_i,Q_i) \stackrel{?}{=} 1.
$$

Pairing is a complex operation. But all we need to know in this blog is that the final step raises the intermediate value to a very large power.
Let $f$ be that intermediate value. Then the initial check is equivalent to

$$
f^h \stackrel{?}{=} 1,\qquad h=\frac{q^k-1}{r}.
$$

The final exponentiation can be expensive to verify in a circuit.
We can make an observation: If $f^h = 1$, then $f$ must be an element of $G^r$, i.e., an $r$-th residue.
Equivalently, it means there must exist some element $c$ such that $f = c^r$.
Computing $c^r$ is much cheaper than computing $f^h$, but the verifier cannot find $c$ by itself.
The paper proposes providing that $c$ as a witness.
Furthermore, it adds a scaling factor $u$ on the left-hand side so that we can check $fu=c^\lambda$, choosing a multiple $\lambda=rm$ that works well with the Frobenius map to reduce the exponentiation cost.

We will go through the three theorems to come up with the final optimized equation, but for now it is:

$$
f\cdot u \stackrel{?}{=} c^\lambda,\qquad u\in S.
$$

Here, $d=\gcd(m,h)$, and $S$ is a subgroup of $G^r$ satisfying

$$
\operatorname{lcm}(h/d,|S|)=h.
$$

We will write

$$
H:=G^r,\qquad K:=G^\lambda.
$$

# Three theorems

The three theorems describe successive steps in this optimization. The first identifies the condition $f^h=1$ with membership in $H$. The second describes the subgroup $K$ reached by the chosen exponent. The third introduces a scaling witness so that the check covers all of $H$. At each step, we give the general statement and relate it to the paper's argument.

## Theorem 1

![Theorem 1 and its proof](https://blog.zksecurity.xyz/posts/pairing-residue-proofs/theorem_1.png)

The intermediate value $f$ we introduced earlier is $\prod f_{r, Q_i}(P_i)$.

The original proof establishes completeness by constructing a witness using $h^{-1}\pmod r$. For this inverse to exist, we need $\gcd(r,h)=1$, or equivalently $r^2\nmid q^k-1$.
The proof uses this condition without establishing it from the earlier assumptions.

In practice, it is true for popular curves such as BN254, BLS12-381, and BLS12-377, and gives provers an efficient way to compute witnesses.
However, there is a "not-too-well-known" class of pairing-friendly elliptic curves named **Type E** in Stanford's PBC library that satisfy $r^2 | q^k - 1$.[1](#fn:lte)

> [!NOTE]
> For another concrete counterexample, take $E: y^2=x^3+x+2$ over $\mathbb F_{17}$ and $r=3$. The curve has 24 points, so $r\mid#E(\mathbb F_{17})$ but $r^2\nmid#E(\mathbb F_{17})$. Its embedding degree is $k=2$, yet $q^k-1=288$ is divisible by $r^2=9$. Thus the assumption on the curve's point count does not guarantee the coprimality needed by the proof.

The theorem itself holds more generally: even when $r^2\mid q^k-1$ and that inverse does not exist, we can prove the equivalence directly using the cyclic structure of $G$:

Because $G$ is cyclic, we can write $f = g^a$ for some $a$.
Then we have $f^h = g^{ah} = 1 \Longleftrightarrow N | ah \Longleftrightarrow r | a \Longleftrightarrow f\in G^r$.

By the definition of $G^r$, there must exist some group element $c$ such that $f = c^r$. Specifically, $c = g^{a/r}$.
This establishes the paper's first equivalence **without the $r^2 \nmid q^k - 1$ assumption**.

> [!NOTE] A minor typo in the original proof:
> The proof writes $p^k-1$ where the relevant multiplicative group has order $q^k-1$.

## Theorem 2

![Theorem 2 and its proof](https://blog.zksecurity.xyz/posts/pairing-residue-proofs/theorem_2.png)

For optimization purposes, we choose an integer $m$ and then let $\lambda=rm$ and $d=\gcd(m,h)$.
The paper claims that $f^h=1$ if and only if $f=c^{\lambda/d}$ for some $c\in G$.
In the language of group theory, combining this with Theorem 1, we want to claim that $G^{\lambda/d} = G^r$,
or equivalently, $|G^{\lambda/d}| = |G^r|$[4](#fn:subgroup).

The original proof assumes that $\gcd(m/d, h) = 1$.
However, this assumption is not true.
The definition of $d$ does not guarantee $\gcd(m/d,h)=1$. For example, take $m=12$ and $h=18$. Then we have $d=6$, so $m/d=2$ still shares a factor with $h$.

> [!NOTE] A counterexample:
> Take $G=\mathbb F_7^*$, so $N=6$, and choose $r=3$, $h=2$, and $m=4$. Then $d=2$ and $\lambda/d=6$. The element $f=-1$ satisfies $f^h=1$, but every $c\in G$ satisfies $c^6=1$. Thus no witness can satisfy $f=c^{\lambda/d}$.

Unlike Theorem 1, Theorem 2 can fail without this extra condition.
But is it enough? Let's see:

We can state the missing condition precisely using the subgroup formula from the background:

$$
|G^{\lambda/d}|
=\frac{N}{\gcd(\lambda/d,N)}
=\frac{h}{\gcd(m/d,h)}.
$$

Since $\lambda/d=r(m/d)$, we always have $G^{\lambda/d}\subseteq G^r$. The two groups are equal exactly when their orders agree. Therefore,

$$
\boxed{|G^{\lambda/d}|=|G^r|
\quad\Longleftrightarrow\quad
|G^{\lambda/d}| = h
\quad\Longleftrightarrow\quad
\gcd(m/d,h)=1.}
$$

So that extra condition $\gcd(m/d,h)=1$ is necessary and sufficient for Theorem 2.

But is there any violation in practical settings?

BN254 satisfies this condition, so Theorem 2's equivalence applies there.
For BLS12-381, however, the choice $\lambda=q-t$ discussed below gives $\gcd(m/d,h)=5044125407647214251$, where $t$ is the curve's family seed.
Thus dividing $\lambda$ by $d$ does not recover every $r$th power for those parameters.

Actually, we don't really need Theorem 2 to achieve the final optimized equation.
To handle the general case, we can instead describe which elements are full $\lambda$-th powers. Since $\gcd(\lambda,N)=rd$,

$$
\boxed{K=G^\lambda=\langle g^{rd}\rangle,
\qquad |K|=h/d,
\qquad [H:K]=d.}
$$

Every element of $K$ is still an $r$-th power, so the check $f=c^\lambda$ preserves soundness.
When $d=1$, we have $H = K$ and therefore that check is also complete.
When $d>1$, it covers only one of the $d$ cosets of $K$ in $H$.
So, in general, the new check in Theorem 2 cannot accept an invalid value, but it might reject a valid one.

Theorem 3 introduces a scaling witness to cover the remaining cosets to make the final check both sound and complete.

## Theorem 3

![Theorem 3 and its proof](https://blog.zksecurity.xyz/posts/pairing-residue-proofs/theorem_3.png)

The paper introduces a scaling witness $u$ to reach the cosets missing from $K=G^\lambda$. It claims that every $f\in H$ can be written as $f=c^\lambda u$, where $u^{d^i}=1$ and $i$ is the largest exponent that still satisfies $d^i | h$.

The original proof starts by assuming $\gcd(d,rm)=1$ and computing $(rm)^{-1}\pmod{d^i}$. But $d=\gcd(m,h)$ divides $m$, so $\gcd(d,rm)=d$. When $d>1$ and $i\ge1$, that inverse does not exist. The proof also uses $m^{-1}\pmod N$, which does not exist either: $d$ divides both $m$ and $N=rh$.

> [!NOTE] A counterexample:
> Take $G=\mathbb F_{61}^*$, with $N=60$, $r=5$, $h=12$, and $m=6$. Then $d=6$, $\lambda=30$, and $K=G^{30}$ has order 2. Here $i=1$, since $6\mid12$ but $6^2\nmid12$, so the allowed scaling witnesses form $S={u\in G:u^6=1}$, of order 6. Since $K\subseteq S$, every product $c^{30}u$ remains in $S$, which covers only half of $H$, of order 12. This example satisfies both $\gcd(r,h)=1$ and $\gcd(m/d,h)=1$, so the earlier conditions do not resolve this issue.

The scaling idea still works, but we need a different proof and a precise condition on the allowed values of $u$. In particular, choosing the largest power $d^i$ dividing $h$ is not always enough when $d$ is composite.

We can express exactly what scaling needs to achieve using subgroups. Let $S\le H$ be the allowed scaling subgroup. The elements represented by $c^\lambda u$ form the product subgroup $KS$. Therefore, the check covers every element of $H$ exactly when

$$
KS=H
\quad\Longleftrightarrow\quad
\operatorname{lcm}(|K|,|S|)=h
\quad\Longleftrightarrow\quad
\operatorname{lcm}(h/d,|S|)=h.
$$

Under this condition, for every $f\in G$,

$$
\boxed{f^h=1
\quad\Longleftrightarrow\quad
\exists c\in G,\ u\in S:\ fu=c^\lambda.}
$$

Here we move the scaling witness to the left by replacing it with its inverse, which also belongs to $S$.

For soundness, $f=c^\lambda u^{-1}\in H$, since both factors lie in $H$. For completeness, $KS=H$ gives $f=c^\lambda s$ for some $s\in S$; choose $u=s^{-1}$. This proves the equivalence without either of the inverses used in the original proof.

How do we choose $S$? One general choice is

$$
M=\prod_{\ell\mid d}\ell^{v_\ell(h)},\qquad
S=\mu_M:={u\in G:u^M=1}.
$$

The product runs over the prime divisors of $d$, and $v_\ell(h)$ is the exponent of $\ell$ in $h$. This takes the full prime-power parts of $h$ wherever $K$ is missing a factor. Since $M\mid h$ and $\operatorname{lcm}(h/d,M)=h$, this choice satisfies both conditions on $S$.

For BN254, $d=3$ and $i=v_3(h)=3$, so the original choice is $u\in\mu_{27}$, which agrees with $M=27$. The intended construction therefore remains valid. Roots of order dividing 3 or 9 would not suffice, because they already lie in $K$.

For BLS12-381 and BLS12-377, take $\lambda=q-t$, where $t$ is the curve's family seed. For both concrete parameter sets, $i=v_d(h)=1$. Following the original $d^i$ choice would therefore restrict $u$ to $S=\mu_d$. However, direct calculation gives

$$
|KS|=\operatorname{lcm}(h/d,d)=h/3.
$$

Thus this choice covers only one-third of $H$. The missing factor is a power of 3:

- For **BLS12-381**, $d=1-t$, so the original choice is $u\in\mu_{1-t}$. We have $v_3(h)=3$, but $v_3(|K|)=2$ and $v_3(|S|)=1$. Their LCM still contains only $3^2$, whereas $H$ requires $3^3$. Instead, gnark chooses $S=\mathbb F_{q^6}^*$, which satisfies the completeness condition.
- For **BLS12-377**, $d=4(t-1)$, so the original choice is $u\in\mu_{4(t-1)}$. Here $v_3(h)=2$, but both $|K|$ and $|S|$ contain only one factor of 3. Enlarging $S$ to $\mu_{12(t-1)}$ supplies the missing factor and gives $KS=H$.

These calculations concern completeness for every $f\in H$.

**Why proper subfields are useful**

Root-of-unity membership can require another exponentiation. A proper subfield can be cheaper to recognize in the field representation already used by a circuit.

Assume $k$ is the embedding degree, meaning the multiplicative order of $q$ modulo the prime $r$. For a proper divisor $j\mid k$,

$$
r\nmid q^j-1.
$$

Since $q^j-1\mid q^k-1=rh$, it follows that $q^j-1\mid h$. Consequently

$$
\mathbb F_{q^j}^{*}\le H.
$$

This establishes the soundness condition for using any such subfield. Completeness still requires

$$
\operatorname{lcm}(h/d,q^j-1)=h.
$$

In a suitable tower basis, restricting a witness to a subfield amounts to setting certain coefficients to zero. The exact coefficients depend on the basis. Those constraints are the implementation of $u\in S$, which was the issue in the OpenVM investigation.

For the intended pairing optimization, the reusable statement is now precise: choose an exponent whose powers are cheap to check, and a scaling subgroup $S$ such that $S\le G^r$ and $G^\lambda S=G^r$. The first inclusion gives soundness; the equality gives completeness. These conditions explain why the BN254 construction works and which arithmetic must be revisited for another curve.

Revisiting these proofs helped us make the assumptions behind the optimization explicit while retaining the intended BN254 result. It also gives us a concrete way to review how the same technique carries over to other curves and motivation to continue this kind of work with other papers.

We thank Andrija for the discussions that led to the note behind this post.

---

1. 
[https://github.com/blynn/pbc/blob/8df04da/param/e.param](https://github.com/blynn/pbc/blob/8df04da/param/e.param)qq3936677670287331zz[zz1337820767766393qq](#fnref:lte)

   [https://github.com/blynn/pbc/blob/8df04da/param/e.param](https://github.com/blynn/pbc/blob/8df04da/param/e.param)qq3936677670287331zz[zz1337820767766393qq](#fnref:lte)
2. 
[https://blog.trailofbits.com/2022/04/18/the-frozen-heart-vulnerability-in-plonk/](https://blog.trailofbits.com/2022/04/18/the-frozen-heart-vulnerability-in-plonk/)qq3936677670287331zz[zz1337820767766393qq](#fnref:tob)

   [https://blog.trailofbits.com/2022/04/18/the-frozen-heart-vulnerability-in-plonk/](https://blog.trailofbits.com/2022/04/18/the-frozen-heart-vulnerability-in-plonk/)qq3936677670287331zz[zz1337820767766393qq](#fnref:tob)
3. 
[https://eprint.iacr.org/2021/377.pdf](https://eprint.iacr.org/2021/377.pdf) and [https://eprint.iacr.org/2021/323](https://eprint.iacr.org/2021/323).qq3936677670287331zz[zz1337820767766393qq](#fnref:quan)

   [https://eprint.iacr.org/2021/377.pdf](https://eprint.iacr.org/2021/377.pdf) and [https://eprint.iacr.org/2021/323](https://eprint.iacr.org/2021/323).qq3936677670287331zz[zz1337820767766393qq](#fnref:quan)
4. 
Because there is exactly one subgroup of $G$ having order $h$.qq3936677670287331zz[zz1337820767766393qq](#fnref:subgroup)

   Because there is exactly one subgroup of $G$ having order $h$.qq3936677670287331zz[zz1337820767766393qq](#fnref:subgroup)
5. 
You might also know the term "$r$-th residue". It just means an element of $G^r$. For $r=2$, these are squares, also known as "quadratic residues".qq3936677670287331zz[zz1337820767766393qq](#fnref:r-residue)

   You might also know the term "$r$-th residue". It just means an element of $G^r$. For $r=2$, these are squares, also known as "quadratic residues".qq3936677670287331zz[zz1337820767766393qq](#fnref:r-residue)

---

This article was published on the [ZK/SEC Quarterly](https://blog.zksecurity.xyz) blog by [ZK Security](https://www.zksecurity.xyz), a leading security firm specialized in zero-knowledge proofs, MPC, FHE, and advanced cryptography. ZK Security has audited some of the most critical ZK systems in production, discovered vulnerabilities in major protocols including Aleo, Solana, and Halo2, and built open-source tools like [Clean](https://github.com/Verified-zkEVM/clean) for formally verified ZK circuits. For more articles, see the [full list of posts](https://blog.zksecurity.xyz/llms.txt).
