I'm looking for the homomorphic version of the following (I'm using Python here):

$ a = [1,2,3]
$ s = sum(a)  
$ print(s)

Is there an open source fully homomorphic library which is able to do $sum(vector)$? So far I just found libraries allowing operations with input-output either only vectorial or only integer. Here I'm asking for a vector to integer operation.

Of course there is another way, namely encrypting every integer element of $a$ individually, summing in the encrypted domain, and then decrypt the result. Since I would like to take advantage of the speed of vector batching, I'm not considering this as a good solution.

  • 1
    $\begingroup$ "I would like to take advantage of the speed of vector batching"; what is it about Paillier encrypting each individual element of the vector that makes 'vector batching' difficult? $\endgroup$
    – poncho
    Oct 10, 2019 at 18:08
  • $\begingroup$ I'm not aware of libraries capable of quickly handling vectors of encrypted integers (instead of encrypted vectors of integers), but I'm happy to be proved wrong here. Also, I need fully homomorphic encryption, I will make this clear in the question. $\endgroup$
    – Rexcirus
    Oct 10, 2019 at 18:40
  • 1
    $\begingroup$ I am not aware of schemes whose plaintext space is $\mathbb{Z}^n$ and that allow us to create ciphertexts encrypting values in $\mathbb{Z}$... But there are schemes that encrypt natively vectors and matrices and we can perform vector-matrix products. If you have several vectors $a_i$'s, you can put them in the columns of a matrix $A$, encrypt the vector $v = (1, 1, ..., 1)$, and do $v\cdot A$ to get $(sum(a_1), ..., sum(a_n))$. Well, it is already something... $\endgroup$ Oct 10, 2019 at 19:35
  • $\begingroup$ NTRU enables generic bit-sliced however, you need to find a way to combine the 2048 results. $\endgroup$
    – kelalaka
    Oct 11, 2019 at 21:41

1 Answer 1


As far as I know, there are many libraries that use lattices and LWE schemes to implement fully homomorphic Encryptions.

This is a set, Most of them is in C++ and Only one by MSFT is C#, But in all cases you can port the code to python aftor compiling:

  1. HElib in C++
  2. SEAL By MicroSoft C++/C#
  3. Palisade C++
  4. FHEW C/C++
  5. TFHE C++
  6. NFLib C++

Note: The set in no particular order.

  • $\begingroup$ Did you see the Hilder's comment? The OP asking in $\mathbb{Z}^n$. OP doesn't ask for the list of libraries. $\endgroup$
    – kelalaka
    Oct 11, 2019 at 17:42
  • $\begingroup$ Ok, You are right, my answer is irrelevant. but I think the original question needes updates. Any way KNN encryption scheme (not the classification) Allows multiplication of two encrypted values and the result is a vector. Is this what question you asks for ? $\endgroup$ Oct 11, 2019 at 21:04
  • $\begingroup$ No, he just wants to add but wants to use parallelization. TheElGamal, Paillier may be enough for him, however, they have not vector to integer. $\endgroup$
    – kelalaka
    Oct 11, 2019 at 21:10
  • $\begingroup$ Then his question can be solved using divide and conquer. The can split his data into multiple parts, each part is sent a processor then adds them... There are like a ton of methods to execute similar approaches? More importantly, I think he is asking in the wrong place !!! $\endgroup$ Oct 11, 2019 at 21:34
  • $\begingroup$ Do you know the message size of 1-bit encryption? He is not looking for software way. AFAIK, NTRU enables generic bit-sliced. They run 2048 encryption altogether. $\endgroup$
    – kelalaka
    Oct 11, 2019 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.