diff --git a/internal/sm2ec/sm2p256_asm_test.go b/internal/sm2ec/sm2p256_asm_test.go index 6554a9e..17ddf33 100644 --- a/internal/sm2ec/sm2p256_asm_test.go +++ b/internal/sm2ec/sm2p256_asm_test.go @@ -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") + } +}