internal/sm2ec: make sure point double is correct

This commit is contained in:
Sun Yimin 2024-08-26 14:28:15 +08:00 committed by GitHub
parent d4a812927d
commit 700edb923d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -208,7 +208,6 @@ func TestScalarMult(t *testing.T) {
fatalIfErr(t, err) fatalIfErr(t, err)
p2, err := NewSM2P256Point().ScalarMult(G, scalar) p2, err := NewSM2P256Point().ScalarMult(G, scalar)
fatalIfErr(t, err) fatalIfErr(t, err)
fmt.Printf("scalar: %x, p2: %x\n", scalar, p2.Bytes())
if !bytes.Equal(p1.Bytes(), p2.Bytes()) { if !bytes.Equal(p1.Bytes(), p2.Bytes()) {
t.Errorf("[k]G != ScalarBaseMult(k), k=%x, p1=%x, p2=%x", scalar, p1.Bytes(), p2.Bytes()) t.Errorf("[k]G != ScalarBaseMult(k), k=%x, p1=%x, p2=%x", scalar, p1.Bytes(), p2.Bytes())
} }

View File

@ -203,4 +203,7 @@ func TestPointDouble(t *testing.T) {
if !bytes.Equal(double1.Bytes(), double2.Bytes()) { if !bytes.Equal(double1.Bytes(), double2.Bytes()) {
t.Error("PointDouble6Times is incorrect") t.Error("PointDouble6Times is incorrect")
} }
if hex.EncodeToString(double1.Bytes()) != "0497662389f36ce643a47dcf644f700651e988794843797b0c4a69c806e78615c2cd4d9449aea5cac5328b8d67d4ae956f5eb06c4515ff01bd17eef58bf866b33f" {
t.Errorf("PointDouble6Times is incorrect %x", double1.Bytes())
}
} }