# On-chain ZK Verifiers

To verify ZK proofs on-chain, Axiom uses specialized smart contracts which are programmatically generated for each SNARK. This was done with the [`snark-verifier`](https://github.com/axiom-crypto/snark-verifier/releases/tag/v0.1.7-goerli-beta) library developed by the [Privacy Scaling Explorations](https://github.com/privacy-scaling-explorations/snark-verifier) group at the Ethereum Foundation, which generates Solidity assembly code for verifying any given ZK circuit.

#### Deployed Verifier Contracts <a href="#deployed-verifier-contracts" id="deployed-verifier-contracts"></a>

We deployed the verifier contracts to Goerli from Solidity source code using `solc` Version: `0.8.19`. The Solidity assembly code for each contract can be inspected on Etherscan.

| [**`AxiomV2CoreGoerliVerifier`**](https://goerli.etherscan.io/address/0xaA1D4372355aB67Fb033Dc244c32A6423C0E87B7#code) |
| ---------------------------------------------------------------------------------------------------------------------- |
| [**`AxiomV2QueryVerifier`**](https://goerli.etherscan.io/address/0x0f330c38eda10Ec94601FE4289BD0B2bCC6F359f#code)      |

We will soon be open-sourcing the Rust code used to programmatically generate the Solidity code above.

#### Checking Verifiers are not Metamorphic <a href="#checking-verifiers-are-not-metamorphic" id="checking-verifiers-are-not-metamorphic"></a>

In `AxiomV2CoreMockHistorical`and `AxiomV2Query`, each of these verifiers is subject to a timelock upgrade guarantee. To ensure that this timelock guarantee cannot be bypassed by a [metamorphic contract attack](https://0age.medium.com/the-promise-and-the-peril-of-metamorphic-contracts-9eb8b8413c5e), users should verify on each upgrade that the bytecode for verifier contracts above does not contain `DELEGATECALL` or `SELFDESTRUCT` opcodes. This can be done either by searching the Solidity assembly code or analyzing the compiled bytecode itself. Thanks to Zellic for pointing out this concern.
