-
Notifications
You must be signed in to change notification settings - Fork 812
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
Validate hd public keys when creating accounts #696
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #696 +/- ##
==========================================
- Coverage 62.1% 62.02% -0.08%
==========================================
Files 147 147
Lines 25379 25381 +2
==========================================
- Hits 15762 15743 -19
- Misses 9617 9638 +21
Continue to review full report at Codecov.
|
test/wallet-test.js
Outdated
} | ||
|
||
assert(err); | ||
assert.strictEqual(err.message, 'Master key mismatch.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're testing collisions maybe the error should say "key already exists at index..."
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's testing if the key is derived from the same parent. The collision of the accountDepth
is one of the potential issues of mismatching.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other issue is that if account 0, 1, 2 are from key-a, and account 3 is from key-b, it's a mismatch issue again, and an attempt to sign account 3 with key-a would fail.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parentFingerPrint
can be used to validate that the accounts all derived from the same key to avoid those issues.
I'm almost certain this will break existing infrastructure built on bcoin |
Any existing watch-only usage that:
This gives the benefit that the mnemonic seed phrase is the only data needed to backup for recovery of coins. Otherwise the account space, which is often updated, becomes necessary to backup similarly. |
I've separated out the issue about gaps between accounts: #698 |
Validates extended public keys (e.g. xpub) during account creation for watch-only wallets:
accountKey
(extended public key) is at the correct depth, the account depth.accountKey
is at the expected BIP44 account index, to avoid issues as described in wallet: add "accountPath" attribute to handle edges cases with watch-only accountKeys #689 and Wallet: support import of x/y/zpubkey (BIP49 and BIP84) #616 with the account index being unknown and mismatching.accountKey
shares the same master key (skipped for now), as to avoid collisions of the BIP44 account index and further mismatches of the signing keys.accountKey
matches the wallet derivation scheme (skipped for now), for example BIP44, BIP45, BIP49, or BIP84.