Zero Knowledge Verifier

ZeroKnowledge precompile based on EZKL is available at address 0x42. The precompile takes 5 arguments: srs, vk, settings, proof and instances. Only proof and instances changes between different proofs while srs, vk and settings stay the same. To save on gas cost users are encouraged to deploy a helper contracts that would store those values during initial deployment so that proofs can be submitted with only proof and instances. For user convenience Neural has deployed a Factory contract that allows anyone to easily deploy their own verifiers given the vk,srs and settings. The factory is available at 0x95AF2694e3359a8DF8294E7A3ad66E68F7066dB9.

To deploy the verifier using factory, call newVerifier(srs, vk, settings) where srs, vk, and settings are all hex encoded.

Here is the verifier contract deployed by the factory:

pragma solidity >=0.4.21 <0.9.0;

import "../precompiles/NeuralSimple.sol";

contract EzklVerifier {
    bytes srs;
    bytes vk;
    bytes settings;
    NeuralSimple neural = NeuralSimple(0x42);

    constructor(bytes memory _srs, bytes memory _vk, bytes memory _settings) {
        srs = _srs;
        vk = _vk;
        settings = _settings;
    }

    function verify(bytes memory proof, bytes memory instances) external returns (bool) {
        return neural.verify(srs, vk, settings, proof, instances);
    }
}

Given the hex encoded proof and the instances call verify(hex_proof, hex_instances) function on your newly deployed verifier to verify the proof on chain. The limitation of the Solidity verifier does not apply, which means that the instances are not limited to 1 column and rotated queries are allowed. For now, Neural only supports BDFG21 batch open scheme.

To learn more about EZKL and how to get started see the following section.

Last updated