Skip to main content

Elliptic Curve Utils

Project description

Elliptic Curve Utils (ecutils)

Documentation Status Latest Version Downloads Downloads Downloads

Elliptic Curve Utils, or ecutils, is a Python package that provides utilities for working with elliptic curves, particularly in the context of cryptography. It includes functionality for operations like point addition and scalar multiplication on curves, as well as higher-level protocols like key exchange and digital signatures.


  • Implements common elliptic curve operations such as point addition and multiplication.
  • Provides classes for encoding/decoding textual messages to and from elliptic curve points (e.g., Koblitz encoding).
  • Supports several standardized elliptic curves including secp192k1, secp256r1, and secp521r1.
  • Includes an implementation of the Elliptic Curve Digital Signature Algorithm (ECDSA) for signing messages and verifying signatures.
  • Features key exchange protocols like Diffie-Hellman and Massey-Omura over elliptic curves.


You can install the ecutils package using pip:

pip install ecutils


Encoding and Decoding Messages with Koblitz

from ecutils.algorithms import Koblitz

# Initialize Koblitz with a specific curve
koblitz = Koblitz(curve_name="secp256k1")

# Encode a message to a curve point
point, j = koblitz.encode("Hello, World!")

# Decode the curve point back to a message
decoded_message = Koblitz.decode(point, j)

Digital Signatures with ECDSA

from ecutils.algorithms import DigitalSignature

# Create a DigitalSignature instance with your private key
ds = DigitalSignature(private_key=123456)

# Hash of your message
message_hash = hash('your message')

# Generate signature
r, s = ds.generate_signature(message_hash)

# Verify signature (typically on the receiver's side)
is_valid = ds.verify_signature(ds.public_key, message_hash, r, s)

Diffie-Hellman Key Exchange

from ecutils.protocols import DiffieHellman

# Alice's side
alice = DiffieHellman(private_key=12345)

# Bob's side
bob = DiffieHellman(private_key=67890)

# Alice computes her shared secret with Bob's public key
alice_shared_secret = alice.compute_shared_secret(bob.public_key)

# Bob computes his shared secret with Alice's public key
bob_shared_secret = bob.compute_shared_secret(alice.public_key)

# alice_shared_secret should be equal to bob_shared_secret


For more in-depth use and examples, check out the official documentation.


For issues, questions, or contributions, please refer to the project's GitHub repository.


This project is licensed under the MIT License.

Don't forget to give this project a star if you find it useful! 🌟

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

ecutils-0.0.1a0.tar.gz (15.1 kB view hashes)

Uploaded source

Built Distribution

ecutils-0.0.1a0-py3-none-any.whl (11.0 kB view hashes)

Uploaded py3

Supported by

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