I’m working in my graduation project and would like to use Integer Comparison on Encrypted Data. Is there an function for that in the library? If not, is there a way for me to implement it?
You can use binfhe to build an n-bit comparator as a boolean circuit, where n is the size of your integers. You can build the circuit yourself or use the Google transpiler which translates C++ source code into boolean circuits and generates an FHE-friendly program that can be executed by any of the supported FHE backend libraries. Note that OpenFHE is supported in Google transpiler.
If you want to use other FHE schemes (specifically CKKS, BFV or BGV) to implement comparison, it is more complicated.
Hi there! Yes, there is! In addition to what @Caesar said about the Google Transpiler, you can also check out how we do it here: binfhe/examples
Hi @trandus,
I want to add more detail to what @iquah wrote. We have an example of large-precision comparison (sign function) at openfhe-development/eval-sign.cpp at v1.0.1 · openfheorg/openfhe-development · GitHub Under the hood, it uses the algorithm proposed in Large-Precision Homomorphic Sign Evaluation using FHEW/TFHE Bootstrapping.
Also I suggest reading a related topic: Optimization of Homomorphic Comparison Algorithm on RNS-CKKS Scheme
It’s more complicated, but is it possible? Because I would also like to use the Threshold FHE that seems to only be present in the other schemes
Comparing two integers with FHE is possible. For integer comparison, the most relevant method in BGV/BFV is this paper. The code is available. However, the integers need to be decomposed before encryption.
If you want to compare two encrypted integers directly, check this paper.
Hello, do you have any python threshhold (multiparty) solution for integer comparison? More specifically, we need an equality check for integer values.
Hi, you can check the this paper for multi-party BGV / BFV. Since BGV / BFV can support integer comparison, their multi-party variant should support integer comparison as well. But for now as far as I know, the only multi-party FHE that is well implemented well is the threshold CKKS in OpenFHE.
Threshold FHE is also implemented for BGV and BFV.
Thank you, which method from your library can we use for comparison? Of course, we can implement some workarounds, such as taking the difference between two inputs and then multiplying it by other inputs, but this is a very cumbersome solution and does not sound quite correct.
EvalSign (sign function) can be used (it is discussed earlier in the the topic).