summaryrefslogtreecommitdiff
path: root/ss2017/cryptography/Notes14.txt
diff options
context:
space:
mode:
Diffstat (limited to 'ss2017/cryptography/Notes14.txt')
-rw-r--r--ss2017/cryptography/Notes14.txt208
1 files changed, 208 insertions, 0 deletions
diff --git a/ss2017/cryptography/Notes14.txt b/ss2017/cryptography/Notes14.txt
new file mode 100644
index 0000000..e6075ff
--- /dev/null
+++ b/ss2017/cryptography/Notes14.txt
@@ -0,0 +1,208 @@
114 El Gamal and elliptic curve cryptography
2-------------------------------------------
3
4The El Gamal cryptosystem is based on the DDH assumption and is
5provably secure under the assumption of the latter. Just like DH-key
6exchange it is parametrised by a group (generating algorithm) G(n) and
7works as follows:
8
9Gen(n) :
10 (G,q,g) = G(n)
11 x <- Z_q
12 h <- g^x
13 pk = (G,q,g,h)
14 sk = (G,q,g,x)
15 output (pk,sk)
16
17Enc_(G,q,g,h)(m) :
18 check that m:G
19 y <- Z_q
20 c = (g^y,h^y*m)
21 output c
22
23Dec_(G,q,g,g,x)(c1,c2) :
24 m = c2 / c1^x
25 output m
26
27
28Let us first see that this scheme is correct: If c1=g^y and c2=h^y*m
29where h=g^x then c2 / c1^x= g^(xy) * m / g^(xy) = m
30
31We also notice that messages and ciphertexts are actually elements of
32the group G which must therefore by somehow encoded as binary
33strings. This can be done in various ways for the various groups, see
34KL for details.
35
36Theorem: If the DDH assumptions holds for a group (generating
37algorithm) G() then the El Gamal cryptosystem basd on G() is
38semantically secure.
39
40Proof: Let A be an adversary against the El Gamal system and let its
41success probability be 1/2+eps(n). We must show that eps(n) is
42negligible. We construct from A an adversary A' as in the DDH
43assumption.
44
45Suppose that A' receives g^x, g^y, u where u is either g^(xy) or g^z
46for random z and A' is to decide which of the two.
47
48We forward (G,q,g,g^x) as "public key" to A and wait for it to output
49m0,m1:G. We choose a random bit b and build c = (g^y,u*m_b) and let b'
50be the bit that A returns.
51
52If u=g^(xy) then A is played with according to the rules of the El
53Gamal cryptosystem and therefore b'=b with probability 1/2+eps(n). If
54u=g^z for random z then u*m0 is also uniformly random (since x|->x*m0
55is a bijection G->G) and therefore the probability that b'=b is
56exactly 1/2. The difference between the two probabilities is precisely
57eps(n) which under the DDH assumption will be negligible. QED
58
59
60Elliptic curve cryptography
61- - - - - - - - - - - - - -
62
63As already mentioned, elliptic curves furnish a large reservoir of
64cyclic groups for which taking discrete logarithms, CDH, and DDH are
65believed to be hard. With existing algorithms, solving these problems
66on elliptic curve groups is consistently harder than doing so for
67groups of invertible elements mod p or in a finite field.
68
69Recall that an elliptic curve over some field F of characteristic =/=
702,3 is defined by two constants a, b and comprises the points (x,y)
71that solve the equation
72
73 y^2 = x^3 + ax + b
74
75Here, one assumes that the *discriminant* 4a^3+27b^2 =/= 0 for
76otherwise the curve might be *singular*, i.e. contain anomalies like
77isolated points, sharp bends ("cusps") or similar. When viewed over
78the reals such a curve looks roughly as follows:
79
80 | |
81 | /
82 - | - /
83 / | \ _ -
84 | |
85---------------------------------------------------------------------
86 | | - _
87 \ | / \
88 -| - \
89 | |
90
91Depending on the parameters the knob to the left may also become
92detached and form a closed loop sitting to the right. In either case
93whenever a line intersects the curve in two points it meets it again
94in a third point except when the line is parallel to the y-axis in
95which case we say that the third point of intersection is at infinity,
96here denoted O.
97
98This property also holds for curves over other fields, in particular
99finite ones which are of interest for cryptography. There is an
100explicit formula for obtaining the third point of intersection. To
101wit, if (x1,y1) and (x2,y2) lie on the curve then the line through
102them is y=m(x-x1)+y1 where m=(y2-y1)/(x2-x1). Plugging this into the
103curve yields
104
105 (m(x-x1)+y1)^2 = x^3+ax+b
106
107The three solutions of this equation are x=x1, x=x2, x=m^2-x1-x2, so
108the last one is the desired third point of intersection.
109
110Now, it is a remarkable fact that the points on the curve together
111with O form an abelian group, traditionally written additively, where
112the sum of points P and Q is obtained by first taking the third curve
113point on the line through P and Q, call it R=(x_R,y_R), and then
114reflecting R on the x-axis, i.e. P+Q=(x_R,-y_R).
115
116This, however, only applies when P=/=Q and when P and Q do not have
117the same x-coordinate. In the latter case, one has P+Q=O, the special
118point at infinity. In the former case, i.e. when P=Q, one must take
119the tangent through P and intersect it with the curve.
120
121One can show using implicit differentiation that the coordinates of
122that point are given by
123
124 (((3x_1^2+a)/2y_1)^2 - 2x1, -y1+((3x_1^2+a)/2y_1)^2(x1-x2))
125
126and this formula, just as the one above for the general case, also
127makes sense for finite fields where there are no "tangents". Yet
128another special case is when P or Q is O. One simply puts O+P=P+O=P.
129
130Curves over fields of characteristic 2 or 3 are also possible, but
131then both the defining equations and the formulas for addition of
132points become slightly different (notice e.g. that in the formula
133above we divide by 2). We refer to the literature, but stress that it
134is very important not to make mistakes with the implementation of the
135addition formulas and that doing so has lead to security flaws.
136
137We have already seen that addition of points is well-defined and
138commutative. It is also clear that the inverse of a point (x,y) is
139given by (x,-y), i.e. reflection on the x-axis. Associativity of
140addition follows from nontrivial results, e.g. the Weierstrass
141p-function, but can in principle also be validated "by hand" on the
142basis of the above formulas.
143
144For integer n and point P on a curve we use the notation n.P for
145P+P+...+P with summands. This is the same as the exponent notation in
146multiplicatively written groups. Therefore, the "repeated squaring"
147method can be used here as well:
148
149 100.P = 4.P+32.P+64.P = 2.(2.(P + 2.(2.(2.(P+2.P)))))
150
151Now, the plan is to use the groups coming from elliptic curves for
152cryptosystems like Diffie-Hellman key exchange or El Gamal. For this
153to work, a couple more considerations are in order: we need to encode
154plaintexts as points on the group and we need to ascertain that the
155group is cyclic or else move to a cyclic subgroup.
156
157In order to find a cyclic group one can rely on one of the publicly
158available and recommended curves. Many of them have a prime number of
159points and hence are cyclic with any element other than O being a
160generator. Alternatively, one can try out random coefficients a and b
161until one finds a curve with a prime number of points. To do this, one
162needs to invoke Schoof's algorithm which allows one to determine the
163number of points on a given elliptic curve.
164
165If one would like to use a curve with a nonprime number, say N, of
166points, then one must factor N and it is then important that N has a
167large prime factor p, i.e. p>sqrt(N). In this case, by the
168representation theorem for finite(ly generated) abelian groups there
169is a subgroup of order p and any of its nonzero elements are
170generators. Moreover, the remaining subgroups have smaller order. To
171check whether a point P is in the subgroup of order p it suffices to
172check that p.P = O. To obtain a point in that subgroup one can pick a
173random point P and if Q := N/p.P =/= O then p.Q is in the subgroup,
174hence Q can serve as a generator.
175
176For the most, however, one uses one of the already publicised elliptic
177curves such as those recommended by the NIST "for government use".
178See http://csrc.nist.gov/groups/ST/toolkit/documents/dss/NISTReCur.pdf
179There is no need to choose a "fresh" curve for every application and
180on the other hand, some curves are "weak" and should be avoided.
181
182In order to encode plaintexts as points we can proceed as
183follows. First, we note that it suffices to store the x-coordinate of
184a point and a single bit telling whether the y-coordinate is above or
185below the x-axis, i.e., which of the two square roots of x^3 +ax+b are
186meant. This is known as point compression. As for the x-coordinates
187one fixes a bijection alpha between bitstrings of length l=log(q) and
188field elements. Now one puts t=l-k where k is chosen sufficiently
189large. Then, to encode message x of length t one searches for a string
190z of length k so that alpha(x||z) has a square root y over GF(q),
191i.e., is a quadratic residue. At that point, (alpha(x||z),y) can be
192taken as the desired encoding of x as a curve point. For random
193padding z the chance for alpha(x||z) to be a quadratic residue is
194about 1/2, so after a short number of iterations one is almost sure to
195find an appropriate encoding. We also remark that there exist
196efficient algorithms for testing whether a given field element is a
197quadratic residue and if so to compute its square root.
198
199With all this machinery in place, the Diffie-Hellman and El Gamal
200cryptosystems can be used with elliptic curve groups without any
201change, bearing in mind, of course, that instead of exponentiation
202g^x, we now use multiplication x.P and instead of multiplication we
203use addition, so that, e.g. the encryption of message m encoded as a
204point M becomes (y.P,y.Q+M) where P is the generator and Q=x.P
205
206We close by remarking that since the early 2000 elliptic curve
207cryptography (ECC) has become more and more common. Also the bitcoin
208cryptocurrency uses it.