aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/crypto/bn256/twist.go
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/golang.org/x/crypto/bn256/twist.go')
-rw-r--r--vendor/golang.org/x/crypto/bn256/twist.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/vendor/golang.org/x/crypto/bn256/twist.go b/vendor/golang.org/x/crypto/bn256/twist.go
index 4f8b3fe..056d80f 100644
--- a/vendor/golang.org/x/crypto/bn256/twist.go
+++ b/vendor/golang.org/x/crypto/bn256/twist.go
@@ -219,10 +219,19 @@ func (c *twistPoint) Mul(a *twistPoint, scalar *big.Int, pool *bnPool) *twistPoi
return c
}
+// MakeAffine converts c to affine form and returns c. If c is ∞, then it sets
+// c to 0 : 1 : 0.
func (c *twistPoint) MakeAffine(pool *bnPool) *twistPoint {
if c.z.IsOne() {
return c
}
+ if c.IsInfinity() {
+ c.x.SetZero()
+ c.y.SetOne()
+ c.z.SetZero()
+ c.t.SetZero()
+ return c
+ }
zInv := newGFp2(pool).Invert(c.z, pool)
t := newGFp2(pool).Mul(c.y, zInv, pool)