microsoft / SealPIR

Example implementation of the SealPIR protocol
MIT License
139 stars 54 forks source link

SEAL 3.5.8 and expanded query invalid encryption parameters on decryption #9

Closed ReverseControl closed 4 years ago

ReverseControl commented 4 years ago

I am trying to make the the expanded_query() function work with SEAL 3.5.8 and I am having a hard time. The generate_query function is fine, but when I try the expand query I get my vector of ciphertexts, and when I try to decrypt any one of them to verify the expansion was done correctly I get:

terminate called after throwing an instance of 'std::invalid_argument'
  what():  encrypted is not valid for encryption parameters
Aborted (core dumped)

Should I not be able to decrypt all the ciphertexts returned by expanded_query? I was looking at the multiply_power_of_X and wonder if that internal manipulation of data to do the multiply is compatible with SEAL 3.5.8. Any suggestions to fix this would be greatly appreciated.

ReverseControl commented 4 years ago

So, it seems to be incompatible with 3.5.8 as the this new version does all that work internally for you. Eliminating the inner loop fixes the issue.

sga001 commented 4 years ago

Sorry I didn't get to this earlier. I haven't used the latest version of SEAL so I wasn't sure how to address your issue. Glad you could sort it out though. If you manage to get SealPIR working with SEAL 3.5.8 let us know! And if you want to share your code or submit a PR, even better! (but you don't have to, obviously :)).

kzhong130 commented 4 years ago

Hi there, @ReverseControl I am also trying out the expand_query() function as well to work on SEAL 3.5.6, where I have checked it has the same implementations of negacyclic_shift_poly_coeffmod() function as SEAL 3.5.8. My issue seems to be more related to the memorypool of SEAL, when I use expand_query() for twice, the first run can work out the results correctly, however when I run it for the second time, it would incur some segfault errors when calling negacyclic_shift_poly_coeffmod() functions.

Since you are mentioning there is difference of negacyclic_shift_poly_coeffmod() between SEAL 3.2.0 and latest version, I am wondering whether my issue is also related to the observations that you have. Can you help explain a bit more like how you modified the multiply_power_of_X() function to make that works?

I also compared the difference between different SEAL. However I find out that actually they have the same implementation of negacyclic_shift_poly_coeffmod(), only with different type of parameters.

In SEAL 3.2.0, the function is "void negacyclic_shift_poly_coeffmod(const uint64_t operand, size_t coeff_count, size_t shift, const SmallModulus &modulus, uint64_t result)" while in latest SEAL, it is "void negacyclic_shift_poly_coeffmod(ConstCoeffIter poly, size_t coeff_count, size_t shift, const Modulus &modulus, CoeffIter result)". The internal implementation of these two functions are exactly the same. Although in latest SEAL, they provided some wrapper to run the loop internally, I think we can still use the original implementation of multiply_power_of_X().

Thank you! Any suggestions/comments are highly appreciated.

haochenuw commented 4 years ago

Hi -- I have created a fork for SealPIR under my account haochenuw (I couldn't access the issues in the original repo since I left Microsoft). I can try migrating it to support newer version of SEAL. Could you submit an issue in the forked repo, containing a minimal example which reproduces the error, along with the version of SEAL you were using?

On Fri, Oct 30, 2020 at 8:01 AM Ke Zhong notifications@github.com wrote:

Hi there, @ReverseControl https://github.com/ReverseControl I am also trying out the expand_query() function as well to work on SEAL 3.5.6, where I have checked it has the same implementations of negacyclic_shift_poly_coeffmod() function as SEAL 3.5.8. My issue seems to be more related to the memorypool of SEAL, when I use expand_query() for twice, the first run can work out the results correctly, however when I run it for the second time, it would incur some segfault errors when calling negacyclic_shift_poly_coeffmod() functions.

Since you are mentioning there is difference of negacyclic_shift_poly_coeffmod() between SEAL 3.2.0 and latest version, I am wondering whether my issue is also related to the observations that you have. Can you help explain a bit more like how you modified the multiply_power_of_X() function to make that works?

I also compared the difference between different SEAL. However I find out that actually they have the same implementation of negacyclic_shift_poly_coeffmod(), only with different type of parameters.

In SEAL 3.2.0, the function is "void negacyclic_shift_poly_coeffmod(const uint64_t operand, size_t coeff_count, size_t shift, const SmallModulus &modulus, uint64_t result)" while in latest SEAL, it is "void negacyclic_shift_poly_coeffmod(ConstCoeffIter poly, size_t coeff_count, size_t shift, const Modulus &modulus, CoeffIter result)". The internal implementation of these two functions are exactly the same. Although in latest SEAL, they provided some wrapper to run the loop internally, I think we can still use the original implementation of multiply_power_of_X().

Thank you! Any suggestions/comments are highly appreciated.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/microsoft/SealPIR/issues/9#issuecomment-719604341, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7YZSGCXYAQKM5YLR5MFDTSNLIKBANCNFSM4SDO26GA .

kzhong130 commented 4 years ago

Thanks! I have submitted an issue in the forked repo.

ReverseControl commented 3 years ago

@kzhong130 You can see it here: https://github.com/ReverseControl/MuchPIR/blob/main/src/sealpir_select.cpp#L93

@haochenuw @kimlaine