[vFHE 1.] About TFHE

DoHoon Kim·2025년 3월 4일

vFHE

목록 보기
1/1

Ciphertext

GLWE ciphertext

  • p<qp \lt q, pp is plaintext modulus, qq is ciphertext modulus, Δ=q/p\Delta = q / p is scaling factor, typically p,qp, q are powers of two
  • MRpM \in \mathcal{R}_p is a message
  • Secret key is (s0,,sk1)Rk(s_0, \dots, s_{k-1}) \in \mathcal{R}^k where the coefficients are sampled from uniform binary distribution
  • (a0,,ak1,b)Rqk+1(a_0, \dots, a_{k-1}, b) \in \mathcal{R}_q^{k+1} is GLWE ciphertext where (a0,,ak1)(a_0, \dots, a_{k-1}) is sampled uniformly from Rqk\mathcal{R}_q^k and b=i=0k1aisi+ΔM+eb = \sum_{i=0}^{k-1} a_i \cdot s_i + \Delta M + e where eRqe \in \mathcal{R}_q is sampled from Gaussian distribution χσ\chi_{\sigma}
  • Decryption happens in two phase:
    • Given GLWE ciphertext (a0,,ak1,b)Rqk(a_0, \dots, a_{k-1}, b) \in \mathcal{R}_q^k, bi=0k1aisi=ΔM+eb - \sum_{i=0}^{k-1} a_i \cdot s_i = \Delta M + e
    • Divide the result by Δ\Delta and do rounding, for decryption to be successful, the (infinity) norm of ee should be smaller than Δ/2\Delta / 2

GLev ciphertext

For base β\beta and ll, GLev ciphertext for the message MM is represented as following:

(GLWEs,σ(qβM),GLWEs,σ(qβ2M),,GLWEs,σ(qβlM))Rl(k+1)(GLWE_{\vec{s}, \sigma}(\frac{q}{\beta} M), GLWE_{\vec{s}, \sigma}(\frac{q}{\beta^2} M), \dots, GLWE_{\vec{s}, \sigma}(\frac{q}{\beta^l} M)) \subset \mathcal{R}^{l \cdot (k+1)}

All GLWE ciphertexts are encrypted using the same secret key (s0,,sk1)(s_0, \dots, s_{k-1}). The difference is that in GLev ciphertext, GLWE ciphertexts are not scaled by Δ\Delta. For j=0,,l1j = 0, \dots, l-1,

bj=i=0k1aijsi+qβj+1M+ejb^j = \sum_{i=0}^{k-1} a^j_i \cdot s_i + \frac{q}{\beta^{j+1}} \cdot M + e^j

GGSW ciphertext

GGSW ciphertext for the message MM is given as the following:

(GLevs,σβ,l(s0M),,GLevs,σβ,l(sk1M),GLevs,σβ,l(M))(GLev_{\vec{s}, \sigma}^{\beta, l}(-s_0M), \dots, GLev_{\vec{s}, \sigma}^{\beta, l}(-s_{k-1}M), GLev_{\vec{s}, \sigma}^{\beta, l}(M))

Homomorphic addition

For two GLWE ciphertexts encrypting M1,M2RpM_1, M_2 \in \mathcal{R}_p, the homomorphic addition of two ciphertexts is as follows:

(a0,,ak1,b)+(a0,,ak1,b)=(a0+a0,,ak1+ak1,b+b)(a_0, \dots, a_{k-1}, b) + (a_0', \dots, a_{k-1}', b') = (a_0 + a_0', \dots, a_{k-1}+a_{k-1}', b+b')

Since b=i=0k1aisi+ΔM1+eb = \sum_{i=0}^{k-1} a_i \cdot s_i + \Delta M_1 + e and b=i=0k1aisi+ΔM2+eb' = \sum_{i=0}^{k-1} a_i' \cdot s_i + \Delta M_2 + e', b+b=i=0k1(ai+ai)si+Δ(M1+M2)+e+eb+b' = \sum_{i=0}^{k-1} (a_i+a_i') \cdot s_i + \Delta (M_1 + M_2) + e + e'. The resulting ciphertext is encryption of M1+M2M_1 + M_2 with slightly bigger noise.

Homomorphic multiplication

First, let's consider the multiplication of GLWE ciphertext GLWEs,σ(ΔM)=(a0,,ak1,b)GLWE_{\vec{s}, \sigma}(\Delta M) = (a_0, \dots, a_{k-1}, b) with the constant ΛRq\Lambda \in \mathcal{R}_q with small coefficients. Then the multiplication is as follows:

Λ(a0,,ak1,b)=(Λa0,,Λak1,Λb)\Lambda \cdot (a_0, \dots, a_{k-1}, b) = (\Lambda \cdot a_0, \dots, \Lambda \cdot a_{k-1}, \Lambda \cdot b)

Since b=i=0k1aisi+ΔM1+eb = \sum_{i=0}^{k-1} a_i \cdot s_i + \Delta M_1 + e, Λb=i=0k1Λaisi+ΔΛM1+Λe\Lambda \cdot b = \sum_{i=0}^{k-1} \Lambda \cdot a_i \cdot s_i + \Delta \Lambda \cdot M_1 + \Lambda \cdot e.

Key switching

Let's first consider homomorphic multiplication of the message MM by the constant with large coefficients γRq\gamma \in \mathcal{R}_q. Applying the same method as above would make the noise big enough to make decryption to fail. In order to handle this, consider the decomposition of rZqr \in \mathbb{Z}_q by base β\beta as following:

rq=r1β++rlβl\frac{r}{q} = \frac{r_1}{\beta} + \dots + \frac{r_l}{\beta^l}

We will assume that βl=q\beta^l=q for now. r1,,rlr_1, \dots, r_l is smaller than β\beta. For γRq\gamma \in \mathcal{R}_q, one can decompose each coefficient as above, and then γ=i=1lqβiγi\gamma = \sum_{i=1}^l \frac{q}{\beta^i} \cdot \gamma_i and γi\gamma_i has small norm.

Now, consider GLev ciphertext of MM, (GLWEs,σ(qβM),,GLWEs,σ(qβlM))(GLWE_{\vec{s}, \sigma}(\frac{q}{\beta} M), \dots, GLWE_{\vec{s}, \sigma}(\frac{q}{\beta^l} M)). Since γ=γ1qβ++γlqβl\gamma = \gamma_1 \frac{q}{\beta} + \dots + \gamma_l \frac{q}{\beta^l} by the decomposition, γM=γ1qβM++γlqβlM\gamma M = \gamma_1 \frac{q}{\beta} M + \dots + \gamma_l \frac{q}{\beta^l} M. Thus, this can be obtained by Decompβ,l(γ),GLevs,σβ,l(M)\langle Decomp^{\beta, l}(\gamma), GLev_{\vec{s}, \sigma}^{\beta, l}(M) \rangle. However, since GLev ciphertext does not contain Δ\Delta, it is not directly used as homomorphic multiplication.

Now let's consider key switching. Key switching is to replace the secret key that was used to encrypt GLWE ciphertext with another secret key without decryption.

For GLWE ciphertext (a0,,ak1,b)GLWEs,σ(ΔM)(a_0, \dots, a_{k-1}, b) \in GLWE_{\vec{s}, \sigma}(\Delta M), the following is key switching key:

KSKiGLevs,σKSKβ,l(si)KSK_i \in GLev_{\vec{s'}, \sigma_{KSK}}^{\beta, l}(s_i)

What we want to do is bi=0k1aisi=ΔM+eb - \sum_{i=0}^{k-1} a_i \cdot s_i = \Delta M + e without decryption.

(0,,0,b)i=0k1Decompβ,l(ai),KSKi(0, \dots, 0, b) - \sum_{i=0}^{k-1} \langle Decomp^{\beta, l}(a_i), KSK_i \rangle

External product

s=(s0,,sk1)Rk\vec{s} = (s_0, \dots, s_{k-1}) \in \mathcal{R}^k
c=(a0,,ak1,b)GLWEs,σ(Δm1)c = (a_0, \dots, a_{k-1}, b) \in GLWE_{\vec{s}, \sigma} (\Delta m_1)
cˉˉ=(c0ˉ,,ck1ˉ,ckˉ)=(GLevs,σβ,l(s1m2),,GLevs,σβ,l(skm2),GLevs,σβ,l(m2))\bar{\bar{c}} = (\bar{c_0}, \dots, \bar{c_{k-1}}, \bar{c_k}) = (GLev_{\vec{s}, \sigma}^{\beta, l}(-s_1 m_2), \dots, GLev_{\vec{s}, \sigma}^{\beta, l}(-s_k m_2), GLev_{\vec{s}, \sigma}^{\beta, l}(m_2))

External product is defined as follows:

c=Decompβ,l(c),cˉˉ=Decompβ,l(b),ckˉ+i=0k1Decompβ,l(ai),ciˉc' = \langle Decomp^{\beta, l}(c), \bar{\bar{c}} \rangle = \langle Decomp^{\beta, l}(b), \bar{c_k} \rangle + \sum_{i=0}^{k-1} \langle Decomp^{\beta, l}(a_i), \bar{c_i} \rangle

cc' is GLWE ciphertext of m1m2m_1 m_2.

Programmable Bootstrapping

The PBS of TFHE has input

  • LWE ciphertext (a,b=a,s+e+Δm)Zqn+1(a, b = \langle a, s \rangle + e + \Delta \cdot m) \in \mathbb{Z}_q^{n+1} where s{0,1}ns \in \{0, 1\}^n
  • LUT encoded in tRqt \in \mathcal{R}_q
    • LUT encodes the values Δf(m)+e\Delta \cdot f(m) + e where f:RqRqf: \mathcal{R}_q \rightarrow \mathcal{R}_q, e<Δ/2|e| \lt \Delta / 2
    • LUT has blocks of which the position corresponds to Δm+e\Delta \cdot m + e
    • each element of LUT is embedded in each coefficient of Rq\mathcal{R}_q element by mod switching
  • Bootstrapping secret key
    • GLWE ciphertext secret key sRks' \in \mathcal{R}^k
  • Bootstrapping key
    • Collection of GGSW ciphertexts of each bit of LWE secret key (sis_i) encrypted by ss'
  • Key switching key
    • GLev ciphertexts of bootstrapping secret key encrypted by ss

The goal of PBS is to compute decryption procedure and evaluation of f(m)f(m) homomorphically, which means to compute LWE ciphertext of Δf(m)\Delta \cdot f(m) with small error than in input LWE ciphertext.

Step 0: Modulus switching

Input: LWE ciphertext (a,b=a,s+e+Δm)Zqn+1(a, b = \langle a, s \rangle + e + \Delta \cdot m) \in \mathbb{Z}_q^{n+1}
Output: LWE ciphertext (a,b=a,s+e+Δm)Z2Nn+1(a, b = \langle a, s \rangle + e + \Delta \cdot m) \in \mathbb{Z}_{2N}^{n+1}

Since LUT conceptually has q/2q/2 or qq possible values (depending on the negacyclic property of LUT), we should properly embed these values into Rq\mathcal{R}_q element. Since Rq\mathcal{R}_q has NN coefficients and has negacyclic property, we multiply each element of LUT by 2N/q2N/q and embed the resulting values into coefficients. Also, we do the similar thing to LWE ciphertext to embed them into Z2Nn+1\mathbb{Z}_{2N}^{n+1}. We will keep the notation for a,e,Δa, e, \Delta, but should be aware that these values actually change after mod switching.

Step 1: Chain of CMux operations

Input: GLWE ciphertext of tXbt \cdot X^{-b} encrypted by secret key ss'
Output: GLWE ciphertext of tX(Δm+e)=tXb+i=0n1aisit \cdot X^{-(\Delta \cdot m + e)} = t \cdot X^{-b + \sum_{i=0}^{n-1} a_i s_i} encrypted by secret key ss'

At the first part of PBS, one should compute X(Δm+e)=Xb+a,sX^{-(\Delta \cdot m + e)} = X^{-b+\langle a,s \rangle} (this holds trivially in Rq\mathcal{R}_q because the exponents are in mod 2N2N). So how can homomorphically compute this? Since bb is public value, GLWE ciphertext of XbX^{-b} is given first. Depending on the value of each si{0,1}s_i \in \{0, 1\}, one can multiply the GLWE ciphertext of XaiX^{a_i} or just skip multiplying. This is where CMux operation and bootstrapping key comes to play. Since bootstrapping key is the GGSW ciphertext of each sis_i, it is given to CMux operation as selector, and two GLWE ciphertexts, each of encrypting Xb+a0X^{-b+a_0} and XbX^{-b}. Then this CMux operation will compute Xb+a0s0X^{-b+a_0 s_0}. Applying CMux operation nn times, one can compute Xb+i=0n1aisiX^{-b+\sum_{i=0}^{n-1} a_i s_i}.

Step 2: Sample extraction

Input: GLWE ciphertext of tX(Δm+e)t \cdot X^{-(\Delta \cdot m + e)} encrypted by secret key ss'
Output: LWE ciphertext of the constant coefficient of tX(Δm+e)Rqt \cdot X^{-(\Delta \cdot m + e)} \in \mathcal{R}_q under secret key (s0,0,,s0,N1,,sk1,0,,sk1,N1)(s'_{0, 0}, \dots, s'_{0, N-1}, \dots, s'_{k-1, 0}, \dots, s'_{k-1, N-1}) which are the coefficients of sRks' \in \mathcal{R}^k

Since LUT is the encoding of the values Δf(m)+e\Delta \cdot f(m) + e' in coefficients, GLWE ciphertext of tX(Δm+e)t \cdot X^{-(\Delta \cdot m + e)} has Δf(m)+e\Delta \cdot f(m) + e' in its constant coefficient. Thus we should extract the constant coefficient of the ciphertext homomorphically.

Step 3: Key switching

Input: LWE ciphertext of Δf(m)+e\Delta \cdot f(m) + e under secret key (s0,0,,s0,N1,,sk1,0,,sk1,N1)(s'_{0, 0}, \dots, s'_{0, N-1}, \dots, s'_{k-1, 0}, \dots, s'_{k-1, N-1}) which are the coefficients of sRks' \in \mathcal{R}^k
Output: LWE ciphertext of Δf(m)+e\Delta \cdot f(m) + e' under secret key ss

Finally, using key switching key, which is the collection of GLev ciphertexts of si,js'_{i,j} under secret key ss, we obtain the LWE ciphertext of Δf(m)+e\Delta \cdot f(m) + e' under secret key ss.

Below is the full description of PBS.

Next topic

In the next post, I will discuss about verifiable PBS using SNARK proof system.

Reference

[1] https://eprint.iacr.org/2024/451.pdf
[2] https://www.zama.ai/post/tfhe-deep-dive-part-4

profile
Researcher & Developer

0개의 댓글