Hi,
I have several questions about the modulus switch and modup/down routines.
I notice that
- in thesis A Full RNS Variant of Approximate Homomorphic Encryptioniacr, modUp/Down requires complicated basis conversion operation.
- there is a step called ModUp in ckks-bootstrapping,
- in
key switch key generation
step we need to expand the original decryption key s(x) (not the s^2(x) in mult case) from mod Q to mod PQ.
The modUp in bootstrapping, and the key expansion mentioned above all call modulus switch function
in OpenFHE, which in my opinion is completely different from the modUp/Down that requires basis conversion given in the above thesis.
To be specific,
- in
ckksrns-fhe.cpp
,below the commentraising the modulus
, I found that the main code doing the taskraising the moudlus
is an operation “=” with overload function. And the core computation within the overload function isSwitchModulus
Func. - in
keyswitch-hybrid.cpp
, in the function
EvalKey<DCRTPoly> KeySwitchHYBRID::KeySwitchGen(const PrivateKey<DCRTPoly> oldKey,const PrivateKey<DCRTPoly> newKey) const {}
,
below the comment// The part with basis P
there isauto sNew0 = sNew.GetElementAtIndex(0); sNew0.SwitchModulus(pj, rootj, 0, 0);
. I can’t understand why the first RNS poly ofsNew
(i.e.sNew[0]
), is always the input operation number when dealing with//The part with basis P
in KSGen.
My question is,
- When should I use ModUp which includes basis conversion, and when should I use modulus switch? Are they equivalent to some extent? And how about ModDown?
- What’s the difference and connection between modulus switch and ModUp/Down?
- How to use the modulus switch correctly?
For example, why the first RNS poly ofsNew
is always the input operation number for the key expansion when dealing withThe part with basis P
in KSGen?(Detailed information is given in the second example above.) - I first ModUp a normal ct, and then ModDown the ct back, finally do the decryption and failed. I would like to know why it failed. (Both ModUp and Down is implemented as the A Full RNS Variant of Approximate Homomorphic Encryptioniacr told, and they perform correctly when called in the key switch procedure.)
Thanks for your help!