|
@ -2,7 +2,6 @@ package gocircomprover |
|
|
|
|
|
|
|
|
import ( |
|
|
import ( |
|
|
"encoding/json" |
|
|
"encoding/json" |
|
|
"fmt" |
|
|
|
|
|
"io/ioutil" |
|
|
"io/ioutil" |
|
|
"math/big" |
|
|
"math/big" |
|
|
"testing" |
|
|
"testing" |
|
@ -14,13 +13,9 @@ import ( |
|
|
func TestSmallCircuitGenerateProf(t *testing.T) { |
|
|
func TestSmallCircuitGenerateProf(t *testing.T) { |
|
|
provingKeyJson, err := ioutil.ReadFile("testdata/small/proving_key.json") |
|
|
provingKeyJson, err := ioutil.ReadFile("testdata/small/proving_key.json") |
|
|
require.Nil(t, err) |
|
|
require.Nil(t, err) |
|
|
pk, err := ParseProvingKey(provingKeyJson) |
|
|
|
|
|
|
|
|
pk, err := ParsePk(provingKeyJson) |
|
|
require.Nil(t, err) |
|
|
require.Nil(t, err) |
|
|
|
|
|
|
|
|
fmt.Println("polsA", pk.PolsA) |
|
|
|
|
|
fmt.Println("polsB", pk.PolsB) |
|
|
|
|
|
fmt.Println("polsC", pk.PolsC) |
|
|
|
|
|
|
|
|
|
|
|
witnessJson, err := ioutil.ReadFile("testdata/small/witness.json") |
|
|
witnessJson, err := ioutil.ReadFile("testdata/small/witness.json") |
|
|
require.Nil(t, err) |
|
|
require.Nil(t, err) |
|
|
w, err := ParseWitness(witnessJson) |
|
|
w, err := ParseWitness(witnessJson) |
|
@ -30,12 +25,9 @@ func TestSmallCircuitGenerateProf(t *testing.T) { |
|
|
|
|
|
|
|
|
proof, pubSignals, err := GenerateProof(pk, w) |
|
|
proof, pubSignals, err := GenerateProof(pk, w) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
fmt.Println("proof", proof) |
|
|
|
|
|
fmt.Println("pubSignals", pubSignals) |
|
|
|
|
|
|
|
|
|
|
|
proofStr, err := ProofToJson(proof) |
|
|
proofStr, err := ProofToJson(proof) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
fmt.Println("prover\n", string(proofStr)) |
|
|
|
|
|
|
|
|
|
|
|
err = ioutil.WriteFile("testdata/small/proof.json", proofStr, 0644) |
|
|
err = ioutil.WriteFile("testdata/small/proof.json", proofStr, 0644) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
@ -51,7 +43,7 @@ func TestSmallCircuitGenerateProf(t *testing.T) { |
|
|
func TestBigCircuitGenerateProf(t *testing.T) { |
|
|
func TestBigCircuitGenerateProf(t *testing.T) { |
|
|
provingKeyJson, err := ioutil.ReadFile("testdata/big/proving_key.json") |
|
|
provingKeyJson, err := ioutil.ReadFile("testdata/big/proving_key.json") |
|
|
require.Nil(t, err) |
|
|
require.Nil(t, err) |
|
|
pk, err := ParseProvingKey(provingKeyJson) |
|
|
|
|
|
|
|
|
pk, err := ParsePk(provingKeyJson) |
|
|
require.Nil(t, err) |
|
|
require.Nil(t, err) |
|
|
|
|
|
|
|
|
witnessJson, err := ioutil.ReadFile("testdata/big/witness.json") |
|
|
witnessJson, err := ioutil.ReadFile("testdata/big/witness.json") |
|
@ -61,12 +53,9 @@ func TestBigCircuitGenerateProf(t *testing.T) { |
|
|
|
|
|
|
|
|
proof, pubSignals, err := GenerateProof(pk, w) |
|
|
proof, pubSignals, err := GenerateProof(pk, w) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
fmt.Println("proof", proof) |
|
|
|
|
|
fmt.Println("pubSignals", pubSignals) |
|
|
|
|
|
|
|
|
|
|
|
proofStr, err := ProofToJson(proof) |
|
|
proofStr, err := ProofToJson(proof) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|
fmt.Println("prover\n", string(proofStr)) |
|
|
|
|
|
|
|
|
|
|
|
err = ioutil.WriteFile("testdata/big/proof.json", proofStr, 0644) |
|
|
err = ioutil.WriteFile("testdata/big/proof.json", proofStr, 0644) |
|
|
assert.Nil(t, err) |
|
|
assert.Nil(t, err) |
|
|