Comparison sequence of enc_numbers
jahidhasanlinix opened this issue · 16 comments
I have some questions, say I have a set or sequence of encrypted numbers outsourced to the cloud. Now client sent an encrypted range query to the server. Now I want the server to do the computation and return the value whose range is greater or equal to (>=) given numbers (ignore the lower numbers, filtered). How this can be implemented using TFHE-rs, any library, or pseudocode that explains this setup? Any help
Hello @jahidhasanlinix
A preliminary question : where do the encrypted numbers come from ? Are they encrypted by the user ? By someone else ?
There should definitely be a solution to what you are asking, in terms of algorithms, we’ll probably answer Monday when we resume work !
@IceTDrinker Thank you for your response.
- Client/User encrypts the numbers before outsourcing it, also the range query whose maximum numbers he wants to return.
I saw tfhe-rs have comparison operations, I was curious any example code to look how this can be implemented, also, what algorithm did it used to perform such operations, any paper link as well to look into?
So if I understand correctly
the client has a set of numbers and wants to find the numbers in a certain range, I'm not sure I understand the use case as the client has all the information to perform the computation in the clear.
In any case you can check the HL API documentation to see how things would work:
https://docs.zama.ai/tfhe-rs/high-level-api/tutorial
https://docs.zama.ai/tfhe-rs/high-level-api/operations
https://docs.zama.ai/tfhe-rs/high-level-api/serialization
You would be able to use the comparison operators directly for each encrypted integer and return an integer that would contain a 0 for false and 1 for true
hello @jahidhasanlinix is your problem solved ? 🙂
@IceTDrinker Not solved. But I'll close it.
@jahidhasanlinix did we answer your question though ? the objective is not to close issues if we can still help !
@jahidhasanlinix is there anything we can still do to help ? Again was not trying to close a relevant issue, there just wasn't activity here for a while 🙂
@IceTDrinker Thank you for trying to help me out regarding this subject matter.
The situation is if a user encrypts multiple polynomial functions and outsources them to the cloud, how range setting (greater than or equal to ">=" [say this range only return whose range setting is >= 50 only after calculating the functions in the cloud computation]) can be applied to do the comparison of the sequence of polynomial functions to find whose range is within that setting in the cloud without decrypting it? If TFHE-rs can do such operations, is there any resource that could help to understand how it might applied (Especially which algorithm either CKKS is good one to pick in such use cases), I have seen there are (>=) operations available, does it work for a cont. polynomial function or just for discrete numbers?
@jahidhasanlinix the >= function we have are for discrete numbers. Which algorithm did you hope to use for polynomial function comparison (I’m guessing you have a paper or a technique you already use outside of the FHE use case) ?
@IceTDrinker, I see. Does CKKS support for cont polynomial function for such >= comparison? I was reading CryptDB and ORE papers but it's not clear yet to me whether this technique would work or not. Do you know any other algorithm to look into outside these, or TFHE-rs >= also works for cont functions?
I don’t know CKKS myself. For functions unless it gets evaluated for a certain x (for a univariate f: x -> f(x) function) TFHE-rs cannot say if a function will always yield values greater than an other for a given input.
To do a range query @jahidhasanlinix you can do the following:
given a range [a; b] encrypted under a secret key sk and a value, the query called q encrypted under the same secret key, if you want to know if q € [a; b] you can:
- compute in FHE q >= a which yields a boolean we will call ge_a (greater than or equal to a)
- compute in FHE q <= b which yields a boolean we will cal le_b (less than or equal to b)
- compute in FHE ge_a and le_b which yields a boolean that will indicate whether the value was in the range
For other cases i.e. smaller than a or greater than b you can apply a bit wise negation to ge_a or le_b
The result can be decrypted by the secret key and you get your answer.
That's the best I can think of to check if a value is in a given range
@IceTDrinker Thank you. Does this also applicable to any continuous function with real numbers or just work for discrete numbers? If other way around, is there any algorithm that you suggest that works for cont function with real numbers instead of discrete value?
@jahidhasanlinix we don't have support for floating point numbers so we don't really have something for "continuous function with real numbers", to be noted that floating point values are still discrete values :) but I understand that's not what you mean here.
So I guess I gave the answer for what we support (integer ranges) but cannot provide more at the moment for floating point ranges
ok to close now @jahidhasanlinix ?
Sure. Thank you.