Skip to content

Commit

Permalink
build generify parallelization
Browse files Browse the repository at this point in the history
  • Loading branch information
Tabaie committed Dec 19, 2024
1 parent dd5cac2 commit be02fb6
Show file tree
Hide file tree
Showing 7 changed files with 77 additions and 70 deletions.
21 changes: 11 additions & 10 deletions backend/groth16/bls12-377/mpcsetup/phase2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions backend/groth16/bls12-381/mpcsetup/phase2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions backend/groth16/bls24-315/mpcsetup/phase2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions backend/groth16/bls24-317/mpcsetup/phase2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions backend/groth16/bw6-633/mpcsetup/phase2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 11 additions & 10 deletions backend/groth16/bw6-761/mpcsetup/phase2.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import (
"bytes"
"crypto/sha256"
"errors"
"github.com/consensys/gnark/internal/utils"
"math/big"
"fmt"
"slices"
Expand Down Expand Up @@ -115,14 +116,18 @@ func (p *Phase2) update(delta *fr.Element, sigma []fr.Element) {
panic("unknown type")
}
}
scaleG1Slice := func(s []curve.G1Affine) {
utils.Parallelize(len(s), func(start, end int) {
for i := start; i < end; i++ {
s[i].ScalarMultiplication(&s[i], &I)
}
})
}

for i := range sigma {
sigma[i].BigInt(&I)
s := p.Parameters.G1.SigmaCKK[i]
for j := range s {
scale(&s[j])
}
scale(&p.Parameters.G2.Sigma[i])
scaleG1Slice(p.Parameters.G1.SigmaCKK[i])
}

delta.BigInt(&I)
Expand All @@ -131,12 +136,8 @@ func (p *Phase2) update(delta *fr.Element, sigma []fr.Element) {

delta.Inverse(delta)
delta.BigInt(&I)
for i := range p.Parameters.G1.Z {
scale(&p.Parameters.G1.Z[i])
}
for i := range p.Parameters.G1.PKK {
scale(&p.Parameters.G1.PKK[i])
}
scaleG1Slice(p.Parameters.G1.Z)
scaleG1Slice(p.Parameters.G1.PKK)
}

func (p *Phase2) Contribute() {
Expand Down

0 comments on commit be02fb6

Please sign in to comment.