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

hdkeychain: Use secp256k1 privkey to pubkey method. #2156

Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Apr 4, 2020

This is rebased on #2155.

This makes use of the PubKey method on secp256k1.PrivateKey to convert a private key to a public key instead of manually performing the conversion.

This is desirable since secp256k1 provides the method specifically for this purpose and it also has the benefit of allowing secp256k1 to perform the task without round tripping through big integers which results in slightly faster derivation.

The following benchmarks show a before and after comparison of the affected operations:

benchmark                 old ns/op    new ns/op    delta
----------------------------------------------------------
BenchmarkDeriveHardened   3702         3671         -0.84%
BenchmarkDeriveNormal     4053         3999         -1.33%

benchmark                 old allocs   new allocs   delta
----------------------------------------------------------
BenchmarkDeriveHardened   14           14           +0.00%
BenchmarkDeriveNormal     15           15           +0.00%

benchmark                 old bytes    new bytes    delta
----------------------------------------------------------
BenchmarkDeriveHardened   1360         1360         +0.00%
BenchmarkDeriveNormal     1409         1409         +0.00%

@davecgh davecgh added this to the 1.6.0 milestone Apr 4, 2020
This makes use of the PubKey method on secp256k1.PrivateKey to convert a
private key to a public key instead of manually performing the
conversion.

This is desirable since secp256k1 provides the method specifically for
this purpose and it also has the benefit of allowing secp256k1 to
perform the task without round tripping through big integers which
results in slightly faster derivation.

The following benchmarks show a before and after comparison of the
affected operations:

benchmark                 old ns/op    new ns/op    delta
----------------------------------------------------------
BenchmarkDeriveHardened   3702         3671         -0.84%
BenchmarkDeriveNormal     4053         3999         -1.33%

benchmark                 old allocs   new allocs   delta
----------------------------------------------------------
BenchmarkDeriveHardened   14           14           +0.00%
BenchmarkDeriveNormal     15           15           +0.00%

benchmark                 old bytes    new bytes    delta
----------------------------------------------------------
BenchmarkDeriveHardened   1360         1360         +0.00%
BenchmarkDeriveNormal     1409         1409         +0.00%
@davecgh davecgh force-pushed the hdkeychain_use_secp2561_privkey_to_pubkey branch from 54916fe to 79fa2f0 Compare April 6, 2020 20:39
@davecgh davecgh merged commit 79fa2f0 into decred:master Apr 6, 2020
@davecgh davecgh deleted the hdkeychain_use_secp2561_privkey_to_pubkey branch April 6, 2020 21:19
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.

None yet

3 participants