mirror of
https://github.com/emmansun/gmsm.git
synced 2025-04-26 12:16:20 +08:00
sm9/bn256: add miller benchmark test
This commit is contained in:
parent
b493f8cb99
commit
1e5ba7f5a1
@ -162,6 +162,20 @@ func BenchmarkFinalExponentiation(b *testing.B) {
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkMiller(b *testing.B) {
|
||||
pk := bigFromHex("0130E78459D78545CB54C587E02CF480CE0B66340F319F348A1D5B1F2DC5F4")
|
||||
g2 := &G2{}
|
||||
_, err := g2.ScalarBaseMult(NormalizeScalar(pk.Bytes()))
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
b.ReportAllocs()
|
||||
b.ResetTimer()
|
||||
for i := 0; i < b.N; i++ {
|
||||
miller(g2.p, curveGen)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkPairingB4(b *testing.B) {
|
||||
pk := bigFromHex("0130E78459D78545CB54C587E02CF480CE0B66340F319F348A1D5B1F2DC5F4")
|
||||
g2 := &G2{}
|
||||
|
@ -58,7 +58,7 @@ func NewTwistGenerator() *twistPoint {
|
||||
|
||||
func (c *twistPoint) polynomial(x *gfP2) *gfP2 {
|
||||
x3 := &gfP2{}
|
||||
x3.Square(x).Mul(x3, x).Add(x3, twistB)
|
||||
x3.SquareNC(x).Mul(x3, x).Add(x3, twistB)
|
||||
return x3
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ func (c *twistPoint) IsOnCurve() bool {
|
||||
}
|
||||
|
||||
y2 := &gfP2{}
|
||||
y2.Square(&c.y)
|
||||
y2.SquareNC(&c.y)
|
||||
x3 := c.polynomial(&c.x)
|
||||
|
||||
return *y2 == *x3
|
||||
|
Loading…
x
Reference in New Issue
Block a user