diff --git a/dcrec/secp256k1/bench_test.go b/dcrec/secp256k1/bench_test.go index b23ffbfb..a8f39e10 100644 --- a/dcrec/secp256k1/bench_test.go +++ b/dcrec/secp256k1/bench_test.go @@ -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) + } + } +}