diff --git "a/notes-Chinese/10 \345\257\206\347\240\201\345\255\246\345\215\217\350\256\256\345\212\250\347\211\251\345\233\255.md" "b/notes-Chinese/10 \345\257\206\347\240\201\345\255\246\345\215\217\350\256\256\345\212\250\347\211\251\345\233\255.md" index ceabc92..f765eb4 100644 --- "a/notes-Chinese/10 \345\257\206\347\240\201\345\255\246\345\215\217\350\256\256\345\212\250\347\211\251\345\233\255.md" +++ "b/notes-Chinese/10 \345\257\206\347\240\201\345\255\246\345\215\217\350\256\256\345\212\250\347\211\251\345\233\255.md" @@ -96,7 +96,7 @@ - 加密:按照普通的Elgamal加密方案加密$(c_1, c_2) = (g^y, h^y \cdot m)$,$y$为新的随机数; - 解密:秘密持有者 $i$用自己的小秘密来解密,输出 $d_i = c_1^{s_i}$ 和一个关于 $\log_gh_i = \log_{c_1} d_i$ 的零知识证明(后面会介绍); - 这里秘密持有者利用自己的小秘密来实现解密,但不泄漏小秘密;同时,证明自己是秘密持有者; - - 解密出消息 $ m = c_2/\Pi_i d_i^{\lambda_i} $,因为$c_2/\Pi_i d_i^{\lambda_i} = c_2/\Pi_i c_1^{s_i\cdot \lambda_i} = c_2/c_1^{\Sigma_i s_i\cdot \lambda_i} = c_2/c_1^s=m$。 + - 解密出消息 $m = c_2/\Pi_i d_i^{\lambda_i}$,因为$c_2/\Pi_i d_i^{\lambda_i} = c_2/\Pi_i c_1^{s_i\cdot \lambda_i} = c_2/c_1^{\Sigma_i s_i\cdot \lambda_i} = c_2/c_1^s=m$。 20. 承诺方案 - 互联网上掷硬币:利用哈希函数实现对承诺的绑定(binding),即信息和承诺一一对应,承诺后不能改变信息;和隐藏(hiding),即承诺本身不泄漏信息; - 掷硬币并对结果做出承诺:随机选择一个比特$b$为掷硬币结果,将$h = \mathsf{Hash}(b\|r)$作为承诺发送给对方;其中,$r$为随机串;这个承诺具有绑定和隐藏的功能; diff --git "a/notes-Chinese/2 \345\256\214\347\276\216\344\277\235\345\257\206.md" "b/notes-Chinese/2 \345\256\214\347\276\216\344\277\235\345\257\206.md" index 92caa5c..89fef47 100644 --- "a/notes-Chinese/2 \345\256\214\347\276\216\344\277\235\345\257\206.md" +++ "b/notes-Chinese/2 \345\256\214\347\276\216\344\277\235\345\257\206.md" @@ -56,8 +56,8 @@ - 这个从之前例子中可以体会到,无论是什么明文被加密,密文出现的概率不变。 - 从右到左证明: - 两边同时乘以$\Pr[M=m]/\Pr[C=c]$,得到 - - $ \Pr[C=c | M=m] \cdot \Pr[M=m] / \Pr[C=c] = \Pr[M=m]$ - - 应用贝叶斯定理,左边等于 $ \Pr[M=m | C=c] \cdot \Pr[C=c] / \Pr[C=c] = \Pr[M=m | C=c]$ + - $\Pr[C=c | M=m] \cdot \Pr[M=m] / \Pr[C=c] = \Pr[M=m]$ + - 应用贝叶斯定理,左边等于 $\Pr[M=m | C=c] \cdot \Pr[C=c] / \Pr[C=c] = \Pr[M=m | C=c]$ - 得到完美保密定义:$\Pr[M=m \| C=c] = \Pr[M=m]$ - 从左到右证明略。 - 从另一个方向思考,在完美保密中,密文出现概率根据明文概率分布和密钥概率分布以及加密算法可以预先计算。给定任意明文,对加密结果的预期与预先计算结果是一样。 diff --git "a/notes-Chinese/3.1 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247-\347\254\254\344\270\200\351\203\250\345\210\206.md" "b/notes-Chinese/3.1 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247-\347\254\254\344\270\200\351\203\250\345\210\206.md" index 8c772ff..b992e8d 100644 --- "a/notes-Chinese/3.1 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247-\347\254\254\344\270\200\351\203\250\345\210\206.md" +++ "b/notes-Chinese/3.1 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247-\347\254\254\344\270\200\351\203\250\345\210\206.md" @@ -16,7 +16,7 @@ 为什么相对于完美保密,要放松对安全的需求。考虑之前的不可区分实验, - 为了对抗蛮力攻击,需要限定敌手的能力;因为只要给了充足的时间来遍历$|\mathcal{K}|$,蛮力攻击一定会成功; - - 为了对抗随机猜测,需要允许小到可忽略的**(negligible)**成功概率;因为瞎猜也有$1/|\mathcal{K}|$概率成功; + - 为了对抗随机猜测,需要允许小到可忽略的 **(negligible)** 成功概率;因为瞎猜也有$1/|\mathcal{K}|$概率成功; 5. 具体法与渐进法 @@ -116,7 +116,7 @@ 19. 真实案例 - C语言的`random()` - - Netscape早期版本的漏洞https://people.eecs.berkeley.edu/~daw/papers/ddj-netscape.html + - Netscape早期版本的漏洞[https://people.eecs.berkeley.edu/~daw/papers/ddj-netscape.html](https://people.eecs.berkeley.edu/~daw/papers/ddj-netscape.html) - 从这两个例子可以看出来,输出都是可预测的。 20. 关于PRG的一些问题 diff --git "a/notes-Chinese/3.2 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247 \347\254\254\344\272\214\351\203\250\345\210\206.md" "b/notes-Chinese/3.2 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247 \347\254\254\344\272\214\351\203\250\345\210\206.md" index a2c7132..f88acfa 100644 --- "a/notes-Chinese/3.2 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247 \347\254\254\344\272\214\351\203\250\345\210\206.md" +++ "b/notes-Chinese/3.2 \347\247\201\351\222\245\345\212\240\345\257\206\344\270\216\344\274\252\351\232\217\346\234\272\346\200\247 \347\254\254\344\272\214\351\203\250\345\210\206.md" @@ -50,7 +50,7 @@ - $\Pi$ 是**窃听者出现时不可区分的多重加密方案**,如果任意PPT的敌手$\mathcal{A}$, 存在可忽略的函数$\mathsf{negl}$ 使得 - $ \Pr\left[\mathsf{PrivK}^{\mathsf{mult}}_{\mathcal{A},\Pi}(n)=1\right] \le \frac{1}{2} + \mathsf{negl}(n).$ + $\Pr\left[\mathsf{PrivK}^{\mathsf{mult}}_{\mathcal{A},\Pi}(n)=1\right] \le \frac{1}{2} + \mathsf{negl}(n).$ - 根据这个定义,来分析迄今学习的密码学方案是否是多重加密不可区分的? @@ -84,7 +84,7 @@ - $\Pi$ 是CPA不可区分加密方案 (CPA安全的),如果任意概率多项式时间算法$\mathcal{A}$,存在可忽略的函数$\mathsf{negl}$使得, - $ \Pr\left[\mathsf{PrivK}^{\mathsf{cpa}}_{\mathcal{A},\Pi}(n)=1\right] \le \frac{1}{2} + \mathsf{negl}(n)$ + $\Pr\left[\mathsf{PrivK}^{\mathsf{cpa}}_{\mathcal{A},\Pi}(n)=1\right] \le \frac{1}{2} + \mathsf{negl}(n)$ - 定理:CPA安全也是多重加密安全的。证明略。直觉上,CPA敌手比多重加密敌手更强大。 @@ -140,15 +140,15 @@ - 当有相同随机串时,根据$r$可以得到$f(r_c)$,$m_b=f(r_c)\oplus s$,但这种情况发生的概率$q(n)/2^n$是可忽略的; - 当没有相同随机串时,输出是随机串,相当于一次一密,成功概率=1/2; - - $ \Pr[D^{F_k(\cdot)}(1^n)=1] = \Pr[\mathsf{PrivK}_{\mathcal{A},\Pi}^{\mathsf{cpa}}(n) = 1] = \frac{1}{2} + \varepsilon(n). $ - - $ \Pr[D^{f(\cdot)}(1^n)=1] = \Pr[\mathsf{PrivK}_{\mathcal{A},\tilde{\Pi}}^{\mathsf{cpa}}(n) = 1] = \Pr[\mathsf{Break}] \le \frac{1}{2} + \frac{q(n)}{2^n}. $ + - $\Pr[D^{F_k(\cdot)}(1^n)=1] = \Pr[\mathsf{PrivK}_{\mathcal{A},\Pi}^{\mathsf{cpa}}(n) = 1] = \frac{1}{2} + \varepsilon(n)$ + - $\Pr[D^{f(\cdot)}(1^n)=1] = \Pr[\mathsf{PrivK}_{\mathcal{A},\tilde{\Pi}}^{\mathsf{cpa}}(n) = 1] = \Pr[\mathsf{Break}] \le \frac{1}{2} + \frac{q(n)}{2^n}$ - $\Pr[D^{F_k(\cdot)}(1^n)=1] - \Pr[D^{f(\cdot)}(1^n)=1] \ge \varepsilon(n) - \frac{q(n)}{2^n}.$ 根据伪随机函数定义,$\varepsilon(n)$ 是可忽略的. - 小结:通过规约将$\mathcal{A}$的不可区分实验成功的概率与$D$的区分器实验输出1的概率建立等式;分析输入真随机函数预言机时$D$输出1的概率(即不可区分实验成功概率)是1/2+一个可忽略函数;根据PRF的定义,输入伪随机函数预言机时$D$输出1的概率(1/2+$\varepsilon(n)$)与输入真随机函数预言机时$D$输出1的概率(1/2)的差异时可忽略的。 19. CPA安全例题 - $\mathsf{Enc}_k(m) = PRG(k\|r) \oplus m $, $r$ 是新的随机串。这是CPA安全的吗? - 从PRF到CPA安全:变长消息 - - 对于任意长度消息 $m = m_1, \dots , m_{\ell}$,$ c := \left< r_1, F_k(r_1) \oplus m_1, r_2, F_k(r_2) \oplus m_2, \dots, r_\ell, F_k(r_\ell) \oplus m_\ell\right> $ + - 对于任意长度消息 $m = m_1, \dots , m_{\ell}$,$c := \left< r_1, F_k(r_1) \oplus m_1, r_2, F_k(r_2) \oplus m_2, \dots, r_\ell, F_k(r_\ell) \oplus m_\ell\right>$ - 推论:如果$F$是一个 PRF,那么 $\Pi$ 对任意长度消息是 CPA 安全的。 - 问题:这个方案有什么缺点? - 有效性: $|c| = 2|m|$. 密文长度是明文长度的二倍,并且需要大量的真随机串。 @@ -166,7 +166,7 @@ - 定义:一个有效的带密钥的排列 $F$ 是PRP,如果对于任意PPT的区分器$D$, - $ \left|\Pr[D^{F_k(\cdot),F_k^{-1}(\cdot)}(1^n)=1] - \Pr[D^{f(\cdot),f^{-1}(\cdot)}(1^n)=1]\right| \le \mathsf{negl}(n) $ + $\left|\Pr[D^{F_k(\cdot),F_k^{-1}(\cdot)}(1^n)=1] - \Pr[D^{f(\cdot),f^{-1}(\cdot)}(1^n)=1]\right| \le \mathsf{negl}(n)$ - 问题:一个PRP也是一个PRF吗? @@ -291,11 +291,11 @@ - 一旦获得消息的长度,也就知道了填充的长度$b$,采用下面的方法来获得消息的最后一个字节内容,进而获得整个消息; - 更改密文中倒数第二块,来获得消息的最后一个字节$s$; - - 明文的最后一个块 $m_{last} = \cdots s \| \{b\}^{b}$,密文的倒数第二个块 $c_{last-1} = \cdots t \| \{\cdot \}^{b} $; - - 最后一块的PRP输入为$c_{last-1} \oplus m_{last} = \cdots (s \oplus t) \| (\{b\}^b \oplus \{\cdot \}^{b}) $; - - 敌手更改 $c_{last-1}$ 为 $c_{last-1}' = \cdots u \| (\{\cdot \}^{b} \oplus \{b\}^{b} \oplus \{b+1\}^{b}) $;其中,$u$是敌手猜测的某个字节; + - 明文的最后一个块 $m_{last} = \cdots s \| \{b\}^{b}$,密文的倒数第二个块 $c_{last-1} = \cdots t \| \{\cdot \}^{b}$; + - 最后一块的PRP输入为$c_{last-1} \oplus m_{last} = \cdots (s \oplus t) \| (\{b\}^b \oplus \{\cdot \}^{b})$; + - 敌手更改 $c_{last-1}$ 为 $c_{last-1}' = \cdots u \| (\{\cdot \}^{b} \oplus \{b\}^{b} \oplus \{b+1\}^{b})$;其中,$u$是敌手猜测的某个字节; - 解密获得最后一块明文$m'_{last} = c_{last-1} \oplus m_{last} \oplus c_{last-1}' = \cdots (s \oplus t \oplus u)\| \{ b+1 \}^b$; - - 如果没有返回坏填充错误,那么意味着填充了$b+1$个字节的$b+1$,所以 $s \oplus t \oplus u = (b+1)$ ,而 $s = t \oplus u \oplus (b+1) $ 。 + - 如果没有返回坏填充错误,那么意味着填充了$b+1$个字节的$b+1$,所以 $s \oplus t \oplus u = (b+1)$ ,而 $s = t \oplus u \oplus (b+1)$ 。 38. 总结 diff --git "a/notes-Chinese/4 \344\274\252\351\232\217\346\234\272\346\216\222\345\210\227\347\232\204\345\256\236\350\267\265\346\236\204\351\200\240-\345\235\227\345\257\206\347\240\201.md" "b/notes-Chinese/4 \344\274\252\351\232\217\346\234\272\346\216\222\345\210\227\347\232\204\345\256\236\350\267\265\346\236\204\351\200\240-\345\235\227\345\257\206\347\240\201.md" index 4b070f2..89d6c8f 100644 --- "a/notes-Chinese/4 \344\274\252\351\232\217\346\234\272\346\216\222\345\210\227\347\232\204\345\256\236\350\267\265\346\236\204\351\200\240-\345\235\227\345\257\206\347\240\201.md" +++ "b/notes-Chinese/4 \344\274\252\351\232\217\346\234\272\346\216\222\345\210\227\347\232\204\345\256\236\350\267\265\346\236\204\351\200\240-\345\235\227\345\257\206\347\240\201.md" @@ -217,7 +217,7 @@ - 在输入和输出之间的线性分析:对于随机选择的输入$x$和密钥$k$,有 $y=F_k(x)$,在比特位置 $i_1, ... ,i_\ell$ 与 $i_1', ... , i_\ell'$ 之间存在**偏差(bias)** $p$ , 之所以称为“偏差”,是与“正常”概率$\frac{1}{2}$相比而言; - $ \Pr [x_{i_1} \oplus \cdots \oplus x_{i_\ell} \oplus y_{i_1'} \oplus \cdots \oplus y_{i_\ell'} = 0] = p+\frac{1}{2}. $ + $\Pr [x_{i_1} \oplus \cdots \oplus x_{i_\ell} \oplus y_{i_1'} \oplus \cdots \oplus y_{i_\ell'} = 0] = p+\frac{1}{2}.$ 线性关系就是指这些比特的异或值的统计结果与随机值之间存在偏差,**无论异或结果为0还是为1**,重点在于这些位置比特之间存在线形关系。 @@ -247,9 +247,9 @@ 2. 第2轮S盒线性分析结果为$S_{2,2}$: $x_2 = y_2 \oplus y_4$,输出的2个比特影响最后一轮的2个S盒输入$u_{3,6}, u_{3,14}$。 - 3. 将输入、密钥和最后一轮S盒输入间关系表达出来:$ p_5 \oplus p_7 \oplus p_8 \oplus k_{1,5} \oplus k_{1,7} \oplus k_{1,8} \oplus k_{2,6} \oplus k_{3,6} \oplus k_{3,14} = u_{3,6} \oplus u_{3,14} $, + 3. 将输入、密钥和最后一轮S盒输入间关系表达出来:$p_5 \oplus p_7 \oplus p_8 \oplus k_{1,5} \oplus k_{1,7} \oplus k_{1,8} \oplus k_{2,6} \oplus k_{3,6} \oplus k_{3,14} = u_{3,6} \oplus u_{3,14}$, - 其中,密钥比特异或部分$\Sigma{k} = k_{1,5} \oplus k_{1,7} \oplus k_{1,8} \oplus k_{2,6} \oplus k_{3,6} \oplus k_{3,14}$ 是由密钥决定的一个固定的值。根据前面线性关系的含义,无论$\Sigma{k}$是0还是1,都有一个线性关系$ p_5 \oplus p_7 \oplus p_8 = u_{3,6} \oplus u_{3,14} $; + 其中,密钥比特异或部分$\Sigma{k} = k_{1,5} \oplus k_{1,7} \oplus k_{1,8} \oplus k_{2,6} \oplus k_{3,6} \oplus k_{3,14}$ 是由密钥决定的一个固定的值。根据前面线性关系的含义,无论$\Sigma{k}$是0还是1,都有一个线性关系$p_5 \oplus p_7 \oplus p_8 = u_{3,6} \oplus u_{3,14}$; 4. 从SPN的输出反向分析,$u_{3,6} \oplus u_{3,14} $ 由密文和第4个子密钥的所有偶数位异或值决定; diff --git "a/notes-Chinese/5 \344\274\252\351\232\217\346\234\272\345\257\271\350\261\241\347\232\204\347\220\206\350\256\272\346\236\204\351\200\240.md" "b/notes-Chinese/5 \344\274\252\351\232\217\346\234\272\345\257\271\350\261\241\347\232\204\347\220\206\350\256\272\346\236\204\351\200\240.md" index d7d50ee..a72b951 100644 --- "a/notes-Chinese/5 \344\274\252\351\232\217\346\234\272\345\257\271\350\261\241\347\232\204\347\220\206\350\256\272\346\236\204\351\200\240.md" +++ "b/notes-Chinese/5 \344\274\252\351\232\217\346\234\272\345\257\271\350\261\241\347\232\204\347\220\206\350\256\272\346\236\204\351\200\240.md" @@ -25,7 +25,7 @@ 易于计算: $\exists$ $M_f$: $\forall x, M_f(x) = f(x)$. *注:这里说明计算不需要用原本的函数,只要结果相同就可以* - 难以求逆: $\forall$ $\mathcal{A}$, $\exists\;\mathsf{negl}$ 使得,$\Pr[\mathsf{Invert}_{\mathcal{A},f}(n)=1] \le \mathsf{negl}(n)$ 或者 $\Pr_{\substack{x \gets \{0,1\}^n}}[\mathcal{A}(f(x)) \in f^{-1}(f(x))] \le \mathsf{negl}(n). $ + 难以求逆: $\forall$ $\mathcal{A}$, $\exists\;\mathsf{negl}$ 使得,$\Pr[\mathsf{Invert}_{\mathcal{A},f}(n)=1] \le \mathsf{negl}(n)$ 或者 $\Pr_{\substack{x \gets \{0,1\}^n}}[\mathcal{A}(f(x)) \in f^{-1}(f(x))] \le \mathsf{negl}(n).$ - *注:后半部分是难以求逆的另一种表达* @@ -47,14 +47,14 @@ - 一个函数 $\mathsf{hc}\; : \; \{0,1\}^* \to \{0,1\}$ 是一个函数$f$的核心断言( **hard-core predicate**),如果 - (1) $\mathsf{hc}$ 可在多项式时间计算; - - (2) $\forall$ 概率多项式时间 $\mathcal{A}$, $\exists\; \mathsf{negl}$ 使得 $ \Pr_{\substack{x \gets \{0,1\}^n}}[\mathcal{A}(f(x)) = \mathsf{hc}(x)] \le \frac{1}{2} + \mathsf{negl}(n). $ + - (2) $\forall$ 概率多项式时间 $\mathcal{A}$, $\exists\; \mathsf{negl}$ 使得 $\Pr_{\substack{x \gets \{0,1\}^n}}[\mathcal{A}(f(x)) = \mathsf{hc}(x)] \le \frac{1}{2} + \mathsf{negl}(n).$ - *注:核心断言可以理解为根据函数的输出最难推断的关于输入的一个比特信息,任意敌手算法与随机猜测相比几乎没有差异。* 9. 对于任意OWF的HCP [Goldreich and Levin] - 定理:$f$是一个OWF。那么,存在一个OWF $g$ 并与 $g$ 伴随着一个HCP $gl$。 - 问题: $\mathsf{gl}(x) = \bigoplus^{n}_{i=1} x_i$ 是任意OWF的HCP吗? 答案是否定的,例如一个单向函数输出的最后一个比特就是输入按位异或的结果; - - 证明:$g(x,r) \overset{\text{def}}{=} (f(x), r)$, for $|x| = |r|$, 并定义 $ \mathsf{gl}(x,r) \overset{\text{def}}{=} \bigoplus^{n}_{i=1} x_i \cdot r_i $。 其中,$r$ 是一个随机串。 + - 证明:$g(x,r) \overset{\text{def}}{=} (f(x), r)$, for $|x| = |r|$, 并定义 $\mathsf{gl}(x,r) \overset{\text{def}}{=} \bigoplus^{n}_{i=1} x_i \cdot r_i$。 其中,$r$ 是一个随机串。 - *说明:$\mathsf{gl}$就是从$x$中随机选择若干比特异或结果作为核心断言。即便敌手根据输出推断出$x$中若干比特的信息,但仍不能推断出(由$r$来)随机挑选的任意若干比特信息(核心断言),否则意味着敌手可以求出整个$x$。* 10. 从OWP到PRG:Blum-Micali Generator diff --git "a/notes-Chinese/6 \346\266\210\346\201\257\350\256\244\350\257\201\347\240\201\344\270\216\346\212\227\347\242\260\346\222\236\345\223\210\345\270\214\345\207\275\346\225\260.md" "b/notes-Chinese/6 \346\266\210\346\201\257\350\256\244\350\257\201\347\240\201\344\270\216\346\212\227\347\242\260\346\222\236\345\223\210\345\270\214\345\207\275\346\225\260.md" index a2a8f95..0f5a59f 100644 --- "a/notes-Chinese/6 \346\266\210\346\201\257\350\256\244\350\257\201\347\240\201\344\270\216\346\212\227\347\242\260\346\222\236\345\223\210\345\270\214\345\207\275\346\225\260.md" +++ "b/notes-Chinese/6 \346\266\210\346\201\257\350\256\244\350\257\201\347\240\201\344\270\216\346\212\227\347\242\260\346\222\236\345\223\210\345\270\214\345\207\275\346\225\260.md" @@ -36,7 +36,7 @@ 1. 挑战者生成密钥 $k \gets \mathsf{Gen}(1^n)$. 2. 敌手 $\mathcal{A}$ 具有访问标签生成算法$\mathsf{Mac}_k(\cdot)$的预言机的能力,并输出 $(m,t)$. 对预言机查询的消息集合为 $\mathcal{Q}$ 。 3. $\mathsf{Macforge}_{\mathcal{A},\Pi }(n)=1 \iff$ $\mathsf{Vrfy}_k(m,t)=1$ $\land$ $m \notin \mathcal{Q}$. 敌手成功,如果输出的消息和标签通过了验证,并且输出的消息是从未向预言机查询过的新消息。 - - 定义:一个 MAC $\Pi$ 是在适应性CMA下的存在性不可伪造 (**existentially unforgeable under an adaptive CMA**),如果 $\forall$ PPT $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得: $ \Pr [\mathsf{Macforge}_{\mathcal{A},\Pi }(n)=1] \le \mathsf{negl}(n). $ + - 定义:一个 MAC $\Pi$ 是在适应性CMA下的存在性不可伪造 (**existentially unforgeable under an adaptive CMA**),如果 $\forall$ PPT $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得: $\Pr [\mathsf{Macforge}_{\mathcal{A},\Pi }(n)=1] \le \mathsf{negl}(n).$ 7. 真实例子 @@ -74,13 +74,13 @@ - 如果是真随机 $f$ 被使用 $t=f(m)$ 是均匀随机的. - $ \Pr[D^{f(\cdot)}(1^n)=1] = \Pr[\mathsf{Macforge}_{\mathcal{A},\tilde{\Pi}}(n) = 1] \le 2^{-n}.$ + $\Pr[D^{f(\cdot)}(1^n)=1] = \Pr[\mathsf{Macforge}_{\mathcal{A},\tilde{\Pi}}(n) = 1] \le 2^{-n}.$ - 如果 $F_k$ 被使用,那么就是在执行实验 $\mathsf{Macforge}_{\mathcal{A},\Pi}(n)$. - $ \Pr[D^{F_k(\cdot)}(1^n)=1] = \Pr[\mathsf{Macforge}_{\mathcal{A},\Pi}(n) = 1] = \varepsilon(n).$ + $\Pr[D^{F_k(\cdot)}(1^n)=1] = \Pr[\mathsf{Macforge}_{\mathcal{A},\Pi}(n) = 1] = \varepsilon(n).$ - - 根据PRF的定义有,$ \left| \Pr[D^{F_k(\cdot)}(1^n)=1] - \Pr[D^{f(\cdot)}(1^n)=1] \right| \ge \varepsilon(n) - 2^{-n}. $ + - 根据PRF的定义有,$\left| \Pr[D^{F_k(\cdot)}(1^n)=1] - \Pr[D^{f(\cdot)}(1^n)=1] \right| \ge \varepsilon(n) - 2^{-n}.$ 13. 扩展到变长消息 @@ -142,7 +142,7 @@ - 哈希函数 $\Pi$ ($\mathsf{Gen}$, $H^s$) 是抗碰撞的,如果$\forall$ ppt $\mathcal{A}$, $\exists\;\mathsf{negl}$ 使得 - $ \Pr[\mathsf{Hashcoll}_{\mathcal{A},\Pi}(n)=1] \le \mathsf{negl}(n).$ + $\Pr[\mathsf{Hashcoll}_{\mathcal{A},\Pi}(n)=1] \le \mathsf{negl}(n).$ 20. 哈希函数安全的更弱的概念 @@ -277,8 +277,8 @@ 36. 构造一个SUF - - 定理:对于任意质数 $P$,函数 $h$ 是一个SUF: $ h_{a,b}(m) \overset{\mathsf{def}}{=} [ a \cdot m + b \mod p] $ - - 证明:$h_{a,b}(m) = t$ 且 $h_{a,b}(m') = t'$,只有当 $a \cdot m + b = t \mod p$ 且 $a \cdot m' + b = t' \mod p$. 我们有 $a = [(t-t') \cdot (m - m')^{-1} \mod p]$ 且 $b = [t - a \cdot m \mod p]$,这意味着存在一个唯一的密钥 $(a, b)$。由于存在 $|\mathcal{T}|^2$ 个密钥,$ \Pr [h_k(m) = t \land h_k(m') = t'] = \frac{1}{|\mathcal{T}|^2}$。 + - 定理:对于任意质数 $P$,函数 $h$ 是一个SUF: $h_{a,b}(m) \overset{\mathsf{def}}{=} [ a \cdot m + b \mod p]$ + - 证明:$h_{a,b}(m) = t$ 且 $h_{a,b}(m') = t'$,只有当 $a \cdot m + b = t \mod p$ 且 $a \cdot m' + b = t' \mod p$. 我们有 $a = [(t-t') \cdot (m - m')^{-1} \mod p]$ 且 $b = [t - a \cdot m \mod p]$,这意味着存在一个唯一的密钥 $(a, b)$。由于存在 $|\mathcal{T}|^2$ 个密钥,$\Pr [h_k(m) = t \land h_k(m') = t'] = \frac{1}{|\mathcal{T}|^2}$。 37. 来自SUF的MAC的安全性 @@ -290,7 +290,7 @@ - 任意 $\ell$次 $2^{-n}$-安全 MAC 需要密钥长度至少为 $(\ell +1) \cdot n$. - 定理:令 $\Pi$ 为一次 $2^{-n}$-安全 MAC,其中所有密钥长度相同。那么,密钥必须具有$2n$长度。 - 证明:直觉上,每对消息和标签成立需要$2^n$个密钥,才能保证 $2^{-n}$-安全。一共2对,需要$2^{2n}$。 - - 令 $\mathcal{K}(t') \overset{\mathsf{def}}{=} \{ k | \mathsf{Vrfy}_k(m', t') = 1\}$,即所有由所查询消息得到标签的密钥集合。对于任意 $t'$, $|\mathcal{K}(t')| \leq 2^{-n} \cdot |\mathcal{K}|$。 否则,敌手$\mathcal{A}$从全体密钥集合中随机挑选一个密钥得到 $(m, t)$ 是一个有效标签的概率至少为 $|\mathcal{K}(t')|/|\mathcal{K}|> 2^{-n}$,这与安全要求矛盾。 $\mathcal{A}$有无限算力可以根据从第一次查询中得到对应的密钥集合$\mathcal{K}(t')$,从中选择一个密钥$k^*$,并输出一个新消息$m$的有效标签的概率是至少 $\frac{1}{|\mathcal{K}(t')|}$。固定$m'$遍历所有标签$t'$计算敌手成功概率为: $\sum_{t'} \Pr [\mathsf{Mac}_k(m') = t'] \cdot \frac{1}{|\mathcal{K}(t')|} \geq \sum_{t'} \Pr [\mathsf{Mac}_k(m') = t'] \cdot \frac{2^n}{|\mathcal{K}|} = \frac{2^n}{|\mathcal{K}|} $ 。由于概率至多 $2^{-n}$, $|\mathcal{K}| \geq 2^{2n}$。由于所有密钥具有相同长度,每个密钥的长度至少是 $2n$。 + - 令 $\mathcal{K}(t') \overset{\mathsf{def}}{=} \{ k | \mathsf{Vrfy}_k(m', t') = 1\}$,即所有由所查询消息得到标签的密钥集合。对于任意 $t'$, $|\mathcal{K}(t')| \leq 2^{-n} \cdot |\mathcal{K}|$。 否则,敌手$\mathcal{A}$从全体密钥集合中随机挑选一个密钥得到 $(m, t)$ 是一个有效标签的概率至少为 $|\mathcal{K}(t')|/|\mathcal{K}|> 2^{-n}$,这与安全要求矛盾。 $\mathcal{A}$有无限算力可以根据从第一次查询中得到对应的密钥集合$\mathcal{K}(t')$,从中选择一个密钥$k^*$,并输出一个新消息$m$的有效标签的概率是至少 $\frac{1}{|\mathcal{K}(t')|}$。固定$m'$遍历所有标签$t'$计算敌手成功概率为: $\sum_{t'} \Pr [\mathsf{Mac}_k(m') = t'] \cdot \frac{1}{|\mathcal{K}(t')|} \geq \sum_{t'} \Pr [\mathsf{Mac}_k(m') = t'] \cdot \frac{2^n}{|\mathcal{K}|} = \frac{2^n}{|\mathcal{K}|}$ 。由于概率至多 $2^{-n}$, $|\mathcal{K}| \geq 2^{2n}$。由于所有密钥具有相同长度,每个密钥的长度至少是 $2n$。 39. 总结 diff --git "a/notes-Chinese/7 CCA\345\256\211\345\205\250\344\270\216\350\256\244\350\257\201\345\212\240\345\257\206.md" "b/notes-Chinese/7 CCA\345\256\211\345\205\250\344\270\216\350\256\244\350\257\201\345\212\240\345\257\206.md" index 0e05ceb..c0d775a 100644 --- "a/notes-Chinese/7 CCA\345\256\211\345\205\250\344\270\216\350\256\244\350\257\201\345\212\240\345\257\206.md" +++ "b/notes-Chinese/7 CCA\345\256\211\345\205\250\344\270\216\350\256\244\350\257\201\345\212\240\345\257\206.md" @@ -28,7 +28,7 @@ - $k = (k_1,k_2) \gets \mathsf{Gen}'(1^n)$. - $\mathcal{A}$ 输入 $1^n$ 和对 $\mathsf{EncMac'}_k$的预言机访问,并输出 $c \gets \mathsf{EncMac'}_{k}(m)$. - $m := \mathsf{Dec}'_k(c)$. $\mathsf{Auth}_{\mathcal{A},\Pi'}(n) = 1 \iff m \ne \bot \land\; m \notin \mathcal{Q}$. - - 定义:$\Pi'$ 实现认证通信( **authenticated communication**),如果 $\forall$ ppt $\mathcal{A}$, $\exists\; \mathsf{negl}$ 使得,$ \Pr[\mathsf{Auth}_{\mathcal{A},\Pi'}(n) = 1] \le \mathsf{negl}(n). $ + - 定义:$\Pi'$ 实现认证通信( **authenticated communication**),如果 $\forall$ ppt $\mathcal{A}$, $\exists\; \mathsf{negl}$ 使得,$\Pr[\mathsf{Auth}_{\mathcal{A},\Pi'}(n) = 1] \le \mathsf{negl}(n).$ - 定义:$\Pi'$ 是安全的认证加密(**secure Authenticated Encryption (A.E.)**), 如果其既是CCA安全的也是实现了认证通信。 - 问题:CCA安全意味着A.E.吗?(作业) @@ -38,9 +38,9 @@ 7. 加密和认证组合 - 加密和认证如何组合来同时保护机密性和真实性? - - 加密并认证(**Encrypt-and-authenticate**) (例如, SSH):$ c \gets \mathsf{Enc}_{k_1}(m),\; t \gets \mathsf{Mac}_{k_2}(m).$ - - 先认证后加密(**Authenticate-then-encrypt**) (例如, SSL):$ t \gets \mathsf{Mac}_{k_2}(m),\; c \gets \mathsf{Enc}_{k_1}(m\| t).$ - - 先加密后认证(**Encrypt-then-authenticate**) (例如, IPsec):$ c \gets \mathsf{Enc}_{k_1}(m),\; t \gets \mathsf{Mac}_{k_2}(c). $ + - 加密并认证(**Encrypt-and-authenticate**) (例如, SSH):$c \gets \mathsf{Enc}_{k_1}(m),\; t \gets \mathsf{Mac}_{k_2}(m).$ + - 先认证后加密(**Authenticate-then-encrypt**) (例如, SSL):$t \gets \mathsf{Mac}_{k_2}(m),\; c \gets \mathsf{Enc}_{k_1}(m\| t).$ + - 先加密后认证(**Encrypt-then-authenticate**) (例如, IPsec):$c \gets \mathsf{Enc}_{k_1}(m),\; t \gets \mathsf{Mac}_{k_2}(c).$ 8. 分析组合的安全性 - 采用全或无(All-or-nothing)分析,即一种组合方案要么在全部情况下都是安全的,要么只要存在一个不安全的反例就被认为是不安全的; @@ -72,7 +72,7 @@ - 证明:$\mathsf{VQ}$ (有效查询): $\mathcal{A}$ 向预言机$\mathsf{Dec}'$提交一个新查询并且 $\mathsf{Vrfy}=1$。*注:VQ表示敌手向预言机查询可经过验证并解密。* - - $ \Pr[\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi'}(n)=1] \le \Pr[\mathsf{VQ}] + \Pr[\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi'}(n)=1 \land \overline{\mathsf{VQ}}] $ + - $\Pr[\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi'}(n)=1] \le \Pr[\mathsf{VQ}] + \Pr[\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi'}(n)=1 \land \overline{\mathsf{VQ}}]$ - 我们需要证明以下: @@ -87,7 +87,7 @@ - 当$\mathcal{A}$以$m$查询加密预言机时, $\mathcal{A}_M$ 产生加密密钥并以加密预言机的角色先计算密文$c$,然后用密文查询MAC预言机并将$\left$返回给$\mathcal{A}$; - 当$\mathcal{A}$以$\left$查询解密预言机时,如果这是第 $i$ 个查询,那么$\mathcal{A}_M$ 输出$\left$并停止;否则,如果这是曾经在加密预言机查询过的,$\mathcal{A}_M$ 返回明文,否则,返回$\bot$(因为只要$\mathsf{VQ}$未发生,就应该返回$\bot$); - $\mathsf{Macforge}_{\mathcal{A}_M,\Pi_M }(n)=1$ 的条件是,只有当 $\mathsf{VQ}$ 发生并且 $\mathcal{A}_M$ 正确地猜测了 $i$ (概率为 $1/q(n)$)。 - - $ \Pr [\mathsf{Macforge}_{\mathcal{A}_M,\Pi_M }(n)=1] \ge \Pr[\mathsf{VQ}]/q(n).$ + - $\Pr [\mathsf{Macforge}_{\mathcal{A}_M,\Pi_M }(n)=1] \ge \Pr[\mathsf{VQ}]/q(n).$ 12. 证明在无法利用解密预言机时难以破解加密方案 @@ -99,7 +99,7 @@ - $\Pr[\mathsf{PrivK}^{\mathsf{cpa}}_{\mathcal{A}_E,\Pi_E}(n)=1 \land \overline{\mathsf{VQ}}] = \Pr[\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi'}(n)=1 \land \overline{\mathsf{VQ}}]$; - $ \Pr [\mathsf{PrivK}^{\mathsf{cpa}}_{\mathcal{A}_E,\Pi_E }(n)=1] \ge \Pr[\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi'}(n)=1 \land \overline{\mathsf{VQ}}] $。 + $\Pr [\mathsf{PrivK}^{\mathsf{cpa}}_{\mathcal{A}_E,\Pi_E }(n)=1] \ge \Pr[\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi'}(n)=1 \land \overline{\mathsf{VQ}}]$。 13. 认证加密理论与实践 @@ -133,7 +133,7 @@ 16. 在变长加密中的一个常见错误 - 常见错误:在 CBC/CTR 模式中采用固定的$IV$。这虽然是确定性的,但是不安全。 - - 敌手能够查询 $(m_{q1}, m_{q2})$ 并且得到 $(c_{q1}, c_{q2})$;然后输出明文:$ IV\oplus c_{q1} \oplus m_{q2}$ 并且期待密文: $c_{q2}$。注:第一个PRF的输入就是$ IV\oplus IV\oplus c_{q1} \oplus m_{q2} = c_{q1} \oplus m_{q2}$ + - 敌手能够查询 $(m_{q1}, m_{q2})$ 并且得到 $(c_{q1}, c_{q2})$;然后输出明文:$IV\oplus c_{q1} \oplus m_{q2}$ 并且期待密文: $c_{q2}$。注:第一个PRF的输入就是$IV\oplus IV\oplus c_{q1} \oplus m_{q2} = c_{q1} \oplus m_{q2}$ - 下面介绍三种变长明文的CPA安全的确定性加密方案。 17. 合成初始向量法(**Synthetic** IV **(SIV)**) diff --git "a/notes-Chinese/8.1 \345\205\254\351\222\245\345\212\240\345\257\206\347\220\206\350\256\272.md" "b/notes-Chinese/8.1 \345\205\254\351\222\245\345\212\240\345\257\206\347\220\206\350\256\272.md" index 167ff30..eb1431b 100644 --- "a/notes-Chinese/8.1 \345\205\254\351\222\245\345\212\240\345\257\206\347\220\206\350\256\272.md" +++ "b/notes-Chinese/8.1 \345\205\254\351\222\245\345\212\240\345\257\206\347\220\206\350\256\272.md" @@ -139,8 +139,8 @@ - 一组多项式时间算法 $\Pi = (\mathsf{Gen}, \mathsf{Samp}, f, \mathsf{Inv})$ 是一个陷门排列族(family of trapdoor permutations,TDP),如果: - 参数生成(parameter generation)算法 $\mathsf{Gen}$, 输入 $1^n$,输出 $(I,\mathsf{td})$ 有 $|I| \ge n$。其中, $(I, \mathsf{td})$ 定义了集合 $\mathcal{D}_I = \mathcal{D}_{\mathsf{td}}$。注:陷门排列族是一个函数集合,参数生成算法产生一个具体陷门排列所需的参数。 - $\mathsf{Gen}_I$ 只输出 $I$。$(\mathsf{Gen}_I, \mathsf{Samp}, f)$ 是 OWP。其中的$\mathsf{Samp}$是采样函数,用于获得函数的输入$x \gets \mathcal{D}_I$。 - - 一个确定性求逆算法 $\mathsf{Inv}$,对于 $\forall (I,\mathsf{td})$ 并且 $\forall x \in \mathcal{D}_{I}$, $ \mathsf{Inv}_{\mathsf{td}}(f_I(x))=x$。*注:可求逆* - - 核心断言:确定性多项式时间算法 $\mathsf{hc}$ 是$\Pi$ 的一个核心断言(hard-core predicate),如果 $\forall$ ppt $\mathcal{A}$,$\exists$ $\mathsf{negl}$ 使得 $ \Pr[\mathcal{A}(I,f_I(x)) = \mathsf{hc}_I(x)] \le \frac{1}{2} +\mathsf{negl}(n)$。 + - 一个确定性求逆算法 $\mathsf{Inv}$,对于 $\forall (I,\mathsf{td})$ 并且 $\forall x \in \mathcal{D}_{I}$, $\mathsf{Inv}_{\mathsf{td}}(f_I(x))=x$。*注:可求逆* + - 核心断言:确定性多项式时间算法 $\mathsf{hc}$ 是$\Pi$ 的一个核心断言(hard-core predicate),如果 $\forall$ ppt $\mathcal{A}$,$\exists$ $\mathsf{negl}$ 使得 $\Pr[\mathcal{A}(I,f_I(x)) = \mathsf{hc}_I(x)] \le \frac{1}{2} +\mathsf{negl}(n)$。 - 定理:给定一个陷门排列族$\Pi = (\mathsf{Gen}, \mathsf{Samp}, f, \mathsf{Inv})$,则存在一个带有核心断言的陷门排列族$\widehat{\Pi} = (\widehat{\mathsf{Gen}}, \mathsf{Samp}, f, \mathsf{Inv})$。注:证明与单向函数部分关于核心断言的定理类似。 17. TDP例题 @@ -193,7 +193,7 @@ - $b \gets \{0,1\}$。挑战密文 $c \gets \mathsf{Enc}_{pk}(m_b)$ 给 $\mathcal{A}$。 - 在CCA2中,$\mathcal{A}$ 除了 $c$ 之外还可以访问 $\mathsf{Dec}_{sk}(\cdot)$,并输出$b'$ 。注:CCA 也被称作午餐攻击。CCA2 也被称为适应性的 CCA。 - 如果 $b' = b$,那么 $\mathcal{A}$ 成功, $\mathsf{PrivK}^{\mathsf{cca}}_{\mathcal{A},\Pi}=1$,否则 0。 - - $\Pi$ 是 CCA/CCA2安全的,如果 $\forall$ ppt $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得 $ \Pr\left[\mathsf{PubK}^{\mathsf{cca}}_{\mathcal{A},\Pi}(n)=1\right] \le \frac{1}{2} + \mathsf{negl}(n)$. + - $\Pi$ 是 CCA/CCA2安全的,如果 $\forall$ ppt $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得 $\Pr\left[\mathsf{PubK}^{\mathsf{cca}}_{\mathcal{A},\Pi}(n)=1\right] \le \frac{1}{2} + \mathsf{negl}(n)$. 23. 例题 diff --git "a/notes-Chinese/8.2 RSA\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" "b/notes-Chinese/8.2 RSA\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" index 5a53f42..84ef825 100644 --- "a/notes-Chinese/8.2 RSA\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" +++ "b/notes-Chinese/8.2 RSA\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" @@ -63,7 +63,7 @@ 7. $\mathbb{Z}_N^*$ 群 - - $ \mathbb{Z}_N^* \overset{\text{def}}{=} \{a \in \{1,\dotsc,N-1 \} | \gcd(a,N) = 1\} $ + - $\mathbb{Z}_N^* \overset{\text{def}}{=} \{a \in \{1,\dotsc,N-1 \} | \gcd(a,N) = 1\}$ - 群是一个集合 $\mathbb{G}$ 带有一个二元操作 $\circ$: - 闭包: $\forall g,h \in \mathbb{G}$, $g \circ h \in \mathbb{G}$. - 单位元: $\exists$ 单位元 $e\in \mathbb{G}$ 使得 $\forall g\in \mathbb{G}, e \circ g = g = g \circ e$. @@ -76,7 +76,7 @@ 8. 群指数 - - $ g^m \overset{\text{def}}{=} \underbrace{g\circ g\circ \cdots \circ g}_{m\; \text{times}}. $ + - $g^m \overset{\text{def}}{=} \underbrace{g\circ g\circ \cdots \circ g}_{m\; \text{times}}.$ - 欧拉定理:$\mathbb{G}$ 是有限群。那么, $\forall g \in \mathbb{G}, g^{|\mathbb{G}|}=1$. - 注:课上证明,将群中每个元素与 $g$ 相乘后连乘等于群中元素连乘。 - 例子:计算 $3 \in \mathbb{Z}_{7}^*$ 的所有幂。 @@ -167,7 +167,7 @@ 2. 选择 $y \gets \mathbb{Z}^*_N$。 3. 敌手 $\mathcal{A}$ 给定 $N,e,y$, 并输出 $x \in \mathbb{Z}^*_N$. 4. $\mathsf{RSAinv}_{\mathcal{A},\mathsf{GenRSA}}(n)=1$ ,实验成功,如果 $x^e \equiv y \pmod N$,否则实验失败 0 。 - - 定义:RSA问题相对于$\mathsf{GenRSA}$是难的,如果 $\forall$ PPT算法 $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得,$ \Pr[\mathsf{RSAinv}_{\mathcal{A},\mathsf{GenRSA}}(n) = 1] \le \mathsf{negl}(n). $ + - 定义:RSA问题相对于$\mathsf{GenRSA}$是难的,如果 $\forall$ PPT算法 $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得,$\Pr[\mathsf{RSAinv}_{\mathcal{A},\mathsf{GenRSA}}(n) = 1] \le \mathsf{negl}(n).$ 17. 构造陷门排列 @@ -215,7 +215,7 @@ - 情况1:多个用户带有自己的密钥。每个用户可以以自己的 $e,d$ 计算 $\phi(N)$ ,然后找到其他人的 $d$. - 情况2:用两个公钥为同一个消息加密。 - 假设 $\gcd(e_1,e_2)=1$, $c_1 \equiv m^{e_1}$ and $c_2 \equiv m^{e_2} \pmod N$. $\exists X,Y$ 使得 $Xe_1 + Ye_2 = 1$ (贝祖定理). - - $ c_1^X\cdot c_2^Y \equiv m^{Xe_1}m^{Ye_2} \equiv m^1 \pmod N. $ + - $c_1^X\cdot c_2^Y \equiv m^{Xe_1}m^{Ye_2} \equiv m^1 \pmod N.$ - $N = 15, e_{1} = 3, e_{2} = 5, c_{1} = 8, c_{2} = 2, m = ?$ 22. 对“书本上RSA”的CCA @@ -227,7 +227,7 @@ - 将二进制串编码为 $\mathbb{Z}^*_N$ 中元素: $\ell = \|N\|$。任意长度为$\ell - 1$ 的二进制串 $m$ 可以被看作是 $Z_N$ 中元素。尽管 $m$ 不在 $Z_N^*$ 中,RSA 仍工作。 - $e$ 的选择:$e=3$ 或小 $d$ 都是坏选择。 推荐 $e=65537=2^{16}+1$ - - 使用中国剩余定理来加速解密:$ [c^d \bmod N] \leftrightarrow ([c^d \bmod p],[c^d \bmod q]). $ + - 使用中国剩余定理来加速解密:$[c^d \bmod N] \leftrightarrow ([c^d \bmod p],[c^d \bmod q]).$ - 假设一个 $n$ 比特整数指数预算需要 $n^3$ 操作。RSA 解密花费 $(2n)^3=8n^3$,其中使用中国剩余定理需要 $2n^3$。 24. Padded RSA @@ -277,7 +277,7 @@ - 之前提到过使用中国剩余定理来加速解密: - $ [c^d \bmod N] \leftrightarrow ([m_p \equiv c^d \pmod p],[m_q \equiv c^d \pmod q])$ + $[c^d \bmod N] \leftrightarrow ([m_p \equiv c^d \pmod p],[m_q \equiv c^d \pmod q])$ - 假设在计算 $m_q$ 时发生错误,但在计算 $m_p$ 时没有错误。 - $m' \equiv c^d \pmod p$, $m' \not \equiv c^d \pmod q$。 diff --git "a/notes-Chinese/8.3 DH\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" "b/notes-Chinese/8.3 DH\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" index 1f5862f..8648bdc 100644 --- "a/notes-Chinese/8.3 DH\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" +++ "b/notes-Chinese/8.3 DH\351\227\256\351\242\230\344\270\216\345\212\240\345\257\206.md" @@ -6,7 +6,7 @@ 3. 循环群(Cyclic Groups)与生成元(Generators) - - $\mathbb{G}$ 是一个群并且一个元素 $g \in \mathbb{G}$通过运算生成一个子群 $ \langle g \rangle \overset{\text{def}}{=} \{ g^0,g^1,\dotsc,\} = \{ g^0,g^1,\dotsc, g^{i-1}\}$。 + - $\mathbb{G}$ 是一个群并且一个元素 $g \in \mathbb{G}$通过运算生成一个子群 $\langle g \rangle \overset{\text{def}}{=} \{ g^0,g^1,\dotsc,\} = \{ g^0,g^1,\dotsc, g^{i-1}\}$。 - $g$ 的阶是最小的正整数 $i$ 令 $g^i=1$。 - $\mathbb{G}$ 是一个循环群(cyclic group)如果 $\exists\;g$ 有阶 $m = |\mathbb{G}|$. $\langle g \rangle = \mathbb{G}$, $g$ 是 $\mathbb{G}$ 的生成元。注:循环群中存在一个元素通过指数运算可生成整个群中每个元素。 - 例题: 乘法下的$\mathbb{Z}_6^*$, $\mathbb{Z}_7^*$,或 $\mathbb{Z}_8^*$ 是循环群吗? 找到生成元。 @@ -63,13 +63,13 @@ - 挑选一个 $h \gets \mathbb{G}$. ($x' \gets \mathbb{Z}_q$ and $h := g^{x'}$) - 敌手 $\mathcal{A}$ 给定 $\mathbb{G}, q, g, h$,并且输出 $x \in \mathbb{Z}_q$. - 实验成功 $\mathsf{DLog}_{\mathcal{A},\mathcal{G}}(n) = 1$,如果 $g^x = h$, 否则 0 。 - - 定义:离散对数问题相对于群$\mathcal{G}$是难的,如果 $\forall$ ppt 算法 $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得 $ \Pr[\mathsf{DLog}_{\mathcal{A},\mathcal{G}}(n)=1] \le \mathsf{negl}(n).$ + - 定义:离散对数问题相对于群$\mathcal{G}$是难的,如果 $\forall$ ppt 算法 $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得 $\Pr[\mathsf{DLog}_{\mathcal{A},\mathcal{G}}(n)=1] \le \mathsf{negl}(n).$ 9. DH假设 - - 计算性DH(Computational Diffie-Hellman, CDH)问题:$ \mathsf{DH}_g(h_1,h_2) \overset{\text{def}}{=} g^{\log_gh_1\cdot \log_gh_2} $ + - 计算性DH(Computational Diffie-Hellman, CDH)问题:$\mathsf{DH}_g(h_1,h_2) \overset{\text{def}}{=} g^{\log_gh_1\cdot \log_gh_2}$ - 判断性DH(Decisional Diffie-Hellman, DDH))问题:区分 $\mathsf{DH}_g(h_1,h_2)$ 与一个随机的群元素 $h'$. - - 定义:DDH问题与$\mathcal{G}$相关的是难的,如果 $\forall$ ppt $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得 $ |\Pr[\mathcal{A}(\mathbb{G},q,g,g^x,g^y,g^z)=1] - \Pr[\mathcal{A}(\mathbb{G},q,g,g^x,g^y,g^{xy})=1]|\le \mathsf{negl}(n). $ + - 定义:DDH问题与$\mathcal{G}$相关的是难的,如果 $\forall$ ppt $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得 $|\Pr[\mathcal{A}(\mathbb{G},q,g,g^x,g^y,g^z)=1] - \Pr[\mathcal{A}(\mathbb{G},q,g,g^x,g^y,g^{xy})=1]|\le \mathsf{negl}(n).$ - DL, CDH 和 DDH 的难解性:DDH 比 CDH 和 DL 容易。 10. 安全密钥交换实验 @@ -83,7 +83,7 @@ - 定义:一个密钥交换协议 $\Pi$ 在出现窃听者攻击下是安全的,如果 $\forall$ ppt $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得 - $ \Pr[\mathsf{KE}^{\mathsf{eav}}_{\mathcal{A},\Pi}(n) = 1] < \frac{1}{2} + \mathsf{negl}(n). $ + $\Pr[\mathsf{KE}^{\mathsf{eav}}_{\mathcal{A},\Pi}(n) = 1] < \frac{1}{2} + \mathsf{negl}(n).$ 11. DH密钥交换协议 @@ -93,12 +93,12 @@ 12. 证明 - - $\Pr \left[ \widehat{\mathsf{KE}}^{\mathsf{eav}}_{\mathcal{A},\Pi} =1\right] $ $= \frac{1}{2}\cdot \Pr\left[ \widehat{\mathsf{KE}}^{\mathsf{eav}}_{\mathcal{A},\Pi} =1 | b=1\right] + \frac{1}{2}\cdot \Pr\left[ \widehat{\mathsf{KE}}^{\mathsf{eav}}_{\mathcal{A},\Pi} =1 | b=0\right] $ + - $\Pr \left[ \widehat{\mathsf{KE}}^{\mathsf{eav}}_{\mathcal{A},\Pi} =1\right]$ $= \frac{1}{2}\cdot \Pr\left[ \widehat{\mathsf{KE}}^{\mathsf{eav}}_{\mathcal{A},\Pi} =1 | b=1\right] + \frac{1}{2}\cdot \Pr\left[ \widehat{\mathsf{KE}}^{\mathsf{eav}}_{\mathcal{A},\Pi} =1 | b=0\right]$ - 如果 $b=1$, 那么给真密钥;否则给随机的 $g^z$. - - $= \frac{1}{2}\cdot \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] + \frac{1}{2}\cdot \Pr\left[ \mathcal{A}(g^x,g^y,g^z)=0 \right] $ - - $= \frac{1}{2}\cdot \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] + \frac{1}{2}\cdot (1-\Pr\left[ \mathcal{A}(g^x,g^y,g^z)=1 \right]) $ - - $= \frac{1}{2} + \frac{1}{2}\cdot \left( \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] - \Pr\left[ \mathcal{A}(g^x,g^y,g^z)=1 \right] \right) $ - - $ \le \frac{1}{2} + \frac{1}{2}\cdot \mathsf{negl}(n) %\left| \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] - \Pr\left[ \mathcal{A}(g^x,g^y,g^z)=1 \right] \right| $ + - $= \frac{1}{2}\cdot \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] + \frac{1}{2}\cdot \Pr\left[ \mathcal{A}(g^x,g^y,g^z)=0 \right]$ + - $= \frac{1}{2}\cdot \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] + \frac{1}{2}\cdot (1-\Pr\left[ \mathcal{A}(g^x,g^y,g^z)=1 \right])$ + - $= \frac{1}{2} + \frac{1}{2}\cdot \left( \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] - \Pr\left[ \mathcal{A}(g^x,g^y,g^z)=1 \right] \right)$ + - $\le \frac{1}{2} + \frac{1}{2}\cdot \mathsf{negl}(n) %\left| \Pr\left[ \mathcal{A}(g^x,g^y,g^{xy})=1 \right] - \Pr\left[ \mathcal{A}(g^x,g^y,g^z)=1 \right] \right|$ 13. DHKE例子 @@ -117,8 +117,8 @@ 15. 完美保密私钥加密引理 - - 引理:$\mathbb{G}$ 是有限群并且 $m\in \mathbb{G}$ 是任意元素。那么选择随机 $k \gets \mathbb{G}$ 并令 $c := m\cdot k$ ,将得到与随机选择的 $c \gets \mathbb{G}$ 相同的分布,即 $\forall g \in \mathbb{G}$: $ \Pr[m\cdot k = g] = 1/|\mathbb{G}| $。 - - 证明:$g \in \mathbb{G}$ 是任意的,那么 $\Pr[m\cdot k = g] = \Pr[k = m^{-1}\cdot g] $。由于 $k$ 均匀随机选择,选择 $k$ 的概率与一个固定元素 $m^{-1}\cdot g$ 相同,都是 $1/|\mathbb{G}$|。 + - 引理:$\mathbb{G}$ 是有限群并且 $m\in \mathbb{G}$ 是任意元素。那么选择随机 $k \gets \mathbb{G}$ 并令 $c := m\cdot k$ ,将得到与随机选择的 $c \gets \mathbb{G}$ 相同的分布,即 $\forall g \in \mathbb{G}$: $\Pr[m\cdot k = g] = 1/|\mathbb{G}|$。 + - 证明:$g \in \mathbb{G}$ 是任意的,那么 $\Pr[m\cdot k = g] = \Pr[k = m^{-1}\cdot g]$。由于 $k$ 均匀随机选择,选择 $k$ 的概率与一个固定元素 $m^{-1}\cdot g$ 相同,都是 $1/|\mathbb{G}$|。 - 注:这是一种完美保密的私钥加密方案,将一个元素(明文)与另一个元素(密钥)的运算得到第三个元素(密文),与之前一个字母的移位密码是完美保密是类似的。 16. Elgamal加密方案 @@ -143,7 +143,7 @@ 18. 证明 - 思路:通过将DDH问题的算法$D$规约到窃听者算法$\mathcal{A}$来证明 $\Pi$ 在窃听者出现时是安全的。 - - 将 $\Pi$ 改造为 $\tilde{\Pi}$: 加密是通过随机选择的 $y \gets \mathbb{Z}_q$ 和 $z \gets \mathbb{Z}_q$ 然后输出密文:$ \langle g^y, g^z\cdot m\rangle$。 + - 将 $\Pi$ 改造为 $\tilde{\Pi}$: 加密是通过随机选择的 $y \gets \mathbb{Z}_q$ 和 $z \gets \mathbb{Z}_q$ 然后输出密文:$\langle g^y, g^z\cdot m\rangle$。 - $\tilde{\Pi}$ 不是一个加密方案. - $g^y$ 独立于 $m$。 - $g^z\cdot m$ 是独立于 $m$ 的随机元素 (之前的私钥加密引理)。 @@ -157,15 +157,15 @@ - 情况1: $g_3 = g^z$, 密文是 $\langle g^y, g^z\cdot m_b\rangle$. - $ \Pr[D(g^x,g^y,g^z)=1] = \Pr\left[\mathsf{PubK}^{\mathsf{eav}}_{\mathcal{A},\tilde{\Pi}}(n)=1\right] = \frac{1}{2}. $ + $\Pr[D(g^x,g^y,g^z)=1] = \Pr\left[\mathsf{PubK}^{\mathsf{eav}}_{\mathcal{A},\tilde{\Pi}}(n)=1\right] = \frac{1}{2}.$ - 情况2: $g_3 = g^{xy}$, 密文是 $\langle g^y, g^{xy}\cdot m_b\rangle$. - $ \Pr[D(g^x,g^y,g^{xy})=1] = \Pr\left[\mathsf{PubK}^{\mathsf{eav}}_{\mathcal{A},\Pi}(n)=1\right] = \varepsilon(n). $ + $\Pr[D(g^x,g^y,g^{xy})=1] = \Pr\left[\mathsf{PubK}^{\mathsf{eav}}_{\mathcal{A},\Pi}(n)=1\right] = \varepsilon(n).$ - 由于DDH问题是难的, - $ \mathsf{negl}(n) \ge |\Pr[D(g^x,g^y,g^z)=1] - \Pr[D(g^x,g^y,g^{xy})=1]| =|\frac{1}{2}-\varepsilon(n)|. $ + $\mathsf{negl}(n) \ge |\Pr[D(g^x,g^y,g^z)=1] - \Pr[D(g^x,g^y,g^{xy})=1]| =|\frac{1}{2}-\varepsilon(n)|.$ 21. Elgamal加密中CCA @@ -174,7 +174,7 @@ - 给定 $pk=\langle g, h\rangle$, $c = \langle c_1, c_2\rangle$, $c_1=g^y$, $c_2=h^y\cdot m$, - 方法1:计算 $c_2' := c_2\cdot m'$, 和 $c' = \langle c_1, c_2'\rangle$. $ \frac{c_2'}{c_1^x} = ? $ - 方法2:计算 $c_1'' := c_1\cdot g^{y''}$, 和 $c_2'' := c_2\cdot h^{y''}\cdot m'$。 - - $ c_1''=g^y\cdot g^{y''} = g^{y+y''}\;\text{and}\; c_2''= ? $ + - $c_1''=g^y\cdot g^{y''} = g^{y+y''}\;\text{and}\; c_2''= ?$ - 所以 $c''=\langle c_1'',c_2''\rangle$ 是 $m\cdot m'$ 的密文。 22. Elgamal实现问题 diff --git "a/notes-Chinese/9 \346\225\260\345\255\227\347\255\276\345\220\215.md" "b/notes-Chinese/9 \346\225\260\345\255\227\347\255\276\345\220\215.md" index 365ace3..cb3cc25 100644 --- "a/notes-Chinese/9 \346\225\260\345\255\227\347\255\276\345\220\215.md" +++ "b/notes-Chinese/9 \346\225\260\345\255\227\347\255\276\345\220\215.md" @@ -31,7 +31,7 @@ 1. 挑战者生成密钥对 $(pk,sk) \gets \mathsf{Gen}(1^n)$。 2. 敌手 $\mathcal{A}$ 给予输入 $1^n$ 以及对签名预言机的访问 $\mathsf{Sign}_{sk}(\cdot)$,然后输出 $(m,\sigma)$。 $\mathcal{Q}$ 是对预言机的查询的集合。 3. 实验成功 $\mathsf{Sigforge}_{\mathcal{A},\Pi }(n)=1 \iff$ $\mathsf{Vrfy}_{pk}(m,\sigma)=1$ $\land$ $m \notin \mathcal{Q}$. - - 一个签名方案 $\Pi$ 是在适应性选择消息攻击下的存在性不可伪造(existentially unforgeable under an adaptive CMA),如果 $\forall$ PPT $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得: $ \Pr [\mathsf{Sigforge}_{\mathcal{A},\Pi }(n)=1] \le \mathsf{negl}(n).$ + - 一个签名方案 $\Pi$ 是在适应性选择消息攻击下的存在性不可伪造(existentially unforgeable under an adaptive CMA),如果 $\forall$ PPT $\mathcal{A}$, $\exists$ $\mathsf{negl}$ 使得: $\Pr [\mathsf{Sigforge}_{\mathcal{A},\Pi }(n)=1] \le \mathsf{negl}(n).$ - 问题:在MAC和数字签名中敌手能力的差别是什么?如果敌手不限制算力为PPT会如何? 6. “书本上RSA”的不安全性 @@ -189,7 +189,7 @@ - 一个签名方案 $\Pi$ 在单个消息攻击下是存在性不可伪造的,如果 $\forall$ PPT $\mathcal{A}$,$\exists$ $\mathsf{negl}$ 使得: - $ \Pr [\mathsf{Sigforge}_{\mathcal{A},\Pi }^{\text{1-time}}(n)=1] \le \mathsf{negl}(n).$ + $\Pr [\mathsf{Sigforge}_{\mathcal{A},\Pi }^{\text{1-time}}(n)=1] \le \mathsf{negl}(n).$ 15. Lamport的OTS (1979) @@ -218,7 +218,7 @@ - 如果$\mathcal{A}$ 的查询正好落在位置$(i^*,b^*)$,而该位置的$x_{i^*,b^*}$本应该是$y$对应的$x$,是未知的,终止实验。否则,正常返回签名。 - 当 $\mathcal{A}$ 输出 $(m,\sigma)$,$\sigma=(x_1,\dotsc,x_{\ell})$,如果 $\mathcal{A}$ 在 $(i^*,b^*)$输出了一个伪造的值,并且有 $\mathsf{Vrfy}_{pk}(m,\sigma)=1$ 且 $m_{i^*} =b^* \neq m'_{i^*}$,那么输出 $x_{i^*,b^*}$; - 通过验证并且在$y$对应位置上输出签名,说明 $\mathcal{A}$ 输出的签名满足 $f(x_{i,m_i}) = y_{i,m_i}$。 - - $ \Pr[\mathcal{I}\;\; \text{succeeds} ] \ge \frac{1}{2\ell}\Pr[\mathcal{A}\;\; \text{succeeds}] $ + - $\Pr[\mathcal{I}\;\; \text{succeeds} ] \ge \frac{1}{2\ell}\Pr[\mathcal{A}\;\; \text{succeeds}]$ - 这是因为位置正好在特定位置满足条件的概率是$\frac{1}{2\ell}$. 18. 有状态签名方案 @@ -258,7 +258,7 @@ - 从之前的方案中可以观察到,一种安全地分发公钥的方法是对该公钥做一个数字签名。 - 对一个公钥的数字签名被称为,数字证书(Certificate);专门签发数字证书的机构被称为,证书权威机构(Certificate Authority,CA),CA是一个可信的第三方,其公钥($pk_C$)被所有相信CA的主体所持有。 - - 一个数字证书 $ \mathsf{cert}_{C\to B} \overset{\text{def}}{=} \mathsf{Sign}_{sk_C}(\text{`Bob's key is } pk_B\text{'})$,表示 CA 用其私钥($sk_C$)给一个主体 Bob 签发的数字证书,其中消息内容包括:主体的身份(Bob)和该主体所持的公钥($pk_B$)。其本质是**绑定一个身份和一个公钥。** + - 一个数字证书 $\mathsf{cert}_{C\to B} \overset{\text{def}}{=} \mathsf{Sign}_{sk_C}(\text{`Bob's key is } pk_B\text{'})$,表示 CA 用其私钥($sk_C$)给一个主体 Bob 签发的数字证书,其中消息内容包括:主体的身份(Bob)和该主体所持的公钥($pk_B$)。其本质是**绑定一个身份和一个公钥。** - Bob 将自己的公钥提交给 CA,然后收到证书,最后将自己的公钥和证书一起发送给通信的另一个方。 - 一个问题是 CA 的公钥是如何分发的?通常随应用程序一起分发,例如浏览器中内置了全世界约170个左右的CA的公钥。在DNSSEC中,递归服务器软件中内置了DNS根的公钥。 - 另一个问题:CA如何知道收到的公钥是否是Bob的?需要采用其它渠道,例如一个CA “Let's Encrypt” 通过证明域名的所有权来识别证书申请者的身份。 @@ -295,11 +295,11 @@ - 过期法(Expiration):在证书中包含一个过期时间,待过期后自动作废。 - $\mathsf{cert}_{C \to B} \overset{\text{def}}{=} \mathsf{Sign}_{sk_C}(\text{`bob's key is}\; pk_B \text{'},\; \text{date}). $ + $\mathsf{cert}_{C \to B} \overset{\text{def}}{=} \mathsf{Sign}_{sk_C}(\text{`bob's key is}\; pk_B \text{'},\; \text{date}).$ - 撤销/召回法(Revocation): 显式地撤销证书。 - $\mathsf{cert}_{C \to B} \overset{\text{def}}{=} \mathsf{Sign}_{sk_C}(\text{`bob's key is}\; pk_B \text{'},\; \text{\#\#\#}). $ + $\mathsf{cert}_{C \to B} \overset{\text{def}}{=} \mathsf{Sign}_{sk_C}(\text{`bob's key is}\; pk_B \text{'},\; \text{\#\#\#}).$ 其中的 ### 表示证书的序列号。