crypto: use btcec/v2 for no-cgo#24533
Merged
fjl merged 1 commit intoethereum:masterfrom Mar 16, 2022
Merged
Conversation
chappjc
commented
Mar 13, 2022
Contributor
|
Thanks! I will review tomorrow! |
8e1026c to
2f96c2b
Compare
Contributor
Author
|
Pushed some minor changes to make it a bit more defensive: checking expected lengths, using package-level consts, and zeroing the temporary |
This updates the no-cgo implementations in the crypto package to use the github.com/btcsuite/btcd/btcec/v2 module instead of the older btcec package that was part of the main github.com/btcsuite/btcd module. name old time/op new time/op delta EcrecoverSignature-32 198µs ± 0% 144µs ± 0% -27.11% VerifySignature-32 177µs ± 0% 128µs ± 0% -27.44% DecompressPubkey-32 20.9µs ± 0% 10.1µs ± 0% -51.51% Use (*ModNScalar).IsOverHalfOrder instead of math/big.Int when checking for malleable signatures.
fjl
approved these changes
Mar 16, 2022
Contributor
fjl
left a comment
There was a problem hiding this comment.
I've checked this some more and it works as expected! While performance of btcec still lags behind C libsecp256k1 quite a bit, I can confirm 20% speedup of the non-cgo path with this update.
Thanks again for this work!
sidhujag
pushed a commit
to syscoin/go-ethereum
that referenced
this pull request
Mar 16, 2022
JacekGlen
pushed a commit
to JacekGlen/go-ethereum
that referenced
this pull request
May 26, 2022
This updates the no-cgo implementations in the crypto package to use the github.com/btcsuite/btcd/btcec/v2 module instead of the older btcec package that was part of the main github.com/btcsuite/btcd module. name old time/op new time/op delta EcrecoverSignature-32 198µs ± 0% 144µs ± 0% -27.11% VerifySignature-32 177µs ± 0% 128µs ± 0% -27.44% DecompressPubkey-32 20.9µs ± 0% 10.1µs ± 0% -51.51% Use (*ModNScalar).IsOverHalfOrder instead of math/big.Int when checking for malleable signatures.
This was referenced Jul 18, 2022
Closed
cp-wjhan
pushed a commit
to cp-yoonjin/go-wemix
that referenced
this pull request
Nov 16, 2022
This updates the no-cgo implementations in the crypto package to use the github.com/btcsuite/btcd/btcec/v2 module instead of the older btcec package that was part of the main github.com/btcsuite/btcd module. name old time/op new time/op delta EcrecoverSignature-32 198µs ± 0% 144µs ± 0% -27.11% VerifySignature-32 177µs ± 0% 128µs ± 0% -27.44% DecompressPubkey-32 20.9µs ± 0% 10.1µs ± 0% -51.51% Use (*ModNScalar).IsOverHalfOrder instead of math/big.Int when checking for malleable signatures.
19 tasks
gzliudan
added a commit
to gzliudan/XDPoSChain
that referenced
this pull request
Dec 9, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 updates the no-cgo code in the
cryptopackage to use the new github.com/btcsuite/btcd/btcec/v2 module instead of the older btcec package that was part of the main github.com/btcsuite/btcd module.This is nice as it removes the dependency on the legacy
btcdmega-module that does not yet follow semantic import versioning (has breaking Go API changes between versions like v0.21 and v0.22) with the newbtcec/v2module that does follow SIV, plus it brings performance improvements:The tests that passed previously with
CGO_ENABLED=0still pass, and the secp256k1 fuzzing results show no discrepancies with the cgo version.tests/fuzzers/secp256k1:
The most notable recent breaking change in the main
btcdmodule that was previously required is that with the introduction of thebtcec/v2module, there is no longer a btcec package in the mainbtcdmodule, which creates build errors when the latest revisions of btcd are used by either go-ethereum or transitive dependencies. Moving to thebtcec/v2module resolves this issue.CC @fjl