Six new tests and repairs to two that were confounded. The suite goes
from 12 cases to 16.
Two existing tests would have stayed green with the checks they target
deleted, which is the worst kind of passing test:
- The "helper id out of range" case also passed new_id = 5 > n = 4,
which params_are_valid rejects several lines earlier. It now uses a
valid enrollment target (new_id = 4) and an id of 5, so the id range
check is the sole failing condition.
- Every call in the empty-set test used (n = 1, t = 2), which fails on
threshold > n_participants regardless of n_ids. It now uses
(n = 2, t = 2, new_id = 2) -- a valid tuple in every respect except
n_ids = 0.
New coverage, in the order the review ranked it:
- run_frost_enrollment_api_test: NULL for every ARG_NONNULL pointer on
all five entry points, plus an unusable pubkey object on the four that
take one (previously only params_hash was covered). Also asserts that
a shares_gen call rejected at an ARG_CHECK does NOT consume the seed,
since it never reaches the body -- the complement of the "a failed
call always consumes it" property the previous commit pinned.
- run_frost_enrollment_infinity_test: pubshare_derive's infinity
rejection, which nothing reached before. With u = 2 and new_id = 2 the
Lagrange coefficients are exactly -1 and 2, so P_0 = 2*P_1 makes the
interpolation vanish; the same two points at a different target
succeed, which is what distinguishes the infinity check from a
parameter rejection.
- run_frost_enrollment_max_size_test: full protocol runs at the largest
sizes the API admits -- enrollment at n = 127 with u = 127, and repair
in a full n = 128 group with u = 127. u cannot reach 128 in either
mode (enrollment needs n < 128, repair excludes the target from the
helper set), so these reach one entry below the fixed-size arrays'
bound, which is as far as a valid tuple goes. Everything before this
capped at n <= 7. Runs in 51 ms.
- run_frost_enrollment_no_side_effects_test: the C analogue of the
reference implementation's test_participant_not_in_dkg, which plan
§1.2 listed and the Phase 3 list dropped. Every existing
participant's secret share, public share and the group key are
byte-identical before and after an enrollment, and the new share
differs from all of them.
- The pubshare_derive test now also pins the OTHER end of the
polynomial. The public API cannot ask for x-coordinate 0 -- that is
identifier -1, and new_id is a uint32_t bounded by n_participants --
so the convention there is checked by running frost's own
derive_thresh_pubkey over the same loaded points and requiring it to
reproduce the group key. With the existing check at x = new_id, both
ends of the interpolation this module depends on are now fixed.
Test-structure repairs the review called out:
- The mismatch test's disagreement now enters where it would in reality,
at helper 0's round 1.1 call (which is made with new_id = 3 while
helper 1 uses 4), rather than by running a clean round and
overwriting the outputs afterwards.
- The oversized-helper-set test re-points a single dealt run at {0,1}
and then {0,1,2} through a named helper, instead of struct-copying a
~540 KB run and hand-editing u and ids[2] -- which would have broken
silently if deal()'s helper-selection rule changed.
- frost_enrollment_test_run instances in the mismatch test are now
static. That test needs four live at once, which was over 2 MB of
stack.
- The randomized test's `if (sub_ids[t-2] >= new_id) continue;` was
unreachable: the loop bound gives sub_ids[t-2] <= n-1 and new_id == n
in that branch. It is now the CHECK that states the invariant.
- The pubshare_derive test's `k` was reset and reused as both helper
counter and aligned-array index inside the same loop body.
Verification: 16/16 pass at -i=16, -i=200 and -i=1000; ./tests,
./noverify_tests and ./exhaustive_tests exit 0; the module is clean
under valgrind (0 errors from 0 contexts).
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
c8206b1c b6c2a3cd e7f7083b be5e4f02 5c751833 540fec8a aa2a39c1 8d445730 f9a944ff 2d9137ce 4721e077 471e3a13 ebb35882 1a53f496 c7a52400 ' into temp-merge-1809
c8206b1c b6c2a3cd e7f7083b be5e4f02 5c751833 540fec8a aa2a39c1 8d445730 f9a944ff 2d9137ce 4721e077 471e3a13 ebb35882 1a53f496 c7a52400 ' into temp-merge-1809
libsecp256k1-zkp
A fork of libsecp256k1 with support for advanced and experimental features
Added features:
- Experimental module for ECDSA adaptor signatures.
- Experimental module for ECDSA sign-to-contract.
- Experimental modules for Confidential Assets (Pedersen commitments, range proofs, and surjection proofs).
- Experimental module for address whitelisting.
- Experimental module for Schnorr signature half-aggregation.
- Experimental module for FROST (BIP 445).
- Experimental module for ChillDKG, distributed key generation for FROST (bip-frost-dkg draft).
- Experimental module for Iceberg, a threshold scheme that lets a group of parties stand in for a single MuSig2 (BIP 327) participant.
- Experimental module for Prefractal, a nested FROST+MuSig2 signer that lets a FROST group occupy one participant slot of an ordinary MuSig2 (BIP 327) session.
- Experimental module for FROST enrollment, which grows a (t, n) FROST group into a (t, n+1) one, and repairs a lost share, without re-running key generation.
Experimental features are made available for testing and review by the community. The APIs of these features should not be considered stable.
Build steps
Obtaining and verifying
The git tag for each release (e.g. v0.6.0) is GPG-signed by one of the maintainers.
For a fully verified build of this project, it is recommended to obtain this repository
via git, obtain the GPG keys of the signing maintainer(s), and then verify the release
tag's signature using git.
This can be done with the following steps:
- Obtain the GPG keys listed in SECURITY.md.
- If possible, cross-reference these key IDs with another source controlled by its owner (e.g. social media, personal website). This is to mitigate the unlikely case that incorrect content is being presented by this repository.
- Clone the repository:
git clone https://github.com/bitcoin-core/secp256k1 - Check out the latest release tag, e.g.
git checkout v0.7.1 - Use git to verify the GPG signature:
% git tag -v v0.7.1 | grep -C 3 'Good signature' gpg: Signature made Mon 26 Jan 2026 07:42:46 PM UTC gpg: using RSA key 2840EAABF4BC9F0FFD716AFAFBAFCC46DE2D3FE2 gpg: Good signature from "Pieter Wuille <pieter@wuille.net>" [unknown] gpg: aka "Pieter Wuille <pieter.wuille@gmail.com>" [full] gpg: aka "[jpeg image of size 5996]" [undefined] gpg: WARNING: This key is not certified with a trusted signature! gpg: There is no indication that the signature belongs to the owner. Primary key fingerprint: 133E AC17 9436 F14A 5CF1 B794 860F EB80 4E66 9320 Subkey fingerprint: 2840 EAAB F4BC 9F0F FD71 6AFA FBAF CC46 DE2D 3FE2
Building with Autotools
$ ./autogen.sh # Generate a ./configure script
$ ./configure # Generate a build system
$ make # Run the actual build process
$ make check # Run the test suite
$ sudo make install # Install the library into the system (optional)
To compile optional modules (such as Schnorr signatures), you need to run ./configure with additional flags (such as --enable-module-schnorrsig). Run ./configure --help to see the full list of available flags. For experimental modules, you will also need --enable-experimental as well as a flag for each individual module, e.g. --enable-module-rangeproof.
Building with CMake
To maintain a pristine source tree, CMake encourages to perform an out-of-source build by using a separate dedicated build tree.
Building on POSIX systems
$ cmake -B build # Generate a build system in subdirectory "build"
$ cmake --build build # Run the actual build process
$ ctest --test-dir build # Run the test suite
$ sudo cmake --install build # Install the library into the system (optional)
To compile optional modules (such as Schnorr signatures), you need to run cmake with additional flags (such as -DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON). Run cmake -B build -LH or ccmake -B build to see the full list of available flags.
Cross compiling
To alleviate issues with cross compiling, preconfigured toolchain files are available in the cmake directory.
For example, to cross compile for Windows:
$ cmake -B build -DCMAKE_TOOLCHAIN_FILE=cmake/x86_64-w64-mingw32.toolchain.cmake
To cross compile for Android with NDK (using NDK's toolchain file, and assuming the ANDROID_NDK_ROOT environment variable has been set):
$ cmake -B build -DCMAKE_TOOLCHAIN_FILE="${ANDROID_NDK_ROOT}/build/cmake/android.toolchain.cmake" -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=28
Building on Windows
The following example assumes Visual Studio 2022. Using clang-cl is recommended.
In "Developer Command Prompt for VS 2022":
>cmake -B build -T ClangCL
>cmake --build build --config RelWithDebInfo
Usage examples
Usage examples can be found in the examples directory. To compile them you need to configure with --enable-examples.
- ECDSA example
- Schnorr signatures example
- Deriving a shared secret (ECDH) example
- ElligatorSwift key exchange example
- MuSig2 Schnorr multi-signatures example
To compile the examples, make sure the corresponding modules are enabled.
Benchmark
If configured with --enable-benchmark (which is the default), binaries for benchmarking the libsecp256k1-zkp functions will be present in the root directory after the build.
To print the benchmark result to the command line:
$ ./bench_name
To create a CSV file for the benchmark result :
$ ./bench_name | sed '2d;s/ \{1,\}//g' > bench_name.csv
Reporting a vulnerability
See SECURITY.md
Contributing to libsecp256k1
See CONTRIBUTING.md