Skip to content

Commit

Permalink
crypto/bn256/cloudflare: checks for nil pointers in Marshal functions (
Browse files Browse the repository at this point in the history
…ethereum#19609)

* Added checks for nil pointers in Marshal functions

* Set nil pointer to identity in GT before marshaling
  • Loading branch information
AntoineRondelet authored and wgr523 committed Jan 18, 2024
1 parent 3d635c5 commit c48e987
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions crypto/bn256/cloudflare/bn256.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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{}

Expand Down

0 comments on commit c48e987

Please sign in to comment.