Skip to main content

btclib-ecc

Elliptic curve arithmetic, and the signature, key-agreement and commitment schemes built on it, in typed Python.

PyPI version GitHub release development status license downloads supported Python versions implementation wheel

pre-commit.ci status lint workflow status test workflow status docs workflow status documentation build vendored-vectors workflow status mutation workflow status fuzz workflow status zkp-oracle workflow status deps-latest workflow status pypi-install workflow status deps-oldest workflow status py-arm-authority workflow status os-macos workflow status os-ubuntu workflow status os-windows workflow status links workflow status sdist-rebuild workflow status codeql workflow status

OpenSSF Scorecard

It is fully annotated and ships py.typed.

What is here

  • modular arithmetic: inverse, blinded and variable-time, Legendre symbol, square root (number_theory)
  • the elliptic curve class, over any curve in short Weierstrass form
    • Jacobian coordinates, and the secp256k1 endomorphism
    • double and multi scalar multiplication (Straus's algorithm and Bos-Coster's)
    • SEC 1 octet encodings of points and scalars
    • the SEC 2 v1 and v2, NIST and Brainpool curves, and low cardinality test curves
  • ECDSA, with DER encoding, public key recovery, low-R grinding and RFC 6979 deterministic nonces
  • BIP340 Schnorr signatures, and their batch verification
  • the anti-exfil protocol, and the sign-to-contract commitment it rests on, for both signature schemes
  • MuSig2 multi-signatures and FROST threshold signatures, one primitive per round of each protocol
  • Diffie-Hellman, and the BIP324 ElligatorSwift encoding of a public key
  • BIP374 discrete logarithm equality proofs
  • ECIES in the BIE1 layout, the block cipher supplied by the caller
  • Pedersen commitments, Borromean ring signatures and the range proofs of libsecp256k1-zkp
  • the ANSI X9.63 key derivation function and HKDF (kdf), and the BIP340 tagged hash (hashes)

For secp256k1 the arithmetic is delegated to btclib-secp256k1, bindings to Bitcoin Core's libsecp256k1, wherever a call's own guard admits them. They are the secp256k1 extra below. Without them, or with the delegation turned off, every call still answers, on the Python arithmetic, which is slower and not constant-time; that Python arithmetic serves every other curve anyway, and the suite validates it against the bindings. SECURITY.md's "Limitations, not vulnerabilities" states which calls delegate and what the Python path does and does not hide.

The suite answers to vectors their authors publish -- the BIPs' own, Wycheproof's and libsecp256k1-zkp's -- and tests/_data/README.md pins each vendored file to the upstream commit it was copied from.

Installing

python -m pip install --upgrade "btclib-ecc[secp256k1]"

The secp256k1 extra installs the libsecp256k1 bindings. The quotes are for zsh, which reads the brackets as a glob.

Security

SECURITY.md says how to report a vulnerability, which versions are supported, and how a published file is traced back to the run that built it.

Contributing

CONTRIBUTING.md has the commands each CI job runs, verbatim. uv sync creates the environment; uv is the only tool that has to be installed. REVIEWING.md is what a pull request is answered against.

How the organization decides, and who holds which role, is its GOVERNANCE.md; what it intends to do, and what it deliberately does not, is its ROADMAP.md.


The btclib organization and its projects are actively supported by DGI and CheckSig.

Metadata

Release files for btclib-ecc 2026.9.26

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for btclib-ecc 2026.9.26
File Size Uploaded
btclib_ecc-2026.9.26.tar.gz 1.7 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for btclib-ecc 2026.9.26
File Interpreter ABI Platform
btclib_ecc-2026.9.26-py3-none-any.whl Python 3 none any Details

Total release size: 2.0 MB

Release files / btclib_ecc-2026.9.26.tar.gz

Download URL btclib_ecc-2026.9.26.tar.gz
Size 1.7 MB
Tags Source
SHA-256 checksum
How to use checksums
653a5806e941623032da317f3e67e57a0b8c9c6483680922274005cdd9a46d9e
BLAKE2b-256 checksum
How to use checksums
784a92157cbf14a4891d19020eb995838d1c1427aa377c585ee128b4ec36a802
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / btclib_ecc-2026.9.26-py3-none-any.whl

Download URL btclib_ecc-2026.9.26-py3-none-any.whl
Size 267.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c0c7ef490fa61d5aed67638894e355293671591dddf83a1b06a7e4f901f8dedd
BLAKE2b-256 checksum
How to use checksums
0adeda66fc24e078a0bf09cad99de222b3c077c1772a5e94bcb5324b0a59879c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

2026.9.26 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page