0%

Introduction to Modern Cryptography(6)

Introduction to Modern Cryptography Reading Notes

6 Hash Functions and Applications

哈希函数的定义

A hash function (with output length (n)) is a pair of probabilistic polynomial-time algorithms (Gen,H) satisfying the following:

  • Gen is a probabilistic algorithm that takes as input a security parameter 1n and outputs a key s. We assume that n is implicit in s.
  • H is a deterministic algorithm that takes as input a key s and a string x{0,1} and outputs a string Hs(x){0,1}(n) (where n is the value of the security parameter implicit in s).

If Hs is defined only for inputs x of length (n)>(n), then we say that (Gen,H) is a fixed-length hash function for inputs of length (n). In this case, we also call H a compression function.

在这里,攻击者往往会知道 s 的值,因此 s 放在 H 的上标。

The collision-finding experiment Hash-collA,H(n) (H=(Gen,H)):

  1. A key s is generated by running Gen(1n).
  2. The adversary A is given s, and outputs x,x . (If H is a fixed-length hash function for inputs of length (n), then we require x,x{0,1}(n).)
  3. The output of the experiment is defined to be 1 if and only if x=x and Hs(x)=Hs(x). In such a case we say that A has found a collision.

如果 Pr[Hash-collA,H(n)=1]negl(n),则称 Hcollision resistant的。

下面给出两个其他关于哈希安全的概念。

  • Second-preimage resistance 给出 s 和一个均匀分布的 x,一个PPT的 A 几乎无法找到 x 使得 xx,H(x)=H(x)
  • Preimage resistance 给出 sy=Hs(x) 对于一个均匀分布的 x,一个PPT的 A 几乎无法找到 x 使得 H(x)=H(x) (x 可以等于 x)

Merkle–Damgård 变换

Merkle–Damgård 变换可以将一个固定长度的哈希函数,用于任意长度的输入。

Let (Gen,h) be a compression function for inputs of length n+n2n with output length n. Fix n and IV{0,1}n. Construct hash function (Gen,H) as follows:

  • Gen: remains unchanged.

  • H: on input a key s and a string x{0,1} of length L<2 , do:

    1. Append a 1 to x, followed by enough zeros so that the length of the resulting string is less than a multiple of n. Then append L, encoded as an -bit string. Parse the resulting string as the sequence of n-bit blocks x1,...,xB.
    2. Set z0:=IV.
    3. For i=1,...,B, compute zi:=hs(zi1||xi).
    4. Output zB.

可以证明,如果 (Gen,h) 是 collision resistent 的,那么 (Gen,H) 也是。(证明先跳过)


使用哈希函数的消息认证


对哈希函数的一般攻击


The Random-Oracle Model

random-oracle model 将哈希函数视为一个随机函数,假设存在一个随机函数 H,只能通过黑盒访问 H 获取 H(x) 的值。

注意,random-oracle model 不是伪随机函数,因为伪随机函数只有在 key 保密时是伪随机的,但是所有群体都能计算 random-oracle model,不可能有一个保密的 key。

If x has not been queried to H, then the value of H(x) is uniform.

If A queries x to H, the reduction can see this query and learn x.

The reduction can set the value of H(x) (i.e., the response to query x) to a value of its choice, as long as this value is correctly distributed, i.e., uniform.