mirror of
https://github.com/logos-storage/logos-storage-proofs-circuits.git
synced 2026-01-03 05:53:11 +00:00
Revert "circuit: remove unused templates"
This reverts commit 521619c65fd03b7f6f3f6a6ba490cf427ff6d9a8. Co-Authored-By: Balazs Komuves <bkomuves@gmail.com>
This commit is contained in:
parent
34cd599c38
commit
46c17fa2ce
@ -41,3 +41,57 @@ template BinaryCompare(n) {
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// given two numbers in `n`-bit binary decomposition (little-endian), we compute
|
||||
//
|
||||
// out := (A <= B) ? 1 : 0
|
||||
//
|
||||
// NOTE: we don't check that the digits are indeed binary;
|
||||
// that's the responsibility of the caller!
|
||||
//
|
||||
|
||||
template BinaryLessOrEqual(n) {
|
||||
signal input A[n];
|
||||
signal input B[n];
|
||||
signal output out;
|
||||
|
||||
var phalf = 1/2; // +1/2 as field element
|
||||
var mhalf = -phalf; // -1/2 as field element
|
||||
|
||||
component cmp = BinaryCompare(n);
|
||||
cmp.A <== A;
|
||||
cmp.B <== B;
|
||||
|
||||
var x = cmp.out;
|
||||
out <== mhalf * (x-1) * (x+2);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//
|
||||
// given two numbers in `n`-bit binary decomposition (little-endian), we compute
|
||||
//
|
||||
// out := (A >= B) ? 1 : 0
|
||||
//
|
||||
// NOTE: we don't check that the digits are indeed binary;
|
||||
// that's the responsibility of the caller!
|
||||
//
|
||||
|
||||
template BinaryGreaterOrEqual(n) {
|
||||
signal input A[n];
|
||||
signal input B[n];
|
||||
signal output out;
|
||||
|
||||
var phalf = 1/2; // +1/2 as field element
|
||||
var mhalf = -phalf; // -1/2 as field element
|
||||
|
||||
component cmp = BinaryCompare(n);
|
||||
cmp.A <== A;
|
||||
cmp.B <== B;
|
||||
|
||||
var x = cmp.out;
|
||||
out <== mhalf * (x+1) * (x-2);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user