Range check solution 1 (public with verifier precompute)

Suppose is a public value, known to both prover and verifier. In this setting, it’s okay to ask the verifier to verify an out-of-circuit computation.

So here’s the solution. Both prover and verifier compute the largest power of 2 less than ; call it . They also compute , which will satisfy .

The main idea is a slight generalization of the “range check by binary expansion” trick. The integer lies in the interval if and only if we can decompose

where:

for ,

and

for .

Let for , , and for . These ’s, for , will be public inputs to the circuit; both prover and verifier will compute them from .

Additionally, the prover will produce private witnesses . These witnesses are required to satisfy:

(Notice that is satisfied if and only if is either or .) This solves the problem with only 64 quadratic constraints.