Skip to main content

Implements El Gamal scheme over Elliptic Curves for encryption. Overwrites Pythons inbuilt functions to allow modular arithmetic in finite fields and elliptic curve group operations by using the * symbol

Project description

This package was written for learning purposes only. It should not be used in any situation where real security is required.

I have implemented the El Gamal method of asymetric key exchnge over elliptic curves. The field, curve, and starting point used in this implementation came from http://www.secg.org/sec2-v2.pdf under the nickname 'secp256r1'. I used this curve and field because it provides an adequate level of security while remaining relatively fast. It is my understanding that fields any larger cannot be proccessed quickly due to current hardware design limitations. One way around this is by using a larger field for an initial asymetric key which would be used to communicate a symmetric key. This would seem to be a best of both worlds type approach but more research would be needed to be certain.

I chose three different classes/objects for this project. The first is modNum.The class of modNum is an integer number that can be manipulated by the usual math functions of +,-,*,/,//,**,+=,...,/= as well as it's own sqrt() function.

The second class is EllipticCurve. The EllipticCurve class has immutable class variables that define the field and curve to be used. Instantiating an instance of EllipticCurve takes two integers, x and y, and uses them to create two instances of the modNum class. The instantiation also confirms that the given x,y are valid points on the curve. This check is crucial since the field must be closed. This class also supercedes the built in functions for * and **. Multiplication becomes the elliptic curve group operation and ** powering using that group operation.

The third class is ElGamal. This class creates a random private key for each instance of the class and uses that private key to create a secondary public key, h. Using encrypt() you can encrypt any message by providing the prime and both public keys of the recipient of the message. Then using the specific instance ElGamal that generated the private key and secondary public key you can decrypt a message intended for for the create of that specifc instance. Obviously in a real application you would need to be able to store the private key. But I chose to not implement a method to do that since this code shouldn't be used in real applications.

I also wrote a full suite of tests for all exposed functions. I even wrote a specifc version of encrypt with a lower level of security to be used solely for testing purposes.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ElGamalEllipticCurves-0.1.11.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ElGamalEllipticCurves-0.1.11-py3-none-any.whl (10.4 kB view details)

Uploaded Python 3

File details

Details for the file ElGamalEllipticCurves-0.1.11.tar.gz.

File metadata

  • Download URL: ElGamalEllipticCurves-0.1.11.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.8.8

File hashes

Hashes for ElGamalEllipticCurves-0.1.11.tar.gz
Algorithm Hash digest
SHA256 c871afcb9a81aa02db47fb2af7b15a84d925b1b045b320a4a5f20dae1999590b
MD5 db858f714c045860aa55143d9166eba6
BLAKE2b-256 e0f90a458ee1d02fb56a593d69bf070deddfb66640e49dbace65cb03b77ec7af

See more details on using hashes here.

File details

Details for the file ElGamalEllipticCurves-0.1.11-py3-none-any.whl.

File metadata

File hashes

Hashes for ElGamalEllipticCurves-0.1.11-py3-none-any.whl
Algorithm Hash digest
SHA256 7b20fad9a8212711d74b32d0e4617d4c2332e80c061f9901f7cca0863f668ded
MD5 09607fc30fb8f0e5cec805c60527ceb5
BLAKE2b-256 71a5eeb03f134ab957c9641aead9ac95c8b3de2f45e5c2f41fc204bbb54fced3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page