[PROPOSAL] Add Rust/Solana export commands for Groth16#615
Draft
vitorpy wants to merge 1 commit intoiden3:masterfrom
Draft
[PROPOSAL] Add Rust/Solana export commands for Groth16#615vitorpy wants to merge 1 commit intoiden3:masterfrom
vitorpy wants to merge 1 commit intoiden3:masterfrom
Conversation
Add two new CLI commands for exporting Groth16 artifacts as Rust code: - `zkey export rustverifier` - exports verification key as Rust struct - `zkey export rustcalldata` - exports proof and public inputs as Rust constants The byte transformations follow groth16-solana conventions for compatibility with Solana's alt_bn128 precompiles.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Solana's groth16-solana crate, as well as most Solana ZK applications, use snarkjs for generating proofs. I'm adding, mostly verbatim from groth16-solana JS scripts, native methods to the snarkjs CLI to export Solana-compatible artifacts.
This is a proposal - I'm happy and more than open to take feedback and rework this in a way that's amenable to snarkjs maintainers.
New Commands
snarkjs zkey export rustverifier [circuit.zkey] [verifier.rs](alias:zkerv)snarkjs zkey export rustcalldata [public.json] [proof.json](alias:zkerc)Implementation Details
The byte transformations follow the conventions established by groth16-solana for compatibility with Solana's
alt_bn128precompiles:Test Plan
rustverifieroutput matches existing groth16-solanaparse_vk_to_rust.jsoutput