Coders Packet

Elliptic Curve Cryptography based secured messaging using Python

By Shivang Kohli

Elliptic Curve Cryptography, a public key cryptography system that makes use of private and public keys of receiver to encrypt a message, is used to create a secured messaging service in Python.

Using Python and NumPy library, i have created the Elliptic Curve Cryptography based encryption and decryption service that sends messages in a secured way. It can be used in numerous applications besides messaging. 

The algorithm for Elliptic Curve Cryptography is :

E -> Elliptic Curve in the form of y2 = x3 + a*x + b 

where, a and b are constants

P -> Point on the curve
n -> Maximum limit ( This should be a prime number )

Key Generation
1. select a number ‘d’ within the range n.
2. Generate public key by Q = d * P
(d = The random number that we have selected within the range of ( 1 to n-1 ). P is
the point on the curve.)
3.Private key =d , Public key = Q
4.Take input message in form of point M.
5.Randomly select ‘k’ from [1 – (n-1)].
6. Generate 2 cipher texts:
C1 = k*P
C2 = M + k*Q
C1 and C2 will be sent.
M = C2 – d * C1
M is the original message that we have sent

The code takes in values of n,a,b and d as inputs.

It generates the generator point G and public keys for the encryption.

It then takes in the message as input and encrypts it.

This is then decrypted at the receivers side back into the message.

For example :


Download Complete Code


No comments yet