Skip to content

Commit

Permalink
perf(bn254): subgroup memebership
Browse files Browse the repository at this point in the history
  • Loading branch information
yelhousni committed Feb 14, 2025
1 parent 3f18b72 commit 96ab5da
Show file tree
Hide file tree
Showing 3 changed files with 151 additions and 2 deletions.
51 changes: 50 additions & 1 deletion ecc/bn254/g1.go

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

51 changes: 50 additions & 1 deletion ecc/bn254/g2.go

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

51 changes: 51 additions & 0 deletions internal/generator/ecc/template/point.go.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,57 @@ func (p *{{ $TJacobian }}) mulBySeed(q *{{ $TJacobian }}) *{{ $TJacobian }} {
res.Double(&res)
}
p.Set(&res)
{{- else if eq .Name "bn254"}}
// Generated by github.com/mmcloughlin/addchain v0.4.0.
// Operations: 62 squares 17 multiplies

// Allocate Temporaries.
var res, t0, t1, t2, t3 {{ $TJacobian }}

res.Double(q)
t0.Set(q).AddAssign(&res)
t2.Set(q).AddAssign(&t0)
t1.Set(&res).AddAssign(&t2)
res.Double(&t1)
res.AddAssign(&t0)
t0.AddAssign(&res)
t2.AddAssign(&t0)
t1.AddAssign(&t2)
t0.AddAssign(&t1)
t1.AddAssign(&t0)
t0.AddAssign(&t1)
t2.AddAssign(&t0)
t3.Double(&t2)
t1.AddAssign(&t3)
t2.AddAssign(&t1)
res.AddAssign(&t2)
t2.AddAssign(&res)
t3.Double(&t2)
res.AddAssign(&t3)
t0.AddAssign(&res)
t1.AddAssign(&t0)
t3.Double(&t1)
for s := 1; s < 2; s++ {
t3.Double(&t3)
}
t3.AddAssign(&t1)
t2.AddAssign(&t3)
t1.AddAssign(&t2)
t2.AddAssign(&t1)
for s := 0; s < 17; s++ {
t2.Double(&t2)
}
t1.AddAssign(&t2)
for s := 0; s < 14; s++ {
t1.Double(&t1)
}
t0.AddAssign(&t1)
for s := 0; s < 16; s++ {
t0.Double(&t0)
}
res.AddAssign(&t0)

p.Set(&res)
{{- else}}
p.mulWindowed(q, &xGen)
{{- end}}
Expand Down

0 comments on commit 96ab5da

Please sign in to comment.