Skip to content
Lattice

Groth16Verifier

Git Source

Inherits: IGroth16Verifier

Title: Groth16Verifier

Authors: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80), Modified from snarkjs (https://github.com/iden3/snarkjs)

Stateless Diamond facet exposing a GENERIC Groth16 verifier over BN254. The verifying key is a parameter, so one deployment verifies proofs for any circuit — the primitive the ZK privacy modules plug their circuit's key into.

All logic lives in Groth16VerifierLib. Pure verification (view): no state beyond the ERC-165 registration written at init. The facet does not authenticate the key it is given: consumers MUST pin it (see KEY PINNING on IGroth16Verifier). reimplemented under MIT with the key as a parameter; pairing math is the standard BN254 check.

Notes:

  • lattice-version: 0.1.0
  • lattice-source: Generalized from the snarkjs (iden3) Groth16 verifier template (GPL-3.0),

Functions

verifyProof

Verifies a Groth16 proof against vk for the given public input.

Returns false (does not revert) for an invalid proof, an out-of-range public input (>= SNARK_SCALAR_FIELD), an off-curve / out-of-range proof point, or a failed pairing. Reverts only on structural misuse (key/input arity mismatch).

function verifyProof(VerifyingKey calldata vk, Proof calldata proof, uint256[] calldata input)
        external
        view
        virtual
        returns (bool);

Parameters

NameTypeDescription
vkVerifyingKeyThe verifying key for the circuit. MUST be a key the consumer pins (see KEY PINNING
above), never one taken from an untrusted caller.
proofProofThe Groth16 proof.
inputuint256[]The public inputs, in the circuit's public-signal order.

Returns

NameTypeDescription
<none>boolTrue iff the proof is valid for vk and input.

exportSelectors

ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).

Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches forge inspect Groth16Verifier methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: verifyProof((uint256[2],uint256[2][2],uint256[2][2],uint256[2][2],uint256[2][]),(uint256[2],uint256[2][2],uint256[2]),uint256[]) 0x6d832d8e

function exportSelectors() external pure virtual returns (bytes memory selectors);

Returns

NameTypeDescription
selectorsbytes