Previous Tip  |  Next Tip  |  Design Tips   | [Bill's Home]

152. Diffie-Hellman key exchange


[Zoom] The following shows a design of a Diffie-Hellman key exchange [View ASP.NET page]:

This is easily designed with:

There is thus no timeline, and the code is added to the buttons, such as for the Gen button:

on (press) {
 gval=random(20)+4;
 nval=random(120)+25;
 xval=random(7)+3;
 yval=random(7)+3;

 g=parseInt(gval);
 n=parseInt(nval);
 x=parseInt(xval);
 y=parseInt(yval);
 a=Math.pow(g,x)%n;
 b=Math.pow(g,y)%n;

 aval=a;
 bval=b;

 k1=Math.pow(b,x)%n;
 k2=Math.pow(a,y)%n;

 k1val=k1;
 k2val=k2;

}