The two findings from the second review round, plus the coverage gap and
comment error it noted.
Finding 8: the zeroing exception was narrower in the docs than in the
code.
The previous commit's fix leaves shares32_out untouched on EVERY
params_are_valid rejection -- duplicate ids, threshold < 2, new_id
among the helpers, an id >= n, the mode bounds -- but the header
scoped the exception to "when n_ids itself is out of range", and
frost_enrollment.md still said flatly that outputs are zeroed on every
failure path. A caller who inspects the buffer after a failed call
would, on a duplicate-id or t = 1 rejection, read whatever was there
before. In this protocol that can be additive shares of a secret from
an earlier call.
Both now state the actual invariant: not written when the parameter
tuple is rejected, because its extent is only known to be u*32 once
n_ids has been validated against the rest of the tuple; zeroed on
every failure found after that point (an unusable thresh_pk, my_id not
among the helpers, an invalid secret share). The .md adds the sentence
a defensive caller needs: treat a rejected tuple as leaving the buffer
unmodified, not as leaving it zeroed. Documentation only -- the
implementation and the tests already agreed with this reading.
Finding 9: the new CMake CI step never checked that the modules landed.
It configured, built and installed with all five module flags, then
ran `ls -RlAh` -- which prints and does not assert -- and linked
examples/ecdsa.c, which uses core symbols only. Deleting the
add_compile_definitions or PUBLIC_HEADER line for a module during an
upstream sync would keep the step green: no module code means no
undefined references, and the install simply omits the header. The
guard added one commit ago caught a MISORDERED block but not a
MISSING one.
The step now asserts both halves. `ls` of all five module headers
fails the step under bash -e if any is absent, and
examples/frost_enrollment.c is compiled and run against the installed
library, which no header-only check would cover -- it needs the
symbols to actually be in the library.
Verified by running the step's exact command sequence under bash -e:
it exits 0 as written, and against an install configured WITHOUT the
modules the header assertion exits 2 and the example fails to compile
on the missing include.
Coverage: the params-hash attribution path was still only tested where
identifier equals index. The previous commit pinned identifier
semantics for the scalar-overflow path on helper set {0, 2}, but
share_agg's other `*mismatch_id = ids[i]` -- the parameters-hash
disagreement -- was exercised only on {0, 1}. It is now pinned on
{1, 3}, corrupting each slot in turn so the mapping is fixed at both
ends: index 0 must report 1, index 1 must report 3. Verified
load-bearing by changing the assignment to `(uint32_t)i`, which fails
the new case.
Comment error: the {0, 2} overflow case carried the claim that it would
catch an implementation returning array indices. It would not -- it
corrupts slot 0, whose identifier is also 0. The discrimination comes
from the paired own-slot case at slot 1 (identifier 2), and the comment
now says so.
Correcting the record rather than rewriting it: commit 69766dd3's
message says the suite goes "from 12 cases to 16" with "six new tests".
Both counts are wrong. The contract test landed in 266c6a7c, so the
table went 13 -> 17, and that commit added four cases (api, infinity,
no_side_effects, max_size) alongside the x = 0 addition to an existing
test and the two de-confoundings. The commits are unpushed and could be
amended, but the review cites them by hash, so the numbers are corrected
here instead. With this commit the module has 17 tests.
Verification: warning-free build; 17/17 at -i=16, -i=200 and -i=1000;
./tests, ./noverify_tests and ./exhaustive_tests exit 0; `make check`
12/12; the module clean under valgrind (0 errors from 0 contexts);
ctime_tests clean under valgrind; CMake ctest 542/542; vectors.h still
regenerates byte for byte, so nothing here touched a frozen encoding.
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