Skip to content

Make coincurve optional (not installable on Python 3.14) #131

Open

Description

@fdegros

Problem

coincurve is a hard dependency (requirements.txt: coincurve>=20.0.0,<21), and it cannot currently be installed on Python 3.14:

  • coincurve 20.x has no Python 3.14 wheel, and building it from source fails with recent scikit-build-core (ERROR: Use build.verbose instead of cmake.verbose for scikit-build-core >= 0.10). See also Poetry install crash #116.
  • coincurve 21.x is excluded by the <21 pin, and its source build also fails when the cffi distribution has no LICENSE file (RuntimeError: Expected exactly one LICENSE file in cffi distribution, got 0). A fix exists upstream but has not been released: Add get_cffi_distribution_license_files() ofek/coincurve#188, tracked in python 3.14 ofek/coincurve#219 (Python 3.14), #208 and #223.

So pip install hdwallet (and anything depending on it) fails on Python 3.14.

Observation

The pure-Python ecdsa backend is already implemented and selectable through SLIP10_SECP256K1_CONST.USE. However, hdwallet/eccs/slip10/secp256k1/{point,public_key,private_key}.py run import coincurve unconditionally, and use coincurve.PublicKey / coincurve.PrivateKey in annotations, so the package cannot even be imported without it.

Suggested change

Make coincurve optional and fall back to ecdsa when it is not installed:

  • Import coincurve in a try/except ImportError in the three modules above, and add from __future__ import annotations so the annotations are not evaluated.
  • Default SLIP10_SECP256K1_CONST.USE to "ecdsa" when coincurve is not installed.
  • Only define SLIP10Secp256k1ECCCoincurve (in eccs/slip10/secp256k1/__init__.py) when coincurve is the selected backend.
  • Move coincurve from requirements.txt to an optional extra (e.g. pip install hdwallet[coincurve]).
  • Skip the *_coincurve tests in tests/hdwallet/eccs/test_slip10_sec256k1_ecc.py when it is not installed.

Testing

I tried this on Python 3.14.4 against the python-slip39 fork of this project (commit 3d18107, v4.0.3):

  • Without coincurve installed (ecdsa backend): 290 tests passed and 4 skipped (the *_coincurve ones); the 117 tests/test_examples.py and tests/test_clients.py script tests also passed.
  • With coincurve 21 installed (backend coincurve): 294 passed.

Trade-off: the ecdsa backend is slower and not constant-time, so coincurve remains the preferred backend whenever it is installed.

I can open a PR with this change if you are interested.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions