microsoft/EVA

Horizontal sum - encrypted size must be 2

jimouris opened this issue · 0 comments

Hi,

I'm trying to run a horizontal_sum on a vector of values and return one single sum (or a vector that has that sum in every position) by following your std test.

from eva import EvaProgram, Input, Output
from eva.ckks import CKKSCompiler
from eva.seal import generate_keys
from eva.std.numeric import horizontal_sum

vec_sz = 16

poly = EvaProgram('poly', vec_size=vec_sz)
with poly:
  a = Input('a')
  b = Input('b')

  diff = a - b
  sq_diff = diff * diff
  diff = horizontal_sum(sq_diff)

  Output('diff', diff)

poly.set_input_scales(40)
poly.set_output_ranges(10)
a = [i % 10 for i in range(vec_sz)]
b = [i % 5 for i in range(vec_sz)]

compiler = CKKSCompiler()
compiled_poly, params, signature = compiler.compile(poly)
public_ctx, secret_ctx = generate_keys(params)
inputs = {'a': a, 'b': b}
encInputs = public_ctx.encrypt(inputs, signature)
encOutputs = public_ctx.execute(poly, encInputs)
outputs = secret_ctx.decrypt(encOutputs, signature)
print(outputs)

I'm getting the following error:

Traceback (most recent call last):
  File "std_test.py", line 29, in <module>
    encOutputs = public_ctx.execute(poly, encInputs)
ValueError: encrypted size must be 2

I might be missing something obvious, but it seems that this is very similar to the std example.

cc: @cgouert