ZkVerifier

Git Source

Inherits: Ownable, IZkVerifier

Title: Zero-knowledge verifier wrapper

Author: Malda Protocol

Ownable wrapper around the Risc0 verifier with configurable imageId

State Variables

verifier

Current Risc0 verifier contract

IRiscZeroVerifier public verifier

imageId

Current Risc0 image identifier

bytes32 public imageId

Functions

constructor

Initializes the verifier wrapper

constructor(address owner_, bytes32 _imageId, address _verifier) Ownable(owner_);

Parameters

NameTypeDescription
owner_addressContract owner
_imageIdbytes32Risc0 image identifier
_verifieraddressRisc0 verifier contract address

setVerifier

Sets the _risc0Verifier address

Admin check is needed on the external method

function setVerifier(address _risc0Verifier) external onlyOwner;

Parameters

NameTypeDescription
_risc0Verifieraddressthe new IRiscZeroVerifier address

setImageId

Sets the image id

Admin check is needed on the external method

function setImageId(bytes32 _imageId) external onlyOwner;

Parameters

NameTypeDescription
_imageIdbytes32the new image id

verifyInput

Verifies an input

function verifyInput(bytes calldata journalEntry, bytes calldata seal) external view;

Parameters

NameTypeDescription
journalEntrybytesthe risc0 journal entry
sealbytesthe risc0 seal

Events

ImageSet

Emitted when the imageId is updated

event ImageSet(bytes32 _imageId);

Parameters

NameTypeDescription
_imageIdbytes32New image identifier

VerifierSet

Emitted when the verifier contract address is updated

event VerifierSet(address indexed oldVerifier, address indexed newVerifier);

Parameters

NameTypeDescription
oldVerifieraddressPrevious verifier address
newVerifieraddressNew verifier address

Errors

ZkVerifier_ImageNotValid

Error thrown when the image id is not valid

error ZkVerifier_ImageNotValid();

ZkVerifier_InputNotValid

Error thrown when the input is not valid

error ZkVerifier_InputNotValid();

ZkVerifier_VerifierNotSet

Error thrown when the verifier is not set

error ZkVerifier_VerifierNotSet();