Generating calldata from a proof and using your deployed contract
A npm package is under development to call your contract from the browser.
Once your groth16 contract is deployed and you have its address, you will need to call its main endpoint verify_groth16_proof_bn254, or verify_groth16_proof_bls12_381.
The Groth16 proof needs pre-processing and extra computation to allow efficient verification.
The Garaga CLI takes care of converting your proof to the correct calldata and calling your contract.
To do this, use the garaga verify-onchain command.
Usage: garaga verify-onchain [OPTIONS]
Invoke a SNARK verifier on Starknet given a contract address, a proof and a verification key.
╭─ Options ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * --system [groth16] Proof system [default: None] [required] │
│ * --contract-address TEXT Starknet contract address [default: None] [required] │
│ * --vk FILE Path to the verification key JSON file [default: None] [required] │
│ * --proof FILE Path to the proof JSON file [default: None] [required] │
│ --public-inputs FILE Path to the public inputs JSON file [default: None] │
│ --endpoint TEXT Smart contract function name. If not provided, the default │
│ 'verify_[proof_system]_proof_[curve_name]' will be used. │
│ --env-file FILE Path to the environment file containing rpc, address, private_key │
│ [default: /home/felt/PycharmProjects/garaga-flow/my_project/target/.secrets] │
│ --network [sepolia|mainnet] Starknet network [default: sepolia] │
│ --help -h Show this message and exit. │
╰─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
As for the verifying key, both Snarkjs and Gnark proof.json and public.json are supported out of the box. See the example in the Generate and deploy your verifier contract for Gnark export.
Alternatively, the --public-inputs parameter can be omitted if your proof include everything at once, as below.