# Fully homomorphic encryption (over addition and multiplication) library in python

I was wondering if there is a commonly used library in Python (or another common language such as Java, C++, etc.) for fully homomorphic encryption over multiplication and addition that also supports floating point numbers. This means that if our encryption function is $$f$$ and our decryption function is $$g$$ and we have to plaintext messages $$m_1,m_2$$, then both the following hold:

1. $$g(f(m_1)+f(m_2))=m_1+m_2$$
2. $$g(f(m_1)\cdot f(m_2))=m_1\cdot m_2$$

Python-paillier implementing a Paillier cryptosystem seems to be pretty well documented and it actually does support floats (does so by fixing a precision and scaling all floats up to be integers), but unfortunately it is not fully homomorphic over multiplication (it does not support the multiplication of cipher texts, but rather has a weaker multiplicative property).

I've done a quick search and it seems that there's a lot of such cryptosystems (I don't care too much about runtime as of now), but I've been unable to find a library with concrete implementations.

The CKKS scheme is the main homomorphic encryption scheme for approximate floating-point operations. Several homomorphic encryption libraries implement it including:

Most of the homomorphic encryption schemes work

1. over integers modulo some value, say n
2. or over bits.

In the first case, you can try to simulate floating-point numbers by first scaling all your original data to integers and keeping tracking of the scaling factors during homomorphic evaluation so that you can divide by the correct value after decryption. But this is generally not efficient.

In the second case, you can encrypt each bit of the floating-point numbers and implement circuits to add, multiply, etc, floating-point numbers using the homomorphic binary gates provided by the scheme, but this is very laborious.

The only scheme that I am aware of which works natively on (something very close to) floating-point numbers is this scheme by Cheon et al, which is implemented in this Github reposiroty.

• Thanks - I’ll take a look at this – Max Mar 30 at 20:33