Skip to content
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

[bugfix] Derive correct "signmessage" address #448

Merged
merged 7 commits into from
Aug 23, 2023

Conversation

kdmukai
Copy link
Contributor

@kdmukai kdmukai commented Aug 21, 2023

Prior implementation used the full address derivation path instead of the wallet address when deriving the xpub.

  • Slightly enhances embit_utils parsing
  • Tightens up rejection of custom derivation paths
  • Expanded test scenarios

# CRAZY custom derivation path
(None, SC.CUSTOM_DERIVATION, False): "m/879345978543'/908327034508534983495'/9085098430894380959043'/0/5",
# CRAZY custom derivation paths
(None, SC.CUSTOM_DERIVATION, False, 5): "m/879345978543'/908327034508534983495'/9085098430894380959043'/0/5",
Copy link

Choose a reason for hiding this comment

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

I believe the first 3 nodes of this derivation path are invalid because max hardened representation is 231-1, which is really representing the max child node 232-1. If we were to pass these thru to embit, it would raise an exception eventually because each child needs to fit into a 4byte serialization.

Copy link

Choose a reason for hiding this comment

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

maybe all tests above can also check for the 'index' element on return, if I'm understanding correctly that it's always there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Seemed unnecessarily fussy / repetitive to verify index in the base cases, but was a late addition here to verify the new index parsing logic in this PR.

Even with just three components in the tuple it's hard to keep straight when reading the code. The few 4-tuples added at the end make it even harder. Not super-concerned since it's not in the main app code, but an easier to follow refactor would eventually be nice.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Slightly more realistic intentionally unrealistic test derivation path updated.

@jdlcdl
Copy link

jdlcdl commented Aug 22, 2023

ACK tested

tested before and indeed was not displaying the correct address but was signing for the correct one.
tested after that still produces a valid signature and displayed the correct address before signing.

[updated]: my ACK remains unchanged for commit 928c4ab; as a rule of thumb, a tests/ change would never alter that imo.

@newtonick newtonick added this to the 0.7.0 milestone Aug 23, 2023
@newtonick
Copy link
Collaborator

ACK and Tested

@newtonick newtonick merged commit 2244509 into SeedSigner:dev Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants