Skip to content

Commit

Permalink
fix: code generation fp6
Browse files Browse the repository at this point in the history
  • Loading branch information
yelhousni committed Mar 26, 2023
1 parent 3c7c8f8 commit 4163c05
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 28 deletions.
28 changes: 28 additions & 0 deletions ecc/bls12-377/internal/fptower/e6.go

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

56 changes: 28 additions & 28 deletions ecc/bls12-381/internal/fptower/e6.go

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

28 changes: 28 additions & 0 deletions ecc/bn254/internal/fptower/e6.go

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

28 changes: 28 additions & 0 deletions internal/generator/tower/template/fq12over6over2/fq6.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,34 @@ func (z *E6) MulByE2(x *E6, y *E2) *E6 {
return z
}

// MulBy12 multiplication by sparse element (0,b1,b2)
func (x *E6) MulBy12(b1, b2 *E2) *E6 {
var t1, t2, c0, tmp, c1, c2 E2
t1.Mul(&x.B1, b1)
t2.Mul(&x.B2, b2)
c0.Add(&x.B1, &x.B2)
tmp.Add(b1, b2)
c0.Mul(&c0, &tmp)
c0.Sub(&c0, &t1)
c0.Sub(&c0, &t2)
c0.MulByNonResidue(&c0)
c1.Add(&x.B0, &x.B1)
c1.Mul(&c1, b1)
c1.Sub(&c1, &t1)
tmp.MulByNonResidue(&t2)
c1.Add(&c1, &tmp)
tmp.Add(&x.B0, &x.B2)
c2.Mul(b2, &tmp)
c2.Sub(&c2, &t2)
c2.Add(&c2, &t1)

x.B0 = c0
x.B1 = c1
x.B2 = c2

return x
}

// MulBy01 multiplication by sparse element (c0,c1,0)
func (z *E6) MulBy01(c0, c1 *E2) *E6 {

Expand Down

0 comments on commit 4163c05

Please sign in to comment.