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…

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]:

A sample run [here]:

Value: 5
C1=61731537931976102098597542679169200370390331523343251525778699524875212947483101238547227438607225354481354317898559670746008619595624284788974184415330172: C2=046ea67492e54108756e00275244d7a9decb64a28150ed76f7e97a79e79f1762b28c58f5a3e29e5f11b855409a9e3a45e1a9aed2eca3551d262cfba62b36c51e8f
Decrypted: 5

You can try it out here:

https://asecuritysite.com/kryptology/elgamal02