use new `_eckey_pubkey_serialize{33,65}` functions in public API
What changed, and why it matters
This is a small internal code cleanup in the Bitcoin Core secp256k1 library. It changes how public keys are converted to bytes in one public function, replacing a single flexible helper with two fixed-size helpers. There is no indication of a security bug being fixed.
No security action required. Treat as a normal refactoring/reliability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit refactors secp256k1_ec_pubkey_serialize in src/secp256k1.c to call new specialized helpers _eckey_pubkey_serialize33 and _eckey_pubkey_serialize65 instead of the older _eckey_pubkey_serialize with a compression flag and output-length pointer. The behavior is functionally equivalent for valid inputs: compressed serialization still writes 33 bytes and uncompressed writes 65 bytes. The change removes a length round-trip and makes the output size explicit. No input validation, memory safety, or cryptographic logic changes are evident.
Changed components
src/secp256k1.c: secp256k1_ec_pubkey_serializeInspect captured patch +7 / −3
diff --git a/src/secp256k1.c b/src/secp256k1.c
index 26336a4..c2d3fcb 100644
--- a/src/secp256k1.c
+++ b/src/secp256k1.c
@@ -280,10 +280,14 @@ int secp256k1_ec_pubkey_serialize(const secp256k1_context* ctx, unsigned char *o
ARG_CHECK(pubkey != NULL);
ARG_CHECK((flags & SECP256K1_FLAGS_TYPE_MASK) == SECP256K1_FLAGS_TYPE_COMPRESSION);
if (secp256k1_pubkey_load(ctx, &Q, pubkey)) {
- ret = secp256k1_eckey_pubkey_serialize(&Q, output, &len, !!(flags & SECP256K1_FLAGS_BIT_COMPRESSION));
- if (ret) {
- *outputlen = len;
+ if (flags & SECP256K1_FLAGS_BIT_COMPRESSION) {
+ secp256k1_eckey_pubkey_serialize33(&Q, output);
+ *outputlen = 33;
+ } else {
+ secp256k1_eckey_pubkey_serialize65(&Q, output);
+ *outputlen = 65;
}
+ ret = 1;
}
return ret;
}
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.