aboutsummaryrefslogtreecommitdiffhomepage
path: root/vendor/golang.org/x/crypto/bn256/bn256.go
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-07-06 21:18:14 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-07-06 21:18:14 -0700
commit459bb4531f92f8663afb6f36aa9be5b789bd591f (patch)
treef14e6c06b8e5c63612d1ff36f8cab40ae8a99d20 /vendor/golang.org/x/crypto/bn256/bn256.go
parent34a3fe426b33a63f2d8e02d4a70c88f137fa5410 (diff)
Update vendor dependencies
Diffstat (limited to 'vendor/golang.org/x/crypto/bn256/bn256.go')
-rw-r--r--vendor/golang.org/x/crypto/bn256/bn256.go20
1 files changed, 14 insertions, 6 deletions
diff --git a/vendor/golang.org/x/crypto/bn256/bn256.go b/vendor/golang.org/x/crypto/bn256/bn256.go
index f88f3fc..ff27feb 100644
--- a/vendor/golang.org/x/crypto/bn256/bn256.go
+++ b/vendor/golang.org/x/crypto/bn256/bn256.go
@@ -97,14 +97,18 @@ func (e *G1) Neg(a *G1) *G1 {
// Marshal converts n to a byte slice.
func (e *G1) Marshal() []byte {
+ // Each value is a 256-bit number.
+ const numBytes = 256 / 8
+
+ if e.p.IsInfinity() {
+ return make([]byte, numBytes*2)
+ }
+
e.p.MakeAffine(nil)
xBytes := new(big.Int).Mod(e.p.x, p).Bytes()
yBytes := new(big.Int).Mod(e.p.y, p).Bytes()
- // Each value is a 256-bit number.
- const numBytes = 256 / 8
-
ret := make([]byte, numBytes*2)
copy(ret[1*numBytes-len(xBytes):], xBytes)
copy(ret[2*numBytes-len(yBytes):], yBytes)
@@ -205,6 +209,13 @@ func (e *G2) Add(a, b *G2) *G2 {
// Marshal converts n into a byte slice.
func (n *G2) Marshal() []byte {
+ // Each value is a 256-bit number.
+ const numBytes = 256 / 8
+
+ if n.p.IsInfinity() {
+ return make([]byte, numBytes*4)
+ }
+
n.p.MakeAffine(nil)
xxBytes := new(big.Int).Mod(n.p.x.x, p).Bytes()
@@ -212,9 +223,6 @@ func (n *G2) Marshal() []byte {
yxBytes := new(big.Int).Mod(n.p.y.x, p).Bytes()
yyBytes := new(big.Int).Mod(n.p.y.y, p).Bytes()
- // Each value is a 256-bit number.
- const numBytes = 256 / 8
-
ret := make([]byte, numBytes*4)
copy(ret[1*numBytes-len(xxBytes):], xxBytes)
copy(ret[2*numBytes-len(xyBytes):], xyBytes)