Page MenuHomePhabricator

[secp256k1] tests: Add Wycheproof ECDSA vectors
ClosedPublic

Authored by PiRK on Apr 17 2026, 12:44.

Details

Reviewers
Fabien
Group Reviewers
Restricted Project
Commits
rABC1af86307c05f: [secp256k1] tests: Add Wycheproof ECDSA vectors
Summary

Adds a test using the Wycheproof vectors as outlined in #1106. The
vectors are taken from the Wycheproof repo. We use a python script
to convert the JSON-formatted vectors into C code.

Co-authored-by: Sean Andersen <6730974+andozw@users.noreply.github.com>

This is a backport of secp256k1#1245, secp256k1#1055 (partial), secp256k1#1276, secp256k1#1277 and secp256k1#1279

https://github.com/bitcoin-core/secp256k1/pull/1055/changes/6d1784a2e2c1c5a8d89ffb08a7f76fa15e84fff5

Test Plan

ninja check-secp256k1

$ ninja clean-secp256k1-testvectors
$ git status
...
	deleted:    ../src/secp256k1/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h
$ ninja gen-secp256k1-testvectors
$ git status
On branch pr1245
nothing to commit, working tree clean

Diff Detail

Repository
rABC Bitcoin ABC
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

PiRK requested review of this revision.Apr 17 2026, 12:44
Fabien requested changes to this revision.Apr 17 2026, 18:32
Fabien added a subscriber: Fabien.
Fabien added inline comments.
src/secp256k1/CMakeLists.txt
380 ↗(On Diff #59081)

Why quiet? OTOH you might only want the interpreter part (maybe it's the default, I don't remember). also please enforce a version

391 ↗(On Diff #59081)

You should move this close to the other generation targets, and add a clean rule as well so it has feature parity with autotools

This revision now requires changes to proceed.Apr 17 2026, 18:32
src/secp256k1/CMakeLists.txt
380 ↗(On Diff #59081)

I think what I really meant was OPTIONAL, not QUIET. As this is a maintainer target, I didn't want to make the build depend on python. OTOH the autotools build depends on python after this diff, so I guess that's an acceptable dependency.

PiRK edited the test plan for this revision. (Show Details)

review feedback:

  • move new target close to other gen-* targets
  • specify minimum python version (same as the rest of the project)
  • remove QUIET
  • add a clean target

Also:

  • make the gen- target move the generated file to the source tree, as the clean- target will delete the source file In the previous iteration it was implied that the file had to be copied manually.

Tail of the build log:

[498/546] seeder: testing parse_name_tests
[499/546] pow: testing grasberg_tests
[500/546] Running utility command for check-seeder-parse_name_tests
[501/546] seeder: testing write_name_tests
[502/546] Running utility command for check-pow-grasberg_tests
[503/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/test_bitcoin-qt_autogen/mocs_compilation.cpp.o
[504/546] Running pow test suite
PASSED: pow test suite
[505/546] Running utility command for check-seeder-write_name_tests
[506/546] Running seeder test suite
PASSED: seeder test suite
[507/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/bitcoinaddressvalidatortests.cpp.o
[508/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/guiutiltests.cpp.o
[509/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/optiontests.cpp.o
[510/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/apptests.cpp.o
[511/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/rpcnestedtests.cpp.o
[512/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/test_main.cpp.o
[513/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/uritests.cpp.o
[514/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/util.cpp.o
[515/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/addressbooktests.cpp.o
[516/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/paymentservertests.cpp.o
[517/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/wallettests.cpp.o
[518/546] Building CXX object src/qt/test/CMakeFiles/test_bitcoin-qt.dir/__/__/wallet/test/wallet_test_fixture.cpp.o
[519/546] bitcoin: testing wallet_crypto_tests
[520/546] Running utility command for check-bitcoin-wallet_crypto_tests
[521/546] Linking CXX executable src/qt/test/test_bitcoin-qt
[522/546] bitcoin: testing scriptnum_63bit_tests
[523/546] Running utility command for check-bitcoin-scriptnum_63bit_tests
[524/546] bitcoin: testing random_tests
[525/546] Building C object src/secp256k1/CMakeFiles/secp256k1-tests.dir/src/tests.c.o
[526/546] Running utility command for check-bitcoin-random_tests
[527/546] Linking C executable src/secp256k1/secp256k1-tests
[528/546] secp256k1: testing secp256k1-tests
FAILED: src/secp256k1/CMakeFiles/check-secp256k1-secp256k1-tests /work/abc-ci-builds/build-clang/src/secp256k1/CMakeFiles/check-secp256k1-secp256k1-tests 
cd /work/abc-ci-builds/build-clang/src/secp256k1 && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-clang/test/junit && /usr/bin/cmake -E make_directory /work/abc-ci-builds/build-clang/test/log && /usr/bin/cmake -E env /work/cmake/utils/log-and-print-on-failure.sh /work/abc-ci-builds/build-clang/test/log/secp256k1-secp256k1-tests.log /work/abc-ci-builds/build-clang/src/secp256k1/secp256k1-tests
test count = 64
random seed = bc00a6deb1faa15ab6571bb5f7a4e978
/work/src/secp256k1/src/tests.c:838: test condition failed: ((~x[m][shift]) << (64 - (1 << usebits))) == 0
Aborted (core dumped)
[529/546] bitcoin-qt: testing test_bitcoin-qt
[530/546] Running bitcoin-qt test suite
PASSED: bitcoin-qt test suite
[531/546] bitcoin: testing transaction_tests
[532/546] Running utility command for check-bitcoin-transaction_tests
[533/546] secp256k1: testing secp256k1-exhaustive_tests
[534/546] bitcoin: testing validation_chainstatemanager_tests
[535/546] Running utility command for check-bitcoin-validation_chainstatemanager_tests
[536/546] bitcoin: testing wallet_tests
[537/546] Running utility command for check-bitcoin-wallet_tests
[538/546] Building C object src/secp256k1/CMakeFiles/secp256k1-noverify-tests.dir/src/tests.c.o
[539/546] Linking C executable src/secp256k1/secp256k1-noverify-tests
[540/546] bitcoin: testing coins_tests
[541/546] Running utility command for check-bitcoin-coins_tests
[542/546] bitcoin: testing coinselector_tests
[543/546] Running utility command for check-bitcoin-coinselector_tests
[544/546] Running bitcoin test suite
PASSED: bitcoin test suite
[545/546] secp256k1: testing secp256k1-noverify-tests
ninja: build stopped: cannot make progress due to previous errors.
Build build-clang failed with exit code 1
PiRK planned changes to this revision.Apr 20 2026, 09:50

probably needs a rebase

Actually, looking at the discussions on the upstream repo, this is a known issue that is not solved by one of the couple of bugfixes that I have in my stack. It will eventually be "fixed" (by removing the failing test) by backporting https://github.com/bitcoin-core/secp256k1/pull/1298

In D19853#451264, @PiRK wrote:

Actually, looking at the discussions on the upstream repo, this is a known issue that is not solved by one of the couple of bugfixes that I have in my stack. It will eventually be "fixed" (by removing the failing test) by backporting https://github.com/bitcoin-core/secp256k1/pull/1298

Would be nice to do so, this fails from time to time

This revision is now accepted and ready to land.Apr 20 2026, 13:32