internal/sm2ec: test point double 6 times

This commit is contained in:
Sun Yimin 2024-08-26 13:20:43 +08:00 committed by GitHub
parent ebe5413d1e
commit c50b71f0af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,6 +3,7 @@
package sm2ec
import (
"bytes"
"crypto/rand"
"encoding/hex"
"io"
@ -187,3 +188,19 @@ func BenchmarkP256SelectAffine(b *testing.B) {
p256SelectAffine(&t0, &p256Precomputed[20], 20)
}
}
func TestPointDouble(t *testing.T) {
var double1, double2 SM2P256Point
p := NewSM2P256Point().SetGenerator()
p256PointDoubleAsm(&double1, p)
p256PointDoubleAsm(&double1, &double1)
p256PointDoubleAsm(&double1, &double1)
p256PointDoubleAsm(&double1, &double1)
p256PointDoubleAsm(&double1, &double1)
p256PointDoubleAsm(&double1, &double1)
p256PointDouble6TimesAsm(&double2, p)
if !bytes.Equal(double1.Bytes(), double2.Bytes()) {
t.Error("PointDouble6Times is incorrect")
}
}