Skip to content

Continue with BTC address derivation using account config + derivation info #3335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 20, 2025

Conversation

benma
Copy link
Contributor

@benma benma commented May 8, 2025

No description provided.

@benma benma force-pushed the split-verif branch 2 times, most recently from e35862b to 332e692 Compare May 8, 2025 21:04
benma added 3 commits May 8, 2025 23:09
BitBox01 support was removed (other than device management so users
can check and create backups, etc) in 3d70ed2
- Type-matching is not nice
- BTC address verification input params are inherently different to
- ETH. ETH is basically showing the address at one keypath. BTC
  however is about deriving an address based on (isChange,
  addressIndex) from an account descriptor. So far it worked because
  we only use simple Bitcoin accounts and not descriptors, but it's
  good to be a bit more general to allow more flexible descriptor accounts in the future.
A BTC address is derived from an account using
change/addressIndex. There is no "address-level" signing
configuration. `signingConfig.Derive()` assumes there is one base
level keypath and xpub, which is not true for a descriptor in general. For
example, a multisig descriptor has multiple xpubs, each with their own keypath.
@benma benma requested a review from bznein May 14, 2025 13:29
Copy link
Collaborator

@bznein bznein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM just a couple of questions

s.Require().Equal(uint32(index), address.Configuration.AbsoluteKeypath().ToUInt32()[1])
s.Require().Equal(getPubKey(index), address.Configuration.PublicKey())
s.Require().Equal(uint32(index), address.AbsoluteKeypath().ToUInt32()[1])
_ = getPubKey
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leftover line?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, yeah. Removed

VerifyAddressBTC(
accountConfiguration *signing.Configuration,
derivation btctypes.Derivation,
coin coin.Coin) error
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there a specific reason we don't directly use btc.Coin and eth.Coin (below) so we don't have to cast it inside the method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because of a circular import between the packages 😅 Maybe we can think another time of if and how to break the cycle.

Copy link
Collaborator

@bznein bznein May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate import cycles :D

The previous commits moved towards using an account config plus
derivation info to get to the address. This commit removes the
address-level signing config for BTC.

This is a simplification, as it does not make sense to derive a full "signing config" when all
that is derived is the keypath, nothing else changes.

This is part of moving to general descriptor support. There are still
remaining issues where code assumes it's a single-sig (calls to
address.AbsoluteKeypath(), and NewAddress(), etc.), but we can solve
that later step by step.
Copy link
Collaborator

@bznein bznein left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

VerifyAddressBTC(
accountConfiguration *signing.Configuration,
derivation btctypes.Derivation,
coin coin.Coin) error
Copy link
Collaborator

@bznein bznein May 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hate import cycles :D

@benma benma merged commit 9ec3ed8 into BitBoxSwiss:master May 20, 2025
10 checks passed
@benma benma deleted the split-verif branch May 20, 2025 08:56
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.

2 participants