|
1 | 1 | ---
|
2 | 2 | layout: post
|
3 |
| -title: "Welcome to Jekyll!" |
| 3 | +lang: zh |
| 4 | +title: "密码学中的数据知识" |
4 | 5 | date: 2019-03-25 21:30:00 +0800
|
5 |
| -categories: [jekyll] |
| 6 | +categories: [cryptography] |
6 | 7 | ---
|
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. |
8 | 8 |
|
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 | +### 异或运算 |
10 | 10 |
|
11 |
| -Jekyll also offers powerful support for code snippets: |
| 11 | +异或运算在密码学中被大量使用,它具有如下性质: |
12 | 12 |
|
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 | +* 均匀分布: |
20 | 14 |
|
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的二进制的数组成的集合。 |
22 | 16 |
|
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 |
0 commit comments