Tim Ruffing d575ef9aca Merge ElementsProject/secp256k1-zkp#270: Upstream PRs 1391, 1290, 1389, 1397, 1399, 1400, 1348, 1402, 1274, 1394, 1404, 1062, 1401, 1373, 1403, 1398, 1405, 1396, 1406, 1410, 1409, 1411, 1412, 1414, 1413, 1415, 1417, 1390, 1416, 1422, 1424, 1395
b41caaafd2 bppp: replace memcmp in tests with secp256k1_memcmp_var (Jonas Nick)
6a3aae8f1d group_parse: use secp256k1_memcmp_var instead of memcmp (Jonas Nick)
e9d522fc64 ci: turn on -zkp modules in macos-native job (Jonas Nick)
c45b7c4fbb refactor: introduce testutil.h (deduplicate `random_fe_`, `ge_equals_` helpers) (Sebastian Falbesoner)
dc5514144f tests: simplify `random_fe_non_zero` (remove loop limit and unneeded normalize) (Sebastian Falbesoner)
d9d80fd155 ci: Bump major versions for docker actions (Hennadii Stepanov)
421d84855a ci: Align Autotools/CMake `CI_INSTALL` directory names (Hennadii Stepanov)
9f005c60d6 cmake: Install `libsecp256k1.pc` file (Hennadii Stepanov)
b0f7bfedc9 doc: Do not mention soname in CHANGELOG.md "ABI Compatibility" section (Hennadii Stepanov)
bd9d98d353 doc: Align documented scripts with CI ones (Hennadii Stepanov)
70303643cf tests: add CHECK_ERROR_VOID and use it in scratch tests (Jonas Nick)
f8d7ea68df tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID (Jonas Nick)
a1d52e3e12 tests: remove unnecessary test in run_ec_pubkey_parse_test (Jonas Nick)
875b0ada25 tests: remove unnecessary set_illegal_callback (Jonas Nick)
9b118bc7fb release cleanup: bump version after 0.4.0 (Jonas Nick)
16339804c9 release: Prepare for 0.4.0 (Tim Ruffing)
d9a85065a9 changelog: Catch up in preparation of release (Tim Ruffing)
8659a01714 ci: Add `release` job (Hennadii Stepanov)
f9b38894ba ci: Update `actions/checkout` version (Hennadii Stepanov)
2635068abf ci/gha: Let MSan continue checking after errors in all jobs (Tim Ruffing)
e78c7b68eb ci/Dockerfile: Reduce size of Docker image further (Tim Ruffing)
2f0d3bbffb ci/Dockerfile: Warn if `ulimit -n` is too high when running Docker (Tim Ruffing)
4b8a647ad3 ci/gha: Add ARM64 QEMU jobs for clang and clang-snapshot (Tim Ruffing)
6ebe7d2bb3 ci/Dockerfile: Always use versioned clang packages (Tim Ruffing)
c223d7e33d ci: Switch macOS from Ventura to Monterey and add Valgrind (Hennadii Stepanov)
cce0456304 ci: Make repetitive command the default one (Hennadii Stepanov)
317a4c48f0 ci: Move `git config ...` to `run-in-docker-action` (Hennadii Stepanov)
676ed8f9cf ci: Move "C++ (public headers)" from Cirrus to GitHub Actions (Hennadii Stepanov)
61fc3a2dc8 ci: Move "C++ -fpermissive..." from Cirrus to GitHub Actions (Hennadii Stepanov)
d51fb0a533 ci: Move "MSan" from Cirrus to GitHub Actions (Hennadii Stepanov)
c22ac27529 ci: Move sanitizers task from Cirrus to GitHub Actions (Hennadii Stepanov)
ee1be62d84 ci: Use concurrency for pull requests only (Hennadii Stepanov)
fc3dea29ea ci: Move "ppc64le: Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
7782dc8276 ci: Move "ARM64: Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
0a16de671c ci: Move "ARM32: Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
ea33914e00 ci: Move "s390x (big-endian): Linux..." from Cirrus to GitHub Actions (Hennadii Stepanov)
880be8af99 ci: Move "i686: Linux (Debian stable)" from Cirrus to GiHub Actions (Hennadii Stepanov)
e10878f58e ci, gha: Drop `driver-opts.network` input for `setup-buildx-action` (Hennadii Stepanov)
4ad4914bd1 ci, gha: Add `retry_builder` Docker image builder (Hennadii Stepanov)
6617a620d9 ci: Remove "x86_64: Linux (Debian stable)" task from Cirrus CI (Hennadii Stepanov)
03c9e6508c ci, gha: Add "x86_64: Linux (Debian stable)" GitHub Actions job (Hennadii Stepanov)
ad3e65d9fe ci: Remove GCC build files and sage to reduce size of Docker image (Tim Ruffing)
ef9fe959de ci: Drop no longer needed workaround (Hennadii Stepanov)
87d35f30c0 ci: Rename `cirrus.sh` to more general `ci.sh` (Hennadii Stepanov)
d6281dd008 ci: Remove Windows tasks from Cirrus CI (Hennadii Stepanov)
2b6f9cd546 ci, gha: Add Windows jobs based on Linux image (Hennadii Stepanov)
b0886fd35c ci, gha: Ensure only a single workflow processes `github.ref` at a time (Hennadii Stepanov)
d23da6d557 use secp256k1_scalar_verify checks (stratospher)
c7d0454932 add verification for scalars (stratospher)
ad152151b0 update max scalar in scalar_cmov_test and fix schnorrsig_verify exhaustive test (stratospher)
d78bec7001 ci: Remove Windows MSVC tasks from Cirrus CI (Hennadii Stepanov)
3545dc2b9b ci, gha: Run all MSVC tests on Windows natively (Hennadii Stepanov)
54058d16fe field: remove `secp256k1_fe_equal_var` (siv2r)
bb4efd6404 tests: remove unwanted `secp256k1_fe_normalize_weak` call (siv2r)
c2f6435802 ci: Add comment about switching macOS to M1 on GHA later (Tim Ruffing)
4a24fae0bc ci: Remove "arm64: macOS Ventura" task from Cirrus CI (Hennadii Stepanov)
8e54a346d2 ci, gha: Run "x86_64: macOS Ventura" job on GitHub Actions (Hennadii Stepanov)
747ada3587 test: Silent noisy clang warnings about Valgrind code on macOS x86_64 (Hennadii Stepanov)
d62db57427 ci: Use Homebrew's gcc in native macOS task (Hennadii Stepanov)
b7c685e74a Save _normalize_weak calls in group add methods (Peter Dettman)
c83afa66e0 Tighten group magnitude limits (Peter Dettman)
173e8d061a Implement current magnitude assumptions (Peter Dettman)
49afd2f5d8 Take use of _fe_verify_magnitude in field_impl.h (Sebastian Falbesoner)
4e9661fc42 Add _fe_verify_magnitude (no-op unless VERIFY is enabled) (Peter Dettman)
690b0fc05a add missing group element invariant checks (Sebastian Falbesoner)
9c91ea41b1 ci: Enable ellswift module where it's missing (Tim Ruffing)
db32a24761 ctimetests: Use new SECP256K1_CHECKMEM macros also for ellswift (Tim Ruffing)
8408dfdc4c Revert "ci: Run sage prover on CI" (Hennadii Stepanov)
c8d9914fb1 ci, gha: Run "SageMath prover" job on GitHub Actions (Hennadii Stepanov)
f1774e5ec4 ci, gha: Make MSVC job presentation more explicit (Hennadii Stepanov)
5ee039bb58 ci: Remove "Windows (VS 2022)" task from Cirrus CI (Hennadii Stepanov)
a2f7ccdecc ci: Run "Windows (VS 2022)" job on GitHub Actions (Hennadii Stepanov)
175db31149 ci: Drop no longer needed `PATH` variable update on Windows (Hennadii Stepanov)
116d2ab3df cmake: Set `ENVIRONMENT` property for examples on Windows (Hennadii Stepanov)
cef373997c cmake, refactor: Use helper function instead of interface library (Hennadii Stepanov)
a1bd4971d6 refactor: take use of `secp256k1_scalar_{zero,one}` constants (part 2) (Sebastian Falbesoner)

Pull request description:

  [bitcoin-core/secp256k1#1391]: refactor: take use of `secp256k1_scalar_{zero,one}` constants (part 2)
  [bitcoin-core/secp256k1#1290]: cmake: Set `ENVIRONMENT` property for examples on Windows
  [bitcoin-core/secp256k1#1389]: ci: Run "Windows (VS 2022)" job on GitHub Actions
  [bitcoin-core/secp256k1#1397]: ci: Remove "Windows (VS 2022)" task from Cirrus CI
  [bitcoin-core/secp256k1#1399]: ci, gha: Run "SageMath prover" job on GitHub Actions
  [bitcoin-core/secp256k1#1400]: ctimetests: Use new SECP256K1_CHECKMEM macros also for ellswift
  [bitcoin-core/secp256k1#1348]: tighten group magnitude limits, save normalize_weak calls in group add methods (revival of #1032)
  [bitcoin-core/secp256k1#1402]: ci: Use Homebrew'\''s gcc in native macOS task
  [bitcoin-core/secp256k1#1274]: test: Silent noisy clang warnings about Valgrind code on macOS x86_64
  [bitcoin-core/secp256k1#1394]: ci, gha: Run "x86_64: macOS Ventura" job on GitHub Actions
  [bitcoin-core/secp256k1#1404]: ci: Remove "arm64: macOS Ventura" task from Cirrus CI
  [bitcoin-core/secp256k1#1062]: Removes `_fe_equal_var`, and unwanted `_fe_normalize_weak` calls (in tests)
  [bitcoin-core/secp256k1#1401]: ci, gha: Run all MSVC tests on Windows natively
  [bitcoin-core/secp256k1#1373]: Add invariant checking for scalars
  [bitcoin-core/secp256k1#1403]: ci, gha: Ensure only a single workflow processes `github.ref` at a time
  [bitcoin-core/secp256k1#1398]: ci, gha: Add Windows jobs based on Linux image
  [bitcoin-core/secp256k1#1405]: ci: Drop no longer needed workaround
  [bitcoin-core/secp256k1#1396]: ci, gha: Add "x86_64: Linux (Debian stable)" GitHub Actions job
  [bitcoin-core/secp256k1#1406]: ci, gha: Move more non-x86_64 tasks from Cirrus CI to GitHub Actions
  [bitcoin-core/secp256k1#1410]: ci: Use concurrency for pull requests only
  [bitcoin-core/secp256k1#1409]: ci: Move remained task from Cirrus to GitHub Actions
  [bitcoin-core/secp256k1#1411]: ci: Make repetitive command the default one
  [bitcoin-core/secp256k1#1412]: ci: Switch macOS from Ventura to Monterey and add Valgrind
  [bitcoin-core/secp256k1#1414]: ci/gha: Add ARM64 QEMU jobs for clang and clang-snapshot
  [bitcoin-core/secp256k1#1413]: ci: Add `release` job
  [bitcoin-core/secp256k1#1415]: release: Prepare for 0.4.0
  [bitcoin-core/secp256k1#1417]: release cleanup: bump version after 0.4.0
  [bitcoin-core/secp256k1#1390]: tests: Replace counting_illegal_callbacks with CHECK_ILLEGAL_VOID
  [bitcoin-core/secp256k1#1416]: doc: Align documented scripts with CI ones
  [bitcoin-core/secp256k1#1422]: cmake: Install `libsecp256k1.pc` file
  [bitcoin-core/secp256k1#1424]: ci: Bump major versions for docker actions
  [bitcoin-core/secp256k1#1395]: tests: simplify `random_fe_non_zero` (remove loop limit and unneeded normalize)

  This PR can be recreated with `./contrib/sync-upstream.sh -b master range ee7aaf213ea3eb42fc8960c7d178b5ffb286440f`.
  Tip: Use `git show --remerge-diff` to show the changes manually added to the merge commit.' --web

  - Replace fe_equal_var with fe_equal
  - Use CHECK_ILLEGAL instead of CHECK/ecount
  - Turn on secp256k1-zkp specific modules in CI

ACKs for top commit:
  real-or-random:
    ACK b41caaafd2

Tree-SHA512: e8994fa2590d6e277d60a130d3f11b0256dc7fbe67e8a2b85463d9849d3f9fbfccf366b17b3904f1974f8b7b27a24128d2a04a3337c1b8409d000d136714bf90
2023-10-12 17:14:20 +02:00
2023-09-07 20:47:57 +01:00
2013-05-09 15:24:32 +02:00

libsecp256k1-zkp

Build Status Dependencies: None

A fork of libsecp256k1 with support for advanced and experimental features such as Confidential Assets and MuSig2

Added features:

  • Experimental module for ECDSA adaptor signatures.
  • Experimental module for ECDSA sign-to-contract.
  • Experimental module for MuSig2.
  • Experimental module for Confidential Assets (Pedersen commitments, range proofs, and surjection proofs).
  • Experimental module for Bulletproofs++ range proofs.
  • Experimental module for address whitelisting.

Experimental features are made available for testing and review by the community. The APIs of these features should not be considered stable.

Build steps

libsecp256k1-zkp is built using autotools:

$ ./autogen.sh
$ ./configure
$ make
$ make check  # run the test suite
$ sudo make install  # 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-musig.

Usage examples

Usage examples can be found in the examples directory. To compile them you need to configure with --enable-examples.

To compile the Schnorr signature, ECDH and MuSig examples, you need to enable the corresponding module by providing a flag to the configure script, for example --enable-module-schnorrsig.

Test coverage

This library aims to have full coverage of the reachable lines and branches.

To create a test coverage report, configure with --enable-coverage (use of GCC is necessary):

$ ./configure --enable-coverage

Run the tests:

$ make check

To create a report, gcovr is recommended, as it includes branch coverage reporting:

$ gcovr --exclude 'src/bench*' --print-summary

To create a HTML report with coloured and annotated source code:

$ mkdir -p coverage
$ gcovr --exclude 'src/bench*' --html --html-details -o coverage/coverage.html

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

Description
Experimental fork of libsecp256k1 with support for pedersen commitments and range proofs.
Readme 12 MiB
Languages
C 93.2%
Sage 1.6%
CMake 1.2%
M4 1.2%
Assembly 1.1%
Other 1.7%