1 // Copyright 2013-2016 The btcsuite developers
2 // Copyright (c) 2015-2022 The Decred developers
3 // Use of this source code is governed by an ISC
4 // license that can be found in the LICENSE file.
5 6 package secp256k1
7 8 import (
9 "testing"
10 )
11 12 // BenchmarkScalarBaseMultAdaptor benchmarks multiplying a scalar by the base
13 // point of the curve via the method used to satisfy the elliptic.Curve
14 // interface.
15 func BenchmarkScalarBaseMultAdaptor(b *testing.B) {
16 k := fromHex("d74bf844b0862475103d96a611cf2d898447e288d34b360bc885cb8ce7c00575")
17 curve := S256()
18 b.ReportAllocs()
19 b.ResetTimer()
20 for i := 0; i < b.N; i++ {
21 curve.ScalarBaseMult(k.Bytes())
22 }
23 }
24 25 // BenchmarkScalarBaseMultLargeAdaptor benchmarks multiplying an abnormally
26 // large scalar by the base point of the curve via the method used to satisfy
27 // the elliptic.Curve interface.
28 func BenchmarkScalarBaseMultLargeAdaptor(b *testing.B) {
29 k := fromHex("d74bf844b0862475103d96a611cf2d898447e288d34b360bc885cb8ce7c005751111111011111110")
30 curve := S256()
31 b.ReportAllocs()
32 b.ResetTimer()
33 for i := 0; i < b.N; i++ {
34 curve.ScalarBaseMult(k.Bytes())
35 }
36 }
37 38 // BenchmarkScalarMultAdaptor benchmarks multiplying a scalar by an arbitrary
39 // point on the curve via the method used to satisfy the elliptic.Curve
40 // interface.
41 func BenchmarkScalarMultAdaptor(b *testing.B) {
42 x := fromHex("34f9460f0e4f08393d192b3c5133a6ba099aa0ad9fd54ebccfacdfa239ff49c6")
43 y := fromHex("0b71ea9bd730fd8923f6d25a7a91e7dd7728a960686cb5a901bb419e0f2ca232")
44 k := fromHex("d74bf844b0862475103d96a611cf2d898447e288d34b360bc885cb8ce7c00575")
45 curve := S256()
46 b.ReportAllocs()
47 b.ResetTimer()
48 for i := 0; i < b.N; i++ {
49 curve.ScalarMult(x, y, k.Bytes())
50 }
51 }
52