$ show tlsfuzzer/python-ecdsa
This repository is a pure Python library implementing elliptic curve cryptography algorithms, specifically ECDSA (Elliptic Curve Digital Signature Algorithm), ECDH (Elliptic Curve Diffie-Hellman), and EdDSA (Edwards-curve Digital Signature Algorithm). It provides key generation, signing, verification, and shared secret derivation functionalities across multiple curve types including NIST prime curves, Brainpool curves, and twisted Edwards curves (Ed25519/Ed448). The library is structured as a modular package with clear separation of concerns: high-level API in `keys.py`, low-level arithmetic in `ellipticcurve.py`, curve definitions in `curves.py`, ASN.1 DER handling in `der.py`, and utility functions for encoding/decoding in `util.py`. While the code is well-structured and includes comprehensive test suites, the project explicitly states it is not designed for production security due to vulnerability to side-channel attacks, recommending wrappers like `pyca/cryptography` for sensitive applications.
The LLM identified 2 files worth highlighting for reuse:
Provides essential encoding/decoding utilities for cryptographic operations, including integer-to-byte-string conversions, signature encoding/decoding in multiple formats (DER, raw, SSL), and cryptographically secure random number generation. The module is highly isolated, depending only on standard library and internal `_compat.py` for Python 2/3 support. Its functions are used throughout the library for handling keys, signatures, and random nonces, making it easily extractable for other cryptographic projects requiring similar data transformation primitives.
Implements core number-theoretic algorithms essential for elliptic curve cryptography, such as modular inverse, Jacobi symbol computation, and modular square roots for prime moduli. Despite some deprecated functions noted in release notes, the core algorithms remain well-implemented and dependency-free (only relying on `_compat.py`). This module demonstrates solid mathematical foundations and could be reused in other cryptographic or mathematical contexts requiring these fundamental operations, offering a clean separation from curve-specific logic.