CKKS Bootstrapping gives incorrect results on scale != 60?

Hello,

I am trying to implement an algorithm that uses ciphertexts with small values, therefore I am using a value of scale \Delta=30 (dcrtBits = 59, firstMod = 30).

My issue is that, when I try to perform EvalBootstrap, the output values of the ciphertext are always equal to 0. This only happens when firstMod = 30, if I use firstMod = 60 it works.

Am I missing something? I did not study the implementation of Bootstrapping in OpenFHE.

My parameters are the following:

parameters.SetSecretKeyDist(UNIFORM_TERNARY);  
parameters.SetSecurityLevel(lbcrypto::HEStd_NotSet); 
parameters.SetRingDim(1 << 15);                    
parameters.SetBatchSize(1 << 14);

ScalingTechnique rescaleTech = FLEXIBLEAUTO;
usint dcrtBits               = 59;
usint firstMod               = 30;

context->Enable(PKE);
context->Enable(KEYSWITCH);
context->Enable(LEVELEDSHE);
context->Enable(ADVANCEDSHE);
context->Enable(FHE);

Thank you very much

How small are your values? Have you tried different values to bootstrap and different values for the firstMod other than 30 and 60?

Also, I’ve edited your title to be more in line with the problem you’re describing. Do LMK if this is incorrect

Hello and thank you for your response! These are my values:

[ -0.0065216411, -0.0267370062, -0.0217636138, -0.0251484045, -0.0247041087, -0.0220617031, -0.0215143808, -0.0249791841, -0.0351992667, -0.0227339994, ...

After bootstrapping:

[  0.0000000000,  0.0000000000,  0.0000000000,  0.0000000000,  0.0000000000,  0.0000000000,  0.0000000000,  0.0000000000,  0.0000000000,  0.0000000000, ....

Hi @narger,

It looks like you are not using firstMod and dcrtBits correctly. The scaling factor is given by dcrtBits. So it should be set to 30 (note that I do not recommend setting it to lower than 40 for the scenarios with bootstrapping as the precision will be very low). firstMod should be >= dcrtBits determines the maximum magnitude, e.g., if it is 10 bits larger, the message size can be up to 1024 or so.

1 Like

Hi @ypolyakov ,
Does this imply that if I set firstMod = 60 and dcrtBits = 59, the message space is limited to 1 bit? But when i try to multiply c0=10 and c1=20 under this parameter, the decryption is still 200

Does this imply that if I set firstMod = 60 and dcrtBits = 59, the message space is limited to 1 bit?

No, for the bootstrapping configuration, the message is automatically scaled down by 2^correctionfactor. The correction factor is found automatically by OpenFHE or can be manually set. The correction factor is typically between 7 and 13.

But when i try to multiply c0=10 and c1=20 under this parameter, the decryption is still 200

For leveled CKKS, the extra RNS limbs/towers add support for numbers larger than 2^firstModulus/2^ScalingFactor. For example, if you reserve one extra limb, you will get extra 59 bits (you can support larger numbers in CKKS). But this logic does not apply to CKKS bootstrapping.

1 Like