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 fastecdsaVerified import paths — ran on the pinned version, not inferred.
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.
Upgrade your Python environment to 3.9+ and install the latest fastecdsa version.
Assess the security requirements of your application carefully. For high-stakes security, consider alternatives like `cryptography`.
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).
Upgrade to fastecdsa version 3.0.1 or at least 2.3.2 to mitigate known vulnerabilities.
Install 'Microsoft C++ Build Tools' for Visual Studio (available as a standalone installer or part of Visual Studio).
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`.
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=...)`.