单向函数

One-Way Function.

One-Way Functions are a critical cryptographic primitive, that is both necessary and sufficient for private-key encryption and MACs. Informally speaking, a function ff is one-way if it is easy to compute but hard to invert.

We formally define "hard to invert" with the inverting experiment InvertA,f(n)\mathtt{Invert}_{\mathscr{A}, f}(n).

The Inverting Experiment

  • Challenger C\mathscr{C} choose uniform x∈{0,1}nx\in\{0,1\}^n, and compute y:=f(x)y:=f(x).
  • Adversary A\mathscr{A} is given 1n1^n and yy as inputs. A\mathscr{A} outputs x′x'.
  • A\mathscr{A} succeeds and the experiment evaluates to 11 if and only if f(x′)=yf(x')=y.

Note that the preimage x′x' does NOT neccessarily have to equal xx, as long as f(x′)=yf(x')=y.

Definition. A function f:{0,1}∗→{0,1}∗f:\{0,1\}^{*}\to \{0,1\}^{*} is one-way if the following two conditions hold:

  • (Easy to compute): There is a polynomial-time algorithm that on input xx outputs f(x)f(x).
  • (Hard to invert): For all PPT algorithm A\mathscr{A} there is a negligible function ε(n)\varepsilon(n) such that: Pr⁡[InvertA.f(n)=1]≤ε(n)\Pr[\mathtt{Invert}_{\mathscr{A}. f}(n)=1]\leq \varepsilon(n).

One-Way Functions Based on Assumptions

We could construct one-way functions based on the above four assumptions (factoring assumption, RSA assumption, discrete logarithm assumption, Diffie-Hellman assumption).

We illustrate this by using factoring assumption to construct a one-way function.

Given 1n1^n and GenModulus, define the (deterministic) function fGenf_{Gen} as follows:

  • Input: A random tage: string xx of length nn
  • Output: Integer NN.
  • Compute (N,p,q):=GenModulus(1n;x)(N,p,q):=GenModulus(1^n;x) and return NN.

Theorem. If the Factoring problem is hard relative to GenModulus, then fGenf_{Gen} is one-way.

Hard-Core Predicates

For a one-way function ff, it does not exist any PPT adversary that could efficiently invert it. However, the partial information of the preimage may be easily revealed.

Consider the function f:{0,1}2n→{0,1}2nf:\{0,1\}^{2n}\to \{0,1\}^{2n} and one-way function g:{0,1}n→{0,1}ng:\{0,1\}^n\to \{0,1\}^n. We could define f(x,y)=g(x)∣∣yf(x,y)=g(x)||y. Since gg is one-way, it is trivial that ff is also one-way. However, it is easy to know the last nn bits of the preimage are exactly the last nn bits of f(x,y)f(x,y).

Though ff is one-way, half of the information about the preimage is revealed.

We define hard-core predicate hchc of a one-way function as the bit that could NEVER be revealed. Informally speaking, hc(x)hc(x) is a bit that is efficiently computable given xx, but hard to compute given f(x)f(x).

Definition. A function hc:{0,1}∗→{0,1}hc:\{0,1\}^{*}\to\{0,1\} is a hard-core predicate of a function ff if:

  • hc can be computed in polynomial time.
  • For every probabilistic polynomial-time algorithm A\mathscr{A} there is a negligible function ε(n)\varepsilon(n) such that Pr⁡x←{0,1}n[A(1n,f(x))=hc(x)]≤1/2+ε(n)\Pr_{x\leftarrow \{0,1\}^n}[\mathscr{A}(1^n,f(x))=hc(x)]\leq 1/2+\varepsilon(n).

A hard-core predicate for the RSA problem is the least significant bit. That is to say, compute lsb(x)lsb(x) given y=[xemod  N]y=[x^e\mod{N}] is hard.

Eureka moment!

做了这么长的铺垫,终于来到了单向函数 (one-way function) 的介绍。我觉得单向函数是密码学中最重要的概念之一,它的定义体现了密码学的核心思想—— Easy to compute, hard to invert.

首先来谈谈它的存在性。之前介绍的三个数学难题 (hard problems) 都很符合单向函数的定义;Factoring problem,质数相乘容易,质因数分解难;RSA problem,模意义下幂运算简单,开方运算难;Discrete Logarithm problem,模意义下幂运算简单,对数运算难;因此,由这些难题的猜想 (assumptions) 构造单向函数再自然不过。

最后谈谈它的意义。密码学中,加密方案 (encryption),消息验证码 (MAC),数字签名 (digital signature) 等加密学原语 (cryptographic primitives) 本质上是一个单向函数构建的过程。更具体一点说,是一个 单向陷门函数 (trapdoor one-way function) 的构建。所谓陷门 (trapdoor) 是指,存在某个 zz 使得计算原像 x=f−1(y)x=f^{-1}(y) 简单,则该 zz 称为函数的陷门。

一个单向陷门函数有以下性质:(1) 单向性 (2) 存在陷门。这是否和某些原语的构造十分相似?以公钥加密 (或是 CPA 安全的私钥加密) 为例,加密消息 mm 得到密文 cc 很容易:Encpk(m)→cEnc_{pk}(m)\to c (公钥 pkpk 公开);而由密文 cc 解密得到原文 mm 却很困难。此为单向性 (one-way)。而倘若知道私钥 sksk,由密文 cc 解密得到原文 mm 的过程就非常简单:Decsk(c)→mDec_{sk}(c)\to m。因此,私钥 sksk 是加密函数 EncpkEnc_{pk} 的陷门 (trapdoor)。