# Using zk-snarks to check if value is greater than another

Can I use Zk-SNARKS to prove that a given secret value is greater than another public value. for Example to prove that secret_value >10 . if so How would such a circuit look

I am using snarks.js which uses circuit file .

To do range proofs with zk-snarks, you have to compute an inequality over an arithmetic circuit. The way this is done is by subtracting the two numbers and then checking if the result is negative.

For example - say you want to see if 3 < 10.

1. You calculate 3 - 10 = -7
2. Do a bit decomposition of -7 using 2's compliment. The result is 100111.
3. The first bit of the result is 1, so output 1, signifying that yes, 3 is smaller than 10.

Zokrates has inequalities built into their DSL, so you can use this out of the box.

While this is doable, using proof systems that are catered specifically to range proofs is often beneficial. For example, Bulletproofs have a batching mechanism for range proofs, so if you do enough of them, its proof size becomes comparable to Zk-Snark protocols. Since bulletproofs do not require a trusted setup, this can end up saving you a lot of computation time overall.

Current implementations of bulletproofs include a rust implementation, a haskell implementation, and this summary).