Range check solution 2 (interactive)

(Solution by Alex Ozdemir)

If we allow prover and verifier to interact, we can do this range check in just 48 quadratic constraints plus one additional round of interaction.

This protocol requires a challenge from the verifier. In other words: The prover will commit to some witnesses; the verifier will send a randomly-chosen challenge; and then the prover will produce more witnesses and finish the proof.

As usual, this protocol can be made non-interactive using the Fiat-Shamir heuristic.

The idea is to do the original fixed-size range check using a lookup argument. So suppose you have an , and you just want to check that . Our original binary-expansion protocol checks this with 64 quadratic constraints; this lookup argument will reduce it to 32 quadratic constraints.

We can check by performing two fixed-size range checks: one on and one on . The cost of multiple lookup arguments can be amortized. While one fixed-size range check requires 32 constraints, we will be able to do two of them in just 48 constraints.

The idea is simple: to prove that lies in range, we will expand in base as

where each lies in

OK, so now the problem is: How do we check that each lies between 0 and 16? This is a classic example of a lookup argument.

We’re going to do it using what’s called the “logarithmic derivative trick”; the same trick is used in the cq paper, for instance. (The name “logarithmic derivative” is a little strange, since it involves neither logarithms nor derivatives.)

Remember where we are: The prover has 16 witnesses , each of which must be one of the 16 values .

The prover is going to compute another 16 values . The letter stands for “count”: is the number of ’s that are equal to , for each .

Now, for any , the equality

must hold, because both sides have the same terms. And conversely, if constants and are such that the equality holds for randomly chosen , then both sides must be the same rational function of . We won’t give a full algebraic proof here, but if the two sides are the same rational function, then each must be equal to some .

So, here’s the full protocol.

This proves that each lies in the list , so , using just 32 constraints.

Returning to the original problem, if you want to prove that , you could just perform range checks on both and , for a total of 64 constraints.

But in fact we can cut it down to 48 constraints by amortizing the lookups. Suppose we write

We need to show that all the variables and are in the set . To do this, let be the number of ’s and ’s combined that are equal to .

So now there are 32 witnesses and , but there are still only 16 witnesses for both range checks combined.

Now the equality we want to prove is

We’ll use the same trick as before: Since you can’t do a division in-circuit, the prover will commit to the value of each fraction. So each fraction above translates to one multiplicative constraint to be verified. Since there are 48 fractions in total, we end up with 48 constraints.

Here’s the full protocol.