Skip to main content

World ID

1. Summary​

WorldIdAcceptorController.sol contract enables users to require zero-knowledge proof for their lending or borrowing counterparties through World ID. One of the use cases is verifying the humanness of the counterparty.

info

For more information about World ID please refer to the World Docs.

3. Contract details​

  • WorldIdAcceptorController.sol is written in Solidity version 0.8.16

Features​

  • Verify World ID zero-knowledge proof

Inherited contracts, implemented Interfaces and ERCs​

Functions​

checkAcceptor

Overview​

Proposal contracts call this function to verify submitted World ID proofs.

This function takes three arguments supplied by the proposal contracts:

  • addressacceptor
  • bytes calldataproposerData - data to be verified from the proposer
  • bytes calldataacceptorData - data to be verified from the acceptor

Implementation​

function checkAcceptor(
address acceptor, bytes calldata proposerData, bytes calldata acceptorData
) external view returns (bytes4) {
if (proposerData.length > 0) {
revert NonEmptyProposerData();
}

AcceptorData memory data = abi.decode(acceptorData, (AcceptorData));

worldId.verifyProof(
data.root,
groupId,
_hashToField(abi.encodePacked(acceptor)),
data.nullifierHash,
externalNullifier,
data.proof
);

return type(IPWNAcceptorController).interfaceId;
}

Events and Errors​

The World ID Acceptor Controller contract defines one custom error and no events.

error NonEmptyProposerData();
NonEmptyProposerData

A NonEmptyProposerData error is thrown when proposer data are not empty.

This error doesn't have any parameters.

info

Check for empty acceptorData is ensured though abi.decode validation.

AcceptorData Struct​

TypeNameComment
uint256rootRoot of the proof merkle tree
uint256nullifierHashNullifier hash for the proof
uint256[8]proofZK Proof itself