test: Improve code coverage for pubkey checks
What changed, and why it matters
This commit only adds new test cases to a JSON test data file for Bitcoin Core's script validation tests. It does not change any production code, cryptographic checks, or network rules. The new tests verify that invalid public key formats are correctly rejected, which improves code coverage but introduces no security change by itself.
No action required; treat as routine test-coverage improvement.
Security signals we found
No production code changes
Only test data file modified
Adds negative test vectors for existing pubkey-type validation flags
Evidence from the diff
The diff appends three additional test vectors to src/test/data/script_tests.json: two P2PK cases exercising PUBKEYTYPE rejection for malformed uncompressed/compressed key lengths, and one P2WPKH case exercising WITNESS_PUBKEYTYPE rejection of an invalid compressed-key prefix. These are purely additive test fixtures; no C++ consensus or policy code is modified.
Changed components
src/test/data/script_tests.jsonInspect captured patch +26 / −0
diff --git a/src/test/data/script_tests.json b/src/test/data/script_tests.json
index e276fec2..6c472451 100644
--- a/src/test/data/script_tests.json
+++ b/src/test/data/script_tests.json
@@ -1682,6 +1682,20 @@
"PUBKEYTYPE",
"P2PK with hybrid pubkey"
],
+[
+ "0x00",
+ "0x21 0x0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 CHECKSIG",
+ "STRICTENC",
+ "PUBKEYTYPE",
+ "P2PK with invalid length for uncompressed key"
+],
+[
+ "0x00",
+ "0x41 0x0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG",
+ "STRICTENC",
+ "PUBKEYTYPE",
+ "P2PK with invalid length for compressed key"
+],
[
"0x47 0x30440220035d554e3153c14950c9993f41c496607a8e24093db0595be7bf875cf64fcf1f02204731c8c4e5daf15e706cec19cdd8f2c5b1d05490e11dab8465ed426569b6e92101",
"0x41 0x0679be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8 CHECKSIG NOT",
@@ -2256,6 +2270,18 @@
"WITNESS_PUBKEYTYPE",
"Basic P2SH(P2WPKH)"
],
+[
+ [
+ "",
+ "0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",
+ 0.00000001
+ ],
+ "",
+ "0 0x14 0xfe78b0052557b3d67248d04e4f7b99c361167432",
+ "P2SH,WITNESS,WITNESS_PUBKEYTYPE",
+ "WITNESS_PUBKEYTYPE",
+ "P2WPKH with invalid prefix for compressed key"
+],
["Testing P2WSH multisig with compressed keys"],
[
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.