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);
Name | Type | Description |
---|---|---|
imageId | bytes32 | |
hash | bytes32 | The hash to match. |
Name | Type | Description |
---|---|---|
<none> | Predicate | A 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);
Name | Type | Description |
---|---|---|
imageId | bytes32 | |
prefix | bytes | The prefix to match. |
Name | Type | Description |
---|---|---|
<none> | Predicate | A 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);
Name | Type | Description |
---|---|---|
claimDigest | bytes32 | The claimDigest to match. |
Name | Type | Description |
---|---|---|
<none> | Predicate | A 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);
Name | Type | Description |
---|---|---|
predicate | Predicate | The predicate to evaluate. |
imageId | bytes32 | Image ID to use for evaluation. |
journal | bytes | The journal to evaluate against. |
Name | Type | Description |
---|---|---|
<none> | bool | True 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);
Name | Type | Description |
---|---|---|
predicate | Predicate | The predicate to evaluate. |
claimDigest | bytes32 | Claim digest to use for evaluation. |
Name | Type | Description |
---|---|---|
<none> | bool | True 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);
Name | Type | Description |
---|---|---|
journal | bytes | The journal to check. |
prefix | bytes | The prefix to check for. |
Name | Type | Description |
---|---|---|
<none> | bool | True 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);
Name | Type | Description |
---|---|---|
predicate | Predicate | The predicate to compute the digest for. |
Name | Type | Description |
---|---|---|
<none> | bytes32 | The EIP-712 digest of the predicate. |