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

Merge rust-bitcoin/rust-bitcoin#7127: key_expression: Reduce `alloc` gating to minimal types

Public commit record

What the developer wrote

Authored by Andrew Poelstra

91/100 · Strong
Merge rust-bitcoin/rust-bitcoin#7127: key_expression: Reduce `alloc` gating to minimal types

9b23b16241fc6ddaca5c55f2a85e9b2f160993f6 Remove unused errors and variants (Mitchell Bagot)
b48052c31731e6ce21dd9e5ae7bfbddd4de83bbd Ungate FromStr and Display for Xpriv and Xpub (Mitchell Bagot)
1f13455f1fd6cba340ea3cbfcee49ad5a6410de0 Gate individual items in bip32 instead of whole module (Mitchell Bagot)
df894f30da75b858fb0925de02e5dc2e51b4c05e Add optional feature gate to impl_array_newtype macro (Mitchell Bagot)

Pull request description:

The key_expression crate currently gates all functionality on alloc. However, most of the bip32 module does not depend on alloc, outside of a few types. Instead of gating the entire module on alloc, only the inner types and functionality that truly depend on alloc should be gated. With the new base58 functionality, this can be achieved with minimal changes.

Adjust gating to only gate minimal types and functionality on alloc.
Adjust FromStr+Display on X key types to use no-alloc base58.
Adjust ParseXp*Error types to support no-alloc base58 errors.


ACKs for top commit:
tcharding:
ACK 9b23b16241fc6ddaca5c55f2a85e9b2f160993f6
apoelstra:
ACK 9b23b16241fc6ddaca5c55f2a85e9b2f160993f6; successfully ran local tests


Tree-SHA512: 1df13fcc0af1412ffe8e077cb76cb47a3f797b70837ffdfb52f3ede963c1910a78c672139cb6b8901f8f767ce3ddcb3ad2e49996734af369f0da796ef2b6eca6
✓ 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 commit is a code cleanup and feature-gating refactor for the rust-bitcoin library's key_expression crate. It makes more BIP32 (Bitcoin wallet key derivation) types available when the 'alloc' memory allocator feature is disabled, and switches Xpriv/Xpub string parsing to use a no-alloc base58 decoder. There is no direct security vulnerability visible in the diff; it is primarily a maintainability and no-alloc compatibility improvement.

Recommended action

No immediate security action required. Reviewers should verify that the new no-alloc base58 encode/decode APIs correctly enforce the 78-byte payload length and checksum validation, and that the removed InvalidBase58PayloadLengthError does not hide useful diagnostic information. Confirm test coverage for malformed-length inputs remains equivalent.

Security signals we found

01

Refactor of error types and parsing paths for Xpriv/Xpub base58 decoding

02

Switch from unbounded base58 decode to fixed-size array decode (78 bytes)

03

Removal of explicit length-check error path in favor of decoder-reported length error

04

Feature-gating changes that expose more BIP32 functionality in no-alloc builds

Risk score

Why this scored 19/100

Our methodology →
Potential impact 2/30
Exploitability 1/25
Stealth signal 1/15
Affected reach 3/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.