Is there an implementation of Integer Comparison?

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.

2 Likes

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

1 Like

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

1 Like

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