# Sum vector elements homorphically

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

$$a = [1,2,3]$$ s = sum(a)
$print(s) 6 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. • "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? – poncho Oct 10 '19 at 18:08 • 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. – Rexcirus Oct 10 '19 at 18:40 • 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... – Hilder Vitor Lima Pereira Oct 10 '19 at 19:35 • NTRU enables generic bit-sliced however, you need to find a way to combine the 2048 results. – kelalaka Oct 11 '19 at 21:41 ## 1 Answer 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. • Did you see the Hilder's comment? The OP asking in$\mathbb{Z}^n\$. OP doesn't ask for the list of libraries. – kelalaka Oct 11 '19 at 17:42
• 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 ? – Walid Ashraf Oct 11 '19 at 21:04
• 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. – kelalaka Oct 11 '19 at 21:10
• 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 !!! – Walid Ashraf Oct 11 '19 at 21:34
• 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. – kelalaka Oct 11 '19 at 21:42