Skip to content

Prevent deriving unserializable keys of depth > 255 #21

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

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

quapka
Copy link

@quapka quapka commented Apr 3, 2025

I rarely code in Javascript/Node/Typescript, so this is rather hastily effort to put together example of a fix and test cases. Please, review the code carefully, among other for off-by-one errors int the path lengths, thanks!

This attempts to make the derived keys serializable according to BIP32. See also bitcoin/bitcoin#32201

Unfortunately, this is in a sense breaking backwards-compatibility, in case someone was deriving lower than 255 depth keys, however, these would get serialized, assuming BIP32 format, incorrectly (the depth would overflow).

@quapka
Copy link
Author

quapka commented Apr 3, 2025

Wow, this bun thingie reaaally doesn't like theses iterative tests and just loops (I guess?) forever. I'd say you can kill the GitHub Action if you can. I tried to run bun run --if-present test:bun locally and it hangs similarly. I've tested bun --versinon 1.1.8.

Both of these tests seem to cause it.

'Should throw an error when deriving keys of 256 depth'
'Should throw an error when deriving from path of length 256'
@quapka
Copy link
Author

quapka commented Apr 5, 2025

I don't feel like debugging some Javascript runtime issues. Running

$ bun run --if-present test

works as expected and the tests pass. However,

$ bun run --if-present test:bun

hands on this line and others from the new tests. Feel free to update the branch, you should have the rights.

@paulmillr
Copy link
Owner

The bun error would be fixed after you rebase with main branch

@quapka
Copy link
Author

quapka commented Apr 5, 2025

I've merged main, but the issue persists.

@paulmillr
Copy link
Owner

I will merge it for v2 bc it's backwards incompatible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants