microsoft / EVA

Compiler for the SEAL homomorphic encryption library
MIT License
227 stars 59 forks source link

__pow__ raises invalid value error #24

Open TopFox opened 2 years ago

TopFox commented 2 years ago

In /python/eva/init.py, line 100, in pow: the condition tested is

if exponent < 1:
            raise ValueError("exponent must be greater than zero, got " + exponent)

But it should probably be str(exponent). I think the fact that it has to be an integer and not a float should be tested too.

Is there any way to implement sqrt since x**0.5 is not allowed?

Thanks in advance to those who can enlighten me!

RoryPotter commented 2 years ago

To implement a square root function, you need to approximate the function using a polynomial. numpy.polynomial contains good interfaces to generate these approximations using different methods. The default evaluation is probably not optimal for homomomorphic encryption and you want to use something like Horner's method to reduce the multiplicative depth of your program.

I found this talk https://www.microsoft.com/en-us/research/video/private-ai-bootcamp-techniques-in-ppml/ useful for understand the contraints of using homomorphic encryption.