Skip to content

PredicateLibrary

State Variables

PREDICATE_TYPE

string constant PREDICATE_TYPE = "Predicate(uint8 predicateType,bytes data)";

PREDICATE_TYPEHASH

bytes32 constant PREDICATE_TYPEHASH = keccak256(bytes(PREDICATE_TYPE));

Functions

createDigestMatchPredicate

Creates a digest match predicate.

function createDigestMatchPredicate(bytes32 imageId, bytes32 hash) internal pure returns (Predicate memory);
Parameters
NameTypeDescription
imageIdbytes32
hashbytes32The hash to match.
Returns
NameTypeDescription
<none>PredicateA Predicate struct with type DigestMatch and the provided hash.

createPrefixMatchPredicate

Creates a prefix match predicate.

function createPrefixMatchPredicate(bytes32 imageId, bytes memory prefix) internal pure returns (Predicate memory);
Parameters
NameTypeDescription
imageIdbytes32
prefixbytesThe prefix to match.
Returns
NameTypeDescription
<none>PredicateA Predicate struct with type PrefixMatch and the provided prefix.

createClaimDigestMatchPredicate

Creates a claim digest match predicate.

function createClaimDigestMatchPredicate(bytes32 claimDigest) internal pure returns (Predicate memory);
Parameters
NameTypeDescription
claimDigestbytes32The claimDigest to match.
Returns
NameTypeDescription
<none>PredicateA Predicate struct with type ClaimDigestMatch and the provided claimDigest.

eval

Evaluates the predicate against the image ID and journal.

If the predicate is of type ClaimDigestMatch and image ID and journal are not available, use the evaluation function with the claim digest instead.

function eval(Predicate memory predicate, bytes32 imageId, bytes memory journal) internal pure returns (bool);
Parameters
NameTypeDescription
predicatePredicateThe predicate to evaluate.
imageIdbytes32Image ID to use for evaluation.
journalbytesThe journal to evaluate against.
Returns
NameTypeDescription
<none>boolTrue if the predicate is satisfied, false otherwise.

eval

Evaluates the predicate against the claim digest.

This function should be used when the predicate is of type ClaimDigestMatch and the image ID and journal are not available.

function eval(Predicate memory predicate, bytes32 claimDigest) internal pure returns (bool);
Parameters
NameTypeDescription
predicatePredicateThe predicate to evaluate.
claimDigestbytes32Claim digest to use for evaluation.
Returns
NameTypeDescription
<none>boolTrue if the predicate is satisfied, false otherwise.

startsWith

Checks if the journal starts with the given prefix.

function startsWith(bytes memory journal, bytes memory prefix) internal pure returns (bool);
Parameters
NameTypeDescription
journalbytesThe journal to check.
prefixbytesThe prefix to check for.
Returns
NameTypeDescription
<none>boolTrue if the journal starts with the prefix, false otherwise.

eip712Digest

Computes the EIP-712 digest for the given predicate.

function eip712Digest(Predicate memory predicate) internal pure returns (bytes32);
Parameters
NameTypeDescription
predicatePredicateThe predicate to compute the digest for.
Returns
NameTypeDescription
<none>bytes32The EIP-712 digest of the predicate.