aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine Rondelet <rondelet.antoine@gmail.com>2019-05-26 05:57:07 +0800
committerPéter Szilágyi <peterke@gmail.com>2019-05-26 05:57:07 +0800
commit9efc1a847e53b63847f6f95e0857b1a6300786eb (patch)
tree8725c38c0b7f2d215ed74efa760ef0f1958b1eb2
parent4b622b277ed2d708c2dffbb538adc64a13a06321 (diff)
downloadgo-tangerine-9efc1a847e53b63847f6f95e0857b1a6300786eb.tar
go-tangerine-9efc1a847e53b63847f6f95e0857b1a6300786eb.tar.gz
go-tangerine-9efc1a847e53b63847f6f95e0857b1a6300786eb.tar.bz2
go-tangerine-9efc1a847e53b63847f6f95e0857b1a6300786eb.tar.lz
go-tangerine-9efc1a847e53b63847f6f95e0857b1a6300786eb.tar.xz
go-tangerine-9efc1a847e53b63847f6f95e0857b1a6300786eb.tar.zst
go-tangerine-9efc1a847e53b63847f6f95e0857b1a6300786eb.zip
crypto/bn256/cloudflare: checks for nil pointers in Marshal functions (#19609)
* Added checks for nil pointers in Marshal functions * Set nil pointer to identity in GT before marshaling
-rw-r--r--crypto/bn256/cloudflare/bn256.go9
1 files changed, 9 insertions, 0 deletions
diff --git a/crypto/bn256/cloudflare/bn256.go b/crypto/bn256/cloudflare/bn256.go
index c6ea2d07e..38822a76b 100644
--- a/crypto/bn256/cloudflare/bn256.go
+++ b/crypto/bn256/cloudflare/bn256.go
@@ -100,6 +100,10 @@ func (e *G1) Marshal() []byte {
// Each value is a 256-bit number.
const numBytes = 256 / 8
+ if e.p == nil {
+ e.p = &curvePoint{}
+ }
+
e.p.MakeAffine()
ret := make([]byte, numBytes*2)
if e.p.IsInfinity() {
@@ -382,6 +386,11 @@ func (e *GT) Marshal() []byte {
// Each value is a 256-bit number.
const numBytes = 256 / 8
+ if e.p == nil {
+ e.p = &gfP12{}
+ e.p.SetOne()
+ }
+
ret := make([]byte, numBytes*12)
temp := &gfP{}