This repository was archived by the owner on Oct 22, 2026. It is now read-only.
Repository navigation
13.x: descriptor: reject keys deeper than BIP32 allows - #1074
Merged
Merged
Conversation
DefiniteDescriptorKey::new checks for wildcards, hardened steps and multipath derivation, but not for BIP32's maximum depth of 255. A key that passes these checks but derives past that depth makes rust-bitcoin return MaximumDepthExceeded, and derive_public_key turns this error into a panic labeled "cryptographically unreachable". A descriptor string can trigger it: an xpub with a long enough path parses, becomes definite, and panics when its script pubkey is computed. Return the new NonDefiniteKeyError::MaximumDepthExceeded from DefiniteDescriptorKey::new instead. Derivation at an index goes through it, so it returns the error too. Only the steps after the extended key count, since its depth already includes its origin steps. Assisted-by: Claude Opus 5.5
A key expression that derives past BIP32's maximum depth of 255 can never produce a key. The previous commit rejects such a key when it becomes definite. Reject it when parsing too, so that the error points at the string that caused it. Count the steps after the extended key, plus one for a wildcard, for xpubs and xprvs, including multipath keys. Origin steps don't count. Assisted-by: Claude Opus 5.5
Contributor
Author
|
CI jobs failing seem to be unrelated. A re-run should fix them.
|
Member
|
Glad they're unyanked. We may want to update corepc which has dropped the offending dep https://git.rust-bitcoin.org/rust-bitcoin/corepc/pulls/720 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport of #1065.
It also needs 97c948d from #913, which isn't on 13.x: without it,
at_derivation_indexpanics on the new depth error instead of returning it.13.x has no
NonDefiniteKeyError::NoWildcard,into_definiteorderive_at_index, so those parts of #1065 are left out, and its test usesat_derivation_index(0)instead ofinto_definite().🤖 AI disclosure: the backport was prepared with Claude Opus 5.5.