# Can FHE be used for comparing 2 ciphertexts?

**URL:** <https://openfhe.discourse.group/t/can-fhe-be-used-for-comparing-2-ciphertexts/1045>\
**Category:** FHE Questions\
**Created:** [January 26, 2024, 8:25pm UTC](https://openfhe.discourse.group/t/can-fhe-be-used-for-comparing-2-ciphertexts/1045 "2024-01-26T20:25:32Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![mchenu](https://avatars.discourse-cdn.com/v4/letter/m/ba9def/32.png) [@mchenu](https://openfhe.discourse.group/u/mchenu)\
**Post date:** [January 29, 2024, 12:55pm UTC](https://openfhe.discourse.group/t/can-fhe-be-used-for-comparing-2-ciphertexts/1045/2 "2024-01-29T12:55:15Z")

</div>

Hi @Pavanranganath, as @Caesar kindly pointed out to me in a related question (see [Ciphertexts equality testing in CKKS](https://openfhe.discourse.group/t/ciphertexts-equality-testing-in-ckks/1033/1))

> [@Ciphertexts equality testing in CKKS](https://openfhe.discourse.group/t/ciphertexts-equality-testing-in-ckks/1033/2):
>
> Most existing FHE schemes, including CKKS, are semantically secure cryptoschemes, that is: given access to the ciphertexts only, negligible information about the plaintext can be deduced, such as message length.
> 
> In other words, a cryptoscheme is deemed semantically secure if it satisfies the following: “for any two messages of equal length, the ciphertexts produced by the encryption algorithm are indistinguishable by any efficient adversary”.
> 
> Also, note that CKKS encryption is probabilistic, that is, encrypting the same message twice does not generate the same ciphertext with a fairly large probability.
> 
> To compare encrypted messages, you will need to evaluate a comparison circuit homomorphically, and by definition, the result will also be encrypted. Thus, adversaries who do not own the secret key should not be able to learn the result of the comparison.

However if the ciphertexts are encrypted with the same public key, there are some comparison functions available. The result will be encrypted though.

I hope this helps.

---

_[View the full topic](https://openfhe.discourse.group/t/can-fhe-be-used-for-comparing-2-ciphertexts/1045)._
