Skip to content

Move SHA256 self-test into hash module and remove selftest.h - #1987

Closed
amartya1523 wants to merge 2 commits into
bitcoin-core:masterfrom
amartya1523:selftest-into-hash
Closed

amartya1523 wants to merge 2 commits into
bitcoin-core:masterfrom
amartya1523:selftest-into-hash

Conversation

@amartya1523

Copy link
Copy Markdown
Contributor

This addresses the "Reorganize self-test" item in #1835.

The SHA256 check used by secp256k1_selftest and secp256k1_context_set_sha256_compression only exercises the hash module, so the first commit moves it next to secp256k1_sha256_smoke_test and renames it to secp256k1_sha256_selftest. No functional change.

After that, selftest.h only held a one-line wrapper, so the second commit removes the file and has secp256k1_selftest call the hash self-test directly. A comment there explains why it always uses the built-in implementation: the API function is meant to catch a broken build of the library (e.g. wrong endianness), and a compression override is already checked when it is set on a context.

I kept the move and the removal as separate commits so the first one is easy to review as a pure move.

secp256k1_selftest_sha256 only exercises the hash module and is also
used to validate a caller-supplied compression function in
secp256k1_context_set_sha256_compression. Move it next to
secp256k1_sha256_smoke_test and rename it to secp256k1_sha256_selftest
to match the naming of the module it lives in.

No functional change.
After moving the SHA256 check into the hash module, selftest.h only had
a one-line wrapper left. Drop it and call secp256k1_sha256_selftest
from secp256k1_selftest directly, with a comment explaining why it
always uses the built-in implementation: the API function is meant to
catch a broken build of the library (e.g., wrong endianness), and a
compression override is already checked when it is set on a context.
@amartya1523 amartya1523 closed this Nov 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant