D-5.5 RNS-based Decryption

This subsection will explain how to efficiently decrypt RNS-based ciphertexts for BFV, CKKS, and BGV.

D-5.5.1 BFV Decryption: 𝖣𝖾𝖼𝖱𝖭𝖲𝖑π–₯𝖡

Suppose we have a BFV ciphertext (A,B) such that B = A β‹…S + Ξ”M + E (where Ξ” = ⌊q tβŒ‹). We decrypt the ciphertext as follows: M = ⌈B βˆ’A β‹…S Ξ” βŒ‹ (SummaryΒ D-2.3 in Β§D-2.3). However, RNS does not allow direct division and rounding. Therefore, we need to express this divide-and-round operation in terms of addition and multiplication.

Let’s denote 𝖼𝗍(s) = Ξ”m + e + π‘˜π‘ž (i.e., a decryption of ciphertext 𝖼𝗍 without modulo-q reduction). In this description, we will consider only a single set of coefficients m, e, and k extracted from polynomials M, E, and K for simplicity.

As explained in Β§A-1.2.2, modulo arithmetic does not support direct division. Meanwhile, the special relation a b mod p = a β‹…bβˆ’1 mod p holds if b divides a and an inverse of b modulo p exists (i.e., b and p are co-prime). Inspired by this, we can express the decrypted plaintext m as follows:

m = ⌈|𝖼𝗍(s)|q Ξ” βŒ‹ = ⌊|𝖼𝗍(s)|q Ξ” βŒ‹ + er # where er ∈[0,1] is a rounding error

= ⌊|𝖼𝗍(s)|q β‹…t qβŒ‹ + er + ed # where ed = ⌊|𝖼𝗍(s)|q Ξ” βŒ‹ βˆ’ ⌊|𝖼𝗍(s)|q β‹…t qβŒ‹ is a scaling error

= ⌊t β‹…|𝖼𝗍(s)|q q βŒ‹ + er + ed

= t β‹…|𝖼𝗍(s)|q βˆ’|t ⋅𝖼𝗍(s)|q q + er + ed # where |t ⋅𝖼𝗍(s)|q ≑t β‹…|𝖼𝗍(s)|q mod q, and therefore t β‹…|𝖼𝗍(s)|q βˆ’|t ⋅𝖼𝗍(s)|q is divisible by q

Now, we choose some prime number Ξ³ which is co-prime to t and q. Then, we derive the expression for Ξ³ β‹…m as follows:

Ξ³ β‹…m = Ξ³ β‹… ⌈|𝖼𝗍(s)|q Ξ” βŒ‹

= ⌈γ β‹…|𝖼𝗍(s)|q Ξ” βŒ‹ + esβ€² # where esβ€² = Ξ³ β‹… ⌈|𝖼𝗍(s)|q Ξ” βŒ‹ βˆ’ ⌈γ β‹…|𝖼𝗍(s)|q Ξ” βŒ‹ is a multiplication error

= ⌊γ β‹…|𝖼𝗍(s)|q Ξ” βŒ‹ + esβ€²+ erβ€² # where erβ€² ∈[0,1] is a rounding error

= ⌊γ β‹…|𝖼𝗍(s)|q β‹…t qβŒ‹ + esβ€²+ erβ€²+ edβ€² # where edβ€² = (⌊γ β‹…|𝖼𝗍(s)|q Ξ” βŒ‹ βˆ’ ⌊γ β‹…|𝖼𝗍(s)|q β‹…t qβŒ‹) is a scaling error

= ⌊γ β‹…t β‹…|𝖼𝗍(s)|q q βŒ‹ + esβ€²+ erβ€²+ edβ€²

= Ξ³ β‹…t β‹…|𝖼𝗍(s)|q βˆ’|Ξ³ β‹…t ⋅𝖼𝗍(s)|q q + esβ€²+ erβ€²+ edβ€²

Next, we derive the expression for |Ξ³ β‹…m|𝛾𝑑 as follows:

|Ξ³ β‹…m|𝛾𝑑 = |Ξ³ β‹…t β‹…|𝖼𝗍(s)|q βˆ’|Ξ³ β‹…t ⋅𝖼𝗍(s)|q q + esβ€²+ erβ€²+ edβ€²|𝛾𝑑

= |Ξ³ β‹…t β‹…|𝖼𝗍(s)|q βˆ’|Ξ³ β‹…t ⋅𝖼𝗍(s)|q q |𝛾𝑑 + |esβ€²|𝛾𝑑 + |erβ€²|𝛾𝑑 + |edβ€²|𝛾𝑑

= |Ξ³ β‹…t β‹…|𝖼𝗍(s)|q βˆ’|Ξ³ β‹…t ⋅𝖼𝗍(s)|q q |𝛾𝑑 + esβ€²+ erβ€²+ edβ€² # assuming |esβ€²|β‰ͺ𝛾𝑑 2 and |erβ€²|β‰ͺ𝛾𝑑 2 and |edβ€²|β‰ͺ𝛾𝑑 2

= |(Ξ³ β‹…t β‹…|𝖼𝗍(s)|q βˆ’|Ξ³ β‹…t ⋅𝖼𝗍(s)|q) β‹…qβˆ’1|𝛾𝑑 + esβ€²+ erβ€²+ edβ€² # since Ξ³ β‹…t β‹…|𝖼𝗍(s)|q βˆ’|Ξ³ β‹…t ⋅𝖼𝗍(s)|q is divisible by q, and q is co-prime to 𝛾𝑑

= |βˆ’|Ξ³ β‹…t ⋅𝖼𝗍(s)|q β‹…qβˆ’1| 𝛾𝑑 + esβ€²+ erβ€²+ edβ€² # since Ξ³ β‹…t β‹…|𝖼𝗍(s)|q is a multiple of 𝛾𝑑

= ||Ξ³ β‹…t ⋅𝖼𝗍(s)|q|𝛾𝑑 β‹…|βˆ’qβˆ’1|𝛾𝑑 + esβ€²+ erβ€²+ edβ€²

Given the above relation, notice that the computation result of π–₯π–Ίπ—Œπ—π–‘π–’π—ˆπ—‡π—(Ξ³ β‹…t ⋅𝖼𝗍(s),q,𝛾𝑑) β‹…|βˆ’qβˆ’1|𝛾𝑑 can be expressed as follows:

π–₯π–Ίπ—Œπ—π–‘π–’π—ˆπ—‡π—(Ξ³ β‹…t ⋅𝖼𝗍(s),q,𝛾𝑑) β‹…|βˆ’qβˆ’1|𝛾𝑑

= ||𝛾𝑑 ⋅𝖼𝗍(s)|q + π‘’π‘ž|𝛾𝑑 β‹…|βˆ’qβˆ’1|𝛾𝑑 # where |u|≀k 2 + 1 for the base moduli q1,q2,β‹―,qk

= ||𝛾𝑑 ⋅𝖼𝗍(s)|q β‹…|βˆ’qβˆ’1|𝛾𝑑 βˆ’u|𝛾𝑑

= |Ξ³ β‹…m|𝛾𝑑 βˆ’esβ€²βˆ’erβ€²βˆ’edβ€²βˆ’u # as we previously showed that |Ξ³ β‹…m|𝛾𝑑 = ||Ξ³ β‹…t ⋅𝖼𝗍(s)|q|𝛾𝑑 β‹…|βˆ’qβˆ’1|𝛾𝑑 + +esβ€²+ erβ€²+ edβ€²

= y # let’s denote the above expression as y

Then, if esβ€²,erβ€²,edβ€²,u are small enough such that |esβ€²+ erβ€²+ edβ€²+ u|< Ξ³, then |y|Ξ³ = βˆ’esβ€²βˆ’erβ€²βˆ’edβ€²βˆ’u (as |Ξ³ β‹…m|𝛾𝑑 mod Ξ³ = 0 as a multiple of Ξ³). Therefore, we can effectively remove the noise terms esβ€²,erβ€²,edβ€²,u and derive m as follows:

|(y βˆ’|y|Ξ³) β‹…|Ξ³βˆ’1|t|t

= ||Ξ³ β‹…m|𝛾𝑑 β‹…|Ξ³βˆ’1|t|t

= ||Ξ³ β‹…m|t β‹…|Ξ³βˆ’1|t|t # since ||Ξ³ β‹…m|𝛾𝑑|t = |Ξ³ β‹…m|t

= |m|t

, which is the final decryption of ct we wanted to compute. Let’s denote the RNS vector of y as a (yΞ³,yt) ∈ β„€Ξ³ Γ— β„€t. Then, we can efficiently compute the term |(y βˆ’|y|Ξ³) β‹…|Ξ³βˆ’1|t|t as follows:

|(y βˆ’|y|Ξ³) β‹…|Ξ³βˆ’1|t|t

= |(|yΞ³ β‹…t β‹…|tβˆ’1| Ξ³ + yt β‹…Ξ³ β‹…|Ξ³βˆ’1| t|𝛾𝑑︷ y βˆ’|yΞ³ β‹…t β‹…|tβˆ’1|Ξ³ + yt β‹…Ξ³ β‹…|Ξ³βˆ’1|t|Ξ³οΈ· |y|Ξ³) β‹…|Ξ³βˆ’1|t|t

= |(|yΞ³ β‹…t β‹…|tβˆ’1| Ξ³ + yt β‹…Ξ³ β‹…|Ξ³βˆ’1| t|tοΈ· y βˆ’|yΞ³ β‹…t β‹…|tβˆ’1|Ξ³ + yt β‹…Ξ³ β‹…|Ξ³βˆ’1|t|Ξ³οΈ· |y|Ξ³) β‹…|Ξ³βˆ’1|t|t # since ||y|𝛾𝑑|t = |y|t

= |(|yΞ³ β‹…t β‹…|tβˆ’1| Ξ³ + yt β‹…Ξ³ β‹…|Ξ³βˆ’1| t|tοΈ· y βˆ’|yΞ³ β‹…t β‹…|tβˆ’1|Ξ³|Ξ³οΈ· |y|Ξ³) β‹…|Ξ³βˆ’1|t|t # since yt β‹…Ξ³ β‹…|Ξ³βˆ’1|t mod Ξ³ = 0

= |(|yt β‹…Ξ³ β‹…|Ξ³βˆ’1| t|tοΈ· y βˆ’|yΞ³ β‹…t β‹…|tβˆ’1|Ξ³|Ξ³οΈ· |y|Ξ³) β‹…|Ξ³βˆ’1|t|t # since yΞ³ β‹…t β‹…|tβˆ’1|Ξ³ mod t = 0

= |(yt βˆ’yΞ³) β‹…|Ξ³βˆ’1|t|t # since |Ξ³ β‹…Ξ³βˆ’1|t = 1 and |t β‹…tβˆ’1|Ξ³ = 1

We summarize 𝖣𝖾𝖼𝖱𝖭𝖲𝖑π–₯𝖡 as follows:

⟨SummaryΒ D-5.5.1⟩ 𝖣𝖾𝖼 𝖱𝖭𝖲𝖑π–₯𝖡

Input: 𝖼𝗍(s) = Ξ”m + e + π‘˜π‘ž

1.
Pick some prime number Ξ³ which is co-prime to t and q.
2.
Compute π–₯π–Ίπ—Œπ—π–‘π–’π—ˆπ—‡π—(|Ξ³ β‹…t ⋅𝖼𝗍(s)|q,q,𝛾𝑑) β‹…|βˆ’qβˆ’1|𝛾𝑑

= (yΞ³,yt) ∈ β„€Ξ³ Γ— β„€t

3.
Compute |m|t = |(yt βˆ’yΞ³) β‹…|Ξ³βˆ’1|t|t
D-5.5.2 CKKS and BGV Decryption

CKKS and BGV ciphertexts can be decrypted efficiently by performing the ModDrop operation (SummaryΒ D-5.3 in Β§D-5.3) to the lowest multiplicative level. After this, there remains only a single ciphertext modulus in the RNS base, so the regular decryption algorithm can be executed efficiently without any RNS components.