mirror of
https://github.com/arnaucube/go-circom-prover-verifier.git
synced 2026-02-06 19:06:43 +01:00
Merge pull request #4 from iden3/fix/verify
Fix mutation of inputs in Verify
This commit is contained in:
@@ -32,7 +32,7 @@ func Verify(vk *types.Vk, proof *types.Proof, inputs []*big.Int) bool {
|
||||
}
|
||||
vkX = new(bn256.G1).Add(vkX, vk.IC[0])
|
||||
|
||||
g1 := []*bn256.G1{proof.A, vk.Alpha.Neg(vk.Alpha), vkX.Neg(vkX), proof.C.Neg(proof.C)}
|
||||
g1 := []*bn256.G1{proof.A, new(bn256.G1).Neg(vk.Alpha), vkX.Neg(vkX), new(bn256.G1).Neg(proof.C)}
|
||||
g2 := []*bn256.G2{proof.B, vk.Beta, vk.Gamma, vk.Delta}
|
||||
return bn256.PairingCheck(g1, g2)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,10 @@ func TestVerify1(t *testing.T) {
|
||||
|
||||
v := Verify(vk, proof, public)
|
||||
assert.True(t, v)
|
||||
|
||||
// Verify again to check that `Verify` hasn't mutated the inputs
|
||||
v = Verify(vk, proof, public)
|
||||
assert.True(t, v)
|
||||
}
|
||||
|
||||
func BenchmarkVerify(b *testing.B) {
|
||||
|
||||
Reference in New Issue
Block a user