Skip to content

Commit 0c3868e

Browse files
committed
curve4q: Shared must fail with low order points.
1 parent 9fd570d commit 0c3868e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

dh/curve4q/curve4Q.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,10 @@ func KeyGen(public, secret *Key) {
2020
func Shared(shared, secret, public *Key) bool {
2121
var P, Q fourq.Point
2222
ok := P.Unmarshal((*[Size]byte)(public))
23+
if !ok {
24+
return false
25+
}
2326
Q.ScalarMult((*[Size]byte)(secret), &P)
2427
Q.Marshal((*[Size]byte)(shared))
25-
ok = ok && Q.IsOnCurve()
26-
return ok
28+
return !Q.IsIdentity() && Q.IsOnCurve()
2729
}

0 commit comments

Comments
 (0)