Python implementation of elliptic curve cryptography primitives, elliptic curve algebra, and some cryptanalysis algorithms. It is intended for educational purposes, and the implementation aims to expose as much as possible the components to experiment with them. The jupyter notebook ecc_examples.ipynb illustrates the use of the package.
The package provides:
- Elliptic curve cryptography algorithms
- Elliptic Curve Digital Signature Algorithm (ECDSA)
- Edwards Curve Digital Signature Algorithm (EdDSA)
- Elliptic Curve Diffie-Hellman (ECDH) key exchange
- Elliptic curve algebra with different forms of curves
- Weierstrass curves (the canonical form)
- Montgomery curves
- (twisted) Edwards curves
- Some cryptanalysis algorithms
- Attacks on the discrete logarithm problem
- Partially known nonces attack on ECDSA
However, this package does NOT provide:
- A fast and secure implementation of the algorithms and elliptic curve algebra.
- Support for elliptic curves over finite fields
$\mathrm{F}_q$ with non-prime$q$ (eg$q = 2^m$ ). - Random key generation for the various protocols.
Apart from the cryptanalysis
module, the package uses only the standard
library. Third party packages are necessary to run cryptanalysis algoritms:
- numpy
- sympy (for integer factorization)
- python-flint (for LLL reduction)
The typing annotations in the code are by no means rigorous. They are made to facilitate the understanding of the nature of various parameters.
- SEC 1: Elliptic Curve Cryptography
- SEC 2: Recommended Elliptic Curve Domain Parameters
- RFC 6090 Fundamental Elliptic Curve Cryptography Algorithms
- RFC 6979 Deterministic Usage of the Digital Signature Algorithm (DSA) and Elliptic Curve Digital Signature Algorithm (ECDSA)
- RFC 7748 Elliptic Curves for Security
- RFC 8032 Edwards-Curve Digital Signature Algorithm (EdDSA)
- https://safecurves.cr.yp.to/ ; detailed info about the security of ECC