The Schwartz-Zippel Lemma and its application to Zero Knowledge Proofs

Nearly all ZK-Proof algorithms rely on the Schwartz-Zippel Lemma to achieve succintness.

The Schwartz-Zippel Lemma states that if we are given two polynomials p(x)p(x) and q(x)q(x) with degrees dpd_p and dqd_q respectively, and if p(x)q(x)p(x) \neq q(x), then the number of points where p(x)p(x) and q(x)q(x) intersect is less than or equal to max(dp,dq)\mathsf{max}(d_p, d_q).

Let’s consider a few examples.

Example polynomials and the Schwartz-Zippel Lemma

A straight line crossing a parabola

Consider the polynomial p(x)=xp(x) = x and q(x)=x2q(x) = x^2. They intersect at x=0x = 0 and x=1x = 1.
Plot of y = x and y = x^2

They intersect at two points, which is the maximum degree between the polynomials y=xy = x and y=x2y = x^2.

A degree three polynomial and a degree one polynomial

Consider the polynomials p(x)=x3p(x) = x^3 and q(x)=xq(x) = x. The polynomials intersect at x=1x = -1, x=0x = 0, and x=1x = 1 and nowhere else. The number of intersections is bounded by the maximum degree of the polynomials, which in this case is 3.

Plot of y = x^3 and y = x

Polynomials in finite fields and the Schwartz-Zippel Lemma

The Schwartz-Zippel Lemma holds for polynomials in finite fields (i.e., all computations are done modulo a prime pp).

Polynomial equality testing

We can test that two polynomials are equal by checking if all their coefficients are equal, but this takes O(d)\mathcal{O}(d) time, where dd is the degree of the polynomial.

If instead we can evaluate the polynomials at a random point uu and compare the evaluations in O(1)\mathcal{O}(1) time.

That is, in a finite field Fp\mathbb{F}_{p}, we pick a random value uu from [0,p)[0,p). Then we evaluate yf=f(u)y_f=f(u) and yg=g(u)y_g=g(u). If yf=ygy_f = y_g, then one of two things must be true:

  1. f(x)=g(x)f(x) = g(x)
  2. f(x)g(x)f(x) \neq g(x) and we picked one of the dd points where they intersect where d=max(deg(f),deg(g))d = \mathsf{max}(\deg(f), \deg(g))

If dpd \ll p, then situation 2 is unlikely to the point of being negligible.

For example, if the field Fp\mathbb{F}_{p} has p2254p \approx 2^{254} (a little smaller than a uint256), and if the polynomials are not more than one million degree large, then the probability of picking a point where they intersect is

1×106225422022541223411070\frac{1\times 10^6}{2^{254}} \approx \frac{2^{20}}{2^{254}} \approx \frac{1}{2^{234}} \approx \frac{1}{10^{70}}

To put a sense of scale on that, the number of atoms in the universe is about 107810^{78} to 108210^{82}, so it is extremely unlikely that we will pick a point where the polynomials intersect, if the polynomials are not equal.

Using the Schwartz-Zippel Lemma to test if two vectors are equal

We can combine Lagrange interpolation with the Schwartz-Zippel Lemma to test if two vectors are equal.

Normally, we would test vector equality by comparing if each of the nn components of the vectors are equal.

Instead, if we use a common set of xx values (say [1,2,..,n][1,2,..,n]) to interpolate the vectors:

  1. We can interpolate a polynomial for each vector f(x)f(x) and g(x)g(x)
  2. Pick a random point uu
  3. Evaluate the polynomials at uu
  4. Check if f(u)=g(u)f(u) = g(u)

Although computing the polynomials is more work, the final check is much cheaper.

Here is an example of carrying out this computation in Python:

import galois
import numpy as np

p = 103
GF = galois.GF(p)

xs = GF(np.array([1,2,3]))

# arbitrary vectors
v1 =  GF(np.array([4,8,19]))
v2 =  GF(np.array([4,8,19]))


def L(v):
    return galois.lagrange_poly(xs, v)

p1 = L(v1)
p2 = L(v2)

import random
u = random.randint(0, p)

lhs = p1(u)
rhs = p2(u)

# only one check required
assert lhs == rhs

Using the Schwartz-Zippel Lemma in ZK Proofs

Our end goal is for the prover to send a small string of data to the verifier that the verifier can quickly check.

Most of the time, a ZK proof is essentially a polynomial evaluated at a random point.

The difficulty we have to solve is that we don’t know if the polynomial is evaluated honestly – somehow we have to trust the prover isn’t lying when they evaluate f(u)f(u).

But before we get to that, we need to learn how to represent an entire arithmetic circuit as a small set of polynomials evaluated at a random point, which is the motivation for Quadratic Arithmetic Programs.

Ready to Get Started?Join Thousands of Users Today

Start your free trial now and experience the difference. No credit card required.

© 2025 Better-Start. All rights reserved.