HDWallet now uses Buffers internally #134
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request updates
HDWalletto use Node Buffers internally.It is dependent on #133.
In short, bc05828 adds Buffer input parameter support for
ECKeyandECPubKey, necessary to avoid jumping through compatibility hoops inHDWalletitself.814aa9e does most of the heavy lifting, with some small changes to the tests in
test/hdwallet.js.Some key points for discussion are the changes in how
hd.parentFingerprintis stored internally. I opted for theNumberrepresentation because as per BIP32 the fingerprint is guaranteed to be 32 bits; which fits well withinNumbers integer precision.This made some of the Buffer code nicer to deal with, but is not absolutely necessary.
Something of interest was that despite the previous documentation, all data used in the serialization format was in MSB byte order (that is, Big Endian) as per the test vectors in
test/hdwallet.js.It is not clear if this is intentional, and the serialization specification does not mention it at all.
If the test vectors were adapted from this implementation, this should be fixed as soon as possible, because it may derive completely different/wrong private keys.
Lastly, ddea4b1 takes some of the implicit
modmath currently hidden in theECKeyconstructor and puts it in the open as per the comments and specification.This adheres to changes that will be made to the
ECKeyconstructors soon, and removes unnecessary calculations and error checking that are not pertinent to what is needed here.