I am trying to write a circuit to prove that a number is within a specified range. I am using the circomlib library : https://github.com/iden3/circomlib/tree/master/circuits comparators.circuit file. My code till now is this :
template RangeProof(n) {
assert(n <= 252);
signal input in; // number to be proved
signal input range[2]; // [lower bound, upper bound]
signal output out;
component low = LessEqThan(n);
component high = GreaterEqThan(n);
low.in[0] <== in;
low.in[1] <== range[0];
low.out === 1;
high.in[0] <== in;
high.in[1]<==range[1];
high.out === 1;
out <== (low.out + high.out) == 2 ? 1: 0; //this is the line in question
}
So I want to return 1 if true and 0 if false. But that would depend on whether the other two out signals. Any idea how I can do this? Any help is greatly appreciated.