# How can we define division operation by using Fully homomorphic encryption

Last fews months, I'm working with homomorphic encryption. Now I am dealing with some computational problems with integers or real-numbers (like arithmetic mean, standard deviation) where division is necessary in homomorphic domain. Is there any practical solution of homomorphic division? I'm also looking for practical example.

In case some assistance from plaintext holder is available: (1) choose a random, multiply it with the plaintext and also homomoprhic-encrypt the random; (2) calculate inverse of the product in clear (no encryption); (3) multiply encrypted random by the inverse. This is not exactly division, still it outputs the inverse.

I think there is no trivial or simple way of performing divisions between two ciphertexts.

However, for several applications, as calculating mean and standard deviation (as you wrote in your question), it is sufficient to do divisions between a ciphertext and a plaintext, because the denominator is known (in those cases, it is $N$, the number of elements involved).

To perform this kind of division, you have to encode the double values into the plaintext space of the homomorphic scheme you are using.

For instance, take a look at the section III of this paper to see how double values are encoded to polynomials.

Once you have a encoding function, you can perform divisions between a ciphertext $c$ and a plaintext $m$ by doing

$$c \cdot \text{Encrypt(Encode}(\frac{1}{m}\big)\text{)}$$

which means, encoding the inverse of $m$, encrypting it and then using the homomorphic multiplication you have.