Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upstream PRs 1426, 1430, 1184, 1437, 1442, 1441, 1445, 1438, 1393, 1446, 1450, 1451, 1431, 990, 1455, 1380, 1465, 1466, 1473, 1474, 1476, 1480, 1468, 1482, 1249 #285

Merged
merged 86 commits into from
Jan 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
e02f313
Add comment on length checks when parsing ECDSA sigs
real-or-random Oct 17, 2021
42f8c51
cmake: Add `SECP256K1_LATE_CFLAGS` configure option
hebasto Apr 26, 2023
2262d0e
ci/cirrus: Bring back skeleton .cirrus.yml without jobs
real-or-random Aug 28, 2023
fa4d6c7
ci/cirrus: Add native ARM64 persistent workers
Sep 20, 2023
b314cf2
Merge bitcoin-core/secp256k1#1426: ci/cirrus: Add native ARM64 jobs
real-or-random Sep 20, 2023
5dab0ba
README: remove CI badge
jonasnick Oct 17, 2023
1f1bb78
Merge bitcoin-core/secp256k1#1430: README: remove CI badge
real-or-random Oct 23, 2023
2140da9
Add secp256k1_scalar_half for halving scalars (+ tests/benchmarks).
sipa Dec 29, 2022
ba523be
make SECP256K1_SCALAR_CONST reduce modulo exhaustive group order
sipa Dec 30, 2022
4d16e90
Signed-digit based ecmult_const algorithm
sipa Dec 30, 2022
aa9f3a3
ecmult_const: add/improve tests
jonasnick Jun 20, 2023
115fdc7
Remove unused secp256k1_wnaf_const
sipa Dec 30, 2022
21f49d9
Remove unused secp256k1_scalar_shr_int
sipa Dec 30, 2022
355bbdf
Add changelog entry for signed-digit ecmult_const algorithm
sipa Dec 30, 2022
8e2a5fe
correct assertion for secp256k1_fe_mul_inner
roconnor-blockstream Nov 6, 2023
40f50d0
Merge bitcoin-core/secp256k1#1184: Signed-digit based ecmult_const al…
real-or-random Nov 7, 2023
8185e72
ci: Ignore internal errors in snapshot compilers
hebasto Nov 7, 2023
c891c5c
Merge bitcoin-core/secp256k1#1437: ci: Ignore internal errors of snap…
real-or-random Nov 8, 2023
33dc7e4
asm: add .note.GNU-stack section for non-exec stack
fanquake Nov 13, 2023
1027135
Return temporaries to being unsigned in secp256k1_fe_sqr_inner
roconnor-blockstream Nov 14, 2023
dcdda31
Tighten secp256k1_fe_mul_inner's VERIFY_BITS checks
roconnor-blockstream Nov 14, 2023
ea47c82
Merge bitcoin-core/secp256k1#1442: Return temporaries to being unsign…
real-or-random Nov 16, 2023
e721039
Merge bitcoin-core/secp256k1#1441: asm: add .note.GNU-stack section f…
real-or-random Nov 16, 2023
1ddd76a
bench: add --help option to bench_internal
Nov 23, 2023
2f0762f
field: Remove x86_64 asm
real-or-random Nov 23, 2023
f07cead
build: Don't call assembly an optimization
real-or-random Nov 23, 2023
c1b4966
Merge bitcoin-core/secp256k1#1445: bench: add --help option to bench_…
real-or-random Nov 24, 2023
5814d84
Merge bitcoin-core/secp256k1#1438: correct assertion for secp256k1_fe…
real-or-random Nov 27, 2023
c2688f8
redefine VERIFY_CHECK to empty in production (non-VERIFY) mode
theStack Aug 3, 2023
5d89bc0
remove superfluous `#ifdef VERIFY`/`#endif` preprocessor conditions
theStack Aug 3, 2023
cf25c86
introduce and use SECP256K1_{FE,GE,GEJ}_VERIFY macros
theStack Aug 4, 2023
a0fb68a
introduce and use SECP256K1_SCALAR_VERIFY macro
theStack Aug 18, 2023
a3a3e11
remove unneeded VERIFY_SETUP uses in ECMULT_CONST_TABLE_GET_GE macro
theStack Dec 1, 2023
bb46723
remove VERIFY_SETUP define
theStack Dec 1, 2023
07687e8
Merge bitcoin-core/secp256k1#1393: Implement new policy for VERIFY_CH…
real-or-random Dec 1, 2023
10e6d29
Merge bitcoin-core/secp256k1#1446: field: Remove x86_64 asm
jonasnick Dec 1, 2023
a47cd97
Add group.h ge/gej equality functions
sipa Dec 1, 2023
60525f6
Add unit tests for group.h equality functions
sipa Dec 1, 2023
04af0ba
Replace ge_equals_ge[,j] calls with group.h equality calls
sipa Dec 1, 2023
d3e29db
Merge bitcoin-core/secp256k1#1450: Add group.h ge/gej equality functions
real-or-random Dec 2, 2023
76880e4
Add CONTRIBUTING.md including scope and guidelines for new code
jonasnick Oct 17, 2023
0922a04
docs: move coverage report instructions to CONTRIBUTING
jonasnick Oct 18, 2023
1a432cb
README: update first sentence
jonasnick Oct 18, 2023
d2e36a2
changelog: add entry for "field: Remove x86_64 asm"
jonasnick Dec 5, 2023
e2c9888
Merge bitcoin-core/secp256k1#1451: changelog: add entry for "field: R…
real-or-random Dec 6, 2023
0e5ea62
CONTRIBUTING: add some coding and style conventions
jonasnick Oct 18, 2023
4197d66
Merge bitcoin-core/secp256k1#1431: Add CONTRIBUTING.md
real-or-random Dec 7, 2023
5e9a4d7
Merge bitcoin-core/secp256k1#990: Add comment on length checks when p…
real-or-random Dec 7, 2023
3928b7c
doc: improve secp256k1_fe_set_b32_mod doc
Coding-Enthusiast Dec 8, 2023
77af1da
Merge bitcoin-core/secp256k1#1455: doc: improve secp256k1_fe_set_b32_…
real-or-random Dec 11, 2023
e7f830e
Add `tools/check-abi.sh`
hebasto Dec 20, 2023
74a4d97
doc: Add ABI checking with `check-abi.sh` to the Release Process
hebasto Dec 20, 2023
1a81df8
Merge bitcoin-core/secp256k1#1380: Add ABI checking tool for release …
jonasnick Dec 20, 2023
672053d
release: prepare for 0.4.1
jonasnick Dec 21, 2023
1ad5185
Merge bitcoin-core/secp256k1#1465: release: prepare for 0.4.1
real-or-random Dec 21, 2023
4b2e06f
release cleanup: bump version after 0.4.1
jonasnick Dec 21, 2023
efe85c7
Merge bitcoin-core/secp256k1#1466: release cleanup: bump version afte…
real-or-random Dec 21, 2023
429d21d
release process: Run sanity checks on release PR
real-or-random Dec 21, 2023
e7053d0
release process: Add email step
real-or-random Dec 21, 2023
d77170a
Fix typos
shuoer86 Jan 2, 2024
3dbfb48
tests: restore scalar_mul test
jonasnick Jan 4, 2024
79e0945
Merge bitcoin-core/secp256k1#1473: Fix typos
real-or-random Jan 4, 2024
d373bf6
Merge bitcoin-core/secp256k1#1474: tests: restore scalar_mul test
real-or-random Jan 4, 2024
e3f6900
include: remove obvious "cannot be NULL" doc
jonasnick Jan 4, 2024
aa3dd52
include: make doc about ctx more consistent
jonasnick Jan 4, 2024
da7bc1b
include: in doc, remove article in front of "pointer"
jonasnick Jan 4, 2024
d0ba2ab
util: Add STATIC_ASSERT macro
real-or-random Jan 8, 2024
e53c2d9
Require that sizeof(secp256k1_ge_storage) == 64
real-or-random Jan 8, 2024
ba5d72d
assumptions: Use new STATIC_ASSERT macro
real-or-random Jan 8, 2024
9fb7e2f
release process: Style and formatting nits
real-or-random Dec 21, 2023
ad5f589
check-abi: Default to HEAD for new version
real-or-random Dec 21, 2023
b37fdb2
check-abi: Minor UI improvements
real-or-random Jan 8, 2024
74b7c3b
Merge bitcoin-core/secp256k1#1476: include: make docs more consistent
jonasnick Jan 9, 2024
a9db9f2
Merge bitcoin-core/secp256k1#1480: Get rid of untested sizeof(secp256…
real-or-random Jan 9, 2024
4437886
Merge bitcoin-core/secp256k1#1468: v0.4.1 release aftermath
jonasnick Jan 16, 2024
89ec583
build: Clean up handling of module dependencies
real-or-random Jan 16, 2024
e682267
build: Error if required module explicitly off
real-or-random Jan 16, 2024
3bf4d68
Merge bitcoin-core/secp256k1#1482: build: Clean up handling of module…
real-or-random Jan 17, 2024
e4af41c
Merge bitcoin-core/secp256k1#1249: cmake: Add `SECP256K1_LATE_CFLAGS`…
real-or-random Jan 17, 2024
e626f00
Merge commits 'b314cf28 1f1bb78b 40f50d0f c891c5c2 ea47c82e e7210393 …
real-or-random Jan 18, 2024
c29f28e
include: make docs more consistent
real-or-random Jan 18, 2024
4f65698
extrakeys: Remove redundant secp256k1_pubkey_cmp
real-or-random Jan 18, 2024
de54a1e
musig2: clean up ctx doc in include file
jonasnick Jan 5, 2024
33db8ed
group: add ge_to_bytes and ge_from_bytes
jonasnick Jan 6, 2024
cd17368
musig: replace point_{save,load} with ge_{to,from}_bytes
jonasnick Jan 6, 2024
b673a43
musig: new upstream def of VERIFY_CHECK (empty in non-VERIFY)
jonasnick Jan 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
env:
### cirrus config
CIRRUS_CLONE_DEPTH: 1
### compiler options
HOST:
WRAPPER_CMD:
# Specific warnings can be disabled with -Wno-error=foo.
# -pedantic-errors is not equivalent to -Werror=pedantic and thus not implied by -Werror according to the GCC manual.
WERROR_CFLAGS: -Werror -pedantic-errors
MAKEFLAGS: -j4
BUILD: check
### secp256k1 config
ECMULTWINDOW: auto
ECMULTGENPRECISION: auto
ASM: no
WIDEMUL: auto
WITH_VALGRIND: yes
EXTRAFLAGS:
### secp256k1 modules
EXPERIMENTAL: no
ECDH: no
RECOVERY: no
SCHNORRSIG: no
ELLSWIFT: no
### test options
SECP256K1_TEST_ITERS:
BENCH: yes
SECP256K1_BENCH_ITERS: 2
CTIMETESTS: yes
# Compile and run the tests
EXAMPLES: yes

cat_logs_snippet: &CAT_LOGS
always:
cat_tests_log_script:
- cat tests.log || true
cat_noverify_tests_log_script:
- cat noverify_tests.log || true
cat_exhaustive_tests_log_script:
- cat exhaustive_tests.log || true
cat_ctime_tests_log_script:
- cat ctime_tests.log || true
cat_bench_log_script:
- cat bench.log || true
cat_config_log_script:
- cat config.log || true
cat_test_env_script:
- cat test_env.log || true
cat_ci_env_script:
- env

linux_arm64_container_snippet: &LINUX_ARM64_CONTAINER
env_script:
- env | tee /tmp/env
build_script:
- DOCKER_BUILDKIT=1 docker build --file "ci/linux-debian.Dockerfile" --tag="ci_secp256k1_arm"
- docker image prune --force # Cleanup stale layers
test_script:
- docker run --rm --mount "type=bind,src=./,dst=/ci_secp256k1" --env-file /tmp/env --replace --name "ci_secp256k1_arm" "ci_secp256k1_arm" bash -c "cd /ci_secp256k1/ && ./ci/ci.sh"

task:
name: "ARM64: Linux (Debian stable)"
persistent_worker:
labels:
type: arm64
env:
ECDH: yes
RECOVERY: yes
SCHNORRSIG: yes
ELLSWIFT: yes
matrix:
# Currently only gcc-snapshot, the other compilers are tested on GHA with QEMU
- env: { CC: 'gcc-snapshot' }
<< : *LINUX_ARM64_CONTAINER
<< : *CAT_LOGS

task:
name: "ARM64: Linux (Debian stable), Valgrind"
persistent_worker:
labels:
type: arm64
env:
ECDH: yes
RECOVERY: yes
SCHNORRSIG: yes
ELLSWIFT: yes
WRAPPER_CMD: 'valgrind --error-exitcode=42'
SECP256K1_TEST_ITERS: 2
matrix:
- env: { CC: 'gcc' }
- env: { CC: 'clang' }
- env: { CC: 'gcc-snapshot' }
- env: { CC: 'clang-snapshot' }
<< : *LINUX_ARM64_CONTAINER
<< : *CAT_LOGS
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

## [0.4.1] - 2023-12-21

#### Changed
- The point multiplication algorithm used for ECDH operations (module `ecdh`) was replaced with a slightly faster one.
- Optional handwritten x86_64 assembly for field operations was removed because modern C compilers are able to output more efficient assembly. This change results in a significant speedup of some library functions when handwritten x86_64 assembly is enabled (`--with-asm=x86_64` in GNU Autotools, `-DSECP256K1_ASM=x86_64` in CMake), which is the default on x86_64. Benchmarks with GCC 10.5.0 show a 10% speedup for `secp256k1_ecdsa_verify` and `secp256k1_schnorrsig_verify`.

#### ABI Compatibility
The ABI is backward compatible with versions 0.4.0 and 0.3.x.

## [0.4.0] - 2023-09-04

#### Added
Expand Down Expand Up @@ -109,7 +118,8 @@ This version was in fact never released.
The number was given by the build system since the introduction of autotools in Jan 2014 (ea0fe5a5bf0c04f9cc955b2966b614f5f378c6f6).
Therefore, this version number does not uniquely identify a set of source files.

[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.4.0...HEAD
[unreleased]: https://github.com/bitcoin-core/secp256k1/compare/v0.4.1...HEAD
[0.4.1]: https://github.com/bitcoin-core/secp256k1/compare/v0.4.0...v0.4.1
[0.4.0]: https://github.com/bitcoin-core/secp256k1/compare/v0.3.2...v0.4.0
[0.3.2]: https://github.com/bitcoin-core/secp256k1/compare/v0.3.1...v0.3.2
[0.3.1]: https://github.com/bitcoin-core/secp256k1/compare/v0.3.0...v0.3.1
Expand Down
55 changes: 37 additions & 18 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ project(libsecp256k1
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
# the API. All changes in experimental modules are treated as
# backwards-compatible and therefore at most increase the minor version.
VERSION 0.4.1
VERSION 0.4.2
DESCRIPTION "Optimized C library for ECDSA signatures and secret/public key operations on curve secp256k1."
HOMEPAGE_URL "https://github.com/bitcoin-core/secp256k1"
LANGUAGES C
Expand All @@ -35,7 +35,7 @@ endif()
# All changes in experimental modules are treated as if they don't affect the
# interface and therefore only increase the revision.
set(${PROJECT_NAME}_LIB_VERSION_CURRENT 3)
set(${PROJECT_NAME}_LIB_VERSION_REVISION 1)
set(${PROJECT_NAME}_LIB_VERSION_REVISION 2)
set(${PROJECT_NAME}_LIB_VERSION_AGE 1)

set(CMAKE_C_STANDARD 90)
Expand All @@ -51,29 +51,40 @@ endif()

option(SECP256K1_INSTALL "Enable installation." ${PROJECT_IS_TOP_LEVEL})

option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
if(SECP256K1_ENABLE_MODULE_ECDH)
add_compile_definitions(ENABLE_MODULE_ECDH=1)
endif()
## Modules

# We declare all options before processing them, to make sure we can express
# dependendencies while processing.
option(SECP256K1_ENABLE_MODULE_ECDH "Enable ECDH module." ON)
option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." OFF)
if(SECP256K1_ENABLE_MODULE_RECOVERY)
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
endif()

option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)

# Processing must be done in a topological sorting of the dependency graph
# (dependent module first).
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
endif()

if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
if(DEFINED SECP256K1_ENABLE_MODULE_EXTRAKEYS AND NOT SECP256K1_ENABLE_MODULE_EXTRAKEYS)
message(FATAL_ERROR "Module dependency error: You have disabled the extrakeys module explicitly, but it is required by the schnorrsig module.")
endif()
set(SECP256K1_ENABLE_MODULE_EXTRAKEYS ON)
add_compile_definitions(ENABLE_MODULE_SCHNORRSIG=1)
endif()

if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
add_compile_definitions(ENABLE_MODULE_EXTRAKEYS=1)
endif()

option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
if(SECP256K1_ENABLE_MODULE_RECOVERY)
add_compile_definitions(ENABLE_MODULE_RECOVERY=1)
endif()

if(SECP256K1_ENABLE_MODULE_ECDH)
add_compile_definitions(ENABLE_MODULE_ECDH=1)
endif()

option(SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callback functions." OFF)
Expand Down Expand Up @@ -107,7 +118,7 @@ if(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
endif()
mark_as_advanced(FORCE SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)

set(SECP256K1_ASM "AUTO" CACHE STRING "Assembly optimizations to use: \"AUTO\", \"OFF\", \"x86_64\" or \"arm32\" (experimental). [default=AUTO]")
set(SECP256K1_ASM "AUTO" CACHE STRING "Assembly to use: \"AUTO\", \"OFF\", \"x86_64\" or \"arm32\" (experimental). [default=AUTO]")
set_property(CACHE SECP256K1_ASM PROPERTY STRINGS "AUTO" "OFF" "x86_64" "arm32")
check_string_option_value(SECP256K1_ASM)
if(SECP256K1_ASM STREQUAL "arm32")
Expand All @@ -117,7 +128,7 @@ if(SECP256K1_ASM STREQUAL "arm32")
if(HAVE_ARM32_ASM)
add_compile_definitions(USE_EXTERNAL_ASM=1)
else()
message(FATAL_ERROR "ARM32 assembly optimization requested but not available.")
message(FATAL_ERROR "ARM32 assembly requested but not available.")
endif()
elseif(SECP256K1_ASM)
include(CheckX86_64Assembly)
Expand All @@ -128,14 +139,14 @@ elseif(SECP256K1_ASM)
elseif(SECP256K1_ASM STREQUAL "AUTO")
set(SECP256K1_ASM "OFF")
else()
message(FATAL_ERROR "x86_64 assembly optimization requested but not available.")
message(FATAL_ERROR "x86_64 assembly requested but not available.")
endif()
endif()

option(SECP256K1_EXPERIMENTAL "Allow experimental configuration options." OFF)
if(NOT SECP256K1_EXPERIMENTAL)
if(SECP256K1_ASM STREQUAL "arm32")
message(FATAL_ERROR "ARM32 assembly optimization is experimental. Use -DSECP256K1_EXPERIMENTAL=ON to allow.")
message(FATAL_ERROR "ARM32 assembly is experimental. Use -DSECP256K1_EXPERIMENTAL=ON to allow.")
endif()
endif()

Expand Down Expand Up @@ -254,9 +265,14 @@ if(SECP256K1_BUILD_BENCHMARK OR SECP256K1_BUILD_TESTS OR SECP256K1_BUILD_EXHAUST
enable_testing()
endif()

set(SECP256K1_LATE_CFLAGS "" CACHE STRING "Compiler flags that are added to the command line after all other flags added by the build system.")
include(AllTargetsCompileOptions)

add_subdirectory(src)
all_targets_compile_options(src "${SECP256K1_LATE_CFLAGS}")
if(SECP256K1_BUILD_EXAMPLES)
add_subdirectory(examples)
all_targets_compile_options(examples "${SECP256K1_LATE_CFLAGS}")
endif()

message("\n")
Expand All @@ -280,7 +296,7 @@ message("Parameters:")
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
message(" ecmult gen precision bits ........... ${SECP256K1_ECMULT_GEN_PREC_BITS}")
message("Optional features:")
message(" assembly optimization ............... ${SECP256K1_ASM}")
message(" assembly ............................ ${SECP256K1_ASM}")
message(" external callbacks .................. ${SECP256K1_USE_EXTERNAL_DEFAULT_CALLBACKS}")
if(SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY)
message(" wide multiplication (test-only) ..... ${SECP256K1_TEST_OVERRIDE_WIDE_MULTIPLY}")
Expand Down Expand Up @@ -330,6 +346,9 @@ else()
message(" - LDFLAGS for executables ............ ${CMAKE_EXE_LINKER_FLAGS_DEBUG}")
message(" - LDFLAGS for shared libraries ....... ${CMAKE_SHARED_LINKER_FLAGS_DEBUG}")
endif()
if(SECP256K1_LATE_CFLAGS)
message("SECP256K1_LATE_CFLAGS ................. ${SECP256K1_LATE_CFLAGS}")
endif()
message("\n")
if(SECP256K1_EXPERIMENTAL)
message(
Expand Down
107 changes: 107 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
# Contributing to libsecp256k1

## Scope

libsecp256k1 is a library for elliptic curve cryptography on the curve secp256k1, not a general-purpose cryptography library.
The library primarily serves the needs of the Bitcoin Core project but provides additional functionality for the benefit of the wider Bitcoin ecosystem.

## Adding new functionality or modules

The libsecp256k1 project welcomes contributions in the form of new functionality or modules, provided they are within the project's scope.

It is the responsibility of the contributors to convince the maintainers that the proposed functionality is within the project's scope, high-quality and maintainable.
Contributors are recommended to provide the following in addition to the new code:

* **Specification:**
A specification can help significantly in reviewing the new code as it provides documentation and context.
It may justify various design decisions, give a motivation and outline security goals.
If the specification contains pseudocode, a reference implementation or test vectors, these can be used to compare with the proposed libsecp256k1 code.
* **Security Arguments:**
In addition to a defining the security goals, it should be argued that the new functionality meets these goals.
Depending on the nature of the new functionality, a wide range of security arguments are acceptable, ranging from being "obviously secure" to rigorous proofs of security.
* **Relevance Arguments:**
The relevance of the new functionality for the Bitcoin ecosystem should be argued by outlining clear use cases.

These are not the only factors taken into account when considering to add new functionality.
The proposed new libsecp256k1 code must be of high quality, including API documentation and tests, as well as featuring a misuse-resistant API design.

We recommend reaching out to other contributors (see [Communication Channels](#communication-channels)) and get feedback before implementing new functionality.

## Communication channels

Most communication about libsecp256k1 occurs on the GitHub repository: in issues, pull request or on the discussion board.

Additionally, there is an IRC channel dedicated to libsecp256k1, with biweekly meetings (see channel topic).
The channel is `#secp256k1` on Libera Chat.
The easiest way to participate on IRC is with the web client, [web.libera.chat](https://web.libera.chat/#secp256k1).
Chat history logs can be found at https://gnusha.org/secp256k1/.

## Contributor workflow & peer review

The Contributor Workflow & Peer Review in libsecp256k1 are similar to Bitcoin Core's workflow and review processes described in its [CONTRIBUTING.md](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md).

### Coding conventions

In addition, libsecp256k1 tries to maintain the following coding conventions:

* No runtime heap allocation (e.g., no `malloc`) unless explicitly requested by the caller (via `secp256k1_context_create` or `secp256k1_scratch_space_create`, for example). Moreover, it should be possible to use the library without any heap allocations.
* The tests should cover all lines and branches of the library (see [Test coverage](#coverage)).
* Operations involving secret data should be tested for being constant time with respect to the secrets (see [src/ctime_tests.c](src/ctime_tests.c)).
* Local variables containing secret data should be cleared explicitly to try to delete secrets from memory.
* Use `secp256k1_memcmp_var` instead of `memcmp` (see [#823](https://github.com/bitcoin-core/secp256k1/issues/823)).

#### Style conventions

* Commits should be atomic and diffs should be easy to read. For this reason, do not mix any formatting fixes or code moves with actual code changes. Make sure each individual commit is hygienic: that it builds successfully on its own without warnings, errors, regressions, or test failures.
* New code should adhere to the style of existing, in particular surrounding, code. Other than that, we do not enforce strict rules for code formatting.
* The code conforms to C89. Most notably, that means that only `/* ... */` comments are allowed (no `//` line comments). Moreover, any declarations in a `{ ... }` block (e.g., a function) must appear at the beginning of the block before any statements. When you would like to declare a variable in the middle of a block, you can open a new block:
```C
void secp256k_foo(void) {
unsigned int x; /* declaration */
int y = 2*x; /* declaration */
x = 17; /* statement */
{
int a, b; /* declaration */
a = x + y; /* statement */
secp256k_bar(x, &b); /* statement */
}
}
```
* Use `unsigned int` instead of just `unsigned`.
* Use `void *ptr` instead of `void* ptr`.
* Arguments of the publicly-facing API must have a specific order defined in [include/secp256k1.h](include/secp256k1.h).
* User-facing comment lines in headers should be limited to 80 chars if possible.
* All identifiers in file scope should start with `secp256k1_`.
* Avoid trailing whitespace.

### Tests

#### Coverage

This library aims to have full coverage of 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

#### Exhaustive tests

There are tests of several functions in which a small group replaces secp256k1.
These tests are *exhaustive* since they provide all elements and scalars of the small group as input arguments (see [src/tests_exhaustive.c](src/tests_exhaustive.c)).

### Benchmarks

See `src/bench*.c` for examples of benchmarks.
1 change: 0 additions & 1 deletion Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ noinst_HEADERS += src/field_10x26_impl.h
noinst_HEADERS += src/field_5x52.h
noinst_HEADERS += src/field_5x52_impl.h
noinst_HEADERS += src/field_5x52_int128_impl.h
noinst_HEADERS += src/field_5x52_asm_impl.h
noinst_HEADERS += src/modinv32.h
noinst_HEADERS += src/modinv32_impl.h
noinst_HEADERS += src/modinv64.h
Expand Down
Loading