Repository navigation
feat(key-wallet): add Signer::extended_public_key - #817
Conversation
The Signer trait exposes sign_ecdsa + public_key, the latter returning only the compressed leaf point. A caller that needs a BIP-32 extended public key at a hardened path — e.g. DashPay contact-xpub derivation under m/9'/coin'/15'/account'/sender/recipient — could not obtain the chain code without the wallet's resident root private key, forcing the seed to be made resident. Add a required extended_public_key(path) -> ExtendedPubKey method so a Keychain/hardware-backed signer can return the point + chain code + parent fingerprint at a (possibly hardened) path, letting the caller non-hardened-derive descendants offline with no resident seed. A signer that cannot export an xpub at a hardened path returns an error rather than panicking. The two in-repo InMemorySigner test signers derive it from their root xprv (ExtendedPubKey::from_priv); the NoDigestSigner test stubs are unreachable. Pinned by a test asserting the signer's xpub at a hardened path equals the wallet's own derive_extended_public_key. Required (not defaulted): the trait's associated Error type is opaque, so a default body cannot construct a Self::Error to return; there are no production Signer impls in this crate. Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughAdds a new async ChangesSigner::extended_public_key addition
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## dev #817 +/- ##
==========================================
+ Coverage 72.82% 73.03% +0.21%
==========================================
Files 323 323
Lines 72000 72025 +25
==========================================
+ Hits 52432 52602 +170
+ Misses 19568 19423 -145
|
…endedPubKeySigner subtrait (#839) * refactor(key-wallet): move extended_public_key out of Signer into ExtendedPubKeySigner Signer::extended_public_key (added in #817) forced every signer to implement xpub export, but exporting a chain code is a key-export capability, not a signing one: pure signing backends (HSMs, remote signing services whose policy forbids chain-code export) could not implement Signer without stubbing the method with an error. Move the method unchanged into a new ExtendedPubKeySigner: Signer subtrait. Callers that need offline descendant derivation (e.g. DashPay contact xpubs) bound on the subtrait; everything else keeps the minimal Signer. Reusing the Signer supertrait keeps a single associated Error type. No production code called the method, so only the two InMemorySigner test signers move their impl to the new trait, and the unreachable NoDigestSigner stubs are deleted outright — evidence the requirement never belonged on the base trait. Co-Authored-By: Claude Fable 5 <[email protected]> * test(key-wallet): pin asset-lock InMemorySigner xpub export against wallet derivation The asset_lock_builder test module duplicates the InMemorySigner ExtendedPubKeySigner impl but had no correctness check, unlike its twin in transaction_building.rs. Mirror the hardened-path assertion so both copies stay verified against Wallet::derive_extended_public_key. Co-Authored-By: Claude Fable 5 <[email protected]> --------- Co-authored-by: Claude Fable 5 <[email protected]>
What
Adds a required
extended_public_key(path) -> ExtendedPubKeymethod to thekey_wallet::signer::Signertrait.Why
The trait exposes
sign_ecdsa+public_key, the latter returning only the compressed leaf point. A caller that needs a BIP-32 extended public key at a hardened path — e.g. DashPay contact-xpub derivation underm/9'/coin'/15'/account'/sender/recipient— could not obtain the chain code without the wallet's resident root private key, forcing the seed to be made resident.This lets a Keychain/hardware-backed signer return the point + chain code + parent fingerprint at a (possibly hardened) path, so the caller can non-hardened-derive descendants offline with no resident seed. It unblocks the dashpay-platform work to delete the
attach_wallet_seedworkaround (the wallet stays external-signable; the signer answers xpub requests).Details
InMemorySignertest signers derive it from their root xprv (ExtendedPubKey::from_priv); theNoDigestSignertest stubs areunreachable!().derive_extended_public_key.Errortype is opaque, so a default body cannot construct aSelf::Errorto return; there are no productionSignerimpls in this crate.Test
cargo test -p key-wallet --lib— 497 passed, 0 failed. fmt + clippy clean.🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Tests