Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions driver/common/curve.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,15 @@ func (p *CurveBase) ModAddMul3(a1 driver.Zr, a2 driver.Zr, b1 driver.Zr, b2 driv
m,
)
}

func (p *CurveBase) ModMulInPlace(result, a, b, m driver.Zr) {
result.Clone(p.ModMul(a, b, m))
}

func (p *CurveBase) ModAddMul2InPlace(result driver.Zr, a1, c1, b1, c2, m driver.Zr) {
result.Clone(p.ModAddMul2(a1, c1, b1, c2, m))
}

func (p *CurveBase) ModAddMul3InPlace(result driver.Zr, a1, a2, b1, b2, c1, c2, m driver.Zr) {
result.Clone(p.ModAddMul3(a1, a2, b1, b2, c1, c2, m))
}
36 changes: 36 additions & 0 deletions driver/gurvy/bls12381/bipool.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright IBM Corp. All Rights Reserved.

SPDX-License-Identifier: Apache-2.0
*/

package bls12381

import (
"math/big"
"sync"
)

// bigIntPool is a shared *big.Int memory pool for temporary conversions
var bigIntPool biPool

var _bigIntPool = sync.Pool{
New: func() interface{} {
return new(big.Int)
},
}

type biPool struct{}

func (biPool) Get() *big.Int {
return _bigIntPool.Get().(*big.Int)
}

func (biPool) Put(v *big.Int) {
if v == nil {
panic("put called with nil value")
}
// reset v before putting it back
v.SetInt64(0)
_bigIntPool.Put(v)
}
Loading
Loading