Skip to content

Commit

Permalink
fix: add G2 membership check for constant points (Consensys#1397)
Browse files Browse the repository at this point in the history
  • Loading branch information
ivokub authored Jan 21, 2025
1 parent 52291fa commit 5a846d1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions std/algebra/emulated/sw_bn254/g2.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ func NewG2Affine(v bn254.G2Affine) G2Affine {
// NewG2AffineFixed returns witness of v with precomputations for efficient
// pairing computation.
func NewG2AffineFixed(v bn254.G2Affine) G2Affine {
if !v.IsInSubGroup() {
// for the pairing check we check that G2 point is already in the
// subgroup when we compute the lines in circuit. However, when the
// point is given as a constant, then we already precompute the lines at
// circuit compile time without explicitly checking the G2 membership.
// So, we need to check that the point is in the subgroup before we
// compute the lines.
panic("given point is not in the G2 subgroup")
}
lines := precomputeLines(v)
return G2Affine{
P: newG2AffP(v),
Expand Down

0 comments on commit 5a846d1

Please sign in to comment.