ECC
A pure Python library for Elliptic Curve Cryptography (ECC) — built from scratch with clarity and educational readability in mind.
Supports digital signatures (ECDSA), key generation, and secure field arithmetic over common curves like secp256k1, P-256, and more.
✨ Features
- Finite field arithmetic over prime fields (
FieldElement) - Curve definition (
CurveandPoint) - ECC point addition, doubling, and scalar multiplication
- Key pair generation (
keys.py) - ECDSA signature generation and verification (
ecdsa.py) - Built-in support for popular curves (
secp256k1,P-256,brainpool, etc.) - Easy-to-understand documentation in every module for educational purposes
📦 Installation
From PyPI:
pip install eccrypto
🔍 Quick Examples
🔑 Key Generation
from ecc import generate_keypair
from ecc import secp256k1
priv, pub = generate_keypair(secp256k1)
print("Private Key:\n", priv)
print("Public Key:\n", pub)
✍️ ECDSA Sign & Verify
from ecc import secp256k1
from ecc import generate_keypair
from ecc import sign, verify
priv, pub = generate_keypair(secp256k1)
msg = b"Heyy! :D"
signature = sign(msg, priv)
print("Signature:", signature)
valid = verify(msg, signature, pub)
if valid:
print("The signtature is valid!")
📌 Curve and Point Usage
from ecc import Curve, Point
a, b = 2, 2 # Curve: y^2 = x^3 + 2x + 2
P = 17 # Prime modulus
G = (5, 1) # Generator Point
n = 19 # Number of points in E(Z/17Z)
curve = Curve(a, b, P, G, n)
print(curve)
G = Point(5, 1, curve)
print("Generator point: ", G)
P = 2 * G # Scalar Multiplication
P1 = P + P # Point Addition
print("2G = ", P)
print("2G + 2G = ", P1)
🔢 Field Arithmetic
from ecc import FieldElement
a = FieldElement(7, 13)
b = FieldElement(8, 13)
print("a + b =", a + b)
print("a * b =", a * b)
print("a ** -1 =", a ** -1) # Inverse of a
🧪 Testing
You can run the test suite using pytest:
pytest
All tests are located in the tests/ directory and cover field arithmetic, point operations, key generation, and ECDSA functionality.
🤝 Contributions Welcome
PRs for adding new curves, improving documentation, and optimizations are welcome. Please make sure all tests pass.
📄 License
Licensed under the GPL-3.0 License. See LICENSE.
📞 Contact
Author: Shivakumar Email: shivakumarjagadish12@gmail.com GitHub: drtoxic69
For questions, bug reports, or feature requests, please open an issue on the GitHub repository or contact me directly via email.
Metadata
Release files for eccrypto 0.2.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| eccrypto-0.2.0.tar.gz | 47.3 kB | Without provenance | Details for eccrypto-0.2.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| eccrypto-0.2.0-py3-none-any.whl | Python 3 | none | any | Details for eccrypto-0.2.0-py3-none-any.whl |
Total release size: 73.9 kB
Release files / eccrypto-0.2.0.tar.gz
| Download URL | eccrypto-0.2.0.tar.gz |
|---|---|
| Size | 47.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76f564c229382b15c96697f70d3ee7b4cf0b0d9ba605b2c291e7983c33a7030b
|
|
BLAKE2b-256 checksum How to use checksums |
e7167bd66d014ec9a068462ffd5f84a74f5f7cb9c828bd55b41f966e67ccf6d0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Release files / eccrypto-0.2.0-py3-none-any.whl
| Download URL | eccrypto-0.2.0-py3-none-any.whl |
|---|---|
| Size | 26.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
4e50615e287b02254c4d3f87e68d3ecff7842cbba542ea6adf77662842682bf5
|
|
BLAKE2b-256 checksum How to use checksums |
fa7ce67310f3d1827810e92453a28a78f4aa9a978f0705c9260504349059bf63
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.8.4
|
Security for eccrypto 0.2.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.