D-1.7 Coefficient Extraction

- Reference: TFHE Deep Dive - Part IV - Programmable Bootstrapping [10]

In TFHE, coefficient extraction is a process of extracting a coefficient of a polynomial that is encrypted as GLWE ciphertext. The extracted coefficient is in the form of LWE ciphertext (§B-2).

Note that in the GLWE cryptosystem, plaintext M is encoded as a polynomial, where each coefficient encodes the plaintext value m0,m1,⋯,mn−1.

Suppose we have a GLWE ciphertext setup as the following:
M = ∑ ⁡ j=0n−1mjXj ∈R⟨n,q⟩

S = (S0 = ∑ ⁡ j=0n−1s0,jXj,S1 = ∑ j=0n−1s1,jXj, ⋯ ,Sk−1 = ∑ j=0n−1sk−1,jXj)

𝖦𝖫𝖶𝖤S→,σ(ΔM) = (A0 = ∑ ⁡ j=0n−1a0,jXj,A1 = ∑ j=0n−1a1,jXj, ⋯ ,Ak−1 = ∑ j=0n−1ak−1,jXj,B = ∑ j=0n−1bjXj)

B = ∑ ⁡ i=0k−1AiSi + ΔM + E

E = ∑ ⁡ i=0n−1eiXi

Note that:

ΔM + E = B −∑ ⁡ i=0k−1AiSi

= (Δm0 + Δm1X +  ⋯  + Δmn−1Xn−1) + (e0 + e1X +  ⋯  + en−1Xn−1)

= (Δm0 + e0) + (Δm1 + e1)X +  ⋯  + (Δmn−1 + en−1)Xn−1

Another way to write the formula is:

B −∑ ⁡ i=0k−1AiSi

= (b0 + b1X +  ⋯  + bn−1Xn−1)

−(a0,0 + a0,1X +  ⋯  + a0,n−1Xn−1)(s0,0 + s0,1X +  ⋯  + s0,n−1Xn−1)

−(a1,0 + a1,1X +  ⋯  + a1,n−1Xn−1)(s1,0 + s1,1X +  ⋯  + s1,n−1Xn−1)

− ⋯ 

−(ak−1,0 + ak−1,1X +  ⋯  + ak−1,n−1Xn−1)(sk−1,0 + sk−1,1X +  ⋯  + sk−1,n−1Xn−1)

= (b0 − (∑ ⁡ i=0k−1 ∑ j=00(ai,0−jsi,j) −∑ i=0k−1 ∑ j=1n−1(ai,n−jsi,j)))

+ (b1 − (∑ ⁡ i=0k−1 ∑ j=01(ai,1−jsi,j) −∑ i=0k−1 ∑ j=2n−1(ai,n+1−jsi,j))) ⋅X

+ (b2 − (∑ ⁡ i=0k−1 ∑ j=02(ai,2−jsi,j) −∑ i=0k−1 ∑ j=3n−1(ai,n+2−jsi,j))) ⋅X2

 ⋯ 

+ (bn−1 − (∑ ⁡ i=0k−1 ∑ j=0n−1(ai,n−1−jsi,j) −∑ i=0k−1 ∑ j=nn−1(ai,n+(n−1)−jsi,j))) ⋅Xn−1

▹ Grouping the terms by same exponents

= ∑ ⁡ h=0n−1 (bh − (∑ i=0k−1 ∑ j=0h(ai,h−jsi,j) −∑ i=0k−1 ∑ j=h+1n−1(ai,n+h−jsi,j))) ⋅Xh

= ∑ ⁡ h=0n−1Ch ⋅Xh, where Ch = bh − (∑ ⁡ i=0k−1 ∑ j=0h(ai,h−jsi,j) −∑ i=0k−1 ∑ j=h+1n−1(ai,n+h−jsi,j))

In the above (n −1)-degree polynomial, notice that each Xh term’s coefficient, Ch, can be expressed as an LWE ciphertext 𝖼𝗍h as follows:

S′ = (s0,0,s0,1, ⋯ ,s0,n−1,s1,0,s1,1, ⋯ ,s1,n−1, ⋯ ,sk−1,n−1) = (s0′,s1′, ⋯ ,s𝑛𝑘−1′) ∈ ℤq𝑛𝑘

𝖼𝗍h = (a0′,a1′, ⋯ ,a𝑛𝑘−1′,bh) ∈ ℤq𝑛𝑘+1

, where an⋅i+j′ = { ai,h−j (if 0 ≤j ≤h) −ai,n+h−j (if h + 1 ≤j ≤n −1) ,bh is directly obtained from the polynomial B

Note that bh −∑ ⁡ i=0𝑛𝑘−1si′ai′ = Δmh + eh. This means that Ch can be replaced by its encrypted version, 𝖫𝖶𝖤s→′,σ(Δmh), an LWE ciphertext 𝖼𝗍h encrypting the h-th coefficient of M. Therefore, we just extracted 𝖫𝖶𝖤s→′,σ(Δmh) from 𝖦𝖫𝖶𝖤S→,σ(ΔM). This operation is called coefficient extraction, which does not add any noise because it simply extracts an LWE ciphertext by reordering the polynomial of the GLWE ciphertext.

Once we have 𝖫𝖶𝖤s→′,σ(Δmh), we can key-switch it from s→′ →s→ (§D-1.5).

⟨Summary D-1.7⟩ GLWE Ciphertext’s Coefficient Extraction

Given the following GLWE ciphertext:

M = ∑ ⁡ j=0n−1mjXj ∈R⟨n,t⟩

S→ = (S0 = ∑ ⁡ j=0n−1s0,jXj,S1 = ∑ j=0n−1s1,jXj, ⋯ ,Sk−1 = ∑ j=0n−1sk−1,jXj)

𝖦𝖫𝖶𝖤S→,σ(ΔM) = (A0 = ∑ ⁡ j=0n−1a0,jXj,A1 = ∑ j=0n−1a1,jXj, ⋯ ,Ak−1 = ∑ j=0n−1ak−1,jXj,B = ∑ j=0n−1bjXj)

B = ∑ ⁡ i=0k−1AiSi + ΔM + E mod q, E = ∑ ⁡ i=0n−1eiXi

𝖫𝖶𝖤s→′,σ(Δmh) is an LWE ciphertext that encrypts ΔM’s h-th coefficient (i.e., Δmh). 𝖫𝖶𝖤s→′,σ(Δmh) can be extracted from 𝖦𝖫𝖶𝖤S→,σ(ΔM) as follows:

s→′ = (s0,0,s0,1, ⋯ ,s0,n−1,s1,0,s1,1, ⋯ ,s1,n−1, ⋯ ,sk−1,n−1) = (s0′,s1′, ⋯ ,s𝑛𝑘−1′) ∈ ℤq𝑛𝑘

𝖫𝖶𝖤s→′,σ(Δmh) = (a0′,a1′, ⋯ ,a𝑛𝑘−1′,bh) ∈ ℤq𝑛𝑘+1

, where an⋅i+j′ = { ai,h−j (if 0 ≤j ≤h) −ai,n+h−j (if h + 1 ≤j ≤n −1) ,bh is obtained from the polynomial B

Once we have 𝖫𝖶𝖤s→′,σ(Δmh), key-switch it from s→′ →s→ (§D-1.5).