fix: verify derive signature for all derivation paths and update Swift bindings#67
Open
r1b2ns wants to merge 3 commits intobitcoindevkit:masterfrom
Open
fix: verify derive signature for all derivation paths and update Swift bindings#67r1b2ns wants to merge 3 commits intobitcoindevkit:masterfrom
r1b2ns wants to merge 3 commits intobitcoindevkit:masterfrom
Conversation
The derive response signature was only verified when no derivation path was used (pubkey == master_pubkey). Per the Coinkite protocol, the card always signs with the master private key regardless of path, so the verification must run unconditionally. Also fixes a bug where card_nonce was captured AFTER transmit instead of BEFORE — the card signs with the pre-command nonce, but the code was using the new nonce from the response.
Member
|
Does this fix #23? If so please reference that in the description. Also can you add a unit test to verify the behavior with and without derivation paths? |
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
deriveresponse signature was not verified when a derivation path was providedcard_nonceusage — was using the post-command nonce instead of the pre-command nonce for verificationNotes to the reviewers
Signature verification (security fix)
In
TapSignerShared::derive(), the response signature was only verified whenpubkey == master_pubkey(i.e., no derivation path). When a path was provided,the card returns a derived pubkey different from master, causing the
ifguardto skip verification entirely.
Per the Coinkite Tap Protocol
and the reference Python implementation (
verify_master_pubkeyincktap/utils.py),the card always signs with the master private key, regardless of whether a
derivation path was used. The verification is now unconditional.
Nonce ordering fix
The
card_nonceused in message construction was captured afterset_card_nonce()updated it with the response nonce (intended for the next command). The card signs
with the nonce that existed before the command. This matches the pattern already
used correctly in
SatsCard::derive().Tests report
Issues
#23 Fix verifying the sig when a derivation path is used
Checklists
All Submissions:
cargo fmtandcargo clippybefore committingNew Features:
Bugfixes: