Skip to content

Commit a1b1dc8

Browse files
authored
Merge pull request #2398 from CortexFoundation/dev
g2 comments added
2 parents fdbfe39 + 1c64f48 commit a1b1dc8

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

crypto/bn256/cloudflare/twist.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func (c *twistPoint) Set(a *twistPoint) {
4343
c.t.Set(&a.t)
4444
}
4545

46-
// IsOnCurve returns true iff c is on the curve.
46+
// IsOnCurve returns true iff c is on the curve and is in the correct subgroup.
4747
func (c *twistPoint) IsOnCurve() bool {
4848
c.MakeAffine()
4949
if c.IsInfinity() {
@@ -57,6 +57,8 @@ func (c *twistPoint) IsOnCurve() bool {
5757
if *y2 != *x3 {
5858
return false
5959
}
60+
// Subgroup check: multiply the point by the group order and
61+
// verify that it becomes the point at infinity.
6062
cneg := &twistPoint{}
6163
cneg.Mul(c, Order)
6264
return cneg.z.IsZero()

crypto/bn256/google/twist.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ func (c *twistPoint) Set(a *twistPoint) {
6767
c.t.Set(a.t)
6868
}
6969

70-
// IsOnCurve returns true iff c is on the curve where c must be in affine form.
70+
// IsOnCurve returns true iff c is on the curve and is in the correct subgroup, where c must be in affine form.
7171
func (c *twistPoint) IsOnCurve() bool {
7272
pool := new(bnPool)
7373
yy := newGFp2(pool).Square(c.y, pool)
@@ -80,6 +80,8 @@ func (c *twistPoint) IsOnCurve() bool {
8080
if yy.x.Sign() != 0 || yy.y.Sign() != 0 {
8181
return false
8282
}
83+
// Subgroup check: multiply the point by the group order and
84+
// verify that it becomes the point at infinity.
8385
cneg := newTwistPoint(pool)
8486
cneg.Mul(c, Order, pool)
8587
return cneg.z.IsZero()

0 commit comments

Comments
 (0)