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

Merge bitcoin-core/secp256k1#1948: tests: add ECDSA verify case where r + n overflows p

Public commit record

What the developer wrote

Authored by merge-script

100/100 · Strong
Merge bitcoin-core/secp256k1#1948: tests: add ECDSA verify case where r + n overflows p

fc88acc3e2e2cbba7ee202634eb73d5d21694126 tests: add ECDSA verify case where r + n overflows p (ViniciusCestarii)

Pull request description:

Currently no test checks that ECDSA verify rejects a signature where r + n ≥ p and (r + n) mod p equals x(R), so the following mutant lives:

```diff
diff --git a/src/ecdsa_impl.h b/src/ecdsa_impl.h
index 5963877..5301eaa 100644
--- a/src/ecdsa_impl.h
+++ b/src/ecdsa_impl.h
@@ -258,10 +258,6 @@ static int secp256k1_ecdsa_sig_verify(const secp256k1_scalar *sigr, const secp25
/* xr * pr.z^2 mod p == pr.x, so the signature is valid. */
return 1;
}
- if (secp256k1_fe_cmp_var(&xr, &secp256k1_ecdsa_const_p_minus_order) >= 0) {
- /* xr + n >= p, so we can skip testing the second case. */
- return 0;
- }
secp256k1_fe_add(&xr, &secp256k1_ecdsa_const_order_as_fe);
if (secp256k1_gej_eq_x_var(&xr, &pr)) {
/* (xr + n) * pr.z^2 mod p == pr.x, so the signature is valid. */
```

This adds a case with r = p - n + 1, so that (r + n) mod p = 1, and a pubkey chosen so that x(R) = 1, covering this gap.

ACKs for top commit:
real-or-random:
utACK fc88acc3e2e2cbba7ee202634eb73d5d21694126
theStack:
re-ACK fc88acc3e2e2cbba7ee202634eb73d5d21694126

Tree-SHA512: b9ab5ff0e7312e3ff8b5667eed56f616f7fc59ad8d1777fd54d70fcb3342b5084dc8915c0638a6486fdfe4522da5905521dd32622a64d5a2b5d0a3385e381098
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Explains rationale or failure mode✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference✓ Names security-relevant behavior explicitly
The short version

What changed, and why it matters

This commit only adds a new test case to the project's test suite. It does not change any production cryptographic code. The new test verifies that the ECDSA signature verification function correctly rejects a crafted invalid signature in a rare edge case where a mathematical overflow condition occurs. It closes a testing gap that could otherwise allow a subtle code mutation to go undetected, but it is not a security fix by itself.

Recommended action

No immediate action required. Treat as a normal test-coverage improvement. Reviewers may optionally verify that the new test vector is correct and that existing CI runs pass with the added case.

Security signals we found

01

Adds test coverage for ECDSA verification edge case involving r + n overflow against field order p

02

References a surviving mutant where the early-rejection check in secp256k1_ecdsa_sig_verify is removed

03

Does not modify production code; purely a test-suite enhancement

Risk score

Why this scored 12/100

Our methodology →
Potential impact 0/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 0/15
Confidence 8/10
Evidence quality 4/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.