Skip to content

Commit

Permalink
docs: add init docs
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub committed Nov 22, 2023
1 parent 9e8e2ac commit c1f5c87
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions std/algebra/emulated/sw_bw6761/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ import (
"github.com/consensys/gnark/std/math/emulated"
)

// g2AffP is the raw G2 element without precomputations.
type g2AffP = sw_emulated.AffinePoint[BaseField]

// G2Affine represents G2 element with optional embedded line precomputations.
type G2Affine struct {
P g2AffP
Lines *lineEvaluations
Expand All @@ -20,12 +22,16 @@ func newG2AffP(v bw6761.G2Affine) g2AffP {
}
}

// NewG2Affine returns the witness of v without precomputations. In case of
// pairing the precomputation will be done in-circuit.
func NewG2Affine(v bw6761.G2Affine) G2Affine {
return G2Affine{
P: newG2AffP(v),
}
}

// NewG2AffineFixed returns witness of v with precomputations for efficient
// pairing computation.
func NewG2AffineFixed(v bw6761.G2Affine) G2Affine {
lines := precomputeLines(v)
return G2Affine{
Expand All @@ -34,6 +40,9 @@ func NewG2AffineFixed(v bw6761.G2Affine) G2Affine {
}
}

// NewG2AffineFixedPlaceholder returns a placeholder for the circuit compilation
// when witness will be given with line precomputations using
// [NewG2AffineFixed].
func NewG2AffineFixedPlaceholder() G2Affine {
var lines lineEvaluations
for i := 0; i < len(bw6761.LoopCounter)-1; i++ {
Expand Down

0 comments on commit c1f5c87

Please sign in to comment.