Drop p256k1 in favour of RustCrypto k256, pending MSM benchmarks
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 25/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- cryptography
Research direction
Start by re-benchmarking k256 MSM against the current p256k1/libsecp256k1 path at both 20 keys and 1000+ keys. If MSM remains slow, check whether it is the bottleneck in CheckPrivateShares::MultiMult in common.rs, compute::aggregate_nonce, and the lambda/binding loops in both aggregators; benches/v2_bench.rs covers DKG, party signing, and aggregation. Done means establishing the performance gap and bottleneck; any migration is a major-version change and is explicitly contingent on those results.
Written by the indexing model from the issue text.
Description
Proposal: drop the p256k1 wrapper and move to RustCrypto k256, contingent on benchmarking where the performance gap actually is.
Why now
p256k1 is a single-maintainer C wrapper that exists because libsecp256k1 exposes no public API for raw scalar and point arithmetic. The costs have accumulated:
- Every consumer needs a C toolchain.
with_p256k1_bindgenis inwsts'sdefaultfeatures and forwards top256k1/with_bindgen, so a plaincargo buildruns bindgen over Clibsecp256k1and requires libclang. #29 is a user who simply could not build the crate because of this (clang diagnostics, thenNoRustfmtpanicking insidep256k1'sbuild.rs). - The no-bindgen escape hatch is broken.
cargo check --no-default-featuresfails today:p256k1's pre-generated bindings are missing all fivesecp256k1_context_preallocated_*symbols, so_rename.rsdoes not compile. In practicewstscannot be used withdefault-features = falseat all. - Fixing that means regenerating bindings against libsecp, which is the operation that has historically gone badly, and it is work thrown away if we migrate anyway.
- The repository was never transferred.
Trust-Machines/p256k1remains the unarchived upstream andxoloki/p256k1is a fork of it (currently identical). Published7.2.2dates from 2025-01-31 and its crates.iorepositoryfield still points at the old org. So keeping it means re-homing a repo and cutting a release purely to fix metadata on a dependency we would rather delete.
Dropping it removes the C toolchain requirement outright, which is the largest ergonomic cost wsts currently imposes on consumers.
The blocker, and what to measure
The reason this has not happened is performance: k256's multi-scalar multiplication benchmarked substantially slower than libsecp256k1 when last tested. That measurement is old and may no longer hold — RustCrypto has moved on since.
It also matters less than the raw numbers suggest. The MSM cost only becomes significant with large polynomials, on the order of 1000+ keys; at that scale it dominates, but at the sizes used in normal testing it is visible without being decisive.
So the first step is measurement, not migration:
- Re-benchmark
k256MSM against the currentp256k1/libsecp path. If it has been fixed upstream, the blocker is gone. - If it is still slow, determine whether MSM is actually the bottleneck for
wstsrather than assuming it. The hot paths are concentrated:CheckPrivateShares'sMultiMultimpl incommon.rs,compute::aggregate_nonce, and thelambda/bindingloops in both aggregators.benches/v2_bench.rsalready covers DKG, party signing and aggregation, so ak256-backed branch behind a feature flag can be compared against existing numbers directly. - Benchmark at both ends of the range — small (the current 20 keys / 4 signers) and large (1000+ keys) — since the gap only bites at scale and a small-N benchmark could wrongly clear or wrongly condemn it.
If MSM is slow and is the bottleneck, contributing a Pippenger improvement to k256 is an attractive path: it is self-contained, benchmarkable, carries no protocol risk to wsts, and if it lands we delete a crate.
Scope of the migration itself
Not small. src/lib.rs has pub use p256k1 as curve;, so wsts::curve::{Point, Scalar} is public API and downstream code depends on those types. Point and Scalar appear throughout common.rs, compute.rs, schnorr.rs, traits.rs, v1.rs, v2.rs and both state machines. This is a major-version change for consumers, and worth batching with other breaking work.
Note this is unrelated to #60, which is about converting WSTS signatures into ZCash FROST format for verification, not about the underlying curve implementation.
- Dominant language
- Rust
- Stars
- 34
- Forks
- 19
- Avg merge
- 9h 19m
- Merged PRs (30d)
- 12
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from xoloki/wsts
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 55/100
xoloki/wsts#256 · 3 comments ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
Maintainers usually reply within 1 day
-
marketing
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
difficulty: easy docs help wanted tooling
Difficulty 2/5 1-3 hours Newbie friendliness 83/100
-
bug help wanted ui
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
userFRM/egui-charts#4386 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
eliasstravik/herdr-projects#1605 · 1 comment ·