summaryrefslogtreecommitdiff
path: root/ss2017/cryptography/Notes12.txt
diff options
context:
space:
mode:
Diffstat (limited to 'ss2017/cryptography/Notes12.txt')
-rw-r--r--ss2017/cryptography/Notes12.txt274
1 files changed, 274 insertions, 0 deletions
diff --git a/ss2017/cryptography/Notes12.txt b/ss2017/cryptography/Notes12.txt
new file mode 100644
index 0000000..a1299d7
--- /dev/null
+++ b/ss2017/cryptography/Notes12.txt
@@ -0,0 +1,274 @@
112 Number theory and hardness assumptions
2-----------------------------------------
3
4The next few sections are about *public-key cryptography* (different
5keys for encryption and decryption, one public, the other
6private). This area makes heavy use of number theory, in particular
7arithmetic. In this section we review the necessary mathematics and
8formulate hardness assumptions on which the security of public key
9cryptography is based.
10
11We assume standard knowledge about
12
13- arithmetic: division with remainder, gcd, extended Euclidean
14algorithm, i.e. for all integers u,v, there exists integers s, t such
15that gcd(u,v)=su+tv, Chinese remainder theorem, modular arithmetic, in
16particular inverses modulo.
17
18- groups: additive and multiplicative notation; exponentiation; the
19 additive group Z_N (addition modulo N); the multiplicative group
20 (Z_N)^* of order phi(N) (Euler's phi function); the consequence
21 x^(phi(N)) = 1 (mod N) and the special case x^{p-1}=1 (mod p); the
22 group isomorphisms derived from the Chinese remainder theorem (Z_pq
23 =~= Z_p x Z_q, Z_pq^* =~= Z_p^* x Z_q^*), primitive elements in
24 Z_p^* (cyclicity of Z_p^*).
25
26The required knowledge is part of "Logik und Diskrete Strukturen" and
27can also be looked up in KL.
28
29Next, we discuss the computational complexity of various arithmetic
30operations. We always measure runtimes in terms of the *sizes*
31(lengths in binary representation) of the numbers in question. Notice
32that the size of a number n is O(log(n)). The basic arithmetic
33operations +,-,*,/ can be performed in polynomial time (in terms of
34the sizes) with the standard algorithms taught at school. The same is
35true for gcd-computations using Euclid's algorithm. Furthermore,
36computing modular powers, i.e. a^b mod N can also be done in
37polynomial time using repeated squaring based on the binary expansion
38of N. Note though that a^b cannot be computed in polynomial time
39simply because the result is too long.
40
41Testing whether a given number n is prime can also be done in
42polynomial time; the most efficient algorithms for this use
43probabilistic polynomial time computation, however. This means that
44one has randomised algorithms which given a number n answer either
45"composite" in which case n is definitely composite or "prime" in
46which case n is prime except for a negligible error probability. The
47simplest of these tests is the Miller-Rabin test (KL 7.2.2).
48
49Using such a primality test it is also possible to generate a random
50prime number of a given size s. To that end one chooses random n of
51size s and then tests n,n+1,n+2,n+3,... for primality until a prime
52number has been found. Theorems about the distribution of prime
53numbers assert that this search is successful after a small (in any
54case expected polynomial) time.
55
56
57Factoring
58- - - - -
59
60The factoring problem asks the following question. Given a natural
61number N find a non-trivial factor of N unless N is prime (as usual
62the trivial factors are 1 and N).
63
64If N is even or has some other small divisor then this question is
65easily solved by trial division (the factoring method taught at
66school). If, however, N has only large factors, e.g. is the product of
67two primes of roughly equal size then factoring is believed to be a
68very hard problem and at any rate no efficient algorithm is
69known. Notice that trial division is linear in sqrt(N) hence
70exponential in the size of N. (sqrt(N)=2^{1/2*log(N)}). There do exist
71better algorithms for factoring, but with today's technology finding
72out the factors of a product of two ~512bit primes must be considered
73infeasible with a broad security margin.
74
75
76RSA Cryptosystem
77- - - - - - - - -
78It is believed to be hard to reconstruct x from x^e knowing merely N
79and e so this procedure is used as the basis of a public key
80cryptosystem: RSA. Intuitively, Enc_e(x)=x^e mod N and Dec_d(y)=y^d
81mod N. The encryption key e can be publicized whereas the decryption
82key d must be kept private.
83
84Consider the situation where N=pq for primes p,q. The ring Z_N of
85integers mod N contains phi(N)=(p-1)(q-1) invertible elements. Recall
86that x:Z_N is invertible if gcd(x,N)=1. The elements with a gcd > 1
87are the multiples of p and of q of which there are (q-1) + (p-1) + 1
88with the last summand corresponding to 0=pq. Thus, the number of
89invertible elements is pq-q-p+1 = (p-1)(q-1). Equivalently, with the
90Chinese Remainder Theorem we have Z_N =~= Z_p x Z_q and the invertible
91elements correspond to those pairs (x,y):Z_p x Z_q where x=/=0 and
92y=/=0.
93
94The (multiplicative) group Z^*_N of invertible elements (mod N) thus
95has order /* number of elements */ phi(N)=(p-1)(q-1). For each element
96x:Z^*_N it holds that x^phi(N) = 1 (mod N) (general result about
97groups).
98
99Now suppose that we have e such that gcd(e,phi(N))=1 and ed=1
100(mod phi(N)). Then we can solve the RSA problem,
101 i.e. determine x such that x^e = y mod N for given y, N, e.
102More precisely, if x:Z^*_N we can recover x from y:=x^e as y^d
103(all computations done mod N). Indeed, (x^e)^d = x^{ed} =
104x^{t*phi(N)+1} = x (for any t).
105
106
107Security of RSA relative to factoring
108- - - - - - - - - - - - - - - - - - -
109
110If given e we are able to find d such that x^{ed}=x holds for all
111invertible (mod N) x then we can find the factors of N as follows:
112Namely, in this case, we have a value a (=ed-1) such that x^a=1 (mod
113N) holds for all x:Z^*_N. Such value must necessarily be even as can
114be seen by taking x=-1. Now we can successively divide a by two until
115we have found a value b such that x^{2b} = 1 (mod N) holds for all x
116but x^b =/= 1 for some x. The crucial observation is that once x^b =/=
1171 for some x then x^b =/= 1 for at least 50% of all x so we can find
118such a witness value x by repeated guesses. The reason for the 50%
119bound is that {x | x^b=1} is a proper subgroup of Z^*_N and its order
120must therefore be a proper divisor of |Z^*_N|=phi(N).
121
122So, summing up, we are in possession of a value b such that x^{2b}=1
123for all x, but x^b=1 not for all x. Let us consider u := x^b mod p and
124v := x^b mod q. Since u^2=v^2=1 we have u,v:{-1,1}. Moreover, by the
125Chinese Remainder Theorem, we have Z_N^* =~= Z_p^* x Z_q^* so that if
126x is chosen uniformly at random then u and v are also uniformly at
127random and independent. As before, if one of them *may* be =/=1 then
128this happens for at least 50% of them. As a result, under the
129assumptions, the event u*v=-1 has a a likelihood of at least 50% and
130in this event gcd(x^b-1,N) yields a nontrivial divisor of N.
131
132
133Unfortunately, there is no known reduction from RSA to factoring in
134the sense that we would be able to prove that RSA is semantically
135secure on condition that factoring is hard. Namely, notwithstanding
136the above, it might be possible to break RSA without actually
137producing an exponent d such that x^ed=1 mod N. To date, it is not
138known whether RSA is sec ure relative to factoring, let alone in
139itself.
140
141
142RSA hardness assumption
143- - - - - - - - - - - -
144
145The computational hardness of RSA is thus not proven and not reducible
146to factoring but at least to some extent plausible. It is thus
147justified to formulate the following RSA hardness assumption.
148
149There exists a randomised polynomial time algorithm GenRSA() which
150given security parameter n produces (N,e,d) such that N is the product
151of two primes N=pq and d = e^{-1} mod phi(N) and such that the following
152experiment has negligible success property for all probabilistic polynomial time adversaries A:
153
154RSA-inv_A(n):
155
1561. Run GenRSA(n) to obtain (N,e,d)
1572. Choose x<-Z^*_N
1583. A is given N,e, and x^e mod N and outputs x'
1594. The output of the experiment is 1 if x=x' and 0 otherwise.
160
161
162It is believed that the RSA assumption holds with GenRSA(n) selecting
163two random primes of length n, choosing e at random and outputting
164(pq,e,e^{-1} mod phi(N)).
165
166
167Groups for cryptography
168- - - - - - - - - - - -
169
170A *group generating* algorithm G(n) is a probabilistic polynomial time
171algorithm which given security parameter n produces a description of a
172group G_n whose order is polynomial in n. The description of the group
173comprises generators, a well-formedness test, testing whether a given
174bitstring encodes a group element or not and algorithms implementing
175multiplication and inverses on these representations.
176
177For example, G(n) might determine a random prime p of length n and
178then return an algorithmic description of the group Z_p^*. As for a
179generator, it could produce a primitive element.
180
181For some applications, groups of prime order are preferred. One
182example of those is the following: If q is a prime such that p=2q+1 is
183also prime (p is then called a "strong prime") then the subgroup of
184Z^*_p consisting of the elements of the form y^2 for y:Z_^*p (the
185quadratic residues mod p) form a subgroup of Z^*_p of order q which by
186assumption is prime.
187
188Further examples are furnished by groups of points on an elliptic
189curve. The elements of such a group are pairs (x,y) of elements of
190a finite field GF(q) (q prime) such that
191
192 y^2 = x^3 + Ax + B
193
194holds for fixed parameters A, B which thus determine the elliptic
195groups. In addition to these pairs (x,y) the group contains a special
196element O.
197
198For example, if the field is GF(7) = Z_7 and A=B=3 then the group (the
199elliptic curve) has elements (1,0), (3,2), (3,5), (4,3), (4,4),
200O. Indeed, whenever x^3+3x+3 is (zero or) a quadratic residue mod 7 we find (one
201or) two points and otherwise not.
202
203The group operation, i.e. how elements of the group are added (or
204multiplied, depending on notation), is omitted for now.
205We come back to it later.
206
207
208
209
210
211Discrete logarithm and Diffie Hellman
212- - - - - - - - - - - - - - - - - - -
213
214Given a cyclic group G with generator g the discrete logarithm problem
215is the following: given h:G determine e such that h=g^e. Formally,
216suppose that we are given a group generating algorithm G(n) outputting
217for each n a cyclic group G_n and a generator g.
218
219For adversary A the experiment DLog_{A,G}(n) then is the following:
220
2211. Run G(n) to obtain (G,q,g) where G is a cyclic group of order q
222with generator g.
223
2242. Choose h<-G /* e.g. by putting h=g^d for d<-Z_q */
2253. A is given G,q,g,h and outputs e:Z_q
2264. The output of the experiment is 1 if g^e = h
227
228By definition, the discrete logarithm problem is hard for G() if for
229all adversaries A one has Pr(DLog_{A,G}(n)=1) = negl(n).
230
231It is generally believed that discrete logarithm is hard for the
232aforementioned example groups.
233
234Related problems are computational Diffie-Hellman (CDH) and decisional
235Diffie-Hellman (DDH).
236
237Computational Diffie-Hellman: given a cyclic group G of order q and
238generator g as above and h=g^x, h'=g^y determine (without knowing x,y !)
239the value g^{xy}.
240
241Decisional Diffie-Hellman: given a cyclic group G of order q and
242generator g as above and h=g^x, h'=g^y and h''=g^z determine (without
243knowing x,y,z !) whether or not g^{xy}=g^z.
244
245Clearly, a solution to the discrete logarithm problem implies a
246solution to Diffie-Hellman, but the converse is not known. As a
247result, hardness of discrete log is a weaker assumption than hardness
248of DDH (and CDH)
249
250Diffie-Hellman is important for the eponymous Diffie-Hellman
251key-exchange protocol: In order to share a common secret key Alice may
252choose random x:Z_q and send u=g^x to Bob. Bob does the same and thus
253sends v=g^y to Alice. Now, Alice and Bob can both compute the shared
254key g^{xy} as u^x (Alice) and v^y (Bob). We will show later that
255assuming DDH is hard this scheme is secure in a precise sense.
256
257Formal definition of hardness of DDH:
258
259Given a group-generating algorithm G() producing cyclic groups as
260above, we say that the decisional Diffie Hellman problem is hard for
261G() if for all probabilistic polynomial-time adversaries A and all n we have
262
263 |Pr(A(G,q,g,g^x,g^y,g^z)=1) - Pr(A(G,q,g,g^x,g^y,g^{xy}))| = negl(n)
264
265where G(n)=(G,q,g) and x,y,z <- Z_q.
266
267Thus, DDH is hard, if g^{xy} looks like a random element of G even if
268g^x and g^y are known.
269
270We close this chapter by remarking that under the assumption that RSA
271is hard thre exist pseudo random generators, pseudorandom functions,
272and permutations (see KL6 and 7.4.1). Under the assumption that
273discrete logarithm is hard for some group then there exist collision
274resistant hash functions. (KL7.4.2).