Skip to content
Lattice

PlonkVerifier

Git Source

Inherits: IPlonkVerifier

Title: PlonkVerifier

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

Stateless Diamond facet exposing a GENERIC PLONK verifier over BN254. The verifying key is a parameter, so one deployment verifies proofs for any circuit — a reusable verifier primitive for the ZK privacy modules and consumers who bring PLONK circuits.

All logic lives in PlonkVerifierLib. 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 IPlonkVerifier). reimplemented under MIT with the key as a parameter; verification follows eprint 2019/953.

Notes:

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

Functions

verifyProof

Verifies a PLONK 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 on structural misuse (empty input) or a failed ecMul/ecAdd/modexp precompile call.

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 PLONK 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 PlonkVerifier methodIdentifiers (alphabetical by signature); kept in exact parity by ExportSelectorsParityTest. Chunks: verifyProof((uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256,uint256,uint256,uint256,uint256[2][2]),(uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256[2],uint256,uint256,uint256,uint256,uint256,uint256),uint256[]) 0x5d484314

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

Returns

NameTypeDescription
selectorsbytes