Skip to content

Commit fe2a2ad

Browse files
committed
Commit math related properties of prime
1 parent 121fef1 commit fe2a2ad

File tree

8 files changed

+25
-0
lines changed

8 files changed

+25
-0
lines changed

.DS_Store

6 KB
Binary file not shown.

_posts/2019-03-25-math-in-cryptography.markdown

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,31 @@ categories: [cryptography]
2121

2222
* 可逆性:设c为密文,m为明文,k为密钥,有等式$$c = m \oplus k, m = c \oplus k$$,即在使用同一个密钥时,异或运算既可以得到密文也可得到明文。这种加解密的方式在one time pad中用到。[参考][xor_reverse]
2323

24+
### 素数
25+
26+
素数在密码学中的应用非常广泛,Diffie-Hellman key exchange和RSA中都会选择一个很大(如包含600个数字)素数作为模幂运算的模数。
27+
28+
* 互素:在数论中,如果两个或两个以上的整数的最大公因数是1,即[Greatest common divisor(GCD)][gcd],则称它们为互素。如果gcd(a, b) = 1, 则a和b[互素][coprime](relatively prime, co-prime)
29+
30+
* 欧拉函数$$\Phi(n)$$:欧拉函数$$\Phi(n)$$是小于或者等于n的正整数中与n互素的数目。欧拉函数在RSA公钥加密算法中可以快速计算公钥和密钥的值。
31+
32+
* 若n为素数,则$$\Phi(n) = n - 1$$
33+
34+
* 欧拉函数满足:$$\Phi(A \times B) = A \times B$$
35+
36+
* 欧拉定理:若n,m为正整数,且n,m互素(gcd(n,m)=1),则
37+
38+
* $$m^{\Phi(n)} \equiv 1\bmod n$$,即$$m^{\Phi(n)}\bmod n = 1$$
39+
40+
* 原根:设p为素数,满足条件$$g^i\bmod p \neq g^j\bmod p$$$$i\neq j\ and\ i,j\in [1,p - 1]$$,则称为g为p的原根。如果依据$$g^i\bmod p, i \in [1, p - 1]$$画一张表的话,表中每个元素的值都是不同的;如果将该公式作为一个黑盒子,那么获取表中任意一个值的概率是相同的。
41+
42+
* 上述原根的特性使得构造单向函数f(x)([one way function][one-way-func])成为可能,即给定x的值以及f(x)的算法得到f(x)很容易,但给定f(x)的值和以及f(x)的算法反向获取x的值却很难,这里$$f(x) = g^i\bmod p, f^{-1}(x) = \log_p g$$,Diffie-Hellman Key Exchange就是构建于不能有效求解[离散对数难题][dis-log]$$f^{-1}(x)$$上的公钥加密算法。
43+
44+
2445
[xor_prob]: https://stackoverflow.com/questions/5889238/why-is-xor-the-default-way-to-combine-hashes
2546
[xor_dis_proof]: https://math.stackexchange.com/questions/441329/how-to-prove-uniform-distribution-of-m-oplus-k-if-k-is-uniformly-distributed
2647
[xor_reverse]: https://stackoverflow.com/questions/1379952/why-is-xor-used-in-cryptography
48+
[gcd]: https://en.wikipedia.org/wiki/Greatest_common_divisor
49+
[coprime]: https://en.wikipedia.org/wiki/Coprime_integers
50+
[one-way-func]: https://en.wikipedia.org/wiki/One-way_function
51+
[dis-log]: https://en.wikipedia.org/wiki/Discrete_logarithm

static/.DS_Store

6 KB
Binary file not shown.

static/img/.DS_Store

6 KB
Binary file not shown.

static/img/_posts/.DS_Store

6 KB
Binary file not shown.

static/img/_posts/Broadcast_Mail.png

-27 KB
Binary file not shown.

static/img/_posts/khan-modu-exp.png

182 KB
Loading
157 KB
Loading

0 commit comments

Comments
 (0)