Update libsecp256k1, Go wrapper and tests#1853
Conversation
7aea3d4 to
665d8bd
Compare
665d8bd to
4ff6c21
Compare
|
Did you add zeroing of intermediate buffers yet? |
|
@fjl |
|
LGTM 👍 |
|
@obscuren removed unneeded return matchings. |
Current coverage is
|
There was a problem hiding this comment.
It's usually better to use the same input data for all iterations.
package testing runs benchmarks several times to make the
result more stable, so StartTimer/StopTimer is not required.
This also applies to BenchmarkSign.
_, seckey := GenerateKeyPair()
msg := randentropy.GetEntropyCSPRNG(32)
sig, _ := Sign(msg, seckey)
for i := 0; i < b.N; i++ {
if _, err := RecoverPubkey(msg, sig); err != nil {
b.Fatal(err)
}
} There was a problem hiding this comment.
Actually in this benchmark it's intended to use a new key for every recovery to avoid potential caching affecting the benchmark. I'll add another benchmark where the same key is used though, that will be interesting to see if caching affects the result. In that one starting and stopping of the timer can indeed be skipped.
There was a problem hiding this comment.
What kind of caching? libsecp256k1 shouldn't cache anything.
There was a problem hiding this comment.
I don't know, but it takes much less time if using the same key. See new commit - pushed a separate benchmark for using the same key.
c87db25 to
76f551a
Compare
|
👍 and please squash one more time. |
3fcfc90 to
f32fa07
Compare
Update libsecp256k1, Go wrapper and tests
NOTE:
RecoverPubkeyis on the consensus-critical code path. Please review carefully.Go wrapper update is in it's own commit, files changed:
We'll probably see a more significant speedup when we can improve internal conversions (as in remove where possible) of signatures and pubkeys - currently we need two extra calls to the lib for each recovery - one to serialise signature and one to serialise the returned pubkey.
If we can avoid those calls + other internal conversions we could probably gain a few % more on recovery.
SignandRecoverPubkey