Skip to content

Commit ad966a5

Browse files
authoredJan 13, 2025··
fix: Field element casting to affine representation (#240)
1 parent 44191c1 commit ad966a5

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed
 

‎verify/verifier.go

+7-10
Original file line numberDiff line numberDiff line change
@@ -132,19 +132,16 @@ func (v *Verifier) VerifyCommitment(certCommitment *common.G1Commitment, blob []
132132

133133
certCommitmentX := &fp.Element{}
134134
certCommitmentX.Unmarshal(certCommitment.X)
135-
136-
// map coordinates to G1 and ensure they are on the curve
137-
xAffine := bn254.MapToG1(*certCommitmentX)
138-
if !xAffine.IsOnCurve() {
139-
return fmt.Errorf("commitment x field element is not on the curve: %x", certCommitmentX.Marshal())
140-
}
141-
142135
certCommitmentY := &fp.Element{}
143136
certCommitmentY.Unmarshal(certCommitment.Y)
144137

145-
yAffine := bn254.MapToG1(*certCommitmentY)
146-
if !yAffine.IsOnCurve() {
147-
return fmt.Errorf("commitment y field element is not on the curve: %x", certCommitmentY.Marshal())
138+
certCommitmentAffine := bn254.G1Affine{
139+
X: *certCommitmentX,
140+
Y: *certCommitmentY,
141+
}
142+
143+
if !certCommitmentAffine.IsOnCurve() {
144+
return fmt.Errorf("commitment (x,y) field elements are not on the BN254 curve")
148145
}
149146

150147
errMsg := ""

0 commit comments

Comments
 (0)