Skip to main content

SP1VerifierGateway

SP1VerifierGateway

This contract verifies proofs by routing to the correct verifier based on the verifier selector contained in the first 4 bytes of the proof. It additionally checks that to see that the verifier route is not frozen.

routes

mapping(bytes4 => struct VerifierRoute) routes

Mapping of 4-byte verifier selectors to verifier routes.

Only one verifier route can be added for each selector.

Parameters

NameTypeDescription

Return Values

NameTypeDescription

constructor

constructor(address initialOwner) public

verifyProof

function verifyProof(bytes32 programVKey, bytes publicValues, bytes proofBytes) external view

Verifies a proof with given public values and vkey.

It is expected that the first 4 bytes of proofBytes must match the first 4 bytes of target verifier's VERIFIER_HASH.

Parameters

NameTypeDescription
programVKeybytes32The verification key for the RISC-V program.
publicValuesbytesThe public values encoded as bytes.
proofBytesbytesThe proof of the program execution the SP1 zkVM encoded as bytes.

addRoute

function addRoute(address verifier) external

Adds a verifier route. This enable proofs to be routed to this verifier.

Only callable by the owner. The owner is responsible for ensuring that the specified verifier is correct with a valid VERIFIER_HASH. Once a route to a verifier is added, it cannot be removed.

Parameters

NameTypeDescription
verifieraddressThe address of the verifier contract. This verifier MUST implement the ISP1VerifierWithHash interface.

freezeRoute

function freezeRoute(bytes4 selector) external

Freezes a verifier route. This prevents proofs from being routed to this verifier.

Only callable by the owner. Once a route to a verifier is frozen, it cannot be unfrozen.

Parameters

NameTypeDescription
selectorbytes4The verifier selector to freeze.