Hello,
I found an non-understandable exception message as following, and I figured out the reason. However, I want to suggest to correct this remaining misleading exception message related with scalingModSize.
Code Example & Output
Here’s the simple version of problematic code example (CKKS, v1.1.4):
int main(void)
{
CCParams<CryptoContextCKKSRNS> parameters;
parameters.SetRingDim(32768);
parameters.SetMultiplicativeDepth(5);
parameters.SetFirstModSize(37);
parameters.SetScalingModSize(60);
parameters.SetSecurityLevel(HEStd_256_classic);
parameters.SetScalingTechnique(FIXEDMANUAL);
CryptoContext<DCRTPoly> cc = GenCryptoContext(parameters);
cc->Enable(PKE);
cc->Enable(KEYSWITCH);
cc->Enable(LEVELEDSHE);
KeyPair<DCRTPoly> keyPair;
keyPair = cc->KeyGen();
cc->EvalMultKeyGen(keyPair.secretKey);
size_t slots(11617);
vector<complex<double>> tmp_vec_(11617);
Plaintext tmp;
Ciphertext<DCRTPoly> x, y;
double yP;
int c;
vector<double> tmp_vec_1 = {1.0, 2.0};
tmp = cc->MakeCKKSPackedPlaintext(tmp_vec_1);
x = cc->Encrypt(keyPair.publicKey, tmp);
yP = 3.0;
vector<double> tmp_vec_2(slots, yP);
tmp = cc->MakeCKKSPackedPlaintext(tmp_vec_2);
x = cc->EvalMult(x, tmp);
cc->Rescale(x);
return 0;
}
- I know that this one is not the typical case because the firstModSize (37) is smaller than scalingModSize (60). So if the code returns an exception message, I expected the message related with this.
Above code example, returns the exception message containing:
src/core/include/math/hal/intnat/mubintvecnat.h:l.315:SetModulus(): Requested modulus' size 61 is not supported. NativeVectorT supports only modulus size <= 60
- At first, I couldn’t understand this message since none of mod sizes are above 60.
- By the way, the exception was occurred during
Rescale
.
Reasoning
After I’ve searched for similar behavior reported before, I saw this issue #396. It was exactly same issue that I’ve experienced.
So from the replies, I noticed that following some internal logic, scalingModSize should not exceed 59. But the code above has scalingModSize as 60.
Problem & Suggestion
I’ve also checked created issue after that report: Correct the exception message for small CKKS scaling factor · Issue #339 · openfheorg/openfhe-development · GitHub
However, I found that it was fixed for only small scalingModSize (such as 10, 20).
It was why still the same exception message appeared for the case with scalingModSize = 60.
I think still this exception message is misleading.
Literally, NativeVectorT supports only modulus size <= 60
does not make sense in a situation where both mod sizes are <= 60.
Therefore, I want to suggest to consider correcting this message also for this case.
__
Thank you for your attention!