How to do simple addition/multiplication of clear/cipher data?
qiminghe opened this issue · comments
Not an issue. Just a quick question. I can build/run all test cases, and see how EVA supports polynomial functions and more advanced processing of HE-enc data.
However, it is not obvious to me how primitive operations like addition/multiplication of numbers in clear/cipher vector/matrix works, as seen in other python-to-SEAL bindings, e.g., z = clear_vector_x * cipher_vector_y, and then execute poly(z),....
If I have to use other bindings for such primitive operations, how do we make keys/encrypted-numbers portable with EVA? Thx
Hi! You can add plaintext inputs to EVA programs by setting the is_encrypted
parameter of the Input
function to false
. The following program takes both an unencrypted and encrypted vector with 1 element each as inputs and produces their sum and multiplication:
prog = EvaProgram('AddMult', vec_size=1)
with prog:
x = Input('x', is_encrypted=False)
y = Input('y')
Output('sum', x+y)
Output('multiplication', x*y)
Is input to prog entirely encrypted as one dict separately different keys? if so, what does 'is_encrypted=False' mean here?
If not, please advise a syntax to create a dict with { 'x':[cleartext] , 'y':[ciphertext]}, i.e.,
inputs = { 'x': [1], 'y':[2] }
encInputs = public_ctx.encrypt(inputs, signature)
#this works, but both x and y are encrypted, what is significance of 'is_encrypted=False'?
encOutputs = public_ctx.execute(compiled_prog, encInputs)
inputs = {'y':[2] }
encInputs = public_ctx.encrypt(inputs, signature)
#encOutputs = public_ctx.execute(compiled_prog, {'x':[1],encInputs}) #looking for sth. like this ?
Sorry for the late reply. is_encrypted=False
will skip encryption for that input, instead the value will be stored as-is in encInputs (which is really just a wrapper for a C++ std::map holding the values for each input).
Currently this is mostly useful for performance in cases where a client has some data that doesn't need to be encrypted. In the future we'll add a way to provide inputs from multiple sources, in which case a server providing some privacy preserving service can insert additional values locally and avoid encryption.