handshake-org / handshake-org/hsd

HDPublicKey: need better error handling when deriving child key

Open
#700 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
2.1k
Forks
306
PR merge metrics
No merged PRs in 30d

Description

https://github.com/handshake-org/hsd/blob/107ed2be9280bb4292d21330e7d1ace62da9a002/lib/hd/public.js#L162-L167

This code is here, I believe to satisfy this requirement of the [BIP32 spec](https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki#public-parent-key--public-child-key)

> In case parse256(IL) ≥ n or Ki is the point at infinity, the resulting key is invalid, and one should proceed with the next value for i.

However I just encountered an issue trying to derive RECEIVE `branch` (0) from an account, and the error that was swallowed there was actually: `Error: Entropy source not available.` which resulted in the code deriving the CHANGE `branch` (1) which for whatever reason did not encounter the same error.

I'm still trying to figure out what happened to the entropy source and why the second iteration succeeded at all - but for hsd, I think we need to be more careful about checking the error thrown by the crypto library before just incrementing the index and trying again.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.