gnark icon indicating copy to clipboard operation
gnark copied to clipboard

Proof in Solidity format

Open simonmasson opened this issue 6 months ago • 2 comments

Following the tutorial, I am able to export my verification function from Go to Solidity. However, I couldn't find how to export the proof (including A,B,C, Commitments, CommitmentPok, and the public inputs) in order to test if a proof is verified in Solidity.

Is there such a function that converts automatically into Solidity?

simonmasson avatar Jul 03 '25 17:07 simonmasson

Sorry for the delay. I'm assuming you're using Groth16 Solidity verifier for now? Unfortunately we don't have a super nice direct interfaces for exporting the proof yet, is is still in the todo list https://github.com/Consensys/gnark/issues/1094.

As a reference meanwhile, you could have a look at the gnark-solidity checker which does the conversion for Groth16 (https://github.com/Consensys/gnark-solidity-checker/blob/main/cmd/templates.go#L43-L124) and for PLONK (https://github.com/Consensys/gnark-solidity-checker/blob/main/cmd/templates.go#L178-L211).

I think I can do a quick patch to output exactly the outputs in expected format so that the users wouldn't have to refer to this template. But for Groth16 at least the long-term solution would be to use proof as serialized bytes and we would deserialize in contract already. And imo if we would like to add BLS12-381 support anyway, then it would be needed as well.

ivokub avatar Jul 09 '25 08:07 ivokub

here you have a full implementation ready to use @simonmasson https://github.com/vocdoni/davinci-node/tree/main/solidity

p4u avatar Sep 09 '25 16:09 p4u