Skip to content

Commit 34694ac

Browse files
committed
Initial commit of "math in cryptography"
This part contains reasons why xor is frequently used in cryptography.
1 parent 4232aeb commit 34694ac

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed
Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
---
22
layout: post
3-
title: "Welcome to Jekyll!"
3+
lang: zh
4+
title: "密码学中的数据知识"
45
date: 2019-03-25 21:30:00 +0800
5-
categories: [jekyll]
6+
categories: [cryptography]
67
---
7-
You’ll find this post in your `_posts` directory. Go ahead and edit it and re-build the site to see your changes. You can rebuild the site in many different ways, but the most common way is to run `jekyll serve`, which launches a web server and auto-regenerates your site when a file is updated.
88

9-
To add new posts, simply add a file in the `_posts` directory that follows the convention `YYYY-MM-DD-name-of-post.ext` and includes the necessary front matter. Take a look at the source for this post to get an idea about how it works.
9+
### 异或运算
1010

11-
Jekyll also offers powerful support for code snippets:
11+
异或运算在密码学中被大量使用,它具有如下性质:
1212

13-
{% highlight ruby %}
14-
def print_hi(name)
15-
puts "Hi, #{name}"
16-
end
17-
print_hi('Tom')
18-
#=> prints 'Hi, Tom' to STDOUT.
19-
{% endhighlight %}
13+
* 均匀分布:
2014

21-
Check out the [Jekyll docs][jekyll-docs] for more info on how to get the most out of Jekyll. File all bugs/feature requests at [Jekyll’s GitHub repo][jekyll-gh]. If you have questions, you can ask them on [Jekyll Talk][jekyll-talk].
15+
* 假设随机变量X和Y在集合$$\{0, 1\}^n$$上随机分布,X独立于Y,那么变量$$Z = X \oplus Y$$在空间$$\{0, 1\}^n$$上也是均匀分布的。集合$$U = \{0, 1\}^2 = \{00, 01, 10, 11\}$$,即集合U由四个长度为两个bit的二进制的数组成的集合。
2216

23-
[jekyll-docs]: http://jekyllrb.com/docs/home
24-
[jekyll-gh]: https://github.com/jekyll/jekyll
25-
[jekyll-talk]: https://talk.jekyllrb.com/
17+
* 设m和k为nbit数,k在集合$$U = \{0, 1\}^n$$上均匀分布,那么$$c = m \oplus k$$也是均匀分布的。证明参考[连接][xor_dis_proof]。这里的c为密文,m为明文,k为密钥。
18+
19+
* [同等概率][xor_prob]:设a和b是{0, 1}空间中的随机变量,即a和b为0或1。根据真值表计算:a & b得到0的概率为75%,得到1个概率为25%;$$a \mid b$$得到0的概率为25%,得到1的概率为75%;而$$a \oplus b$$得到0或者1的概率都是50%。
20+
21+
* 可逆性:设c为密文,m为明文,k为密钥,有等式$$c = m \oplus k, m = c \oplus k$$,即在使用同一个密钥时,异或运算既可以得到密文也可得到明文。这种加解密的方式在one time pad中用到。[参考][xor_reverse]
22+
23+
[xor_prob]: https://stackoverflow.com/questions/5889238/why-is-xor-the-default-way-to-combine-hashes
24+
[xor_dis_proof]: https://math.stackexchange.com/questions/441329/how-to-prove-uniform-distribution-of-m-oplus-k-if-k-is-uniformly-distributed
25+
[xor_reverse]: https://stackoverflow.com/questions/1379952/why-is-xor-used-in-cryptography

category/bash.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
layout: posts_by_category
3-
categories: bash
4-
title: Bash
5-
permalink: /category/bash
6-
---
3+
categories: cryptography
4+
title: Cryptography
5+
permalink: /category/cryptography
6+
---
File renamed without changes.

0 commit comments

Comments
 (0)