You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

54 lines
1.4 KiB

  1. package verifier
  2. import (
  3. "io/ioutil"
  4. "testing"
  5. "github.com/iden3/go-circom-prover-verifier/parsers"
  6. "github.com/stretchr/testify/assert"
  7. "github.com/stretchr/testify/require"
  8. )
  9. func TestVerify1(t *testing.T) {
  10. proofJson, err := ioutil.ReadFile("../testdata/big/proof.json")
  11. require.Nil(t, err)
  12. vkJson, err := ioutil.ReadFile("../testdata/big/verification_key.json")
  13. require.Nil(t, err)
  14. publicJson, err := ioutil.ReadFile("../testdata/big/public.json")
  15. require.Nil(t, err)
  16. public, err := parsers.ParsePublicSignals(publicJson)
  17. require.Nil(t, err)
  18. proof, err := parsers.ParseProof(proofJson)
  19. require.Nil(t, err)
  20. vk, err := parsers.ParseVk(vkJson)
  21. require.Nil(t, err)
  22. v := Verify(vk, proof, public)
  23. assert.True(t, v)
  24. // Verify again to check that `Verify` hasn't mutated the inputs
  25. v = Verify(vk, proof, public)
  26. assert.True(t, v)
  27. }
  28. func BenchmarkVerify(b *testing.B) {
  29. proofJson, err := ioutil.ReadFile("../testdata/big/proof.json")
  30. require.Nil(b, err)
  31. vkJson, err := ioutil.ReadFile("../testdata/big/verification_key.json")
  32. require.Nil(b, err)
  33. publicJson, err := ioutil.ReadFile("../testdata/big/public.json")
  34. require.Nil(b, err)
  35. public, err := parsers.ParsePublicSignals(publicJson)
  36. require.Nil(b, err)
  37. proof, err := parsers.ParseProof(proofJson)
  38. require.Nil(b, err)
  39. vk, err := parsers.ParseVk(vkJson)
  40. require.Nil(b, err)
  41. for i := 0; i < b.N; i++ {
  42. Verify(vk, proof, public)
  43. }
  44. }