基于LWE,采用了最大比特编码,把消息编码到了高位,无需模交换,模数可以任意形式(只要满足大小,可以设置为2的幂次来简化运算),密钥分布没有限制。
由于所有运算都是在整数上面,所以运算速度会比BGV慢,但是又因为更优秀的噪声控制,会使得电路深度更深。
Regev的公钥加密方案
本方案是基于这个搭建的,故在此介绍一下,和Regev09里的基本一致,只是表达形式不同。
注意这里没有限制
q
q
q一定是奇数或者素数,另外加密的时候对消息
m
m
m采用了最大比特编码,也就是消息放到了高位上避免与噪声混淆。
向量分解以及密钥交换
向量分解
这里的向量分解也就是利用到以前文章提过的BitDecomp和Powersof2函数,故不再解释,可以参看前面BGV和GSW方案中的描述。
下标
q
q
q经常被省略。
密钥交换
这里的密钥交换函数也和BGV方案中的很类似,功能都是把一个密钥下的密文转换成另一个密钥下的密文。值得注意的是,这里的噪声不是
2
e
2e
2e,而是
e
e
e。
另外第一个
SwitchKeyGen
\operatorname{SwitchKeyGen}
SwitchKeyGen函数中的
P
s
:
t
\mathbf P_{\mathbf s:\mathbf t}
Ps:t就是BGV中同一个函数诞生的矩阵
τ
s
1
→
s
2
=
B
\tau_{\mathbf{s}_{1} \rightarrow \mathbf{s}_{2}}=\mathbf{B}
τs1→s2=B,不同的是,没有把
Powerof2(s)
\operatorname{Powerof2(s)}
Powerof2(s)叠加到第一列,而是类似加密明文一样的加密它。(好吧,其实基本上一样的)
验证一下正确性:
⟨
c
t
,
(
1
,
t
)
⟩
=
BitDecomp
(
c
s
)
⋅
P
s
:
t
T
⋅
(
1
,
t
)
=
BitDecomp
(
c
s
)
⋅
[
b
s
:
t
,
−
A
s
:
t
]
⋅
[
1
,
t
]
=
BitDecomp
(
c
s
)
⋅
(
A
s
:
t
⋅
t
+
e
s
:
t
+
Powersof2
(
s
)
−
A
s
:
t
⋅
t
)
=
⟨
BitDecomp
(
c
s
)
,
e
s
:
t
⟩
+
⟨
BitDecomp
(
c
s
)
,
Powersof2
(
s
)
⟩
=
⟨
BitDecomp
(
c
s
)
,
e
s
:
t
⟩
+
⟨
c
s
,
s
⟩
\begin{aligned} \left\langle\mathbf{c}_{t}, \mathbf{(1,t)}\right\rangle &=\operatorname{BitDecomp}\left(\mathbf{c}_{s}\right) \cdot \mathbf P_{\mathbf s:\mathbf t}^{T} \cdot \mathbf{(1,t)} \\ &=\operatorname{BitDecomp}\left(\mathbf{c}_{s}\right) \cdot [\mathbf b_{\mathbf s:\mathbf t},-\mathbf A_{\mathbf s:\mathbf t}] \cdot [1,\mathbf {t}]\\ &=\operatorname{BitDecomp}\left(\mathbf{c}_{s}\right) \cdot(\mathbf A_{\mathbf s:\mathbf t} \cdot \mathbf t+\mathbf{e}_{\mathbf s:\mathbf t}+\operatorname{Powersof2} (\mathbf{s})-\mathbf A_{\mathbf s:\mathbf t} \cdot \mathbf t)\\ &=\left\langle\operatorname{BitDecomp}\left(\mathbf{c}_{s}\right), \mathbf{e}_{\mathbf s:\mathbf t}\right\rangle+\left\langle\operatorname{BitDecomp}\left(\mathbf{c}_{s}\right), \operatorname{Powersof2} \left(\mathbf{s}\right)\right\rangle \\ &=\left\langle\operatorname{BitDecomp}\left(\mathbf{c}_{s}\right), \mathbf{e}_{\mathbf s:\mathbf t}\right\rangle+\left\langle\mathbf{c}_{s}, \mathbf{s}\right\rangle \end{aligned}
⟨ct,(1,t)⟩=BitDecomp(cs)⋅Ps:tT⋅(1,t)=BitDecomp(cs)⋅[bs:t,−As:t]⋅[1,t]=BitDecomp(cs)⋅(As:t⋅t+es:t+Powersof2(s)−As:t⋅t)=⟨BitDecomp(cs),es:t⟩+⟨BitDecomp(cs),Powersof2(s)⟩=⟨BitDecomp(cs),es:t⟩+⟨cs,s⟩
同态加密方案
q = q ( n ) q = q(n) q=q(n)为一个整数函数, L = L ( n ) L = L(n) L=L(n)为多项式, χ = χ ( n ) \chi = \chi(n) χ=χ(n)为 Z \mathbb Z Z上的分布
-
SI-HE.Keygen ( 1 L , 1 n ) : \operatorname{SI-HE.Keygen}(1^L,1^n): SI-HE.Keygen(1L,1n):
密钥生成过程就是先生成 L + 1 L+1 L+1个私钥链,生成初始的公钥,计算出每一轮私钥的乘积作备用,接着生成每一轮密钥交换的交换密钥作为评估密钥集合。这样通过密钥生成算法就获得了初始加密公钥 p k = P 0 pk= \operatorname{P}_0 pk=P0、评估密钥链(用于密钥交换) e v k evk evk和最终解密的私钥 s k = s L sk=s_L sk=sL -
SI-HE.Enc p k ( m ) : \operatorname{SI-HE.Enc}_{pk}(m): SI-HE.Encpk(m):直接使用 c ← Regev.Enc p k ( m ) \mathbf c \leftarrow \operatorname{Regev.Enc}_{pk}(m) c←Regev.Encpk(m)
-
SI-HE.Eval e v k ( ⋅ ) : \operatorname{SI-HE.Eval}_{evk}(\cdot): SI-HE.Evalevk(⋅):同态运算包含有限域 G F ( 2 ) GF(2) GF(2)上的加法和乘法,这里有个显然的约定就是电路第 i i i级输入(同态运算输入的当然是上一级的密文形式)可以用 s i − 1 \mathbf s_{i-1} si−1来解密,同态运算输入结果自然就可以用 s i \mathbf s_i si来解密了。
-
SI-HE.Add e v k ( c 1 , c 2 ) : \operatorname{SI-HE.Add}_{evk}(\mathbf c_1,\mathbf c_2): SI-HE.Addevk(c1,c2):
首先来看看加法,这里加法和以往的加法不太一样,采用了先相加再与一个特殊向量求张积,显然能这个乘法张积不会改变加法的大小,前面提到了,作者想让同态运算的结果用 s i \mathbf s_i si来解密,但是这里显然如果只单纯把密文相加的话,解密的密钥就是 s i − 1 \mathbf s_{i-1} si−1而不是 s i \mathbf s_i si。所以这里加了一个不会改变加法和密文的乘法运算生成一个“中间密文”来达成目的。 -
SI-HE.Mult e v k ( c 1 , c 2 ) : \operatorname {SI-HE.Mult}_{evk}(\mathbf c_1,\mathbf c_2): SI-HE.Multevk(c1,c2):
首先假定两个密文都是密钥 s i − 1 \mathbf s_{i-1} si−1加密的密文,这里对密文张积的处理是直接乘了一个 2 q \frac 2q q2,等于是把BGV中模交换过程近似的(这里没有 Scale ( ) \operatorname {Scale}() Scale()取最近整数向量过程)放到了乘法运算里面(BGV中是先做乘法运算然后进行一个内嵌模交换的 Refresh ( ) \operatorname {Refresh}() Refresh()过程),最后输出密钥交换后的密文。
-
-
SI-HE.Dec s k ( c ) : \operatorname{SI-HE.Dec}_{sk}(\mathbf c): SI-HE.Decsk(c):直接使用 m ← Regev.Dec s k ( c ) m \leftarrow \operatorname{Regev.Dec}_{sk}(\mathbf c) m←Regev.Decsk(c)
噪声分析
大致如图
对Regev的加密方案,有
<
c
,
s
>
=
q
/
2
⋅
m
+
e
+
q
I
<\mathbf c,\mathbf s> = q/2 \cdot m +e+qI
<c,s>=q/2⋅m+e+qI这里
I
I
I是一个整数(没有模运算),密钥向量也是整数。现在考虑一下小数密文
c
~
=
c
/
q
\tilde{\mathbf c} = \mathbf c/q
c~=c/q,得到解密结果
<
c
~
,
s
>
=
1
/
2
⋅
m
+
e
~
+
I
<\tilde{\mathbf c}, s>=1 / 2 \cdot m+\tilde{e}+I
<c~,s>=1/2⋅m+e~+I,由于除以了一个
q
q
q,那么当前密文元素的取值范围应该是
(
−
1
/
2
,
1
/
2
)
(-1/2,1/2)
(−1/2,1/2)。此外这里的
I
I
I有一个界限就是
∣
∣
s
∣
∣
1
=
l
1
(
s
)
||s||_1 = l_1(s)
∣∣s∣∣1=l1(s)(一阶范数)这个界限来源于除法过后取整所诞生的误差,也就是BGV中模交换的误差。
证明如下,(其实就是把BGV中的模
p
p
p变成了模1)(下面的
c
′
\mathbf c'
c′就是
c
~
\tilde{\mathbf c}
c~)
[
⟨
c
′
,
s
⟩
]
1
=
⟨
c
′
,
s
⟩
−
k
=
⟨
c
′
,
s
⟩
−
k
q
⋅
1
q
=
⟨
c
′
,
s
⟩
+
1
q
⋅
(
[
⟨
c
,
s
⟩
]
q
−
⟨
c
,
s
⟩
)
=
⟨
c
′
,
s
⟩
−
1
q
⟨
c
,
s
⟩
+
1
q
[
⟨
c
,
s
⟩
]
q
=
1
q
⋅
[
⟨
c
,
s
⟩
]
q
+
⟨
c
′
−
(
1
q
)
c
,
s
⟩
<
(
1
q
)
⋅
∣
[
⟨
c
,
s
⟩
]
q
∣
+
ℓ
1
(
s
)
\begin{aligned} [\langle \mathbf c',\mathbf s\rangle]_1 =\langle \mathbf c',\mathbf s\rangle-k &=\langle \mathbf c',\mathbf s\rangle-kq\cdot \frac 1q \\ &= \langle \mathbf c',\mathbf s\rangle+\frac 1q\cdot ([\langle\mathbf c,\mathbf s\rangle]_q-\langle\mathbf c,\mathbf s\rangle)\\ &=\langle \mathbf c',\mathbf s\rangle - \frac 1q \langle\mathbf c,\mathbf s\rangle + \frac 1q [\langle\mathbf c,\mathbf s\rangle]_q\\ &=\frac 1q\cdot [\langle\mathbf c,\mathbf s\rangle]_q+\langle\mathbf c'-(\frac 1q)\mathbf c,\mathbf s\rangle \\ &<(\frac 1q)\cdot |[\langle\mathbf c,\mathbf s\rangle]_q|+\ell_1(\mathbf s) \end{aligned}
[⟨c′,s⟩]1=⟨c′,s⟩−k=⟨c′,s⟩−kq⋅q1=⟨c′,s⟩+q1⋅([⟨c,s⟩]q−⟨c,s⟩)=⟨c′,s⟩−q1⟨c,s⟩+q1[⟨c,s⟩]q=q1⋅[⟨c,s⟩]q+⟨c′−(q1)c,s⟩<(q1)⋅∣[⟨c,s⟩]q∣+ℓ1(s)
现在来看看乘法
c
m
u
l
t
=
2
⋅
c
1
⊗
c
2
\mathbf c_{mult} = 2 \cdot \mathbf c_1 \otimes \mathbf c_2
cmult=2⋅c1⊗c2,使用张量密钥解密后,
<
2
c
1
⊗
c
2
,
s
⊗
s
>
=
2
<
c
1
,
s
>
⋅
<
c
2
,
s
>
=
2
⋅
(
1
2
m
1
+
e
1
+
I
1
)
⋅
(
1
2
m
2
+
e
2
+
I
2
)
=
1
2
m
1
m
2
+
2
(
e
1
I
2
+
e
2
I
1
)
+
2
e
1
e
2
+
e
1
m
2
+
e
2
m
1
+
(
m
1
I
2
+
m
2
I
1
+
2
I
1
I
2
)
∈
Z
\begin{aligned} <2\mathbf c_1 \otimes \mathbf c_2,\mathbf s \otimes \mathbf s> &= 2<\mathbf c_1,\mathbf s>\cdot<\mathbf c_2,\mathbf s> \\ &= 2 \cdot (\frac12m_1+e_1+I_1)\cdot(\frac12m_2+e_2+I_2) \\ &= \frac12m_1m_2+2(e_1I_2+e_2I_1)+2e_1e_2+e_1m_2+e_2m_1+(m_1I_2+m_2I_1+2I_1I_2) \in \mathbb Z \end{aligned}
<2c1⊗c2,s⊗s>=2<c1,s>⋅<c2,s>=2⋅(21m1+e1+I1)⋅(21m2+e2+I2)=21m1m2+2(e1I2+e2I1)+2e1e2+e1m2+e2m1+(m1I2+m2I1+2I1I2)∈Z
以前的噪声增长主要是看两个噪声乘积,现在对于两个小密文
e
1
e
2
e_1e_2
e1e2的噪声乘积自然是非常小的,主要的噪声误差在于后面。假定
ϵ
=
B
/
q
\epsilon = B/q
ϵ=B/q,
B
B
B为噪声上限,那么
e
1
e
2
=
ϵ
2
≪
ϵ
e_1e_2 = \epsilon ^2 \ll \epsilon
e1e2=ϵ2≪ϵ、
e
1
m
2
+
e
2
m
1
≤
2
ϵ
e_1m_2+e_2m_1 \le 2\epsilon
e1m2+e2m1≤2ϵ,那么主要的误差就在
2
(
e
1
I
2
+
e
2
I
1
)
2(e_1I_2+e_2I_1)
2(e1I2+e2I1),然而
I
I
I的界限是
∣
∣
s
∣
∣
1
||s||_1
∣∣s∣∣1,所以需要减小私钥的范数们也就是二进制化。二进制化后,私钥的范数至多就是它的维度们也就是
O
(
n
⋅
log
q
)
=
O
(
p
o
l
y
(
n
)
)
O(n \cdot \log q) = O(poly(n))
O(n⋅logq)=O(poly(n))。
参考
同态加密(十):Bra12:经典GapSVP无模切换全同态加密
Zvika Brakerski. Fully Homomorphic Encryption without Modulus Switching from Classical GapSVP. IACR Cryptology ePrint Archive, 2012:78, 2012.
全同态加密:BFV