Does openFHE support comparison?

does openFHE support some function that can do the comparison of 2 encrypted numbers?

yes, see openfhe-development/eval-sign.cpp at main · openfheorg/openfhe-development · GitHub It is based on TFHE/FHEW. The algorithm is described/proposed in Large-Precision Homomorphic Sign Evaluation using FHEW/TFHE Bootstrapping

1 Like

Thank you very much for replying! I run exact same code in eval-sign.cpp, but got some thing like: “openfhe-development/src/binfhe/lib/fhew.cpp:914 ERROR: EvalSign is only for large precision. For small precision, please use bootstrapping directly”. What does that means?

I just ran the example using the default settings, i.e., when \log Q=17, and it worked without any problems. Did you try to run it for a smaller \log Q? This would cause the exception to be thrown. In the current implementation Q needs to be larger than q.

As a side note, the case of Q=q (1 bootstrapping) requires a trickier API now, and we can make it simpler to use (i.e., we can add support for it directly to EvalSign). Is this the case you tried?

hi, i didn’t change anything in the eval-sign.cpp, and i got:
logQ: 17
Q: 131072
q: 4096
factor: 32
p: 512
but i still got the error “EvalSign is only for large precision. For small precision, please use bootstrapping directly”. I run the code on MacBook with M2 chip, would that affect the result?

  1. As a sanity check can you give us more details? E.g what macbook make, compiler, etc.?

  2. Have you followed all the instructions listed out in our discord Installing OpenFHE on MacOS

Thank you very much! I reinstall the whole thing and it worked!

Amazing! Thank you and please mark this as solved since it osunds like we addressed all your questions :slight_smile: