# Comparison without Private key

**URL:** <https://openfhe.discourse.group/t/comparison-without-private-key/1679>\
**Category:** Library Questions\
**Created:** [October 30, 2024, 1:45pm UTC](https://openfhe.discourse.group/t/comparison-without-private-key/1679 "2024-10-30T13:45:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kanjanarat](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@kanjanarat](https://openfhe.discourse.group/u/kanjanarat)\
**Post date:** [October 30, 2024, 1:45pm UTC](https://openfhe.discourse.group/t/comparison-without-private-key/1679/1 "2024-10-30T13:45:01Z")

</div>

I am working on a project that involves implementing a database for homomorphic encryption. Are there methods available to compare ciphertexts without using the private key to decrypt the result?

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [October 31, 2024, 2:31pm UTC](https://openfhe.discourse.group/t/comparison-without-private-key/1679/2 "2024-10-31T14:31:51Z")

</div>

Yes, there are quite a few. Read these papers and (their counterparts in the related work section) for some examples.

1. [Efficient Homomorphic Comparison Methods with Optimal Complexity](https://eprint.iacr.org/2019/1234.pdf)
2. [Faster homomorphic comparison operations for BGV and BFV](https://eprint.iacr.org/2021/315.pdf)
3. [Large-Precision Homomorphic Sign Evaluation using FHEW/TFHE Bootstrapping](https://eprint.iacr.org/2021/1337.pdf)

---

<div class="post-metadata">

**Author:** ![kanjanarat](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@kanjanarat](https://openfhe.discourse.group/u/kanjanarat)\
**Post date:** [October 31, 2024, 2:53pm UTC](https://openfhe.discourse.group/t/comparison-without-private-key/1679/3 "2024-10-31T14:53:28Z")

</div>

Thank you so much for your response. It seems that the OpenFHE library allows for comparison operations between ciphertexts. However, to obtain and interpret the result of the comparison, you still need to use the private key to decrypt it. Is that correct?

---

<div class="post-metadata">

**Author:** ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)\
**Post date:** [November 1, 2024, 2:23pm UTC](https://openfhe.discourse.group/t/comparison-without-private-key/1679/4 "2024-11-01T14:23:42Z")

</div>

You do not have to immediately decrypt the result of the comparison, but you can use it further in encrypted computations. But at the very end, you do need to perform decryption in order to see the result.

If you are referring to performing operations over ciphertexts and directly obtaining the result in the clear, read more about [Functional Encryption](https://en.wikipedia.org/wiki/Functional_encryption). However, the functionalities that can be practically obtained with current results of functional encryption are not as general as what can be achieved with FHE, and are not implemented in OpenFHE.

---

<div class="post-metadata">

**Author:** ![kanjanarat](https://avatars.discourse-cdn.com/v4/letter/k/aeb1de/32.png) [@kanjanarat](https://openfhe.discourse.group/u/kanjanarat)\
**Post date:** [November 4, 2024, 1:02pm UTC](https://openfhe.discourse.group/t/comparison-without-private-key/1679/5 "2024-11-04T13:02:49Z")

</div>

Thank you so much for your time and help. I really appreciate it.
