Range checks

See end of page for some progress so far.

Problem statement

We have a fixed prime ; all values below are elements of the finite field .

We want to come up with a system of linear and quadratic equations in , , and some auxiliary variables , with the following properties:

The “cost model” is: Linear equations are effectively free; we want to minimize the number of quadratic equations.

We know a way to do it with quadratic equations; we think the best possible bound is much closer to .

Motivation: Range checks in zero-knowledge proofs.

A zero-knowledge proof lets a prover prove claims about a list of values in . The prover can natively prove only linear and quadratic polynomial equalities; any other sort of claim must be rewritten in terms of polynomials.

In practice, one often wants to prove claims like (i.e. that represents a valid 64-bit integer), or . (Note that a single inequality, like or , makes no sense in the context of a finite field. So, in a ZK circuit, “” will often be expressed as “ is a 64-bit integer” and – in other words, .)

Known results

As a warmup, consider the simple “range check” . This is equivalent to the single equation .

The “range check” can be expressed by saying that “ has a valid 64-bit binary expansion”. Algebraically, we introduce auxiliary variables , and require , , , and so forth.

This gives a total of 64 quadratic equations; for heuristic reasons we expect that 64 is best possible.

Returning to the problem , one simple solution is to verify that both and lie in the range ; this solution uses quadratic constraints. We expect that this can be improved.

One potential idea is to change the power-of-2 coefficients in the binary expansion

depending on . For example, replacing with a known constant with in

allows one to test a range of any length between and .

Progress

Intuition from algebraic geometry suggests that it might not be possible to solve the general problem as stated.

But we found two solutions that offer more efficient range checks in slightly different contexts. If is publicly known, our first solution lets you cut the number of constraints from 128 to 64.

Alternatively, if prover and verifier are allowed an additional round of interaction, the range check can be done using a lookup argument in just 48 constraints.