Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Field element casting to affine representation #240

Merged
merged 1 commit into from
Jan 13, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading