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.

50 lines
1.3 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. }
  25. func BenchmarkVerify(b *testing.B) {
  26. proofJson, err := ioutil.ReadFile("../testdata/big/proof.json")
  27. require.Nil(b, err)
  28. vkJson, err := ioutil.ReadFile("../testdata/big/verification_key.json")
  29. require.Nil(b, err)
  30. publicJson, err := ioutil.ReadFile("../testdata/big/public.json")
  31. require.Nil(b, err)
  32. public, err := parsers.ParsePublicSignals(publicJson)
  33. require.Nil(b, err)
  34. proof, err := parsers.ParseProof(proofJson)
  35. require.Nil(b, err)
  36. vk, err := parsers.ParseVk(vkJson)
  37. require.Nil(b, err)
  38. for i := 0; i < b.N; i++ {
  39. Verify(vk, proof, public)
  40. }
  41. }