Modulus switch is an operation of reducing a ciphertext’s modulus from to (where ) and updating the target value from to . Modulus switch is used for lowering the multiplicative level of a ciphertext upon each ciphertext-to-ciphertext multiplication (in the case of BFV, CKKS, or BGV) or even upon each ciphertext-to-plaintext multiplication (in the case of CKKS). Upon each modulus switch from of a ciphertext, the scaling factor of the underlying plaintext in the ciphertext also gets reduced by the same proportion: .
The modulus switch operation of an RNS-based ciphertext is denoted as ModSwitchRNS, which requires that the output base moduli are a subset of the input base moduli. In other words, like the case of ModDropRNS, it only supports a modulus switch from , where and are co-prime.
Suppose we have , which represents the value .
Given , ModSwitchRNS from is an operation of updating to some where . Unlike in regular modulus switch where we can directly arithmetically divide by and round it, an RNS vector is incompatible with direct arithmetic division on the residues. Therefore, our alternative strategy is to find some small value such that . Once we find such , then becomes divisible by (since their difference is some multiple of ), and thus we can compute . Note that in this computation, the additionally introduced error of modulus switch caused by replacing with is equivalent to: . After the (exact) division of , we directly replace the modulus with . This direct replacement of modulus is arithmetically allowed because the computation result of is guaranteed to be within and (since ). Therefore, we can derive the following formula:
In the above relation, we can arithmetically replace with , because is divisible by and is guaranteed to have an inverse modulo (since and are co-prime). Next, we can compute based on their RNS residues as follows:
# where each
Now, our task is to derive an expression for some small such that is divisible by . We propose that for some small integer . Then, notice that is divisible by as follows:
Now, we will derive the RNS vector of , which is to be plugged into . First, we derive the RNS vector of as follows:
Next, we can compute its fast base conversion from as follows:
Now, notice that the above RNS residue vector represents the value (where integer ), which is our desired formula for . Therefore, .
Note that and , because (here we assume that , as we assume the modulus switch operation is used to remove only a single prime factor from the large base ). Therefore, the magnitude of the error generated by computing is approximately .
We summarize the ModSwitchRNS operation as follows:
Summary D-5.4 ModSwitchRNS
Input:
# which represents
Notations
, which represents the value # where
Main Steps
, whose RNS residue vector represents the value . The magnitude of noise generated by ModSwitchRNS is roughly .
Given a big value in an RNS vector, ModSwitchRNS reduces its modulus from as well as explicitly decreases the modulo value by the proportion of (i.e., updates to ). On the other hand, ModDropRNS from updates the modulo value from (where divides ), which is different from decreasing by the proportion of like modulus switch. ModRaiseRNS from (where divides ) increases the modulus without explicitly modifying the modulo value , but generates some -overflow noise. ModSwitchRNS and ModRaiseRNS generate some noise, whereas ModDropRNS does not generate any noise.