Skip to main content

Pure Python library for Elliptic Curve Cryptography (ECC) — built from scratch with clarity and educational readability in mind

Project description

ECC

PyPI version License Downloads Issues

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 (Curve and Point)
  • 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.

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

eccrypto-0.1.1.tar.gz (20.3 kB view details)

Uploaded Source

Built Distribution

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

eccrypto-0.1.1-py3-none-any.whl (21.4 kB view details)

Uploaded Python 3

File details

Details for the file eccrypto-0.1.1.tar.gz.

File metadata

  • Download URL: eccrypto-0.1.1.tar.gz
  • Upload date:
  • Size: 20.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for eccrypto-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9671460df1b62afaa41aa87537251f108715cdf4d110413412710fc476bbec04
MD5 82bcf92f25a8c624e3c3ae5fe3e561c8
BLAKE2b-256 c1b9c292a42ee3cdd3adb0eaf38d040b3576d9369eb2225d352bac1ca6f3fb59

See more details on using hashes here.

File details

Details for the file eccrypto-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: eccrypto-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 21.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.7.15

File hashes

Hashes for eccrypto-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a113c49d5ff499bf503ffe8f2bc443512b9f274958d6e75acc596b403bd58cc9
MD5 6b80e4c5d005f5c694da89ac37339f73
BLAKE2b-256 b56b35a76378df1a694e59589a7d9716e24c2f9a6dd12408f5900bf951cb96b7

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