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

package gocircomprover
import (
"io/ioutil"
"testing"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestVerify1(t *testing.T) {
proofJson, err := ioutil.ReadFile("testdata/big/proof.json")
require.Nil(t, err)
vkJson, err := ioutil.ReadFile("testdata/big/verification_key.json")
require.Nil(t, err)
publicJson, err := ioutil.ReadFile("testdata/big/public.json")
require.Nil(t, err)
public, err := ParsePublicSignals(publicJson)
require.Nil(t, err)
proof, err := ParseProof(proofJson)
require.Nil(t, err)
vk, err := ParseVk(vkJson)
require.Nil(t, err)
v := Verify(vk, proof, public)
assert.True(t, v)
}
func BenchmarkVerify(b *testing.B) {
proofJson, err := ioutil.ReadFile("testdata/big/proof.json")
require.Nil(b, err)
vkJson, err := ioutil.ReadFile("testdata/big/verification_key.json")
require.Nil(b, err)
publicJson, err := ioutil.ReadFile("testdata/big/public.json")
require.Nil(b, err)
public, err := ParsePublicSignals(publicJson)
require.Nil(b, err)
proof, err := ParseProof(proofJson)
require.Nil(b, err)
vk, err := ParseVk(vkJson)
require.Nil(b, err)
for i := 0; i < b.N; i++ {
Verify(vk, proof, public)
}
}