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

Modulus switching for single ciphertext modulus in BFV #714

Open
helloboyxxx opened this issue Nov 18, 2024 · 0 comments
Open

Modulus switching for single ciphertext modulus in BFV #714

helloboyxxx opened this issue Nov 18, 2024 · 0 comments

Comments

@helloboyxxx
Copy link

helloboyxxx commented Nov 18, 2024

Context:

Let's say I want to use a 60-bit ciphertext modulus in BFV. After I finish all the homomorphic operations, I want to switch to a smaller modulus (30-bit). Now, let's say I created the context and seal::EncryptionParameters using the bit_sizes = {60, 60}. I noticed that SEAL only has mod_switch_scale_to_next in evaluator, which always tries to throw away one modulus on the chain.

Related issue:

#444 is related, but calculating round(ct/q) is only one useful special case for modulus switching, but not general enough. (q is the last small prime in the prime chain)

Question:

After the modulus switching, I only need decryption. Suppose I have added a function that calculates the general modulus switching round(ct*Q'/Q) for a Q' that has half the bit size. Then bit_sizes = {60, 60} should become {30, 60}. The problem is that I don't know how to modify the context accordingly. Is implementing a customized decryption function using the new smaller modulus the best choice for me?

Another approach is to use bit_sizes = {30, 30, 60} in the beginning. However, since RNS is using uint64_t to store all modulus, using two 30-bit modulus brings at least 2 times slow down for all calculations. One solution I can think of is to change the word size to 32 bit. This is mentioned before in #105 . It was considered not worth the big changes at that time. However, we now have Intel HEXL, additions and multiplications can be way faster than before. Example: _mm512_mul_epu32. But this approach is too heavy for me.

I would be grateful for any suggestions!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant