Consensys / gnark

gnark is a fast zk-SNARK library that offers a high-level API to design circuits. The library is open source and developed under the Apache 2.0 license
https://hackmd.io/@gnark
Apache License 2.0
1.39k stars 357 forks source link

gnark-EdDSA-Verify example #1193

Open hellojackhelloma opened 1 month ago

hellojackhelloma commented 1 month ago

I found some issues with the circuit code for EdDSA signature verification in the gnark official documentation. Additionally, there are no EdDSA signature verification examples in the gnark source code. I wrote one myself, and it is in the GitHub repository below. I hope it can be merged into the official codebase.

https://github.com/hellojackhelloma/gnark-EdDSA-Verify

ivokub commented 1 month ago

Thank you! It would be a great addition.

Would it be possible to create a PR implementing the example? For documentation purposes, it would be best to add a full-file example as described in https://pkg.go.dev/testing#hdr-Examples:

The entire test file is presented as the example when it contains a single example function, at least one other function, type, variable, or constant declaration, and no test or benchmark functions.

The example test could be created as a file std/signature/eddsa/doc_test.go. See for example https://github.com/Consensys/gnark/blob/master/std/algebra/emulated/sw_bn254/doc_test.go. This would be rendered as https://pkg.go.dev/github.com/consensys/gnark@v0.10.0/std/algebra/emulated/sw_bn254#example-Pairing at the documentation site. The benefit of this approach is that these kinds of examples are testable in CI, so we can ensure that they are always up-to-date.