Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168756
Image: ubuntu2004
Elliptic Diffie--Hellman Key Exchange
# A trusted party chooses and publishes a large prime p and an elliptic curve over F_q, # where q=p^s, for some integer s. q=next_prime(81)^2 F.<a>=GF(q,'a') E=EllipticCurve(F,[0,0,0,F(4),F(5)]) E
# The trusted party also publishes a base point P. P=E.points()[40] P
# Bob and Alice each choose secret integers nB and nA, and compute nB*P and nA*P, respectively # Bob first, nB=23456 QB=nB*P # then Alice, nA=9876 QA=nA*P # Then they sent each other their public values QB;QA
# Now, each multiplies the point they received by their secret integer, # and they should be the same. nB*QA==nA*QB;nB*QA
# They discard the y value, and use the x value as a common key for some other encryption.
reset()
Elliptic ElGamal public key cryptosystem
# A trusted party chooses and publishes a large prime p and an elliptic curve over F_q, # where q=p^s, for some integer s. q=next_prime(100) F.<a>=GF(q,'a') E=EllipticCurve(F,[0,0,0,14,5]) E
# The trusted party also publishes a base point P. P=E.points()[27] P
# Alice chooses a private key, an integer, nA, and publishes QA=nA*P nA=876432 QA=nA*P QA
# Bob embeds a plain text into the x coordinate of a point M on E. He chooses an integer # k to be his ephemeral key and computes C1=kP and C2=M+kQA. M=E.points()[31] k=123456784 C1=k*P C2=M+k*QA # He then sends C1 and C2 to Alice. M;C1;C2
# Alice computes C2-nA*C1=(M+k*QA)-nA*(k*P)=M+k*(nA*P)-nA*(k*P)=M C2-nA*C1