mirror of
https://github.com/logos-blockchain/logos-blockchain-pocs.git
synced 2026-04-14 06:43:34 +00:00
bring back the SafeLessThan
This commit is contained in:
parent
fa940b1ed2
commit
d2c15d96c1
@ -57,4 +57,24 @@ template SafeFullLessThan() {
|
||||
intermediate_results[3] <== B.out * (intermediate_results[0] + intermediate_results[2]);
|
||||
|
||||
out <== (1 - A.out) * ((1 - B.out) + intermediate_results[3]);
|
||||
}
|
||||
|
||||
// Safely compare two n-bit numbers
|
||||
// Performs range checks on the inputs to avoid overflow. Range is n <= 252
|
||||
template SafeLessThan(n) {
|
||||
assert(n <= 252);
|
||||
signal input in[2];
|
||||
signal output out;
|
||||
|
||||
component aInRange = Num2Bits(n);
|
||||
aInRange.in <== in[0];
|
||||
component bInRange = Num2Bits(n);
|
||||
bInRange.in <== in[1];
|
||||
|
||||
component lt = LessThan(n);
|
||||
|
||||
lt.in[0] <== in[0];
|
||||
lt.in[1] <== in[1];
|
||||
|
||||
out <== lt.out;
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user