Skip to content

[RFC] test: integrate secp256k1lab as subtree and use it for low-level EC ops - #34287

Closed
theStack wants to merge 3 commits into
bitcoin:masterfrom
theStack:2026-add-secp256k1lab-subtree2
Closed

theStack wants to merge 3 commits into
bitcoin:masterfrom
theStack:2026-add-secp256k1lab-subtree2

Conversation

@theStack

@theStack theStack commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds secp256k1lab as a subtree and uses it for low-level secp256k1 field and group arithmetic (i.e. replacing the contents of secp256k1.py) as a first step, primarily for demonstration purposes. Keeping it as a draft right now, to assess if there is conceptual support. The goal would be to keep the test framework code maintained here to Bitcoin Core specific parts and develop secp256k1-specific parts (e.g. MuSig, Silent Payments, FROST etc., to name a few upcoming ones) in secp256k1lab. I'm not sure if that's a clear win from a maintenance perspective (it could e.g. add friction, having to depend on and coordinate with secp256k1lab maintainers), but I'm curious to hear opinions. Suggested e.g. in #32642 (review).

Also, there are still some problems and open questions:

  • CI for "Windows native" job is failing (didn't check in detail yet, but I assume the secp256k1lab folder is not found due to failing Path.resolve() symlink resolution, i.e. the library is searched within the build folder)
  • BIP340 signing/verification can't be fully replaced yet (the test framework's Schnorr signing in key.pyuses special testing parameters like flip_p and flip_r that aren't available in secp256k1lab)
  • Where to place the subtree? Originally I added it in test_framework/crypto but moved it up directly to test, for not having to add a linter mypy exception, as it only targets test/functional/*; maybe adding the subtree to a new folder like test/libs would be better for clarity

@DrahtBot

DrahtBot commented Jan 14, 2026 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/34287.

Reviews

See the guideline for information on the review process.
A summary of reviews will appear here.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #34773 (test: migrate functional test equality asserts to assert_equal by l0rinc)

If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.

@theStack
theStack marked this pull request as draft January 14, 2026 17:27
@fjahr

fjahr commented Jan 15, 2026

Copy link
Copy Markdown
Contributor

it could e.g. add friction, having to depend on and coordinate with secp256k1lab maintainers

That would be my main concern. Having worked with the library for BIP specification I would be happy if we use it here too but test code is the part of the code base where we still manage to move relatively quickly and it would be a shame if adding test coverage here would be blocked by changes in secp256k1lab.

The maintainers of secp256k1lab are also maintainers of secp256k1 and they a pretty busy usually so I would feel better about this if there was at least one other maintainer for lab, maybe with a Bitcoin Core focus.

Alternatively maybe there can be a solution where we have a wrapper/companion to the library and the functionality that is not provided from it goes in there and in can be ported to lab whenever. That way we could at least not be blocked on conversations if a flip_p etc. should be added to lab or not. But I haven't thought about what that would look like ideally.

Where to place the subtree?

It should be at least in functional/ because it wouldn't be used outside afaict. Maybe in functional/test_framework/ directly and then the crypto folder could make a transition where it's only containing hashing stuff and gets renamed accordingly at some point? I would be fine with a lib/ folder too but if we don't plan to add anything else yet then I don't think it's needed.

@DrahtBot

Copy link
Copy Markdown
Contributor

🐙 This pull request conflicts with the target branch and needs rebase.

@sedited sedited closed this May 8, 2026
@fjahr

fjahr commented May 9, 2026

Copy link
Copy Markdown
Contributor

I was going to comment here earlier, but I will still put it here for documentation purposes: I found that I do need secp256k1lab in here for my CISA PoC implementation because I have now based the BIPs reference code on the library. I thought about different avenues for CISA functional tests but I don't see any reasonable alternative. Probably CISA will not be the first such BIP to make it into Bitcoin Core but eventually we will need it in here when we implement BIPs that have used the lab for their reference code.

So this turns my skepticism from above into a concept ack. But it's still the most reasonable move for now to keep this closed and wait until one of these BIPs that require lab make it into Bitcoin Core. Until then, the maintenance burden isn't worth it IMO due to the (for now) limited upside.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants