ERC-1923 zk-SNARK Verifier Registry (zk-SNARK Verifier Registry Standard)
Stagnant · Other · created 2018-12-22
A standard that registers zk-SNARK proofs, verifying keys, and verification results in a single registry contract, so that apps using zero-knowledge proofs can record and look up proof-related information in a common way.
Why it is needed
zk-SNARKs can prove that a transaction or computation was performed correctly without revealing its contents, so they can be used for private transactions, private contract operations, and scaling solutions that batch multiple transactions together. However, if the way proofs are registered and verified differs from app to app, it becomes difficult for other contracts or services to determine which proof was actually verified with which verifying key. Since the information left on the blockchain during verification is limited, without a common registry, applications implementing private transactions or scaling solutions struggle to extract and interpret proof-related information.
What to implement
event NewProofSubmitted(bytes32 indexed _proofId, uint256[] _proof, uint64[] _inputs);: Signals that a new proof has been submitted.event NewVkRegistered(bytes32 indexed _vkId);: Signals that a new verifying key has been registered.event NewVerifierContractRegistered(address indexed _contractAddress);: Signals that a new verifier contract has been registered.event NewAttestation(bytes32 indexed _proofId, address indexed _verifier, bool indexed _result);: Signals that a verification result (true or false) has been recorded for a given proof.function getVk(bytes32 _vkId) external returns (uint256[] memory);: Looks up a registered verifying key.function registerVerifierContract(address _verifierContract) external returns (bool);: Registers a verifier contract address in the registry.function registerVk(uint256[] calldata _vk, address[] calldata _verifierContracts) external returns (bytes32);: Registers a verifying key and designates the verifier contracts that will use it.function submitProof(uint256[] calldata _proof, uint64[] calldata _inputs, bytes32 _vkId) external returns (bytes32);: Submits a proof and inputs for a given verifying key.function submitProof(uint256[] calldata _proof, uint64[] calldata _inputs, bytes32 _vkId, address _verifierContract) external returns (bytes32);: Submits a proof while specifying the verifier contract to use.function submitProofAndVerify(uint256[] calldata _proof, uint64[] calldata _inputs, bytes32 _vkId, address _verifierContract) external returns (bytes32);: Submits a proof and simultaneously performs verification with the designated verifier contract.function attestProof(bytes32 _proofId, bytes32 _vkId, bool _result) external;: Records the verification result for a given proof in the registry.function attestProofs(bytes32[] calldata _proofIds, bytes32[] calldata _vkIds, bool[] calldata _results) external;: Records verification results for multiple proofs at once.function challengeAttestation(bytes32 _proofId, uint256[] calldata _proof, uint64[] calldata _inputs, address _verifierContract) external;: Challenges an already recorded verification result.function createNewVkId(uint256[] calldata _vk) external pure returns (bytes32);: Computes vkId from a verifying key.function createNewProofId(uint256[] calldata _proof, uint64[] calldata _inputs) external pure returns (bytes32);: Computes proofId from a proof and its inputs.function supportsInterface(bytes4 interfaceID) external view returns (bool);: Looks up whether a contract supports a given interface (ERC-165).
In depth
Role of the Registry
This standard defines an API for registering all zk-SNARK (zero-knowledge proof) verification activity in a single registry contract. It specifies ERC-165, ERC-196, and ERC-197 as requirements; ERC-196 and ERC-197 are precompiles for addition, scalar multiplication, and pairing operations on the alt_bn128 elliptic curve, used in zk-SNARK verification computations. The original text lists private transactions, private operations, and scalability through transaction batching as the main use cases.
Verifying Key (vk) and vkId
registerVk(uint256[] _vk, address[] _verifierContracts) registers a verifying key, designates the list of verifier contracts that will use it, and returns a bytes32 vkId. getVk(bytes32 _vkId) looks up a registered verifying key. createNewVkId(uint256[] _vk) is a pure function that computes a vkId from a verifying key. Registration triggers a NewVkRegistered event.
Proof Submission and proofId
submitProof is defined in two forms. One takes only (proof, inputs, vkId), and the other also takes a verifier contract address. Both return a bytes32 proofId. createNewProofId(uint256[] _proof, uint64[] _inputs) is a pure function that computes a proofId from a proof and its inputs, and submission triggers a NewProofSubmitted event.
Verifier Contract Registration
registerVerifierContract(address _verifierContract) registers in the registry the address of the contract that will perform the actual verification computation, returns a bool, and triggers a NewVerifierContractRegistered event upon registration. submitProofAndVerify performs proof submission and verification via the verifier contract in a single call.
Attestation of Verification Results
attestProof(bytes32 _proofId, bytes32 _vkId, bool _result) records the verification result (true or false) for a given proof in the registry. attestProofs takes arrays of proofId, vkId, and results to attest multiple proofs at once. In both cases a NewAttestation event is triggered, exposing proofId, the verifier address, and the result, all as indexed fields.
Challenge Procedure
challengeAttestation(bytes32 _proofId, uint256[] _proof, uint64[] _inputs, address _verifierContract) is a function for challenging an already recorded verification result. The original text defines only this function's signature and gives no concrete explanation of the follow-up process after a challenge or how the outcome is reflected.
ERC-165 Support
The interface is specified to inherit from ERC-165 (`is ERC165`), and the specification includes a separate ERC165 interface with a supportsInterface(bytes4 interfaceID) function. However, the original text leaves as a TODO that the ERC-165 interface identifier value for this standard itself has not yet been determined.
Current status of the standard
This ERC is in Stagnant status. Several sections, including Motivation, Rationale, Backwards Compatibility, Test Cases, Implementations, and References, remain as TODOs, and the interface name and ERC-165 identifier value have not been finalized either. The referenced example implementation is also explicitly stated in the original text not to be used in production, making this a proposal that stalled without further refinement or completion.