Skip to content

Conversation

@quapka
Copy link

@quapka quapka commented Dec 6, 2025

It's possible to derive unserializable, as defined by BIP32, extended keys.

Description

BIP32 serializes the depth of an extended key as a single byte. Thus, extended keys that are of depth greater than 255 are not possible to be serialized (in the BIP32 specified format). This commit introduces backwards-incompatible change that prevents a key of depth 256 and greater to be derived.

Notes for QA

Two tests (one for private -> private and another for public -> public derivation) were added, even though they are covered by the same fix. If there are other parts of the code base that do extended key derivation, these should be verified for similar overflow as well.

The changes are backwards-incompatible - however, as long as one has the original seed, any keys, even the unserializable, can be still derived.

Related Issue

BIP32 serializes the `depth` of an extended key as a single byte. Thus,
extended keys that are of depth greater than 255 are not possible to be
serialized (in the BIP32 specified format). This commit introduces
backwards-incompatible change that prevents a key of depth 256 and
greater to be derived.

For more information, see bitcoin/bitcoin#32201
@quapka quapka requested a review from szymonlesisz as a code owner December 6, 2025 18:35
@quapka
Copy link
Author

quapka commented Dec 6, 2025

I have noticed that your implementation originates from https://github.com/bitcoinjs/bip32/, thus it might be relevant to directly mention the upstream author's viewpoint (i.e., won't fix now), see bitcoinjs/bip32#92.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant