secp256k1: Add benchmark for pubkey decompression.

This commit is contained in:
Dave Collins 2020-02-19 04:18:10 -06:00
parent cd441ba534
commit 4c1fe027bb
No known key found for this signature in database
GPG Key ID: B8904D9D9C93D1F2

View File

@ -185,3 +185,20 @@ func BenchmarkNonceRFC6979(b *testing.B) {
}
_ = noElideNonce
}
// BenchmarkPubKeyDecompress benchmarks how long it takes to decompress the y
// coordinate from a given public key x coordinate.
func BenchmarkPubKeyDecompress(b *testing.B) {
// Randomly generated keypair.
// Private key: 9e0699c91ca1e3b7e3c9ba71eb71c89890872be97576010fe593fbf3fd57e66d
pubKeyX := fromHex("d2e670a19c6d753d1a6d8b20bd045df8a08fb162cf508956c31268c6d81ffdab")
b.ReportAllocs()
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := decompressPoint(pubKeyX, false)
if err != nil {
b.Fatalf("unexpected err: %v", err)
}
}
}