fix(key_map): derivation_path for Xprv with key origin info#872
Conversation
9869841 to
64483f3
Compare
We cannot link to a file by directory path in rustdocs. Just remove the link. This is breaking the docs build in rust-bitcoin#805 and is also mentioned in rust-bitcoin#872.
f853906 Remove link to doc file (Tobin C. Harding) Pull request description: We cannot link to a file by directory path in rustdocs. Just remove the link. This is breaking the docs build in #805 and is also mentioned in #872. ACKs for top commit: apoelstra: ACK f853906; successfully ran local tests Tree-SHA512: d2e2eb182cb823297de53635ac23d55ff920b750d28efa7e18de08ddeda3a7f2bdffe8ff32dcf4c54ec32a33a176cea349291260388fd5e5cdad14c6c2e9802e
We cannot link to a file by directory path in rustdocs. Just remove the link. This is breaking the docs build in rust-bitcoin#805 and is also mentioned in rust-bitcoin#872.
43d92da to
32867b3
Compare
- fixes the implementation of `GetKey` for `Xprv` with `KeyRequest::Bip32`, when the the key_origin information is available. - introduces a new test for a scenario with no wildcard used, a specific derivation index is used instead.
- introduce table-driven cases for `get_key_xpriv_with_key_origin` with named fields - drop redundant key parsing, and build requests from explicit key sources Assisted-by: Claude Opus 4.8
9cd3d75 to
a2f4497
Compare
|
@notmandatory I updated this PR and added new test scenarios, it should be ready to review. cc'in @noahjoeris as you had interest in this and a review would be appreciated. |
Xprv with key origin infoXprv with key origin info
- backports rust-bitcoin#872 fixes for the implementation of `GetKey` for `Xprv` with `KeyRequest::Bip32`, when the the key_origin information is available. - introduces a new test for a scenario with no wildcard used, a specific derivation index is used instead.
- backports introduced rust-bitcoin#872 table-driven test cases for `get_key_xpriv_with_key_origin` with named fields - drop redundant key parsing, and build requests from explicit key sources Assisted-by: Claude Opus 4.8
notmandatory
left a comment
There was a problem hiding this comment.
ACK a2f4497
Changes look good, tests easy to follow.
noahjoeris
left a comment
There was a problem hiding this comment.
tACK a2f4497
Looking good, thanks.
|
ping @tcharding @apoelstra for awareness. |
|
Oops, missed this somehow. Will review it and the backport today. |
|
@oleonardolima I noticed that |
|
@evanlinjin it's here #867 |
@evanlinjin It's already covered in #867 as Noah commented above. |
- backports rust-bitcoin#872 fixes for the implementation of `GetKey` for `Xprv` with `KeyRequest::Bip32`, when the the key_origin information is available.
- backports introduced rust-bitcoin#872 table-driven test cases for `get_key_xpriv_with_key_origin` with named fields - drop redundant key parsing, and build requests from explicit key sources Assisted-by: Claude Opus 4.8
…r keys with origin d01ee72 test(key_map): improve `Xprv` key origin tests (Leonardo Lima) 1053799 fix(key_map): derivation_path for `Xprv` with key origin info (Leonardo Lima) Pull request description: backports #872 ### Description It backports the fix for deriving the private key correctly in scenarios where the key origin is available, see #872. The GetKey for DescriptorSecretKey (and thus KeyMap) returned the wrong key when an extended private key with key origin info was queried via KeyRequest::Bip32. The key request path is master-relative, but the xkey is anchored at its origin (e.g. [d34db33f/84h/1h/0h]). The old code stripped the path returned by matches(); the fix strips the origin prefix instead (and uses the full path when there is no origin) before deriving from the xkey. cherry-picks 20ae466 and a2f4497. ### Changelog notice ``` ### Fixed - keymap: fix `GetKey` derivation path for `Xprv` with key origin info [#872](#872) ``` ### Checklists #### Bugfixes: * [ ] This pull request breaks the existing API * [x] I've added tests to reproduce the issue which are now passing * [x] I'm linking the issue being fixed by this PR ACKs for top commit: apoelstra: ACK d01ee72; successfully ran local tests Tree-SHA512: dbba09188978b7d295ebe6a58a3d32e65b22f0208f60f6c0f800e1ee15f1b54e8be2992da6fe6deb7c6b3ae848b100b4c6d44cd04d63eefaec8d563e9ba56c5f
…vailable Ports changes from rust-bitcoin/rust-miniscript#872
Port test for GetKey impl for miniscript::descriptor::KeyMap as of the state of latest state of rust-bitcoin/rust-miniscript#872.
…tions for `DescriptorSecretKey` and `KeyMap` fba23e6 test: port `miniscript::descriptor::key_map` tests (Leonardo Lima) d2fcfca fix: strip origin prefix before deriving xkey or use full path if unavailable (Leonardo Lima) 36bcf54 feat: insource miniscript GetKey impl for DescriptorSecretKey and KeyMap (nymius) Pull request description: This was suggested by https://git.rust-bitcoin.org/rust-bitcoin/rust-psbt/pulls/180#issuecomment-11659. It includes the changes from rust-bitcoin/rust-miniscript#872. A working example using `GetKey` from `KeyMap` and `update_psbt_input` from `PlanExt` is in https://git.rust-bitcoin.org/nymius/rust-psbt/compare/push-xstopvrvruzp...push-rmuzzkyxvrru. ACKs for top commit: tobin: ACK fba23e6 Tree-SHA512: aaa49ab45788cfcfc21e89ab78ea1b22f1e82e7b0e5a637e3dbb324a3f31e4d69cb66d490c2ede7035e547f38d43f36302b2c287897f09ae0f4bf0484b44f605
Description
The
GetKeyforDescriptorSecretKey(and thusKeyMap) returned the wrong key when an extended private key with key origin info was queried viaKeyRequest::Bip32.The key request path is master-relative, but the
xkeyis anchored at its origin (e.g.[d34db33f/84h/1h/0h]). The old code stripped the path returned bymatches(); the fix strips the origin prefix instead (and uses the full path when there is no origin) before deriving from thexkey.--
Also, this PR introduces the test
get_key_xpriv_with_key_origincovering the scenarios: bare wildcard; single fixed step; fixed step then wildcard, and the matching/non-matching cases build requests from explicit(fingerprint, path)key sources.Notes
If you'd like an overview on the issue, see: #863 (comment)
Changelog notice
Checklists
Bugfixes: