This project implements a Groth16 zk-SNARK verifier as a Soroban smart contract, enabling on-chain verification of zero-knowledge proofs within the Stellar network.
- Verifies Groth16 zk-SNARK proofs on-chain.
- Compatible with proofs generated by Circom, SnarkJS, Arkwork.
- Utilizes the stellar bls12-381 host functions for proof verification.
- Designed for deployment on the Stellar Soroban platform.
- Rust toolchain with
wasm32-unknown-unknowntarget installed. - Soroban CLI for building and deploying contracts.
- Circom, SnarkJS or Arkwork for generating proofs.
-
Clone the repository:
git clone https://github.com/veil-protocol-privacy/groth16-soroban.git cd groth16-soroban -
Build the contract using the Soroban CLI:
soroban contract build
-
Deploy the contract to the Soroban network:
soroban contract deploy --wasm target/wasm32-unknown-unknown/release/groth16-soroban.wasm
-
Note the contract ID returned after deployment for future interactions.
-
Generate a proof using Circom and SnarkJS:
circom circuit.circom --r1cs --wasm --sym snarkjs groth16 setup circuit.r1cs powersOfTau28_hez_final_10.ptau circuit_0000.zkey snarkjs groth16 prove circuit_0000.zkey witness.wtns proof.json public.json
-
Convert the proof and public inputs to a format compatible with the Soroban contract.
-
Invoke the contract's verification function:
soroban contract invoke \ --id <CONTRACT_ID> \ --fn verify_proof \ --arg <PROOF_ARGUMENTS>
Replace
<CONTRACT_ID>with your deployed contract ID and<PROOF_ARGUMENTS>with the serialized proof and public inputs.
Run the test suite to ensure the verifier functions correctly:
cargo testThis project is licensed under the MIT License. See the LICENSE file for details.
For a practical example and further reference, you can explore the stellar/soroban-examples repository, which includes a proof-of-concept Groth16 verifier implementation.