backend: add ExportNeoGo for Groth-16 BLS12-381 curve #799
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hello, devs!
First of all, thank you for your amazing zk-SNARK packages! Currently we are adapting them to create and verify Groth-16 BLS12-381 proofs on the Neo blockchain.
PR motivation
We (as developers of Neo node implementation written in Go) are about to add Groth-16 verification support for Neo smart contracts in the upcoming 0.102.0 release. We've successfully adapted your libraries to build an example circuit, generate proof for it and build/invoke Verifier Neo smart contract deployed to the Neo blockchain: nspcc-dev/neo-go@5a19f81. However, to create Verifier contract we have to retrieve paramters of
groth16.VerifyingKey
via its serialized representation (firstly usevk.WriteTo(&buf)
and after that deserialise alpha, beta, gamma, delta and Kvks points from the resulted byte slice, take a look at the lines). It's not very convenient, but at the same time we can't usebls12-381
-specificVerifyingKey
implementation and directly access these parameters since it's located under theinternal
subdirectory.At the same time, I've noticed that exported
groth-16.VerifyingKey
interface hasExportSolidity
method that is supported for BN254 and provides the ability to generate Solidity Verifier contract bygnark
library itself.It would be very helpful for Go smart contract developers of Neo ecosystem to have a similar
ExportToNeoGo
method which is defined for Groth-16 BLS12-381 curve and iss able to generate Go Verifier contract for Neo blockchain. It allows to reduce the number of steps needed to build Verifier contract for contract developers.PR content
This PR contains a very initial implementation of
VerifyingKey.ExportToNeoGo
method that was successfully tested with end-to-end test (the idea of the test is same as forExportSolidity
test in https://github.com/Consensys/gnark-tests/blob/main/solidity/solidity_groth16_test.go). There's a large space for improvement in this PR, but if it's OK for you to add this API, then I'll finish it and fix all the review comments.The question
Is there any chance that this new
VerifyingKey.ExportToNeoGo
API will be added to your library?I'll appreciate any comments and opinions on this topic. Thank you for your time!