AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Low 35 Bitcoin

Add API to override SHA256 compression at runtime

Public commit record

What the developer wrote

Authored by furszy

80/100 · Strong
Add API to override SHA256 compression at runtime

This introduces `secp256k1_context_set_sha256_compression()`,
which allows users to provide their own SHA256 block-compression
function at runtime.

This is useful in setups where the fastest implementation can only
be determined dynamically based on the available CPU features, and
rebuilding the library is not possible.

The callback is installed on the `secp256k1_context` and is then used
by all operations that compute SHA256 hashes. As part of the setup,
the library performs sanity checks to ensure that the supplied
function is equivalent to the default transform.

Passing NULL to the callback setter restores the built-in
implementation.
✓ Descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode
The short version

What changed, and why it matters

This commit adds a new public API that lets users of the libsecp256k1 cryptography library swap out the internal SHA-256 compression function at runtime, typically to use a faster hardware-accelerated version. The library checks that the replacement behaves like the real SHA-256 step before accepting it. The change itself is a feature addition, not a bug fix, and there is no evidence in the commit or supplied references that it addresses a known security vulnerability.

Recommended action

Review the new API as a potential expansion of the library's trust surface. Ensure callers cannot install a malicious or buggy compression function without passing the selftest, and consider hardening against direct mutation of ctx->hash_ctx internal fields. No immediate patch is indicated by the supplied materials.

Security signals we found

01

New public API for runtime cryptographic primitive substitution

02

Sanity check (selftest_sha256) performed before accepting user-supplied compression function

03

Context field ctx->hash_ctx.fn_sha256_compression is now a trust boundary for SHA-256 operations

04

Tests bypass the setter and directly mutate ctx->hash_ctx.fn_sha256_compression to verify behavior

05

No mention of vulnerability, CVE, bug, or security fix in commit message or diff

Risk score

Why this scored 35/100

Our methodology →
Potential impact 8/30
Exploitability 6/25
Stealth signal 4/15
Affected reach 7/15
Confidence 7/10
Evidence quality 3/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.