Full RNA BGV/BFV

references:

  1. [BV11] Brakerski Z, Vaikuntanathan V. Fully homomorphic encryption from ring-LWE and security for key dependent messages[C]//Annual cryptology conference. Berlin, Heidelberg: Springer Berlin Heidelberg, 2011: 505-524.
  2. [GHS12] Gentry C, Halevi S, Smart N P. Homomorphic evaluation of the AES circuit[C]//Annual Cryptology Conference. Berlin, Heidelberg: Springer Berlin Heidelberg, 2012: 850-867.
  3. [CP16] Crockett E, Peikert C. Λολ: Functional Lattice Cryptography[C]//Proceedings of the 2016 ACM SIGSAC Conference on Computer and Communications Security. 2016: 993-1005.
  4. [BEHZ16] Bajard J C, Eynard J, Hasan M A, et al. A full RNS variant of FV like somewhat homomorphic encryption schemes[C]//International Conference on Selected Areas in Cryptography. Cham: Springer International Publishing, 2016: 423-442.
  5. [HPS19] Halevi S, Polyakov Y, Shoup V. An improved RNS variant of the BFV homomorphic encryption scheme[C]//Topics in Cryptology–CT-RSA 2019: The Cryptographers’ Track at the RSA Conference 2019, San Francisco, CA, USA, March 4–8, 2019, Proceedings. Springer International Publishing, 2019: 83-105.
  6. [KPZ21] Kim A, Polyakov Y, Zucca V. Revisiting homomorphic encryption schemes for finite fields[C]//Advances in Cryptology–ASIACRYPT 2021: 27th International Conference on the Theory and Application of Cryptology and Information Security, Singapore, December 6–10, 2021, Proceedings, Part III 27. Springer International Publishing, 2021: 608-639.

RNS Basis Extension

Generally, FHE requires a large modulus Q Q Q, Masashi copy Q = ∏ i = 1 L q i Q=\prod_{i=1}^L q_i Q=i=1Lqi,满足 q i = 1 ( m o d 2 N ) q_i=1\pmod{2N} qi=1(mod2N),我们简记 Q i = q 1 ⋯ q i Q_i=q_1\cdots q_i Qi=q1qi,集合 { q i } \{q_i\} { qi} name RNS basis, virtually any size 64 6464 bits. We hope that all operations of FHE are single-precision (machine words of modern computers), that is, all operations are completed under RNS without the need for multi-precision arithmetic.

Conversion between different RNS, the ring element a ∈ R Q a \in \mathcal R_Q aRQ From modulus Q = q 1 ⋯ q k Q=q_1\cdots q_k Q=q1qk lower [ a ] ​​Q [a]_Q [a]Q Convert to modulus P = p 1 ⋯ p l P=p_1\cdots p_l P=p1pl 下的 [ [ a ] Q ] P [[a]_Q]_P [[a]Q]P可以直接在 RNS 下计算
FastBaseExt ( a , Q , P ) = { ∑ i = 1 k [ a ⋅ ( Q q i ) − 1 ] q i ⋅ Q q i ( m o d p j ) } j = 1 , ⋯   , l \text{FastBaseExt}(a,Q,P) = \left\{ \sum_{i=1}^k \left[ a \cdot \left(\dfrac{Q}{q_i}\right)^{-1} \right]_{q_i} \cdot \dfrac{Q}{q_i} \pmod{p_j} \right\}_{j=1,\cdots,l} FastBaseExt(a,Q,P)= i=1k[a(qiQ)1]qiqiQ(modpj) j=1,,l
I read it q ​​i ∗ : = Q / q i q_i^*:=Q/q_i qi:=Q/qi q ~ i : = ( Q / q i ) − 1 ( m o d q i ) \tilde q_i:=(Q/q_i)^{-1} \pmod{q_i} q~i:=(Q/qi)1(modqi),满足 q i ∗ ⋅ q ~ i ≡ 1 ( m o d q i ) q_i^* \cdot \tilde q_i\equiv 1 \pmod{q_i} qiq~i1(modqi),那么根据 CRT 合成定理,
∑ i [ a ⋅ q ~ i ] q i ⋅ q i ∗ = [ a ] Q + u ⋅ Q ∈ Z \sum_i [a \cdot \tilde q_i]_{q_i} \cdot q_i^* = [a]_Q + u \cdot Q \in \mathbb Z i[aq~i]qiqi=[a]Q+inQZ
其中 ∥ u ∥ ∞ ≤ k / 2 \|u\|_\infty \le k/2 uk/2 Name Q Q Q-overflow,因此算法 FastBaseExt ( a , Q , P ) \text{FastBaseExt}(a,Q,P) FastBaseExt(a,Q,P) Just come out [ [ a ] ​​Q ] P [[a]_Q] _P [[a]Q]P近似值 [ [ a ] Q + u ⋅ Q ] P [[a]_Q + u \cdot Q]_P [[a]Q+inQ]P

Existence in a small practical example, u u The impact of u is almost negligible; however, there are some instances where u u u may cause significant noise growth, and it is necessary to find a way to remove it.

We misuse symbols, Q , P Q,P Q,P represents the corresponding RNS basis set, [ a ] ​​Q [a]_Q [a]Qrepresents its RNS representation.

γ \gammaγ-correction technique

A key calculation of BFV is
⌊ P Q [ a ] ​​Q ⌉ = P ⋅ [ a ] ​​Q − [ P a ] ​​Q Q ∈ R P \left\lfloor \dfrac{P }{Q}[a]_Q \right\rceil = \dfrac{P \cdot[a]_Q - [Pa]_Q}{Q} \in \mathcal R_P QP[a]Q=QP[a]Q[Pa]QRP
Because the above operation is integer division, we can use modular multiplication inverse element Substitution, ( P ⋅ [ a ] ​​Q − [ P a ] ​​Q ) ⋅ Q − 1 ( m o d P ) (P \cdot[a]_Q - [Pa] _Q) \cdot Q^{-1} \pmod P (P[a]Q[Pa]Q)Q1(modP)

[BEHZ16] adopts integer instructions, and additionally introduces P , Q P,Q P,Q allomeric integer γ \gamma γ,假设 [ a ] Q = Q / P ⋅ m + e + Q r [a]_Q=Q/P \cdot m+e+Qr [a]Q=Q/Pm+It is+Qr,将 [ a ] Q [a]_Q [a]Q Multiplication γ \gamma γ, except
   FastBaseExt ( γ P a , Q , γ P ) ⋅ [ − Q − 1 ] P = [ [ γ P a ] Q + u ⋅ Q ] γ P ⋅ [ − Q − 1 ] γ P = ⌊ γ P Q [ a ] ​​Q ⌉ − u = γ ⋅ ( m + P r ) + ⌊ γ P and Q ⌉ − u \begin {aligned} &\,\, \text{FastBaseExt}(\gamma Pa,Q,\gamma P) \cdot [-Q^{-1}]_P\\ =&\,\, [[\gamma Pa]_Q + u \cdot Q]_{\gamma P} \cdot [-Q^{-1}]_{\gamma P}\\ =&\,\, \left\lfloor \dfrac{\gamma P}{Q}[a]_Q \right\rceil - u\\ =&\,\, \gamma \cdot (m + Pr) + \left\lfloor \dfrac{\gamma Pe}{Q} \right \rceil - u \end{aligned}===FastBaseExt(γPa,Q,γP)[Q1]P[[γPa]Q+inQ]γP[Q1]γPQγP[a]Qinc(m+Pr)+QγPeu
γ \gamma γ When certain conditions are met (I can’t understand what is written in the article, it does not explain it), RNS’s about γ \gamma < /span>γ 的部分,满足
[ ⌊ γ P e Q ⌉ − u ] γ = ⌊ γ P e Q ⌉ − u ∈ R \left[ \left\lfloor \dfrac{\gamma Pe}{Q} \right\rceil - u \right]_\gamma = \left\lfloor \dfrac{\gamma Pe}{Q} \right\rceil - u \in \mathcal R [QγPeu]γ=QγPeinR
Individually, independently:
[ m ] P = ( [ γ ⋅ ( m + P r ) + ⌊ γ P and Q ⌉ − u ] P − [ ⌊ γ P and Q ⌉ − u ] γ ) ⋅ [ γ − 1 ] P [m]_P = \left(\left[ \gamma \cdot (m + Pr) + \left \lfloor \dfrac{\gamma Pe}{Q} \right\rceil - u \right]_P - \left[ \left\lfloor \dfrac{\gamma Pe}{Q} \right\rceil - u \right]_ \gamma\right) \cdot[\gamma^{-1}]_P[m]P=([γ(m+Pr)+QγPeu]P[QγPeu]γ)[γ1]P

However, [BEHZ16]’s method can only alleviate but does not fundamentally solve Q Q Q-overflow question. And [HPS19]'s method can completelyremoveit.

Retrieve the Overflow

[HPS19] TakeoverFloating point command, direct calculation u u u 的值(精度受限的),
u = ⌊ ∑ i [ a ⋅ q ~ i ] q i ⋅ q i ∗ Q ⌉ = ⌊ ∑ i = 1 k [ a ⋅ q ~ i ] q i q i ⌉ \begin{aligned} u &= \left\lfloor \dfrac{\sum_i [a \cdot \tilde q_i]_{q_i} \cdot q_i^*}{Q} \right\rceil = \left\lfloor \sum_{i=1}^k \dfrac{[a \cdot \tilde q_i]_{q_i}}{q_i} \right\rceil \end{aligned} u=Qi[aq~i]qiqi=i=1kqi[aq~i]qi
于是 [ a ] Q = ( ∑ i [ a ⋅ q ~ i ] q i ⋅ q i ∗ ) − u ⋅ Q [a]_Q = (\sum_i [a \cdot \tilde q_i]_{q_i} \cdot q_i^*) - u \cdot Q [a]Q=(i[aq~i]qiqi)inQ, increment free:
[ [ a ] ​​Q ] P = FastBaseExt ( a , Q , P ) − u ⋅ Q ] P[[a]_Q]_P = \text{FastBaseExt}(a,Q,P)-u\cdot[Q]_P[[a]Q]P=FastBaseExt(a,Q,P)in[Q]P

Specific steps: precalculation [ q i ∗ ] p j , ∀ i ∈ [ k ] , ∀ j ∈ [ l ] [q_i^*]_{p_j},\forall i \in [k],\forall j \in [l] [qi]pj,i[k],j[l],预计算 [ q ~ i ] q i , ∀ i ∈ [ k ] [\tilde q_i]_{q_i},\forall i \in [k] [q~i]qi,i[k],预计算 [ Q ] p j , ∀ j ∈ [ l ] [Q]_{p_j},\forall j \in [l] [Q]pj,j[l]

  1. Import [ a ] ​​Q [a]_Q [a]Q 的 RNS 表示 ( a 1 , ⋯   , a k ) (a_1,\cdots,a_k) (a1,,ak), inside a i = [ a ] ​​q i a_i=[a]_{q_i} ai=[a]qi
  2. Used precisionInteger command, calculation y i = [ a i ⋅ q ~ i ] q i y_i =[a_i \cdot \tilde q_i]_{q_i} andi=[aiq~i]qi
  3. Using precisionFloating point command, calculation z i = y i / q i z_i = y_i/q_i Withi=andi/qi
  4. Calculation u = ⌊ ∑ i z i ⌉ ∈ Z k u=\lfloor \sum_i z_i \rceil \in\mathbb Z_k in=iWithiWITHk
  5. Q Q Q 的 RNS 下,计算 x i = a i ⋅ [ q ~ i ] q i ( m o d q i ) x_i = a_i \cdot [\tilde q_i]_{q_i} \pmod{q_i} xi=ai[q~i]qi(modqi)
  6. present P P P 的 RNS 下,计算 A j ′ = ∑ i x i ⋅ [ q i ∗ ] p j ( m o d p j ) A_j'=\sum_i x_i \cdot [q_i^*]_{p_j} \pmod{p_j} Aj=ixi[qi]pj(modpj)
  7. 纠正错误 A j = A j ′ − u ⋅ [ Q ] p j A_j=A_j' - u \cdot [Q]_{p_j} Aj=Ajin[Q]pj
  8. 输出 [ a ] P = { A 1 , ⋯   , A l } [a]_{P} = \{A_1,\cdots,A_l\} [a]P={ A1,,Al},易知 [ a ] Q ∪ [ a ] P = [ a ] P Q [a]_Q \cup [a]_P = [a]_{PQ} [a]Q[a]P=[a]PQ

Because the precision of floating point numbers is limited, the actual calculated value is z i ∗ = z i + ϵ i z_i^*=z_i+\epsilon_i Withi=Withi+ϵi, the final result has arrived u ∗ = ⌊ ∑ i z i ∗ ⌉ u^*=\lfloor\sum_i z_i^*\rceil in=iWithi, infinitesimal ϵ = ∑ i ϵ i \epsilon=\sum_i \epsilon_i ϵ=iϵi,使用 IEEE-754 double 那么有 ϵ < k ⋅ 2 − 53 \epsilon < k \cdot 2^{-53} ϵ<k253 Z+[0.5-\epsilon, 0.5+\epsilon] WITH+[0.5ϵ,0.5+ϵ]possible-error region,一旦 ∑ i z i ∗ \sum_i z_i^* iWithiIf you fall into this range, you should use high-precision arithmetic. However, even if it is ignored, it has little effect and only makes a minimal contribution to noise growth.

Modulus-Switching and Scaling in RNS

Simple Reduction

输入 x ∈ Z P Q x \in \mathbb Z_{PQ} xWITHPQThe RNS representation of is denoted as ( x 1 , ⋯ , x k , x 1 ′ , ⋯ , x l ′ ) (x_1,\cdots,x_k,x_1', \cdots,x_l') (x1,,xk,x1,,xl),Branch separation Q = ∏ i q i Q=\prod_i q_i Q=iqi P = ∏ j p j P=\prod_j p_j P=jpj

Module reduction under RNS: In order to calculate x ( m o d Q ) x \pmod Q x(modQ),简单删除 P P Components of P, output [ x ] Q = ( x 1 , ⋯ , x k ) [x]_Q=(x_1,\ cdots,x_k) [x]Q=(x1,,xk)

RNS LowerDivision method:假设 P ∣ x P|x Px(equation x j ′ = 0 x_j'=0 xj=0), 为了计计 x / P x/P x/P,预计 [ P ] q i [P]_{q_i} [P]qi, online calculation [ x / P ] Q = ( [ x 1 ⋅ P ] q 1 , ⋯ , [ x k ⋅ P ] q k ) [x/P]_Q = ([x_1\cdot P]_{q_1},\cdots,[x_k\cdot P]_{q_k}) [x/P]Q=([x1P]q1,,[xkP]qk)

Note that the RNS systemis not a numerical system (positional system) and cannot be calculated Z \mathbb Z < /span>The division with remainder on operations. Therefore, special solutions need to be designed for some necessary operations in BGV and BFV (BGV mode switching, BFV multiplication scaling, key switching, decryption). roundandCompare also cannot be executedZ

Modulus-Switching for BGV

[GHS12] gives a Double-CRT implementation of BGV for t = 2 t =2 t=2 Trivial plaintext modulus, since q i = 1 ( m o d t ) q_i=1\pmod t qi=1(modt) leads to simple implementation. For general plaintext modulus t t t, let it be a larger prime number (for example t = 2 16 + 1 t=2^{16}+1 a>t=216+1), concise sentence c ∈ R Q k 2 c \in \mathcal R_{Q_k}^2 cRQk2, we calculate the special c † ∈ R 2 c^\dagger \in \mathcal R^2 cR2 (with corollary Z \mathbb Z Z top), full foot

  • 解密条件: c † ≡ c ⋅ q k ( m o d t ) c^\dagger \equiv c \cdot q_k \pmod t ccqk(modt),那么 c ′ = c † / q k = [ c † ⋅ q k − 1 ] Q k − 1 c'=c^\dagger/q_k=[c^\dagger \cdot q_k^{-1}]_{Q_{k-1}} c=c/qk=[cqk1]Qk1 Original message encrypted [ m ] t [m]_t [m]t

  • 噪声条件: δ = c † − c \delta=c^\dagger-c d=cc has a smaller norm

  • Divisibility condition: q ​​k ∣ c † q_k\mid c^\dagger qkc,注意 Z \mathbb Z Divisibility on Z is exactly Z Q k − 1 \mathbb Z_{Q_{k-1}} WITHQk1Multiply the above by the inverse element,

We want to calculate the small gap first δ \delta δ 满足 δ ≡ ( q k − 1 ) ⋅ c ( m o d t ) \delta \equiv (q_k-1) \cdot c \pmod t d(qk1)c(modt), then re-search c † c^\dagger c, finally calculated c ′ = c † / q k c'=c^\dagger/q_k c=c/qk, but [ c ] t [c]_t is not present in the input RNS representation[c]t, guide δ \delta δ is difficult to calculate. [GHS12] turns to calculate the following ciphertext (the appendix of [GHS12] is too brief and difficult to understand),
c ^ = [ q k ] t ⋅ c ( m o d Q k ) \hat c=[q_k]_t \cdot c \pmod{Q_k} c^=[qk]tc(modQk)
It encrypts distorted message [ q k ] t ⋅ m [q_k]_t \ cdot m [qk]tm(对于 t = 2 t=2 t=2 special case, just not reversed), and the noise has grown q k q_k qk times,寻找 c † c^\dagger cThe condition for † is changed to:

  • 解密条件: c † ≡ c ^ ( m o d t ) c^\dagger \equiv \hat c \pmod t cc^(modt),它使得 [ [ c † s ] Q k ] t = [ q k m ] t [[c^\dagger s]_{Q_k}]_t = [q_km]_t [[cs]Qk]t=[qkm]t
  • 噪声条件: δ = c † − c ^ \delta=c^\dagger-\hat c d=cc^, note that the change here results in δ ≡ 0 ( m o d t ) \delta \equiv 0 \pmod t d0(modt),这是 δ \delta δ is t t t multiple (unrepeatable demand [ c ] t [c]_t [c]tknowledge
  • Divisibility condition: q ​​k ∣ c † q_k \mid c^\dagger qkc,计算出 c ′ = c † / q k c'=c^\dagger/q_k c=c/qk, what it encrypts isthe original message [ [ c ′ s ] Q k − 1 ] t = [ [ q k − 1 c † s ] Q k − 1 ] t = [ m ] t [[c's]_{Q_{k-1}}]_t = [[q_k^{-1}c^\dagger s]_{Q_ {k-1}}]_t = [m]_t [[cs]Qk1]t=[[qk1cs]Qk1]t=[m]t(This is what I understand, it should be, the original article did not write in detail)

at this time δ \delta δ Easy calculation (because [ δ ] t = 0 [\delta]_t=0 [δ]t=0 已Chi)、Sanpo Nyoge:

  1. 输入 c ( m o d Q k ) c \pmod{Q_k} c(modQkRNS representation of ) (encrypted [ m ] t [m]_t [m]t
  2. 先计算 c ^ = [ q k ] t ⋅ c \hat c=[q_k]_t \cdot c c^=[qk]tRNS representation of c, and then calculate [ c ^ ] q k [\hat c]_{q_k} [c^]qkThe coefficient representation of c ˉ \bar c cˉ
  3. We calculate the gap δ ∈ [ − q k t / 2 , q k t / 2 ) N × 2 \delta \in [-q_kt/2, q_kt/2)^{N \ times 2} d[qkt/2,qkt/2)N×2,使得它满足 δ ≡ 0 ( m o d t ) \delta \equiv 0 \pmod t d0(modt) 以及 δ ≡ − c ˉ ( m o d q k ) \delta \equiv -\bar c \pmod{q_k} dcˉ(modqk), to be exact we set δ = t [ − c ˉ t − 1 ] q k \delta = t[-\bar ct^{-1}]_{q_k} d=t[cˉt1]qk
  4. 计算出 c † = c ^ + δ c^\dagger=\hat c+\delta c=c^+δ(在模数 Q k Q_k Qk 下),易知 c † ≡ c ^ ( m o d t ) c^\dagger \equiv \hat c \pmod t cc^(modt) (decryption is the same) and c  ≡ 0 ( m o d q k ) c^\dagger \equiv 0 \pmod{q_k} c0(modqk)(divisibility)
  5. Final calculationDivisibility c ′ = c † / q k ( m o d Q k − 1 ) c'=c^\dagger/ q_k \pmod{Q_{k-1}} c=c/qk(modQk1), each quantityfrom the inverse element [ q k − 1 ] q i , ∀ i ≤ k − 1 [q_k^{-1}]_{q_i},\forall i\le k-1 [qk1]qi,ik1
  6. 输出 c ′ ( m o d Q k − 1 ) c' \pmod{Q_{k-1}} c(modQk1RNS representation of ), which encrypts c ^ \hat c c^ encrypted message [ m ] t [m]_t [m]t

In fact, mode switching is not required and the result is still the encryption of the original message:

  • The noise condition is changed to δ = c † − c \delta=c^\dagger-c d=cc
  • The decryption condition is changed to c  ≡ c ( m o d t ) c^\dagger \equiv c \pmod t cc(modt)(即 c + δ ≡ c ( m o d t ) c+\delta \equiv c \pmod{t} c+dc(modt)),
  • and such that q ​​∣ c † q \mid c^\dagger qc(即 c + δ ≡ 0 ( m o d q ) c+\delta \equiv 0 \pmod{q} c+d0(modq)

Any plaintext modulus t ≥ 2 t \ge 2 tThe mode switching algorithm of 2 is:

  1. 输入 [ m ] t [m]_t [m]tCiphertext of c = ( c 0 , c 1 ) ∈ R Q c=(c_0,c_1) \in \mathcal R_{Q} c=(c0,c1)RQ,A cry is v v v,从 Q Q Q 切换到 Q ′ Q' Q,简记 q = Q / Q ′ q=Q/Q' q=Q/Q (can span multiple levels)
  2. 计算差距 δ = ( δ 0 = t [ − t − 1 c 0 ] q , δ 1 = t [ − t − 1 c 1 ] q ) \delta = (\delta_0=t[-t^{-1}c_0]_q, \delta_1=t[-t^{-1}c_1]_q) d=(δ0=t[t1c0]q,d1=t[t1c1]q),它满足 δ ≡ 0 ( m o d t ) \delta \equiv 0 \pmod t d0(modt) 以及 δ ≡ − c ( m o d q ) \delta \equiv -c \pmod q dc(modq),Last Commander δ \delta δ rush Q Q Q (not trivial under RNS, requiresRNS Basis Extension)
  3. 那么 c † = [ c + δ ] Q ∈ [ − Q / 2 , Q / 2 ) c^\dagger = [c+\delta]_{Q} \in [-Q/2,Q/2) c=[c+δ]Q[Q/2,Q/2) q q < /span>qDivision” (RNS subgroup q q The corresponding components of q are all zero), Lift it to Z \mathbb Z Z, the division result falls on [ − Q ′ / 2 , Q ′ / 2 ) [-Q'/2 ,Q'/2) [Q/2,Q/2), in this way “乘乘回原” Next change generation (RNS lower group Q ′ Q' Q The inverse element on the corresponding component, gcd ⁡ ( q , Q ′ ) = 1 \gcd(q,Q' ;)=1 gcd(q,Q)=1), we calculate c ′ = [ c  ⋅ q − 1 ] Q ′ c' = [c^ \dagger \cdot q^{-1}]_{Q'} c=[cq1]Q, which is exactly c † / q ∈ Z c^\dagger/q \in \mathbb Z c/qZ result (imitation) Q ′ Q' Q 目)
  4. Output c ′ ∈ R Q ′ c' \in \mathcal R_{Q'} cRQ, it encrypts the distorted message [ m ⋅ q − 1 ] t [m \cdot q^{-1}] _t [mq1]t, the noise is scaled approximately 1 / q 1/q 1/q 成为 v / q + v m s v/q+v_{ms} v/q+inms(注意 [ c † ⋅ q − 1 ] Q ′ [c^\dagger \cdot q^{-1}]_{Q'} [cq1]Q is equivalent to integer division. This scalar multiplication causes the noise to grow to q ​​− 1 q^{-1} q1 times, actually reduces the absolute size of the noise

We need to track the scaling factors of different ciphertexts in real time (simple modular reduction does not distort the message), and two ciphertexts must first be twisted to the same factor before being operated on.

Scaling for BFV

[HPS19] gives two scaling procedures for BFV, the former can be used for decryption and the latter is used for GHS key switching.

Simple scaling

输入: x ∈ Z Q x \in \mathbb Z_Q xWITHQ 的 RNS 表示 ( x 1 , ⋯   , x k ) (x_1,\cdots,x_k) (x1,,xk), any positive integer t t t(single precision integer)

输出: y = ⌊ t / Q ⋅ x ⌉ ∈ Z t y=\lfloor t/Q \cdot x\rceil \in \mathbb Z_t and=t/QxWITHt

Similar to the idea of ​​CRT Basis Extension, [ x ] Q [x]_Q [x]Q Heavy construction x x x,观察提取出可预计算的部分,
y = ⌊ t Q ⋅ x ⌉ = ⌊ t Q ⋅ ∑ i = 1 k x i ⋅ q i ∗ ⋅ q ~ i − u ⋅ t ⌉ = ⌊ ∑ i = 1 k x i ⋅ ( t q i ⋅ q ~ i ) ⌉ − u ⋅ t \begin{aligned} y &= \left\lfloor \dfrac{t}{Q} \cdot x \right\rceil = \left\lfloor \dfrac{t}{Q} \cdot \sum_{i=1}^k x_i \cdot q_i^* \cdot \tilde q_i - u \cdot t \right\rceil\\ &= \left\lfloor \sum_{i=1}^k x_i \cdot \left(\dfrac{t}{q_i} \cdot \tilde q_i\right) \right\rceil - u \cdot t\\ \end{aligned} and=Qtx=Qti=1kxiqiq~iint=i=1kxi(qitq~i)int
I am a constant in the calculation, the fraction isIntegerSumDecimalTwo parts,
t q ~ i q i = ω i + θ i , ω i ∈ Z t , θ i ∈ [ − 0.5 , 0.5 ) \dfrac{t\tilde q_i}{q_i } = \omega_{i}+\theta_{i},\,\, \omega_{i} \in \mathbb Z_{t},\,\, \theta_{i} \in [-0.5,0.5) < /span>qitq~i=ohi+ii,ohiWITHt,ii[0.5,0.5)
Streaming:

  1. Used precisionInteger command, calculation w = [ ∑ i x i ⋅ ω i ] t w= [\sum_i x_i \cdot \omega_{i}]_{t} In=[ixiohi]t
  2. Using precisionFloating point command, calculation v = ⌊ ∑ i x i ⋅ θ i ⌉ ∈ Z k v=\lfloor \sum_i x_i \cdot \theta_{i} \rceil \in \mathbb Z_{k} in=ixiiiWITHk
  3. 合并为 y = [ w + v ] t y=[w+v]_{t} and=[w+v]t

Similarly, there are errors in actual calculations: the decimal part is represented by floating point θ i ∗ = θ i + ϵ i , ∣ ϵ i ∣ < ϵ \theta_i^* =\theta_i+\epsilon_i, |\epsilon_i|<\epsilon ii=ii+ϵi,ϵi<ϵ (If using IEEE-754 double, the error scale is ϵ = 2 − 53 \epsilon=2^{-53} < /span>ϵ=253),计算出的 v ∗ = ⌊ ∑ i = 1 k x i ( ω i + θ i ∗ ) ⌉ v^*=\left\lfloor \sum_{i=1}^k x_i (\omega_{i}+\theta_{i}^*) \right\rceil in=i=1kxi(ωi+ii) 可能会和 v = ⌊ ∑ i = 1 k x i ( ω i + θ i ) ⌉ v=\left\lfloor \sum_{i=1}^k x_i (\omega_{i}+\theta_{i}) \right\rceil in=i=1kxi(ωi+ii) 对于、计误误为为 ∑ i x i ϵ i < ϵ / 2 ⋅ ∑ i q i \sum_i x_i \epsilon_{i} < \epsilon/2 \cdot \sum_i q_i ixiϵi<ϵ/2iqi,其中 x i = [ x ] q i ∈ [ − q i / 2 , q i / 2 ) x_i=[x]_{q_i} \in [-q_i/2,q_i/2) xi=[x]qi[qi/2,qi/2)

Suppose we constrain y = ⌊ t Q ⋅ x ⌉ y = \left\lfloor \frac{t}{Q} \cdot x \right\rceil and=Qtx 满足 y ( m o d Z ) ∈ [ − 1 / 4 , 1 / 4 ] y \pmod{\mathbb Z} \in [-1/4,1/4] and(modZ)[1/4,1/4] (the noise scale in the control ciphertext is less than Q / 4 t Q/ 4t Q/4t, but unusual Q / 2t Q/2t Q/2t), な么么过加积误误满足 ∣ ∑ i x i ϵ i ∣ < 1 / 4 |\sum_i x_i \epsilon_i| < 1/4 ixiϵi<1/4 (a floating point number with high enough precision), it can always be rounded correctly ( v = v ∗ v=v ^* in=in). MaybeIEEE-754 double is not precise enough and you need to use non-standard C/C++ long double

Complex scaling

输入: x ∈ Z P Q x \in \mathbb Z_{PQ} xWITHPQThe RNS of represents a positive integer t t t,满足 x ∈ [ − P Q / 2 t , P Q / 2 t ) x \in [-PQ/2t, PQ/2t) x[PQ/2t,PQ/2t) Fall较小范围

输出: y = ⌊ t / Q ⋅ x ⌉ ∈ Z Q y=\lfloor t/Q \cdot x\rceil \in \mathbb Z_Q and=t/QxWITHQ

Abstractly, this can be done in two steps,

  1. 利用 Simple scaling 过程,设置 Q ′ = P Q , t ′ = t P Q'=PQ, t'=tP Q=PQ,t=tP,获得 y ′ = ⌊ t ′ / Q ′ ⋅ x ⌉ = ⌊ t / Q ⋅ x ⌉ ∈ Z t P y' = \lfloor t'/Q' \cdot x\rceil = \lfloor t/Q \cdot x\rceil \in \mathbb Z_{tP} and=t/Qx=t/QxWITHtP,丢弃 t t Part of t (equivalent to simple modulo) obtains y ′ = ⌊ t / Q ⋅ x ⌉ ∈ [ − P / 2 , P / 2 ) y'=\lfloor t/Q \cdot x\rceil \in [-P/2,P/2) and=t/Qx[P/2,P/2)(以业 x x x 的电影小, y ′ y' and is the result of not taking modulo)
  2. Use RNS Basis Extension [ y ′ ] P [y'] _P [y]P Exhibition [ y ′ ] P Q [y']_{PQ} [y]PQ,丢弃 P P P part, out y = [ y ′ ] Q y=[y']_Q and=[y]Q

Step 1 uses t ′ t' t is a high-precision number. It needs to be decomposed by RNS first and then perform the Simple scaling process separately. However, we actually only need [ y ′ ] P [y']_{P} [y]P 而非 [ y ′ ] t P [y']_{tP} [y]tPPgcd(Q,t), there is actually a faster algorithm.

简记 Q i ∗ = Q / q i = q i ∗ P , P j = Q / p j = Q p j ∗ Q_i^*=Q/q_i=q_i^*P, P_j=Q/p_j=Qp_j^* Qi=Q/qi=qiP,Pj=Q/pj=Qpj,计算 Q ~ i = [ ( Q i ∗ ) − 1 ] q i , P ~ j = [ ( P j ∗ ) − 1 ] p j \tilde Q_i=[(Q_i^*)^{-1}]_{q_i}, \tilde P_j=[(P_j^*)^{-1}]_{p_j} Q~i=[(Qi)1]qi,P~j=[(Pj)1]pj,简记 x i = [ x ] q i , x j ′ = [ x ] p j x_i=[x]_{q_i}, x_j'=[x]_{p_j} xi=[x]qi,xj=[x]pj,那么
y ′ = ⌊ t ′ Q ′ ⋅ x ⌉ = ⌊ t Q ⋅ ( ∑ i = 1 k x i ⋅ Q i ∗ ⋅ Q ~ i + ∑ j = 1 l x j ′ ⋅ P j ∗ ⋅ P ~ j ) − u ⋅ t P ⌉ = ⌊ ∑ i = 1 k x i ⋅ ( t q i ⋅ Q ~ i P ) + ∑ j = 1 l x j ′ ⋅ ( t ⋅ P ~ j p j ∗ ) ⌉ − u ⋅ t P \begin{aligned} y' &= \left\lfloor \dfrac{t'}{Q'} \cdot x \right\rceil = \left\lfloor \dfrac{t}{Q} \cdot \left(\sum_{i=1}^k x_i \cdot Q_i^* \cdot \tilde Q_i + \sum_{j=1}^l x_j' \cdot P_j^* \cdot \tilde P_j\right) - u \cdot tP \right\rceil\\ &= \left\lfloor \sum_{i=1}^k x_i \cdot \left(\dfrac{t}{q_i} \cdot \tilde Q_iP\right) + \sum_{j=1}^l x_j' \cdot \left(t \cdot \tilde P_jp_j^*\right) \right\rceil - u \cdot tP\\ \end{aligned} and=Qtx=Qt(i=1kxiQiQ~i+j=1lxjPjP~j)intP=i=1kxi(qitQ~iP)+j=1lxj(tP~jpj)intP
[y]P 的 RNS 表示,
[ y ′ ] p j = [ ⌊ ∑ i = 1 k x i ⋅ ( t q i ⋅ Q ~ i P ) ⌉ + x j ′ ⋅ ( t ⋅ P ~ j p j ∗ ) ] p j [y']_{p_j} = \left[ \left\lfloor \sum_{i=1}^k x_i \cdot \left(\dfrac{t}{q_i} \cdot \tilde Q_iP\right) \right\rceil + x_j' \cdot \left(t \cdot \tilde P_jp_j^*\right) \right]_{p_j} [y]pj=[i=1kxi(qitQ~iP)+xj(tP~jpj)]pj
需要预计算
t Q ~ i P q i = ω i + θ i ,    ω i ∈ Z P ,    θ i ∈ [ − 0.5 , 0.5 ) \dfrac{t\tilde Q_iP}{q_i} = \omega_{i}+\theta_{i},\,\, \omega_{i} \in \mathbb Z_{P},\,\, \theta_{i} \in [-0.5,0.5) qitQ~iP=ohi+ii,ohiWITHP,ii[0.5,0.5)
General w i w_i Ini Decomposed into single-precision integers w i j : = [ w i ] p j , ∀ i ∈ [ k ] , ∀ j ∈ [ l ] w_{ij}:=[w_i]_ {p_j},\forall i\in [k],\forall j \in [l] Inij:=[wi]pj,i[k],j[l],另外预计算 λ j : = [ t P ~ j p j ∗ ] p j , ∀ j ∈ [ l ] \lambda_j:=[t\tilde P_jp_j^*]_{p_j}, \forall j \in [l] lj:=[tP~jpj]pj,j[l]

输入 ( x 1 , ⋯   , x k , x 1 ′ , ⋯   , x l ′ ) (x_1,\cdots,x_k,x_1',\cdots,x_l') (x1,,xk,x1,,xl), then the steps of step 1 are:

  1. Used floating point number command, calculation v = ⌊ ∑ i x i θ i ⌉ ∈ Z k v=\lfloor \sum_i x_i\theta_i \rceil \in \mathbb Z_k in=ixiiiWITHk, this is shared by
  2. Use integer instructions to calculate w j = [ ∑ i x i w i j + λ j x j ′ ] p j w_j=[\sum_i x_iw_{ij} + \lambda_jx_j']_{p_j} Inj=[ixiInij+ljxj]pj, the second term is accumulated ( m o d p j ) \pmod{p_j} (modpj) BasicDelete
  3. 合并为 [ y ′ ] p j = [ v + w j ] p j [y']_{p_j}=[v+w_j]_{p_j} [y]pj=[v+Inj]pj

Scaling between Arbitrary RNS Bases

[KPZ21] gives another implementation of Simple scaling,

输入: x ∈ Z Q x \in \mathbb Z_{Q} xWITHQThe RNS representation of is the same as Q Q Q Comparatively prime multiple-precision integers P P P

输出: ⌊ P / Q ⋅ [ x ] Q ⌉ ( m o d P ) \lfloor P/Q \cdot [x]_Q\rceil \pmod P P/Q[x]Q(modP)

In [BEHZ16], it roundingcan be written asinteger division ⌊ P Q ⋅ [ x ] Q ⌉ = P ⋅ [ x ] Q − [ P x ] Q Q \left\lfloor \dfrac{P}{Q} \ cdot [x]_Q \right\rceil = \dfrac{P \cdot[x]_Q - [Px]_Q}{Q} ,
QP[x]Q=QP[x]Q[Px]Q
Therefore it is equivalent to Z P \mathbb Z_P in WITHP乘以逆元
[ ⌊ P Q ⋅ [ x ] Q ⌉ ] P = [ − [ P x ] Q ] P ⋅ [ Q − 1 ] P \left[ \left\lfloor \dfrac{P}{Q} \cdot [x]_Q \right\rceil \right]_P = \Big[- [Px]_Q\Big]_P \cdot [Q^{-1}]_P [QP[x]Q]P=[[Px]Q]P[Q1]P
根据 CRT 组合公式,
[ P x ] Q = ∑ i = 1 k [ P x ] q i ⋅ [ q ~ i ] q i ⋅ q i ∗ − u ⋅ Q [Px]_Q = \sum_{i=1}^k [Px]_{q_i} \cdot [\tilde q_i]_{q_i} \cdot q_i^* - u \cdot Q [Px]Q=i=1k[Px]qi[q~i]qiqiinQ
Therefore, the calculation formula of the RNS representation of the final result is:
[ − [ P x ] Q ] p j ⋅ [ Q − 1 ] p j = [ u − ∑ i = 1 k [ P x ] q i ⋅ [ q ~ i ] q i ⋅ q i − 1 ] p j \Big[- [Px]_Q\Big]_{p_j} \cdot [Q^{- 1}]_{p_j} = \left[ u - \sum_{i=1}^k [Px]_{q_i} \cdot [\tilde q_i]_{q_i} \cdot q_i^{-1} \right ]_{p_j} [[Px]Q]pj[Q1]pj=[ui=1k[Px]qi[q~i]qiqi1]pj
Inside ∥ u ∥ ∞ ≤ k / 2 \|u\|_\infty \le k/2 uk/2, you can use [HPS19]'s floating point arithmetic

Key-Switch in RNS

Import s A s_A sA Encrypted ciphertext c t A = ( c 0 , c 1 ) ct_A=(c_0,c_1) ctA=(c0,c1), set s B s_B sB 加密的 s A s_A sA secret sentence k s A → B ks_{A \to B} ksAB
k s A → B : = ( k s 0 = [ a ⋅ s B + t e + s A ] Q , k s 1 = [ − a ] Q ) ks_{A \to B} := (ks_0=[a \cdot s_B+te+s_A]_Q, ks_1=[-a]_Q) ksAB:=(ks0=[asB+te+sA]Q,ks1=[a]Q)
Key switching is homomorphic linear decryption, abstractly described as c 0 + c 1 ⋅ E ( s A ) c_0+c_1 \cdot E(s_A) c0+c1E(sA),具体地:
c t B = c 0 ⋅ ( 1 , 0 ) + c 1 ⋅ k s A → B = ( [ c 0 + c 1 ⋅ k s 0 ] Q , [ c 1 ⋅ k s 1 ] Q ) \begin{aligned} ct_B &= c_0\cdot(1,0)+c_1 \cdot ks_{A \to B}\\ &= ([c_0+c_1 \cdot ks_0]_Q, [c_1 \cdot ks_1]_Q) \end{aligned} ctB=c0(1,0)+c1ksAB=([c0+c1ks0]Q,[c1ks1]Q)
Reproducibility is a special key switching: input ciphertext c t = ( c 0 , c 1 , c 2 ) ct=(c_0,c_1,c_2 ) ct=(c0,c1,c2), set s s s 加密的 s 2 s^2 s2's secret sentence r l k rlk rlk
r l k : = ( r l k 0 = [ a ⋅ s + t e + s 2 ] Q , r l k 1 = [ − a ] Q ) rlk := (rlk_0=[a \cdot s+te+s^2]_Q, rlk_1=[-a]_Q) rlk:=(rlk0=[as+te+s2]Q,rlk1=[a]Q)
Yuyu ( 0 , 1 ) (0,1) (0,1) is s s s's own ciphertext, reproducibility's abstract description is c 0 + c 1 ⋅ E ( s ) + c 2 ⋅ E ( s 2 ) c_0+c_1\cdot E(s)+c_2\cdot E(s^2) c0+c1E(s)+c2E(s2),具体地:
c t ′ = c 0 ⋅ ( 1 , 0 ) + c 1 ⋅ ( 0 , 1 ) + c 2 ⋅ r l k = ( [ c 0 + c 2 ⋅ r l k 0 ] Q , [ c 1 + c 2 ⋅ r l k 1 ] ) \begin{aligned} ct' &= c_0 \cdot(1,0)+c_1\cdot(0,1)+c_2 \cdot rlk\\ &= ([c_0+c_2 \cdot rlk_0]_Q, [c_1+c_2 \cdot rlk_1]) \end{aligned} ct=c0(1,0)+c1(0,1)+c2rlk=([c0+c2rlk0]Q,[c1+c2rlk1])
但是 c 1 c_1 c1The scale of is relative to the ciphertext modulus Q Q Q 过大,导入卼钥切换中 k s A → B ks_{A \to B} ksABThe noise is greatly increased. There are two ways to control noise, [BV11] and [GHS12], as well as a mixture of them.

Brakerski-Vaikuntanathan

[BV11] Adoptdigital decomposition technology, select radix- w w w, the number is l = ⌊ log ⁡ w Q ⌉ + 1 l=\lfloor \log_w Q\rceil+1 l=logwQ+1

  • 分解: D w , Q ( a ) = ( [ a ] w , [ ⌊ a / w ⌉ ] w , ⋯   , [ ⌊ a / w l − 1 ⌉ ] w ) ∈ R w l D_{w,Q}(a) = ([a]_w,[\lfloor a/w\rceil]_w,\cdots,[\lfloor a/w^{l-1}\rceil]_w) \in \mathcal R_w^l Dw,Q(a)=([a]w,[⌊a/w]w,,[⌊a/wl1]w)RInl
  • 幂次: P w , Q ( a ) = ( [ a ] Q , [ a w ] Q , ⋯   , [ a w l ] Q ) ∈ R Q l P_{w,Q}(a) = ([a]_Q,[aw]_Q,\cdots,[aw^l]_Q) \in \mathcal R_Q^l Pw,Q(a)=([a]Q,[aw]Q,,[awl]Q)RQl
  • 易知 ⟨ D ( a ) , P ( b ) ⟩ ≡ a b ( m o d Q ) \langle D(a),P(b)\rangle \equiv ab \pmod Q D(a),P(b)⟩ab(modQ)

Therefore, the key switching key is:
k s A → B B V : = ( k s 0 = [ a ⃗ ⋅ s B + t e ⃗ + P w , Q ( s A ) ] Q , k s 1 = [ − a ⃗ ] Q ) ∈ R Q l × 2 ks_{A \to B}^{BV} := (ks_0=[\vec a \cdot s_B+t\vec e+P_{ w,Q}(s_A)]_Q, ks_1=[-\vec a]_Q) \in \mathcal R^{l \times 2}_Q ksABBV:=(ks0=[a sB+tIt is +Pw,Q(sA)]Q,ks1=[a ]Q)RQl×2
The secret key switching procedure is:
c t B = ( [ c 0 + ⟨ D w , Q ( c 1 ) , k s 0   ] Q , [ ⟨ D w , Q ( c 1 ) , k s 1   ] Q ) ct_B = ([c_0+\langle D_{w,Q}(c_1),ks_0\rangle]_Q, [\langle D_{w,Q}(c_1),ks_1\rangle ]_Q) ctB=([c0+Dw,Q(c1),ks0]Q,[⟨Dw,Q(c1),ks1]Q)
However, the RNS system is not a digital system, and the above radix- w w w Decomposition cannot be performed naturally. [BEHZ16] Directly use each remainder ofRNS as the decomposition form of the element, let Q = q 1 ⋯ q k Q =q_1\cdots q_k Q=q1qk,简记 q i ∗ = Q / q i , q ~ i = ( q i ∗ ) − 1 ( m o d q i ) q_i^*=Q/q_i, \tilde q_i=(q_i^*)^{-1}\pmod{q_i} qi=Q/qi,q~i=(qi)1(modqi)

  • 分解: D Q ( a ) = ( [ a q ~ 1 ] q 1 , [ a q ~ 2 ] q 2 , ⋯   , [ a q ~ k ] q k ) ∈ R k D_{Q}(a) = ([a\tilde q_1]_{q_1},[a\tilde q_2]_{q_2},\cdots,[a\tilde q_k]_{q_k}) \in \mathcal R^k DQ(a)=([aq~1]q1,[aq~2]q2,,[aq~k]qk)Rk
  • 幂次: P Q ( a ) = ( [ a q 1 ∗ ] Q , [ a q 2 ∗ ] Q , ⋯   , [ a q k ∗ ] Q ) ∈ R Q k P_{Q}(a) = ([aq_1^*]_{Q},[aq_2^*]_{Q},\cdots,[aq_k^*]_{Q}) \in \mathcal R_Q^k PQ(a)=([aq1]Q,[aq2]Q,,[aqk]Q)RQk
  • Easy to verify, it also satisfies ⟨ D ( a ) , P ( b )   ≡ a b ( m o d Q ) \langle D(a),P(b)\rangle \equiv ab \pmod Q D(a),P(b)⟩ab(modQ)

Under RNS, the key switching key is:
k s A → B R N S − B V : = ( k s 0 = [ a ⃗ ⋅ s B + t e ⃗ + P Q ( s A ) ] Q , k s 1 = [ − a ⃗ ] Q ) ∈ R Q k × 2 ks_{A \to B}^{RNS-BV} := (ks_0=[\vec a \cdot s_B+t\vec e +P_{Q}(s_A)]_Q, ks_1=[-\vec a]_Q) \in \mathcal R^{k \times 2}_Q ksABRNSBV:=(ks0=[a sB+tIt is +PQ(sA)]Q,ks1=[a ]Q)RQk×2
The secret key switching procedure is:
c t B = ( [ c 0 + ⟨ D Q ( c 1 ) , k s 0   ] Q , [ ⟨ D Q ( c 1 ) , k s 1   ] Q ) ct_B = ([c_0+\langle D_{Q}(c_1), ks_0\rangle]_Q, [\langle D_{Q}(c_1), ks_1\rangle]_Q) ctB=([c0+DQ(c1),ks0]Q,[⟨DQ(c1),ks1]Q)
[HPS19] Further optimization, modified to

  • 分解: D Q ( a ) = ( [ a ] q 1 , [ a ] q 2 , ⋯   , [ a ] q k ) ∈ R k D_{Q}(a) = ([a]_{q_1},[a]_{q_2},\cdots,[a]_{q_k}) \in \mathcal R^k DQ(a)=([a]q1,[a]q2,,[a]qk)Rk
  • 幂次: P Q ( a ) = ( [ a q 1 ∗ q ~ 1 ] Q , [ a q 2 ∗ q ~ 2 ] Q , ⋯   , [ a q k ∗ q ~ k ] Q ) ∈ R Q k P_{Q}(a) = ([aq_1^*\tilde q_1]_{Q},[aq_2^*\tilde q_2]_{Q},\cdots,[aq_k^*\tilde q_k]_{Q}) \in \mathcal R_Q^k PQ(a)=([aq1q~1]Q,[aq2q~2]Q,,[aqkq~k]Q)RQk

Therefore [ c 1 ] Q [c_1]_Q [c1]Q is directly D ( c 1 ) D(c_1) D(c1), thus saving some multiplication operations.

Specific process and corresponding complexity:

Insert image description here

Gentry-Halevi-Smart

[GHS12] Use temporary expansion technique to select a sufficiently large P = p 1 ⋯ p l ≈ Q P=p_1\cdots p_l \approx Q P=p1plQ

Specify the equation:
k s A → B G H S : = ( k s 0 = [ a ⋅ s B + t e + P s A ] P Q , k s 1 = [ − a ] P Q ) ∈ R P Q 2 ks_{A \to B}^{GHS} := (ks_0=[a \cdot s_B+te+Ps_A]_{PQ}, ks_1=[-a]_{PQ}) \ in mathematical R^{2}_{PQ}ksABGHS:=(ks0=[asB+te+PsA]PQ,ks1=[a]PQ)RPQ2
The key switching procedure is:

  1. 先在 P Q PQ PQ 下计算 c 1 ⋅ E ( s A ) c_1 \cdot E(s_A) c1E(sA)
    c t B ′ = ( c 0 ′ = [ c 1 ⋅ k s 0 ] P Q , c 1 ′ = [ c 1 ⋅ k s 1 ] P Q ) ct_B' = (c_0'=[c_1 \cdot ks_0]_{PQ}, c_1'=[c_1 \cdot ks_1]_{PQ}) ctB=(c0=[c1ks0]PQ,c1=[c1ks1]PQ)

  2. Then calculate c t B ′ ct_B' ctB Division P P P Distance (complete) [ δ ] t = 0 [\delta]_t=0 [δ]t=0 [ c t B ′ ] P = [ δ ] P [ct_B']_P=[\delta]_P [ctB]P=[δ]P),
    δ = ( δ 0 = t [ − t − 1 c 0 ′ ] P , δ 1 = t [ − t − 1 c 1 ′ ] P ) ∈ R P Q 2 \delta = (\delta_0=t[-t^{-1}c_0']_P, \delta_1=t[-t^{-1}c_1']_P) \in \mathcal R^{2}_{PQ} d=(δ0=t[t1c0]P,d1=t[t1c1]P)RPQ2

  3. c t B ′ + δ ct_B'+\delta ctB+δ P Q PQ PQ Zoom to Q Q Q(excluding P P P,fix the free range),solve
    c t B = ( [ c 0 + c 0 ′ + δ 0 P Q , [ c 1 + c 1 ′ + δ 1 P ] Q ) ct_B = \left( \left[c_0+\dfrac{c_0'+\delta_0}{P}\right]_Q, \left[c_1+\dfrac {c_1'+\delta_1}{P}\right]_Q\right) ctB=([c0+Pc0+d0]Q,[c1+Pc1+d1]Q)

Executed under RNS,

  1. [ c 1 ] Q [c_1]_Q [c1]Q Extended usingRNS Basis Extension to [ [ c 1 ] Q + u Q ] P [ [c_1]_Q+uQ]_P [[c1]Q+uQ]P, inside ∥ u ∥ ∞ ≤ k / 2 \|u\|_\infty \le k/2 uk/2 Yes CRT synthesis time Q Q Q-overflow
  2. 计算 [ c 1 ] P Q [c_1]_{PQ} [c1]PQ k s A → B G H S ks_{A \to B}^{GHS} ksABGHSThe product of gives [ c t B ′ ] P Q [ct_B']_{PQ} [ctB]PQ
  3. [ − t − 1 c t B ′ ] P [-t^{-1}ct_B']_P [t1ctB]P 利用 RNS Basis Extension 扩展到 [ [ − t − 1 c t B ′ ] P + u ′ P ] Q [[-t^{-1}ct_B']_P+u'P]_Q [[t1ctB]P+inP]Q, inside ∥ u ′ ∥ ∞ ≤ l / 2 \|u'\|_\infty \le l/2 ul/2
  4. We calculated P Q PQ PQ Approximate value of the lower gap δ ′ = δ + t u ′ P \delta'=\delta+tu'P d=d+tuP,再利用 Madulus-Switching / Scaling,计算出 [ c t B ] Q [ct_B]_Q [ctB]Q

其中的 u , u ′ u,u' u,in can be eliminated by the techniques of [BEHZ16] and [HPS19], but here they are both small and only make a negligible contribution to the noise growth.

Specific process and corresponding complexity:

Insert image description here

Hybrid

The disadvantage of BV Key-Switch is: the ciphertext is expanded l l l times, a larger number of NTTs are required. The disadvantage of GHS Key-Switch is: the modulus is increased P P P times, in order to compensate for the loss of safety, either the dimension is expanded twice or the number of multiplication layers is reduced by half. [GHS12] proposed that the two can be mixed to achieve tradeoff performance.

Generally speaking, the hybrid scheme performs better in terms of efficiency and noise control. Use a relatively large radix- w w w, usage number l = ⌊ log ⁡ w Q ⌉ + 1 l=\lfloor \log_w Q\rceil+1 l=logwQ+1 is small, and a smaller scale P ≈ l w / 2 P \approx lw/2 Plw/2
k s A → B H y b r i d = ( [ a ⃗ ⋅ s B + t e ⃗ + P ⋅ P w , Q ( s A ) ] P Q , [ − a ⃗ ] P Q ) ks_{A \to B}^{Hybrid} = ([\vec a \cdot s_B + t\vec e + P\cdot P_{w,Q}(s_A)]_{PQ}, [-\vec a]_{PQ}) ksABHybrid=([a sB+tIt is +PPw,Q(sA)]PQ,[a ]PQ)
The calculation process is:

  1. 输入 c t A = ( c 0 , c 1 ) ∈ R Q 2 ct_A=(c_0,c_1) \in \mathcal R_Q^2 ctA=(c0,c1)RQ2,decompose c 1 c_1 c1 D w , Q ( c 1 ) ∈ R l D_{w,Q}(c_1) \in \mathcal R^l Dw,Q(c1)Rl
  2. 计算 c t B ′ = ( [ ⟨ D w , Q ( c 1 ) , k s 0 ⟩ ] P Q , [ ⟨ D w , Q ( c 1 ) , k s 1 ⟩ ] P Q ) ct_B' = ([\langle D_{w,Q}(c_1), ks_0\rangle]_{PQ}, [\langle D_{w,Q}(c_1), ks_1\rangle]_{PQ}) ctB=([⟨Dw,Q(c1),ks0]PQ,[⟨Dw,Q(c1),ks1]PQ)
  3. Use mode switching to divide it by P P P Zoom to Q Q Q c 1 + ( c 1 ′ + δ 1 ) / P ] Q ) ct_B=([c_0+(c_0'+\delta_0)/P]_Q, [c_1+(c_1'+\delta_1)/P]_Q ) ctB=([c0+(c0+d0)/P]Q,[c1+(c1+d1)/P]Q)

For RNS systems, using a similar decomposition of [BEHZ16], Q Q Q 分为 Q 0 , ⋯   , Q d Q_0,\cdots,Q_d Q0,,Qd,each Q i Q_i Qi 包含 α ≈ k / d \alpha\approx k/d ak/d Small prime number, simple Q i ∗ = Q / Q i Q_i^*=Q/Q_i Qi=Q/Qi Q ~ i = [ ( Q i ∗ ) − 1 ] Q i \tilde Q_i=[(Q_i^*)^{-1}]_{Q_i} Q~i=[(Qi)1]Qi

The decomposition function is D ~ Q ( a ) = ( [ a ] ​​Q 1 , ⋯ , [ a ] ​​Q d ) ∈ R d \tilde D_Q(a)=( [a]_{Q_1},\cdots,[a]_{Q_d}) \in \mathcal R^d D~Q(a)=([a]Q1,,[a]Qd)Rd,幂次函数定义为
P ~ Q ( a ) = ( [ s B Q i ∗ Q ~ i ] Q , ⋯   , [ s B Q i ∗ Q ~ i ] Q ) ∈ R Q d \tilde P_Q(a) = \left( \left[s_B Q_i^*\tilde Q_i\right]_{Q}, \cdots, \left[s_B Q_i^*\tilde Q_i\right]_{Q} \right) \in \mathcal R^d_Q P~Q(a)=([sBQiQ~i]Q,,[sBQiQ~i]Q)RQd
Then, the key switching key is:
k s A → B R N S − H y b r i d = ( [ a ⃗ ⋅ s B + t e ⃗ + P ⋅ P ~ Q ( s B ) ] P Q , [ − a ⃗ ] P Q ) ks_{A\to B}^{RNS-Hybrid} = ([\vec a \cdot s_B + t\vec e + P \cdot \tilde P_Q(s_B)]_ {PQ}, [-\vec a]_{PQ}) ksABRNSHybrid=([a sB+tIt is +PP~Q(sB)]PQ,[a ]PQ)
The calculation step is the appropriate combination of RNS-BV and RNS-GHS,

  1. decompose c 1 c_1 c1 D ~ Q ( c 1 ) \tilde D_Q(c_1) D~Q(c1),并扩到到 P Q PQ PQ
  2. P Q PQ Calculate on PQ c t B ′ ct_B' ctB
  3. Zoom to Q Q Q,再加上 c 0 c_0 c0,得到 c t B ct_B ctB

Specific process and corresponding complexity:

Insert image description here

Complexities and Size

GHS selection: BFV’s k ≈ l k \approx l kl,BGV 的 k ′ ≈ l ′ k' \approx l' kl

Hybrid 选取:BFV 的 α ≈ k , d α ≈ l \alpha \approx k, d\alpha \approx l ak,dαl,BGV 的 α ′ ≈ k ′ , d α ′ ≈ l ′ \alpha' \approx k', d\alpha' \approx l' ak,dαl

The complexity is:

Insert image description here

Guess you like

Origin blog.csdn.net/weixin_44885334/article/details/134808843