Skip to content

ProofRequestLibrary

State Variables

PROOF_REQUEST_TYPE

Id is uint256 as for user defined types, the eip712 type hash uses the underlying type.

string constant PROOF_REQUEST_TYPE =
    "ProofRequest(uint256 id,Requirements requirements,string imageUrl,Input input,Offer offer)";

PROOF_REQUEST_TYPEHASH

bytes32 constant PROOF_REQUEST_TYPEHASH = keccak256(
    abi.encodePacked(
        PROOF_REQUEST_TYPE,
        CallbackLibrary.CALLBACK_TYPE,
        InputLibrary.INPUT_TYPE,
        OfferLibrary.OFFER_TYPE,
        PredicateLibrary.PREDICATE_TYPE,
        RequirementsLibrary.REQUIREMENTS_TYPE
    )
);

Functions

eip712Digest

Computes the EIP-712 digest for the given proof request.

function eip712Digest(ProofRequest memory request) internal pure returns (bytes32);
Parameters
NameTypeDescription
requestProofRequestThe proof request to compute the digest for.
Returns
NameTypeDescription
<none>bytes32The EIP-712 digest of the proof request.

verifyClientSignature

Verifies the client's signature over the proof request.

function verifyClientSignature(ProofRequest calldata, bytes32 structHash, address addr, bytes calldata signature)
    internal
    pure
    returns (bytes32);
Parameters
NameTypeDescription
<none>ProofRequest
structHashbytes32The EIP-712 struct hash of the proof request.
addraddressThe address of the client.
signaturebytesThe signature to validate.
Returns
NameTypeDescription
<none>bytes32The struct hash if the signature is valid.

extractProverSignature

Extracts the prover's signature for the given proof request.

function extractProverSignature(ProofRequest calldata, bytes32 structHash, bytes calldata proverSignature)
    internal
    pure
    returns (address);
Parameters
NameTypeDescription
<none>ProofRequest
structHashbytes32The EIP-712 struct hash of the proof request.
proverSignaturebytesThe prover's signature to extract.
Returns
NameTypeDescription
<none>addressThe address of the prover.

validateForPriceRequest

Validates the proof request with the intention for it to be priced. Does not check if the request is already locked or fulfilled, but does check if it has expired.

function validateForPriceRequest(ProofRequest calldata request)
    internal
    view
    returns (uint64 lockDeadline1, uint64 deadline1);
Parameters
NameTypeDescription
requestProofRequestThe proof request to validate.
Returns
NameTypeDescription
lockDeadline1uint64The deadline for when a lock expires for the request.
deadline1uint64The deadline for the request as a whole.

validateForLockRequest

Validates the proof request with the intention for it to be locked. Checks that the request is not already locked or fulfilled.

function validateForLockRequest(
    ProofRequest calldata request,
    mapping(address => Account) storage accounts,
    address client,
    uint32 idx
) internal view returns (uint64 lockDeadline1, uint64 deadline1);
Parameters
NameTypeDescription
requestProofRequestThe proof request to validate.
accountsmapping(address => Account)The mapping of accounts.
clientaddressThe address of the client.
idxuint32The index of the request.
Returns
NameTypeDescription
lockDeadline1uint64The deadline for when a lock expires for the request.
deadline1uint64The deadline for the request as a whole.