iden3 / go-circom-prover-verifier

Go implementation of the Groth16 zkSNARK Prover and Verifier compatible with Circom
GNU General Public License v3.0
37 stars 13 forks source link

json unmarshal failed #28

Open Stype0912 opened 2 years ago

Stype0912 commented 2 years ago

In the generated file proving_key.json, the name is defined as vk_alfa_1. But in the go struct(29th line of https://github.com/iden3/go-circom-prover-verifier/blob/master/parsers/parsers.go), the json form is defined as vk_alpha_1.It will cause the failure of command "go run ../cli/cli.go -convert" as the error msg is "Error: not enought data for stringToG1".

Stype0912 commented 2 years ago

also, the define of VKString in the 53rd line is wrong.

JanRuettinger commented 2 years ago

Did you get it to work? If yes, can you provide a PR?

Stype0912 commented 2 years ago

here is the pr, i have got it working on my Mac. https://github.com/iden3/go-circom-prover-verifier/pull/29

vmidyllic commented 2 years ago

@Stype0912 @JanRuettinger . This repository is not maintained and utilizes old versions of snarkjs and circom libraries. In newer versions proving key is generated with another field naming. I suggest using the latest version of snarkjs lib. If you need a verifier or prover to be used by golang code you can use this for now web-prover. I can merge #29 if you need it to use this version for some reason. Don't hesitate to contact us if you need help with proof generation

jeffprestes commented 1 year ago

@vmidyllic maybe https://github.com/iden3/go-rapidsnark/tree/main/verifier would be a better option in case you want to use a non web verifier.

CODER-6 commented 5 months ago

When we get verification_key.json using circom, the alpha field in the json file is: vk_alpha_1, whereas the structure field in the parsers.go code is: vk_alfa_1, so there will be an error when stringToG1 is applied to the vk field. We can modify the structure in parsers.go as follows:


// before
type VkString struct {
    // here
    Alpha []string   `json:"vk_alfa_1"`
    Beta  [][]string `json:"vk_beta_2"`
    Gamma [][]string `json:"vk_gamma_2"`
    Delta [][]string `json:"vk_delta_2"`
    IC    [][]string `json:"IC"`
}
// after
type VkString struct {
    Alpha []string   `json:"vk_alpha_1"`
    Beta  [][]string `json:"vk_beta_2"`
    Gamma [][]string `json:"vk_gamma_2"`
    Delta [][]string `json:"vk_delta_2"`
    IC    [][]string `json:"IC"`
}