Elliptic Cryptography and ECDSA
Project description
foss_cryptography
foss_cryptography
is a Python free open source library for Elliptic Curves Cryptography under the MIT license.
The library provides:
- the basic operations for the generic elliptic curve points: addition, doubling and scalar multiplication
- the parameters of the secp256k1 elliptic curve
- the ECDSA (Elliptic Curve Digital Signature Algorithm) for message signing and verification
The main functions of this library are self-contained, and the library doesn't require any external dependencies to perform its core operations.
Features
-
Elliptic Curve Operations: The library includes a module
ellipticCurves.py
that provides essential operations on elliptic curves, such as point doubling, point addition, and scalar multiplication. -
ECDSA Implementation: The
ecdsa.py
module implements the ECDSA algorithm, allowing users to sign and verify messages using the secp256k1 elliptic curve.
Installation
From PyPI:
Install the library
pip install foss-cryptography
From GitHub:
Clone the library from GitHub
git clone https://github.com/stefanogaspari/foss_cryptography.git
Install the library dependencies
pip install -r requirements.txt
Build the library
python setup.py bdist_wheel
Install the library
pip install /path/to/wheelfile.whl
Usage
Elliptic Curves
from cryptography.ellipticCurves import EllipticCurve
from cyptography.secp256k1 import mod, a, b
# Initialize an elliptic curve
curve = EllipticCurve(mod, a, b)
# Point initialization
P = [x1, y1] # x1 and y1: type int
Q = [x2, y2] # x2 and y2: type int
# Point doubling
R = curve.double(P)
# Point addition
R = curve.add(P, Q)
# Scalar multiplication
result = curve.scalar_multiply(n, P)
ECDSA
from cryptography.ecdsa import ECDSA
from cyptography.secp256k1 import mod, a, b, origin_G, n
# Initialize ECDSA instance
ecdsa = ECDSA(m, a, b, origin_G, n)
# Sign a message
signature = ecdsa.sign(k, message, private_key)
# Verify a message
is_verified = ecdsa.verify(signature, message, public_key)
License
This project is under the MIT License.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Hashes for foss_cryptography-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 163e056d1632da2fe50ba89b558d538cc22e872f53515c943b6509e25ebb323f |
|
MD5 | 5bfbde018ed53fd69c6f76983d9c0675 |
|
BLAKE2b-256 | 9cc56c480e617c734f1139bd2140e9c45b7701362aed5e3fd75bf94106fc5ad9 |