Update twist.go

This commit is contained in:
Antonio Sanso 2025-06-20 10:56:10 +02:00 committed by GitHub
parent 35dd61a3bf
commit da8f1a872a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -43,7 +43,7 @@ func (c *twistPoint) Set(a *twistPoint) {
c.t.Set(&a.t)
}
// IsOnCurve returns true iff c is on the curve.
// IsOnCurve returns true iff c is on the curve and is in the correct subgroup.
func (c *twistPoint) IsOnCurve() bool {
c.MakeAffine()
if c.IsInfinity() {
@ -57,6 +57,9 @@ func (c *twistPoint) IsOnCurve() bool {
if *y2 != *x3 {
return false
}
// Subgroup check: multiply the point by the group order and
// verify that it becomes the point at infinity.
cneg := &twistPoint{}
cneg.Mul(c, Order)
return cneg.z.IsZero()