Skip to content

Commit b3ea082

Browse files
committed
ed25519: Test for isEqual must fail on points with z=0.
1 parent f97a896 commit b3ea082

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

sign/ed25519/point_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"testing"
77

88
"github.com/cloudflare/circl/internal/test"
9+
"github.com/cloudflare/circl/math/fp25519"
910
)
1011

1112
func randomPoint(P *pointR1) {
@@ -17,6 +18,17 @@ func randomPoint(P *pointR1) {
1718
func TestPoint(t *testing.T) {
1819
const testTimes = 1 << 10
1920

21+
t.Run("isEqual", func(t *testing.T) {
22+
var valid, invalid pointR1
23+
randomPoint(&valid)
24+
randomPoint(&invalid)
25+
invalid.z = fp25519.Elt{}
26+
test.CheckOk(!valid.isEqual(&invalid), "valid point shouldn't match invalid point", t)
27+
test.CheckOk(!invalid.isEqual(&valid), "invalid point shouldn't match valid point", t)
28+
test.CheckOk(valid.isEqual(&valid), "valid point should match valid point", t)
29+
test.CheckOk(!invalid.isEqual(&invalid), "invalid point shouldn't match anything", t)
30+
})
31+
2032
t.Run("add", func(t *testing.T) {
2133
var P pointR1
2234
var Q pointR1

0 commit comments

Comments
 (0)