silentpayments: check test serialization
What changed, and why it matters
This is a small fix inside a test file for the silent payments module. It makes sure a function that converts a public key into bytes actually succeeds before comparing those bytes against expected test values. Previously, the test could compare stale or uninitialized bytes if the conversion failed, which could hide test failures but does not affect real wallet or network code.
No production action required. The patch is a test-hardening improvement; ensure it is merged so silent-payments tests cannot silently pass on serialization failure.
Security signals we found
Test-only change
Missing return-value check in test harness
Potential false-negative test result if serialization fails
Evidence from the diff
In src/modules/silentpayments/tests_impl.h, the test_recipient_sort_helper unit test now wraps secp256k1_xonly_pubkey_serialize() with CHECK(… == 1). Previously the return value was discarded and the test immediately compared the 32-byte buffer xonly_ser against an expected vector. If serialization failed, xonly_ser could contain uninitialized or leftover data, making the subsequent memcmp meaningless. The change only affects test code, not library runtime behavior.
Changed components
src/modules/silentpayments/tests_impl.hInspect captured patch +1 / −1
diff --git a/src/modules/silentpayments/tests_impl.h b/src/modules/silentpayments/tests_impl.h
index a66e8f9..8a60a95 100644
--- a/src/modules/silentpayments/tests_impl.h
+++ b/src/modules/silentpayments/tests_impl.h
@@ -138,7 +138,7 @@ static void test_recipient_sort_helper(unsigned char (*sp_addresses[3])[2][33],
);
CHECK(ret == 1);
for (i = 0; i < 3; i++) {
- secp256k1_xonly_pubkey_serialize(CTX, xonly_ser, &generated_outputs[i]);
+ CHECK(secp256k1_xonly_pubkey_serialize(CTX, xonly_ser, &generated_outputs[i]) == 1);
CHECK(secp256k1_memcmp_var(xonly_ser, (*sp_outputs[i]), 32) == 0);
}
}
Why this scored 17/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.