Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168699
Image: ubuntu2004
# ECCN: 5D002 under US License Exception TSU (740.13(e)) # Curve P-256 (published by NIST): # Modulus p = 115792089210356248762697446949407573530086143415290314195533631308867097853951 # Order r = 115792089210356248762697446949407573529996955224135760342422259061068512044369 # Coefficients a = -3 b = 41058363725152142129326129780047268409114441015993725554835256314039467401291 # Base Point Gx = 48439561293906451759052585252797914202762949526041747995844080717082404635286 Gy = 36134250956749795798585127919587881956611106672985015071877198253568414405109 #Generate Curve E = EllipticCurve(GF(p),[a,b]) # y^2 = x^3 + ax + b g = E.point((Gx,Gy)) (E,g)
(Elliptic Curve defined by y^2 = x^3 + 115792089210356248762697446949407573530086143415290314195533631308867097853948*x + 41058363725152142129326129780047268409114441015993725554835256314039467401291 over Finite Field of size 115792089210356248762697446949407573530086143415290314195533631308867097853951, (48439561293906451759052585252797914202762949526041747995844080717082404635286 : 36134250956749795798585127919587881956611106672985015071877198253568414405109 : 1))
# Diffie Hellman Key Exchange Example # Alice generates a secret number and multiplies times the base point rA = randrange(2**256);RA = rA*g # Bob generates a secret number and multiplies times the base point rB = randrange(2**256); RB = rB*g # Alice and bob exchange their new points RA and RB # Bob multiplies the point from Alice times his secret number kA = rA*RB # Alice multiplies the point from Alice times his secret number kB = rB*RA # Both Alice and Bob have the shared secret kA = kB (kA,kB)
((92858997737304457521252065746379931338696374205359539900134625392925349057012 : 25826257329444039229011399285538065758919635841044136678692840454595768569900 : 1), (92858997737304457521252065746379931338696374205359539900134625392925349057012 : 25826257329444039229011399285538065758919635841044136678692840454595768569900 : 1))
# El Gamal Example # Encode message message=E.random_element(); # Generate ephemeral key ek = randrange(2**256) # e1 e1 = ek*g # e2 e2 = message + ek*RA message
(33716410284378234666415809925922089422719337098388252201854934211257541142654 : 64870628577544083902154579481388089116632823396012869459173603062127465342661 : 1)
# Decrypt El Gamal # Alice decrypts the message using her secret key (rA) decoded=e2-rA*e1 decoded
(33716410284378234666415809925922089422719337098388252201854934211257541142654 : 64870628577544083902154579481388089116632823396012869459173603062127465342661 : 1)