Skip to content
Lattice

PinnedWithdrawVerifier

Git Source

Inherits: IShieldedWithdrawVerifier

Title: PinnedWithdrawVerifier

Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)

Example IShieldedWithdrawVerifier adapter: fits the generic IGroth16Verifier to a shielded pool's 5-signal withdraw interface, with the circuit's verifying key compiled in. A consumer subclasses it and returns their audited withdraw circuit's key from _verifyingKey as literals (snarkjs vkey.json, G2 pairs swapped to (c1, c0)), then passes the subclass to createPool.

KEY PINNING, constant pattern. The generic verifier checks a proof against whatever key it is given, and whoever generates a key can know its trapdoor and forge a proof for any public signals. This adapter never takes a key from its caller or from storage: the key lives in bytecode, so every withdrawal from the pool is checked against one circuit. There is deliberately no setter; a new circuit means a new adapter and a new pool. Point groth16 at a verifier whose code cannot change under the pool (a standalone facet deployment, or a diamond whose cut authority you already trust). HashPinnedGroth16Verifier shows the stored-hash pattern for keys passed in calldata. EXAMPLE contract; not audited.

Note:

Constants

groth16

The generic Groth16 verifier the pinned key is checked against.

IGroth16Verifier public immutable groth16;

Functions

constructor

constructor(IGroth16Verifier groth16_);

Parameters

NameTypeDescription
groth16_IGroth16VerifierA Groth16Verifier facet deployment, or a diamond that serves it.

verifyProof

function verifyProof(
        uint256[2] calldata a,
        uint256[2][2] calldata b,
        uint256[2] calldata c,
        uint256[5] calldata input
    ) external view returns (bool);

Parameters

NameTypeDescription
auint256[2]Groth16 proof point A.
buint256[2][2]Groth16 proof point B.
cuint256[2]Groth16 proof point C.
inputuint256[5]The public signals [root, nullifierHash, recipient, relayer, fee].

Returns

NameTypeDescription
<none>boolTrue iff the proof is valid.

_verifyingKey

The pinned key, with ic.length == 6. MUST return compile-time constants: no storage reads, no constructor arguments, no calls.

function _verifyingKey() internal pure virtual returns (IGroth16Verifier.VerifyingKey memory vk);

Returns

NameTypeDescription
vkIGroth16Verifier.VerifyingKey

Errors

PinnedWithdrawVerifier__ZeroAddress

error PinnedWithdrawVerifier__ZeroAddress();