Photo by Laura Ockel on Unsplash

Old With New … ElGamal and Elliptic Curve Cryptography

--

The original ElGamal method used discrete logarithms but had interesting properties, such as creating authenticated encryption and implementing homomorphic encryption. But, elliptic curve cryptography came along and provided much smaller keys and faster operations. So, now, we can merge the two, and open up a whole world of privacy and trust.

With ElGamal encryption using elliptic curves, Alice generates a private key (y) and a public key of:

Y=y.G

and where G is the base point on the curve. She can share this public key (Y) with Bob. When Bob wants to encrypt something for Alice, he generates a random value (r) and then computes:

C1=r.G

and then will take the message (M) and computes:

C2=r.Y+M

Note, that we have to convert r.Y into a scalar value, and not a point. This is because M is an integer. To decrypt, Alice takes her private key (y) and computes:

M=C2−y.C1

This works because:

M=C2−y.C1=r.y.G+M−y.r.G=M

We can use the Kryptology library developed by Coinbase and use the secp256k1 curve (as used by Bitcoin and Ethereum) [here]:

--

--

Prof Bill Buchanan OBE FRSE
ASecuritySite: When Bob Met Alice

Professor of Cryptography. Serial innovator. Believer in fairness, justice & freedom. Based in Edinburgh. Old World Breaker. New World Creator. Building trust.