Registry / auth-security / fastecdsa

fastecdsa

JSON →
library3.0.1pypypi✓ verified 89d ago

fastecdsa is a Python library designed for fast elliptic curve digital signatures. It provides an efficient implementation of ECDSA for various standard curves and hash functions, outperforming some other pure Python alternatives. The library is currently at version 3.0.1, with its latest major release in January 2025, and continues to be actively maintained.

pip install fastecdsa
INSTALL
IMPORT
SIG · FASTECDSA
F
fastecdsa
auth-securitypythonv3.0.1
Install
1.6s avg
Import
16ms
Disk
17MB
Pass rate
5/ 10
Env Coverage5 / 10
glibc
3.9–3.13
musl
3.9–3.13
Install & Compatibility
Where this runs
tested against v3.0.1 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.10–3.920 runs
build_error
glibc
py 3.10–3.920 runs
installs and imports cleanly · install 1.6s · import 0.016s · 19MB
17MB installed
● package 17MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

keys
✓ from fastecdsa import keys
curve
✓ from fastecdsa import curve
ecdsa
✓ from fastecdsa import ecdsa
P256
✓ from fastecdsa.curve import P256
Point
✓ from fastecdsa.point import Point

Generates an ECDSA keypair using the P256 curve, signs a sample message with the private key, and then verifies the signature using the public key and the same curve and hash function.

from fastecdsa import keys, curve, ecdsa from hashlib import sha256 # 1. Generate a keypair private_key, public_key = keys.gen_keypair(curve.P256) # 2. Message to sign (can be string, bytes, or bytearray) message = "This is a test message to be signed." # 3. Sign the message r, s = ecdsa.sign(message, private_key, curve.P256, hashfunc=sha256) # 4. Verify the signature valid = ecdsa.verify((r, s), message, public_key, curve.P256, hashfunc=sha256) print(f"Private Key: {hex(private_key)}") print(f"Public Key (x, y): ({hex(public_key.x)}, {hex(public_key.y)})") print(f"Signature (r, s): ({hex(r)}, {hex(s)})") print(f"Signature Valid: {valid}")
Debug
Known issues
breakingfastecdsa versions 2.x and above exclusively support Python 3.5+. Earlier versions (pre-1.2.1) were compatible with Python 2.7, requiring a Python version upgrade for users migrating from older codebases.
fix
Upgrade your Python environment to 3.9+ and install the latest fastecdsa version.
affects: <2.0.0
gotchaThe library author recommends using more established and thoroughly reviewed cryptographic libraries for security-critical applications, despite fastecdsa's internal security considerations.
fix
Assess the security requirements of your application carefully. For high-stakes security, consider alternatives like `cryptography`.
affects: All versions
gotchaInstallation on Windows and macOS (especially M1/Apple Silicon) can be complex due to the requirement for a C compiler and the `gmp` library. Users often encounter build errors if these dependencies are not correctly set up and discoverable by the Python build process.
fix
Ensure you have a C compiler (e.g., Visual Studio Build Tools on Windows, Xcode Command Line Tools on macOS) and the `gmp` library installed on your system, with their headers and libraries accessible via system paths or environment variables (CFLAGS, LDFLAGS).
affects: All versions
breakingOlder versions of fastecdsa (prior to 2.3.2) contained several security vulnerabilities, including timing attacks and use of uninitialized variables, which could lead to information leakage or denial of service.
fix
Upgrade to fastecdsa version 3.0.1 or at least 2.3.2 to mitigate known vulnerabilities.
affects: <2.3.2
Errors
Common errors & fixes
error: Microsoft Visual C++ 14.0 or greater is required.
During installation on Windows, the C extensions fail to compile because the necessary Microsoft Visual C++ Build Tools are not found.
fix
Install 'Microsoft C++ Build Tools' for Visual Studio (available as a standalone installer or part of Visual Studio).
fatal error: 'gmp.h' file not found #include "gmp.h" OR ld: library not found for -lgmp
The C compiler cannot find the GMP library headers or the linker cannot find the GMP library itself during compilation of fastecdsa's C extensions.
fix
Install the GMP development packages for your system:
- Debian/Ubuntu: `sudo apt-get install libgmp3-dev`
- RHEL/CentOS: `sudo yum install gmp-devel`
- macOS (Homebrew): `brew install gmp`. If this doesn't resolve it, try installing with `CFLAGS="-I$(brew --prefix gmp)/include" LDFLAGS="-L$(brew --prefix gmp)/lib" pip install fastecdsa`.
TypeError: Cannot convert int to bits OR TypeError: an integer is required (got type bytes)
Incorrect argument order or type for the `ecdsa.sign()` or `ecdsa.verify()` functions. A common mistake is swapping the message and private key arguments.
fix
Ensure the correct signature `ecdsa.sign(message, private_key, curve, hashfunc=...)` is used, where `message` is `str`, `bytes`, or `bytearray`, and `private_key` is an `int`. Similarly for `ecdsa.verify((r, s), message, public_key, curve, hashfunc=...)`.
Install Issues
1 verified issue
fatal error: gmp.h: No such file or directoryWindows · Python 3.10 · 3.11 · 3.12 →
Upgrade
Version history
3.0.1latest on PyPI · released Jan 28, 2025
Audit
Dependencies
pythonrequiredRequires Python 3.9 or newer.
gmp (GNU Multiple Precision Arithmetic Library)requiredRequired C library for underlying arithmetic operations. Must be installed on the system.
C compiler (e.g., gcc, clang, MSVC)requiredRequired to compile the C extensions of the library during installation.
pysha3optionalOptional, if using SHA3 hash functions with Python versions older than 3.6. Modern Python versions (3.6+) include SHA3 in `hashlib`.
Agent activity
63 hits · last 30 days
node
62
OpenAI (training)
1
Resources
fastecdsa — pip install fastecdsa · libregistry