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

Cannot use large params #84

Closed
crockeea opened this issue Dec 3, 2019 · 3 comments
Closed

Cannot use large params #84

crockeea opened this issue Dec 3, 2019 · 3 comments

Comments

@crockeea
Copy link

crockeea commented Dec 3, 2019

I'm trying to use parameters larger than natively permitted by SEAL with CKKS. Specifically, I'm trying to use a much larger ring dimension so that I can use more moduli.

I've set SEAL_POLY_MOD_DEGREE_MAX to 262144 and SEAL_COEFF_MOD_COUNT_MAX to 122 in defines.h. I'm creating the CKKSContext using context = SEALContext::Create(*params, true, sec_level_type::none);, but I"m still getting "encryption parameters are not set correctly" from line 26 in ckks.cpp. I did more investigation and traced the problem to context creation, specifically parameter validation in context.cpp. Near the end of validate, it tries to create a base_converter, which seems to be failing in the block below the comment // generate Bsk U {mtilde} small ntt tables which is used in Evaluator.

How might I resolve this problem?

@crockeea
Copy link
Author

crockeea commented Dec 3, 2019

I'm using the 3.4.5 branch.

@kimlaine
Copy link
Contributor

kimlaine commented Dec 4, 2019

Thanks for reporting this Eric. If you look at native/src/seal/utils/globals.cpp, you'll see several hard-coded primes towards the end of the file in the namespace internal_mods. These primes are not of the appropriate form for your poly_modulus_degree, and you'll need to regenerate them to make it work.

Specifically, you'll need all of the primes in internal_mods to be 61 bits in size and congruent to 1 mod 2*poly_modulus_degree. They all need to be distinct too. To be clear, this includes m_sk, gamma, and the 128 primes in aux_small_mods. To create these primes compute 2^61 - 2*poly_modulus_degree*A + 1, and then increment A until you find a prime.

There might still be an issue related to some lazy reductions possibly failing with so many coeff_modulus primes, but I'm not sure without digging deep which I can't do right now.

We'll try to make this work correctly and automatically in an upcoming patch (3.4.6) or minor release (3.5.0) at the latest.

@crockeea
Copy link
Author

crockeea commented Dec 5, 2019

Thanks! That got me through this particular problem.

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

2 participants