C-4.1 LWE Modulus Switching

- Reference: Modulus Switching in LWE

Recall that the LWE cryptosystem (§B-2.2) comprises the following components:

In the LWE cryptosystem, modulus switching is a process of converting an original LWE ciphertext’s modulo domain to a smaller modulo domain. This can be seen as scaling down all components, except for the plaintext m and the secret key S, in the original LWE ciphertext to a smaller domain. This operation preserves the size and integrity of the original plaintext m, while the scaling factor Δ gets reduced to a smaller value Δ^ and the noise e to a smaller (reduced) noise e^ (note that noise alteration does not affect the original plaintext m, because the noise gets rounded away after decryption, anyway), and a → also gets scaled down to a smaller a^ →. Modulus switching is used for computational efficiency during TFHE’s bootstrapping (which will be discussed in §D-1.8). Modulus switching is also used for implementing the ciphertext-to-ciphertext multiplication algorithm in BGV (§D-2.7) and CKKS (§D-3.5).

The high-level idea of LWE modulus switch is to rescale the congruence relationship of the LWE scheme. LWE’s homomorphic computation algorithms include the following: ciphertext-to-ciphertext addition, ciphertext-to-plaintext addition, ciphertext-to-plaintext multiplication, ciphertext-to-ciphertext multiplication. However, all congruence relationships used in these algorithms are essentially rewritten versions of the following single fundamental congruence relationship: b = a →⋅s →+ Δm + e mod q. Thus, modulus switch of an LWE ciphertext from q →q′ is equivalent to rescaling the modulo of the above congruence relationship from q →q′.

Based on this insight, the LWE cryptosystem’s modulus switching from q →q^ (where q > q^) is a process of converting the original LWE ciphertext 𝖫𝖶𝖤S,σ(Δm + e) as follows:

⟨Summary C-4.1⟩ LWE Modulus Switching

Given an LWE ciphertext (a →,b) where b = a →⋅s →+ Δm + e mod q and m ∈ ℤt, modulus switch of the ciphertext from q to q^ is equivalent to updating (A,b) to (a^ →,b^) as follows:

a^ → = (a^0,a^1,…,a^k−1), where each a^i = ⌈aq^ q ⌋ ∈ ℤq^ ▹ ⌈⌋ means rounding to the nearest integer

b^ = ⌈bq^ q ⌋ ∈ ℤq^

𝖫𝖶𝖤S,σ(Δ^m + e^ + 𝜖𝑎𝑙𝑙) = (a^0,a^1,…,b^) ∈ ℤq^k+1 ▹ where 𝜖𝑎𝑙𝑙 is a small rounding error

The above update effectively changes e^ and Δ^ as follows:

e^ = ⌈eq^ q ⌋ ∈ ℤq^,

Δ^ = Δq^ q ▹ which should be an integer

Meanwhile, S and m stay the same as before.

Note that in order for (a^0,a^1,…,b^) ∈ ℤq^k+1 to be a valid LWE ciphertext of Δ^m, we need to prove that the following relationship holds:

b^ = ∑ ⁡ i=0k−1a^i ⋅si + Δ^m + e^ ∈ ℤq^

Proof.

1.
Note the following:

b^ = ⌈bq^ q ⌋ = bq^ q + 𝜖b (where −0.5 < 𝜖b < 0.5, a rounding drift error)

ai^ = ⌈aiq^ q ⌋ = aiq^ q + 𝜖ai (where −0.5 < 𝜖ai < 0.5)

e^ = ⌈eq^ q ⌋ = eq^ q + 𝜖e (where −0.5 < 𝜖e < 0.5)

2.
Note the following:

b = a →⋅s →+ Δm + e = ∑ ⁡ i=0k−1(aisi) + Δm + e ∈ ℤq

b = ∑ ⁡ i=0k−1(aisi) + Δm + e + H ⋅q (where modulo q is replaced by adding H ⋅q, some multiple of q)

3.
According to step 1 and 2:

b^ = bq^ q + 𝜖b ∈ ℤq^

= (∑ ⁡ i=0k−1(aisi) + Δm + e + H ⋅q) ⋅q^ q + 𝜖b

= q^ q ⋅∑ ⁡ i=0k−1(aisi) + q^ q ⋅Δm + q^ q ⋅e + q^ q ⋅H ⋅q + 𝜖b

= ∑ ⁡ i=0k−1 (q^ q ⋅aisi) + Δ^m + (e^ −𝜖e) + q^ ⋅H + 𝜖b

= ∑ ⁡ i=0k−1 ((a^i −𝜖ai) ⋅si) + Δ^m + e^ −𝜖e + q^ ⋅H + 𝜖b

= ∑ ⁡ i=0k−1(a^isi −𝜖aisi) + Δ^m + e^ −𝜖e + 𝜖b ∈ ℤq^

= ∑ ⁡ i=0k−1a^isi + Δ^m + (e^ −𝜖e + 𝜖b −∑ i=0k−1𝜖aisi) ∈ ℤq^

= ∑ ⁡ i=0k−1a^isi + Δ^m + e^ + 𝜖𝑎𝑙𝑙 ∈ ℤq^ ▹ where 𝜖𝑎𝑙𝑙 = (−𝜖e + 𝜖b −∑ ⁡ i=0k−1𝜖aisi)

The biggest possible value for 𝜖𝑎𝑙𝑙 is,

𝜖𝑎𝑙𝑙 = |−0.5|+ |0.5|+ |−0.5 ⋅k|= 1 + 0.5k

So, LWE modulus switching results in an approximate congruence relationship (§A-13). However, if Δ^ is large enough, 𝜖𝑎𝑙𝑙 = 1 + 0.5k will be shifted to the right upon LWE decryption and get eliminated, and finally we can recover the original m. Also, in practice, the term ∑ ⁡ i=0k−1𝜖aisi would remain small relative to the ciphertext modulus for a sufficiently large k, because each ai is uniformly sampled and si is also uniformly sampled.

Caution: If Δ^ is not large enough, then 𝜖𝑎𝑙𝑙 may not get eliminated during decryption and corrupt the plaintext m. Also, if Δ →Δ^ shrinks too much, then the distance between Δ^m and e^ would become too narrow and the rounding process of e^ = ⌈eq^ q ⌋ may end up overlapping the least significant bit of Δ^m, corrupting the plaintext.

4.
To summarize, b^ is approximately as follows:

b^ = ∑ ⁡ i=0k−1a^isi + Δ^m + e^ + 𝜖𝑎𝑙𝑙 ≈∑ i=0k−1a^isi + Δ^m + e^ ∈ ℤq^

Thus, (a^0,a^1,…,b^) = 𝖫𝖶𝖤S,σ(Δ^m + e^ + 𝜖𝑎𝑙𝑙), decrypting which will give us m.

□