Skip to content
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

chore: perf improvement #52

Merged
merged 1 commit into from
Jan 6, 2023

Conversation

kewde
Copy link
Contributor

@kewde kewde commented Dec 23, 2022

This PR avoids calling publicKeyConvert because they are really slow using a pure BN.js implementation.

@kewde
Copy link
Contributor Author

kewde commented Dec 23, 2022

cc @RyanZim

@RyanZim
Copy link
Member

RyanZim commented Dec 23, 2022

I'm wondering if these assertions should be combined with the conditional here:

hdkey/lib/hdkey.js

Lines 49 to 50 in 62c25cc

assert(value.length === 33 || value.length === 65, 'Public key must be 33 or 65 bytes.')
assert(secp256k1.publicKeyVerify(value) === true, 'Invalid public key')

@kewde
Copy link
Contributor Author

kewde commented Dec 23, 2022

@RyanZim I was wondering the same, but I assume someone out there might be relying on the error messages, and changing the behavior might be considered a breaking change?

publicKeyConvert also verifies the public key internally, so we technically omit publicKeyVerify calls for uncompressed keys.

@RyanZim
Copy link
Member

RyanZim commented Dec 23, 2022

Ah, true; good point about the error messages.

Copy link
Member

@RyanZim RyanZim left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK

@RyanZim RyanZim merged commit 131da92 into cryptocoinjs:master Jan 6, 2023
@kewde kewde deleted the kewde/optimize-public-key branch January 6, 2023 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants