I get how that works for arithmetic operations - what about stuff like sorting, finding an element in a set etc? This would require knowledge of the cleartext data, wouldn't it?
The point of FHE is it can operate on gibberish-looking ciphertext, and when this ciphertext decrypted afterwards, the result is correct.
Indeed, there are those working on faster FHE sorting: https://eprint.iacr.org/2021/551.pdf
E.g. FHE_SORT(A,B) -> (X,Y)
where Dec(X)<Dec(Y)
But without decoding, there's no way of knowing whether X (or Y) comes from A or B.
Source: II. D of https://eprint.iacr.org/2015/995.pdf
To do anything practical the server usually needs to provide the client with gigabytes of per-client-key encrypted seed data.
0.5 * (sign(a - b) + 1)
And the sign function can be approximated by a polynomial that uses only additions and multiplications and products with constants.Other FHE schemes have support for small-bitwidth lookup tables that makes supporting comparison more direct.