How to compare set of numbers using OpenFHE

Does openFHE support or have any function that can compare set of encrypted numbers in the cloud with some range settings? Lets say I have set of encrypted numbers (1~10) and I want to perform a range query on server to return value whose range greater or equal to any number (lets say >=5), so server should return only encrypted numbers from 5~10 only, and ignore smaller number. What method can do certain comparison operations (>=), also any library function that can help to do such experiment? Thank you.

Are you only interested in performing a comparison over encrypted integers?

If that is the case, I recommend using one of the schemes in the binary FHE family in OpenFHE. You can encrypt your data bit-wise and build a comparator as a binary circuit, or you can use existing compilers such as Google FHE C++ Transpiler to help you transform C++ code into FHE binary circuits.

Thank you for the reply.

“Are you only interested in performing a comparison over encrypted integers?” - Yes.

binary FHE family- Do you have any specific resource or link that you are referring to look into will be helpful to start reading and try to understand.

Does FHE C++ Transpiler acts as a comparator binary circuit? Specifically which code or example code actually closer to this comparator binary circuit to look into for better understanding?

For examples on OpenFHE’s binfhe, check this example folder.

You can refer to the Transpiler repo above for more resources on how to use it.

I have one question, just to understand in a better way.

For say, I have a sequence of encrypted numbers from 1 to 100 and outsource to the cloud. Then client sends an encrypted range query (>= 50) to outsource to the cloud, and it should return whose range is greater or equal to 50. In such a situation how does Tranpiler can help to return larger value only to the client side? How to implement comparison range setting, do you have an example to follow for this?

I don’t think there are examples for your exact use case but I’m sure you can compose various examples together to make what you’re looking for. The examples that Ahmad linked should help most users build what they need or at least get a clearer idea of what their code should look like

Here is a demo of how to use the Transpiler if you choose to implement your application using the transpiler.

All you need to do is write a C++ function that compares (>=) a given input with a constant threshold (50 in your case).

Thank you for the details. That helps. Just to make sure one more time, so that mean comparison range setting function can be implemented using Transpiler or OpenFHE both, am I right?

According to the Transpiler documentation here, OpenFHE is supported as an FHE backend. This means, yes, you can implement a solution to your problem using both the Transpiler and OpenFHE.

Seems like your question has been answered. I’m marking this as solved but feel free to open this discussion again if you have any specific questions