Skip to content

Commit

Permalink
fix: Field element casting to affine representation
Browse files Browse the repository at this point in the history
  • Loading branch information
epociask committed Jan 13, 2025
1 parent 44191c1 commit 588477a
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions verify/verifier.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,16 @@ func (v *Verifier) VerifyCommitment(certCommitment *common.G1Commitment, blob []

certCommitmentX := &fp.Element{}
certCommitmentX.Unmarshal(certCommitment.X)

// map coordinates to G1 and ensure they are on the curve
xAffine := bn254.MapToG1(*certCommitmentX)
if !xAffine.IsOnCurve() {
return fmt.Errorf("commitment x field element is not on the curve: %x", certCommitmentX.Marshal())
}

certCommitmentY := &fp.Element{}
certCommitmentY.Unmarshal(certCommitment.Y)

yAffine := bn254.MapToG1(*certCommitmentY)
if !yAffine.IsOnCurve() {
return fmt.Errorf("commitment y field element is not on the curve: %x", certCommitmentY.Marshal())
certCommitmentAffine := bn254.G1Affine{
X: *certCommitmentX,
Y: *certCommitmentY,
}

if !certCommitmentAffine.IsOnCurve() {
return fmt.Errorf("commitment (x,y) field elements are not on the BN254 curve")
}

errMsg := ""
Expand Down

0 comments on commit 588477a

Please sign in to comment.