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

Merge rust-bitcoin/rust-bitcoin#7096: Add x_only_serde module for `XOnlyPublicKey` serde

Public commit record

What the developer wrote

Authored by Andrew Poelstra

91/100 · Strong
Merge rust-bitcoin/rust-bitcoin#7096: Add x_only_serde module for `XOnlyPublicKey` serde

50940cb20fad4839b00ba56e499df4ab75beb8f2 Remove default XOnlyPublicKey serde impl (Mitchell Bagot)
877faa8f4399a3e6fe20de29bd16f9470a1568a1 Remove uses of default XOnlyPublicKey serde (Mitchell Bagot)
65ea85ba008f8a2f1c3889f8e0bee0b35cb50066 Add x_only_serde module for XOnlyPublicKey serde encoding (Mitchell Bagot)

Pull request description:

Currently, the x-only public key serde encodes and decodes using the inner type, without any parity. Since the bitcoin-crypto type holds the parity, this makes the type unable to roundtrip odd parity keys. Instead, with or without parity encoding should be selectable by users.

Closes #5729


ACKs for top commit:
tcharding:
ACK 50940cb20fad4839b00ba56e499df4ab75beb8f2
apoelstra:
ACK 50940cb20fad4839b00ba56e499df4ab75beb8f2; successfully ran local tests


Tree-SHA512: 9de8f4794a8897c0956540b050e5d4a290516921cb7a2964739626652e2e09d8664c349714e188d9d24a053915422e9803228e3769a124df7618d1958a2884f4
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification✓ Links an issue, advisory, or supporting reference
The short version

What changed, and why it matters

This change fixes a data-integrity problem in how a special Bitcoin public key type (XOnlyPublicKey) was being saved and loaded through serde. Previously, the type silently dropped the 'parity' bit during serialization, so an odd-parity key could be serialized and then deserialized as a different, even-parity key. The patch removes the automatic serde implementation and instead offers two explicit modules: one that preserves parity by serializing the full public key, and one that intentionally drops parity. It also removes serde support from Taproot ControlBlock because that structure contained an XOnlyPublicKey and could no longer round-trip safely by default. This is a correctness and API-breaking change, not a remote code-execution vulnerability.

Recommended action

Treat this as a behavioral/API fix rather than an exploitable vulnerability. Downstream users relying on XOnlyPublicKey serde should migrate to either bitcoin::key::x_only_serde::with_parity or without_parity. Review any persisted serialized XOnlyPublicKey or ControlBlock data, because old odd-parity keys may have been silently stored with even parity. No emergency patch is required, but a changelog note and migration guidance are appropriate.

Security signals we found

01

Loss of cryptographic metadata (parity) during serialization/deserialization

02

Silent mutation of deserialized X-only public keys with odd parity

03

API-breaking removal of default serde traits to prevent accidental misuse

04

Addition of explicit parity-preserving and parity-discarding serde modules

05

Removal of serde derive on Taproot ControlBlock due to non-roundtripping XOnlyPublicKey field

Risk score

Why this scored 37/100

Our methodology →
Potential impact 8/30
Exploitability 5/25
Stealth signal 6/15
Affected reach 7/15
Confidence 7/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.