%hide
html('<h3>Diffie-Hellman Key Exchange (1)</h3>')
# step 0
p = [polygon([(-10,0),(10,0),(10,15),(-10,15)],rgbcolor=(0.5,0.8,1))]
p[0] += polygon([(-2,0),(2,0),(2,15),(-2,15)],rgbcolor=(1,1,0.3))
p[0] += line([(-10,13),(10,13)],rgbcolor=[0,0,0])
p[0] += text('Alice',(-5,14),rgbcolor=[0,0,0],fontsize=14)
p[0] += text('Bob',(5,14),rgbcolor=[0,0,0],fontsize=14)
p[0] += text('Eve',(0,14),rgbcolor=[0,0,0],fontsize=14)
# step 1
p += [text('agree on $p$ and $g$ with Bob',(-5,11),rgbcolor=[0,0,0],fontsize=9)]
p[1] += text('agree on $p$ and $g$ with Alice',(5,11),rgbcolor=[0,0,0],fontsize=9)
p[1] += arrow((-2,11),(2,11),rgbcolor=[0,0,0])
p[1] += arrow((2,11),(-2,11),rgbcolor=[0,0,0])
p[1] += text('$p, g$',(0,11.5),fontsize=12)
# step 2
p += [text('choose random $a$',(-5,8),rgbcolor=[0,0,0])]
p[2] += text('$A$ := $g^a$ mod $p$',(-5,6.7),rgbcolor=[0,0,0])
p[2] += arrow((-2,6.5),(2,3),rgbcolor=[0,0,0])
p[2] += text('$A$',(1.8,4),rgbcolor=[0,0,0],fontsize=12)
# step 3
p += [text('choose random $b$',(5,8),rgbcolor=[0,0,0])]
p[3] += text('$B$ := $g^b$ mod $p$',(5,6.7),rgbcolor=[0,0,0])
p[3] += arrow((2,6.5),(-2,3),rgbcolor=[0,0,0])
p[3] += text('$B$',(-1.8,4),rgbcolor=[0,0,0],fontsize=12)
# step 4
p += [text('$K_A$ := $B^a$ mod $p$',(-5,2),rgbcolor=[0,0,0])]
# step 5
p += [text('$K_B$ := $A^b$ mod $p$',(5,2),rgbcolor=[0,0,0])]
t = ['',
'1. Alice and Bob agree on a prime number $p$ and a primitive root $g.$',
'2. Alice chooses a natural number $a$, computes $A = g^a \\bmod{p},$ and sends $A$ to Bob.',
'3. Bob chooses a natural number $b$, computes $B = g^b \\bmod{p},$ and sends $B$ to Alice.',
'4. Alice computes the key $K_A = B^a \\bmod{p}.$',
'5. Bob computes the key $K_B = A^b \\bmod{p}.$']
@interact
def _(step=selector([0,1,2,3,4,5],nrows=1)):
html(t[step])
pl = p[0]
for i in range(step+1):
pl += p[i]
show(pl,axes=false,xmin=-8,xmax=8,ymin=1,ymax=15)
html('Figure 2.1 This graphic illustrates the Diffie-Hellman key exchange consisting of steps 0 to 5. Click on the numbers to see it <br>step by step. Note that everything in the blue boxes happens secretly (with Alice or Bob), and everything in the yellow box is <br>sent over the insecure network and may be seen by Eve.')
|
|
Diffie-Hellman Key Exchange (1)
Figure 2.1 This graphic illustrates the Diffie-Hellman key exchange consisting of steps 0 to 5. Click on the numbers to see it step by step. Note that everything in the blue boxes happens secretly (with Alice or Bob), and everything in the yellow box is sent over the insecure network and may be seen by Eve.
Click to the left again to hide and once more to show the dynamic interactive window
|