From da8f1a872a73e01e137174dd03177797bfdf04b1 Mon Sep 17 00:00:00 2001 From: Antonio Sanso Date: Fri, 20 Jun 2025 10:56:10 +0200 Subject: [PATCH] Update twist.go --- crypto/bn256/cloudflare/twist.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/crypto/bn256/cloudflare/twist.go b/crypto/bn256/cloudflare/twist.go index 2c7a69a4d7..c048b0b7c7 100644 --- a/crypto/bn256/cloudflare/twist.go +++ b/crypto/bn256/cloudflare/twist.go @@ -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()