I have a 2 dimensional numpy array which I would like to encrypt using the python phe library for paillier homomorphic encryption.
Currently I'm converting my array to a list of lists, encrypting each number separately and then returning the new list as a numpy array:
arr_as_list = arr.tolist() # faster for processing than numpy array?
encrypted_arr_as_list = [[self.public_key.encrypt(int(x)) for x in row] for row in arr_as_list]
encrypted_numpy_arr = np.array(encrypted_arr_as_list)
return encrypted_numpy_arr
This seems slow and cumbersome when it comes to large arrays. Is there a faster method for doing this?
Thanks