mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-24 21:56:43 +00:00
Update twist.go
This commit is contained in:
parent
da8f1a872a
commit
f8331e8b47
1 changed files with 3 additions and 1 deletions
|
|
@ -67,7 +67,7 @@ func (c *twistPoint) Set(a *twistPoint) {
|
||||||
c.t.Set(a.t)
|
c.t.Set(a.t)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsOnCurve returns true iff c is on the curve where c must be in affine form.
|
// IsOnCurve returns true iff c is on the curve and is in the correct subgroup, where c must be in affine form.
|
||||||
func (c *twistPoint) IsOnCurve() bool {
|
func (c *twistPoint) IsOnCurve() bool {
|
||||||
pool := new(bnPool)
|
pool := new(bnPool)
|
||||||
yy := newGFp2(pool).Square(c.y, pool)
|
yy := newGFp2(pool).Square(c.y, pool)
|
||||||
|
|
@ -80,6 +80,8 @@ func (c *twistPoint) IsOnCurve() bool {
|
||||||
if yy.x.Sign() != 0 || yy.y.Sign() != 0 {
|
if yy.x.Sign() != 0 || yy.y.Sign() != 0 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
// Subgroup check: multiply the point by the group order and
|
||||||
|
// verify that it becomes the point at infinity.
|
||||||
cneg := newTwistPoint(pool)
|
cneg := newTwistPoint(pool)
|
||||||
cneg.Mul(c, Order, pool)
|
cneg.Mul(c, Order, pool)
|
||||||
return cneg.z.IsZero()
|
return cneg.z.IsZero()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue