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.

48 lines
1.2 KiB

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