Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to do simple addition/multiplication of clear/cipher data? #7

Open
qiminghe opened this issue Jan 18, 2021 · 3 comments
Open

How to do simple addition/multiplication of clear/cipher data? #7

qiminghe opened this issue Jan 18, 2021 · 3 comments

Comments

@qiminghe
Copy link

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

@olsaarik
Copy link
Contributor

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)

@qiminghe
Copy link
Author

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 ?

@olsaarik
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants