Huelse / SEAL-Python

Microsoft SEAL 4.X For Python
MIT License
310 stars 66 forks source link

NameError: name 'FractionalEncoder' is not defined #42

Closed aman1403 closed 3 years ago

aman1403 commented 3 years ago

Hi,

Actually, I am facing an issue while declaring an encoder as FractionalEncoder. It's working with the IntegerEncoder but it's showing (NameError "FractionalEncoder" doesn't exist) while declaring the variable encoder=FractionalEncoder(context).

I think it doesn't exist in python-seal but I need it as I was dealing with Float Numbers. Do you have any idea or is there any other encoder to encode Fractional values.

Please find the screenshot below for reference. Screenshot from 2020-11-17 00-14-24

Huelse commented 3 years ago

Sorry for the reply late, I'm not sure what your code is, you mean encoder = IntegerEncoder(context)? And FractionalEncoder does not exist in the wrapper.

Huelse commented 3 years ago

If you want to encode fractional values, please refer to tests/4_ckks_basics.py.

aman1403 commented 3 years ago

Thanks for your reply. I need to encode both integer and fractional values. I am using encoder = IntegerEncoder(context) for encoding the integers value. Is there any other encoder exist in BFV scheme to encode fractional values. Because I need both type of encoders in the same file.

aman1403 commented 3 years ago

Actually I wanted to divide the encrypted values by 2. As division is not supported in the SEAL library. So, I was going to multiply 0.5 with the encrypted value. But I am unable to encode 0.5 as I only know about Integer Encoder.

Is there any other encoder exist in BFV Scheme to encode float values?

Huelse commented 3 years ago

You can not mixed-use these two kinds of the scheme, they are encoded in different ways, refer to the C++ code's note.

Huelse commented 3 years ago

No way, consider the ckks scheme or multiply the divisor and dividend 10000 or more times.

aman1403 commented 3 years ago

Okay. Btw, I was trying to send the encrypted list of Ciphertext Object from client to server through sockets in python. And I am using Pickle.dumps to encode it into bytes but getting the following error. Is there any other way to encode this Ciphertext object into bytes as we can only send bytes like object through sockets in python. I have tried Json, base64, pickle but nothing is working. Screenshot from 2020-11-18 14-32-57

Huelse commented 3 years ago

For some reason, we can't directly pickle the Ciphertext in SEAL-3.4.5, we talked in #28, but you can use cipher.save('filename') to save the keys or ciphers to the native. And the pickle function in SEAL-3.3.2 works well.