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

[drlwe]: CKS/PCKS does not properly resizes the level of the output ciphertext to the one of the input ciphertext #279

Closed
macknight opened this issue Sep 19, 2022 · 4 comments · Fixed by #230
Assignees
Labels
bug Something isn't working

Comments

@macknight
Copy link

macknight commented Sep 19, 2022

Hi,
Would you please have a look at below code, it's almost using example/dbfv/psi/main.go, I only changed a little in evalPhase function and add some print code in main. Youc could see evalPhase function.
When I use power function to calculate x -> x^2, the result is wrong.
But when I use mul&relinearize to calculate x -> x^2, the result is correct.
I don't understand why it's wrong when using power function.

BR

@Pro7ech
Copy link
Contributor

Pro7ech commented Sep 20, 2022

@macknight Can you produce a small and self-contained main.go that reproduces the error?

Regardless, we plan to discontinue the .Power(*) method, because it's functionality is now provided by the PolynomialBasis struct. You can use it like this to get your powers :

pb := ckks.NewPolynomialBasis(ct, ckks.Monomial)
pb.GenPower(power, false, params.DefaultScale(), evaluator)
ctPower := pb.Value[power].CopyNew()

@macknight
Copy link
Author

macknight commented Sep 20, 2022

@macknight Can you produce a small and self-contained main.go that reproduces the error?

Regardless, we plan to discontinue the .Power(*) method, because it's functionality is now provided by the PolynomialBasis struct. You can use it like this to get your powers :

pb := ckks.NewPolynomialBasis(ct, ckks.Monomial)
pb.GenPower(power, false, params.DefaultScale(), evaluator)
ctPower := pb.Value[power].CopyNew()

@Pro7ech
OK, I'll try the new method.

main.zip

And I've updated my post with the zip file including the main.go (I put the file here: example/dckks/psi/main.go for run), would you try that for testing? you could toggle in evalPhase function with one of the two options.

BR

@Pro7ech Pro7ech changed the title power function VS mul&relinearize functions issue. power function result is wrong, yet mul&relinearize is correct, why? [drlwe]: CKS/PCKS does not check that the shares are at the level of the ciphertext, correctness is not ensured Sep 20, 2022
@Pro7ech Pro7ech self-assigned this Sep 20, 2022
@Pro7ech Pro7ech added the bug Something isn't working label Sep 20, 2022
@Pro7ech
Copy link
Contributor

Pro7ech commented Sep 20, 2022

@macknight I've found the issue, it doesn't come from the evaluation phase, it comes from the level of the ciphertext that you allocate during the pcks phase. You should allocate a ciphertext of the level of the input ciphertext. However, this mistake should have been caught by the protocol. I'll add checks to ensure that you'd get an appropriate error if the levels do not match.

To fix your code change it to

encOut = ckks.NewCiphertext(params, 1, encRes.Level(), params.DefaultScale())

Pro7ech added a commit that referenced this issue Sep 20, 2022
@Pro7ech Pro7ech linked a pull request Sep 20, 2022 that will close this issue
@Pro7ech Pro7ech changed the title [drlwe]: CKS/PCKS does not check that the shares are at the level of the ciphertext, correctness is not ensured [drlwe]: CKS/PCKS does not properly resizes the level of the output ciphertext to the one of the input ciphertext Sep 20, 2022
@macknight
Copy link
Author

@Pro7ech
Right!
tested with power function and encOut = ckks.NewCiphertext(params, 1, encRes.Level(), params.DefaultScale())
result looks good.
Thanks

@Pro7ech Pro7ech reopened this Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants