snarkVM icon indicating copy to clipboard operation
snarkVM copied to clipboard

[Feature] Implement `snark.verify` opcode

Open raychu86 opened this issue 1 month ago • 1 comments

Motivation

This PR implements the snark.verify and snark.verify.batch opcode, which are finalize-only operations that verifies a Varuna proof. In order to support this, the array size was also increased from 512 to 2048. These features will activate at ConsenusVersion::V13.

Examples:

snark.verify r0 r1 r2 into r3

r0 is the verifying key (represented by a byte array) r1 is the verifier inputs (represented by an array of field elements) r2 is the proof (represented by a byte array) r3 is the verification results (represented by a boolean)

snark.verify.batch r0 r1 r2 into r3

r0 is the array of verifying keys (represented by a 2-D byte array) r1 is the array of verifier inputs (represented by a 3-D array of field elements) r2 is the batch proof (represented by a byte array) r3 is the verification results (represented by a boolean)

Additional Notes

Currently this only supports the native Varuna proofs, but the opcode can be expanded to other proof systems in the future.

TODO

  • [ ] Determine proper fee pricing
  • [x] Implement verification for batch proofs
  • [ ] Determine the required array size. 2048 is likely not sufficient (For batched proofs using the same circuit, proofs are 957 bytes + 144 bytes per additional proof in the batch)
  • [ ] V13 Height needs to be properly set for the networks

Test Plan

Tests have been added to check the proofs are properly verified and/or rejected.

raychu86 avatar Nov 07 '25 05:11 raychu86

Super exciting stuff y'all!

mwyatt896 avatar Dec 10 '25 19:12 mwyatt896