diff --git a/ecc/bls12-377/g1.go b/ecc/bls12-377/g1.go index fe15a31d9..e1bc1809f 100644 --- a/ecc/bls12-377/g1.go +++ b/ecc/bls12-377/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -442,11 +435,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bls12-377/g2.go b/ecc/bls12-377/g2.go index a7594cfc6..c256d8210 100644 --- a/ecc/bls12-377/g2.go +++ b/ecc/bls12-377/g2.go @@ -417,11 +417,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bls12-378/g1.go b/ecc/bls12-378/g1.go index ba42cd158..eb59168b8 100644 --- a/ecc/bls12-378/g1.go +++ b/ecc/bls12-378/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -442,11 +435,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bls12-378/g2.go b/ecc/bls12-378/g2.go index 960c78730..7da45cbc8 100644 --- a/ecc/bls12-378/g2.go +++ b/ecc/bls12-378/g2.go @@ -417,11 +417,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bls12-381/g1.go b/ecc/bls12-381/g1.go index c5be10ed8..c24a82cda 100644 --- a/ecc/bls12-381/g1.go +++ b/ecc/bls12-381/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -442,11 +435,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bls12-381/g2.go b/ecc/bls12-381/g2.go index c6d0fafa8..cd32bfb46 100644 --- a/ecc/bls12-381/g2.go +++ b/ecc/bls12-381/g2.go @@ -418,11 +418,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bls24-315/g1.go b/ecc/bls24-315/g1.go index 5da6c2e13..8b9106450 100644 --- a/ecc/bls24-315/g1.go +++ b/ecc/bls24-315/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -444,11 +437,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bls24-315/g2.go b/ecc/bls24-315/g2.go index 5ad43d49e..7c9510046 100644 --- a/ecc/bls24-315/g2.go +++ b/ecc/bls24-315/g2.go @@ -419,11 +419,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bls24-317/g1.go b/ecc/bls24-317/g1.go index 689f96200..f5a4d287d 100644 --- a/ecc/bls24-317/g1.go +++ b/ecc/bls24-317/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -444,11 +437,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bls24-317/g2.go b/ecc/bls24-317/g2.go index 29bad5b09..0d59a79a7 100644 --- a/ecc/bls24-317/g2.go +++ b/ecc/bls24-317/g2.go @@ -419,11 +419,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bn254/g1.go b/ecc/bn254/g1.go index 4c0a29498..e64b53ffa 100644 --- a/ecc/bn254/g1.go +++ b/ecc/bn254/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -432,11 +425,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bn254/g2.go b/ecc/bn254/g2.go index d0da8e60e..b4f279fc3 100644 --- a/ecc/bn254/g2.go +++ b/ecc/bn254/g2.go @@ -424,11 +424,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bw6-633/g1.go b/ecc/bw6-633/g1.go index 05a610276..282352cc9 100644 --- a/ecc/bw6-633/g1.go +++ b/ecc/bw6-633/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -447,11 +440,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bw6-633/g2.go b/ecc/bw6-633/g2.go index ed44d59d4..17af770db 100644 --- a/ecc/bw6-633/g2.go +++ b/ecc/bw6-633/g2.go @@ -419,11 +419,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bw6-756/g1.go b/ecc/bw6-756/g1.go index 045b384c6..49437c7d8 100644 --- a/ecc/bw6-756/g1.go +++ b/ecc/bw6-756/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -451,11 +444,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bw6-756/g2.go b/ecc/bw6-756/g2.go index fdeb5e14c..012542286 100644 --- a/ecc/bw6-756/g2.go +++ b/ecc/bw6-756/g2.go @@ -423,11 +423,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/bw6-761/g1.go b/ecc/bw6-761/g1.go index 04d23cc9d..70a51e698 100644 --- a/ecc/bw6-761/g1.go +++ b/ecc/bw6-761/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -451,11 +444,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/ecc/bw6-761/g2.go b/ecc/bw6-761/g2.go index 5aa68749a..590621d9f 100644 --- a/ecc/bw6-761/g2.go +++ b/ecc/bw6-761/g2.go @@ -423,11 +423,7 @@ func (p *G2Jac) mulWindowed(a *G2Jac, s *big.Int) *G2Jac { var ops [3]G2Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g2Infinity) diff --git a/ecc/secp256k1/g1.go b/ecc/secp256k1/g1.go index 8631a6767..ed3291938 100644 --- a/ecc/secp256k1/g1.go +++ b/ecc/secp256k1/g1.go @@ -23,15 +23,8 @@ import ( "github.com/consensys/gnark-crypto/internal/parallel" "math/big" "runtime" - "sync" ) -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} - // G1Affine point in affine coordinates type G1Affine struct { X, Y fp.Element @@ -432,11 +425,7 @@ func (p *G1Jac) mulWindowed(a *G1Jac, s *big.Int) *G1Jac { var ops [3]G1Jac ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&g1Infinity) diff --git a/internal/generator/ecc/template/point.go.tmpl b/internal/generator/ecc/template/point.go.tmpl index 8736632ec..dfabf475f 100644 --- a/internal/generator/ecc/template/point.go.tmpl +++ b/internal/generator/ecc/template/point.go.tmpl @@ -8,9 +8,6 @@ import ( "math/big" "runtime" - {{- if eq .PointName "g1"}} - "sync" - {{- end }} {{- if .GLV}} "github.com/consensys/gnark-crypto/ecc" @@ -24,13 +21,6 @@ import ( {{- end}} ) -{{- if eq .PointName "g1"}} -var bigIntPool = sync.Pool{ - New: func() interface{} { - return new(big.Int) - }, -} -{{- end}} // {{ $TAffine }} point in affine coordinates type {{ $TAffine }} struct { @@ -651,11 +641,7 @@ func (p *{{ $TJacobian }}) mulWindowed(a *{{ $TJacobian }}, s *big.Int) *{{ $TJa var ops [3]{{ $TJacobian }} ops[0].Set(a) - e := s if s.Sign() == -1 { - e = bigIntPool.Get().(*big.Int) - defer bigIntPool.Put(e) - e.Neg(s) ops[0].Neg(&ops[0]) } res.Set(&{{ toLower .PointName}}Infinity)