Skip to content

Commit

Permalink
feat: add lazy line eval for Miller loop
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub committed Nov 21, 2023
1 parent 3aa2559 commit bfe1068
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 1,020 deletions.
36 changes: 33 additions & 3 deletions std/algebra/emulated/sw_bw6761/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,41 @@ import (
"github.com/consensys/gnark/std/math/emulated"
)

type G2Affine = sw_emulated.AffinePoint[BaseField]
type g2AffP = sw_emulated.AffinePoint[BaseField]

func NewG2Affine(v bw6761.G2Affine) G2Affine {
return G2Affine{
type G2Affine struct {
P g2AffP
Lines *lineEvaluations
}

func newG2AffP(v bw6761.G2Affine) g2AffP {
return sw_emulated.AffinePoint[BaseField]{
X: emulated.ValueOf[BaseField](v.X),
Y: emulated.ValueOf[BaseField](v.Y),
}
}

func NewG2Affine(v bw6761.G2Affine) G2Affine {
return G2Affine{
P: newG2AffP(v),
}
}

func NewG2AffineFixed(v bw6761.G2Affine) G2Affine {
lines := precomputeLines(v)
return G2Affine{
P: newG2AffP(v),
Lines: &lines,
}
}

func NewG2AffineFixedPlaceholder() G2Affine {
var lines lineEvaluations
for i := 0; i < len(bw6761.LoopCounter)-1; i++ {
lines[0][i] = &lineEvaluation{}
lines[1][i] = &lineEvaluation{}
}
return G2Affine{
Lines: &lines,
}
}
Loading

0 comments on commit bfe1068

Please sign in to comment.