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
35dd61a3bf
commit
da8f1a872a
1 changed files with 4 additions and 1 deletions
|
|
@ -43,7 +43,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.
|
// IsOnCurve returns true iff c is on the curve and is in the correct subgroup.
|
||||||
func (c *twistPoint) IsOnCurve() bool {
|
func (c *twistPoint) IsOnCurve() bool {
|
||||||
c.MakeAffine()
|
c.MakeAffine()
|
||||||
if c.IsInfinity() {
|
if c.IsInfinity() {
|
||||||
|
|
@ -57,6 +57,9 @@ func (c *twistPoint) IsOnCurve() bool {
|
||||||
if *y2 != *x3 {
|
if *y2 != *x3 {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Subgroup check: multiply the point by the group order and
|
||||||
|
// verify that it becomes the point at infinity.
|
||||||
cneg := &twistPoint{}
|
cneg := &twistPoint{}
|
||||||
cneg.Mul(c, Order)
|
cneg.Mul(c, Order)
|
||||||
return cneg.z.IsZero()
|
return cneg.z.IsZero()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue