# Reencrypting in Homomorphic Encryption

I am getting started with Homomorphic Encryption libraries. I am trying to port a codebase written in Python to Haskell. I see that there is a re-encryption operation happening in one part of the code. Something like this:

  def re_encrypt(self, values):
n = values.shape[1]
values = values.flatten()
ret = []
for i in range(n):
pt = self.pri_key.decrypt(values[i])
ret.append(self.pub_key.encrypt(pt))
return np.array(ret)


Irrespective of the contents of values, I see that the operation is simply decrypting and encrypting the same entity. In effect that's simply the identity function. I wonder why is this operation happening. One possibility that I considered is that this is simply a way to remove the noise. After several operations are carried out on the encrypted data, the noise becomes too high and then to remove it, decryption happens. Is that what is happening here?

For information, this Python library uses the Intel Paillier Crypto library. Thanks.

Also, if you are interested in Haskell-based implementations of FHE, there is a some stuff available along these lines for lattice-based FHE. Namely there is the library $$\Lambda \circ \lambda$$. Among FHE libraries it has a pretty high (theoretical cryptography) overhead though --- I wouldn't typically suggest it to a beginner. But it is the only Haskell-based library (put together by well-known cryptographic researchers) I am aware of.