-
-
Notifications
You must be signed in to change notification settings - Fork 11
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
HDKey derive returns Invalid index #8
Comments
You have invalid index, obviously. The specification clearly says indexes over 2^31-1 are banned. Your numbers are bigger than that. Bip32 package does not implement spec correctly. They could change their behavior later and your code would stop running. |
From BIP32 spec:
Also, the path syntax is only remotely mentioned here, the convention of whether to use This is not an issue of spec, but rather, an issue of interpretation of "what is the norm among other implementations?" since the syntax is not specified. That said, I don't care either way, but changing our interpretation from If it is the case that |
If the spec had said There have been instances of BIPs being modified to match convention when ambiguous in the past, so maybe this could be proposed as a clarification modification to BIP32. @Dolu89 @paulmillr Thanks for bringing this up. Please let me know if either of you want to move forward with proposing a change to BIP32, or if anyone wants to take the time to look up the behavior of other libraries. |
pathSuffix.join('/') Can also be changed to Array.from(pathSuffix).map(n => n & 2**31 ? `${n & 2**31-1}'` : `${n}`).join('/') Which should work with either implementation. Edit: Also this, which circumvents the string parsing entirely. [138+2**31].concat(Array.from(pathSuffix)).reduce((hd, idx) => hd.deriveChild(idx), root); |
sigh another disadvantage of bip32 specification. It's too complex: some different solution could achieve similar functionality in a radically simplified fashion. Adjusting scure's behavior to match other libraries can be beneficial in this case. Keeping the current behavior as-is could also be fine, since it asks users to be precise; also keeping it as-is makes audit results more relevant than if we change it. |
I think the best way to move forward would be to create |
Hi,
I'm implementing LNURL LUD-05 in a react-native mobile app
I have started my code based on this codepen and I adapted it using scure-bip32/39 (version 1.1.0 for both)
Using the same MNEMONIC and LNURL string from the codepen, I got the right derivation path
m/138'/2770944631/3393836580/3568300899/2659809102
but thederive
method returns me "Invalid index"Any idea if it can be an issue from scure-bip32? Thanks
Code example
EDIT: I made some tests using npm lib "bip32" from bitcoinjs and it looks like there is no issue on this lib
Here is a repo to try it: https://github.com/Dolu89/bip32-temp
The text was updated successfully, but these errors were encountered: