aboutsummaryrefslogtreecommitdiffstats
path: root/crypto/bn256/google/curve.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2018-08-09 18:46:52 +0800
committerPéter Szilágyi <peterke@gmail.com>2018-08-16 16:02:16 +0800
commit3e21adc6488be41ac882c316486573374785cc82 (patch)
treeed6e1fede007bc8011ed6b12816a5be16ee91c38 /crypto/bn256/google/curve.go
parent2cdf6ee7e00d6127c372e7a28bb27a80ef495cb2 (diff)
downloadgo-tangerine-3e21adc6488be41ac882c316486573374785cc82.tar
go-tangerine-3e21adc6488be41ac882c316486573374785cc82.tar.gz
go-tangerine-3e21adc6488be41ac882c316486573374785cc82.tar.bz2
go-tangerine-3e21adc6488be41ac882c316486573374785cc82.tar.lz
go-tangerine-3e21adc6488be41ac882c316486573374785cc82.tar.xz
go-tangerine-3e21adc6488be41ac882c316486573374785cc82.tar.zst
go-tangerine-3e21adc6488be41ac882c316486573374785cc82.zip
crypto/bn256: fix issues caused by Go 1.11
Diffstat (limited to 'crypto/bn256/google/curve.go')
-rw-r--r--crypto/bn256/google/curve.go10
1 files changed, 9 insertions, 1 deletions
diff --git a/crypto/bn256/google/curve.go b/crypto/bn256/google/curve.go
index 3e679fdc7..819cb81da 100644
--- a/crypto/bn256/google/curve.go
+++ b/crypto/bn256/google/curve.go
@@ -245,11 +245,19 @@ func (c *curvePoint) Mul(a *curvePoint, scalar *big.Int, pool *bnPool) *curvePoi
return c
}
+// MakeAffine converts c to affine form and returns c. If c is ∞, then it sets
+// c to 0 : 1 : 0.
func (c *curvePoint) MakeAffine(pool *bnPool) *curvePoint {
if words := c.z.Bits(); len(words) == 1 && words[0] == 1 {
return c
}
-
+ if c.IsInfinity() {
+ c.x.SetInt64(0)
+ c.y.SetInt64(1)
+ c.z.SetInt64(0)
+ c.t.SetInt64(0)
+ return c
+ }
zInv := pool.Get().ModInverse(c.z, P)
t := pool.Get().Mul(c.y, zInv)
t.Mod(t, P)