Skip to main content

ChronicleProvenanceConsumer

Git Source

Author: sina.eth

Utility mixin for contracts that want to consume provenance.

See the Chronicle contract for more information.

State Variables​

CHRONICLE​

The Chronicle contract that this contract uses to verify provenance.

Chronicle public immutable CHRONICLE;

Functions​

constructor​

Immutably sets the Chronicle address.

constructor(Chronicle _chronicle);

Parameters

NameTypeDescription
_chronicleChronicleThe address that's used as the Chronicle to verify provenance against.

getProvenanceHash​

Maps the given bridgeData to its provenance hash representation for verification.

A default implementation is given here, but it may be overridden by subclasses. Provenance hash refers to the hash that Chronicle uses to verify the provenance of some data payload. Intuitively a provenance hash may be a hard-link from the bridgeData, like a hash, or perhaps something more sophisticated for certain usecases.

function getProvenanceHash(bytes calldata data) public view virtual returns (bytes32);

Parameters

NameTypeDescription
databytesThe data to be mapped to a provenance hash.

Returns

NameTypeDescription
<none>bytes32hash The provenanceHash corresponding to the data.

verifyProvenance​

Checks provenance of a leaf via Chronicle.

This method will throw if the proof is invalid, with a custom error describing how the verification failed.

function verifyProvenance(
uint256 index,
bytes32 leaf,
bytes32[] calldata leftProof,
bytes32[] calldata rightProof,
bytes32 targetRoot
) public view;

Parameters

NameTypeDescription
indexuint256The index of the leaf to be verified in the tree.
leafbytes32The leaf to be verified.
leftProofbytes32[]The left range of the proof.
rightProofbytes32[]The right range of the proof.
targetRootbytes32The root of the tree the proof is being verified against.

safeVerifyProof​

Checks provenance of a leaf via Chronicle, returning a boolean instead of throwing for invalid proofs.

This method is the same as verifyProvenance, except it returns false instead of throwing.

function safeVerifyProof(
uint256 index,
bytes32 leaf,
bytes32[] calldata leftProof,
bytes32[] calldata rightProof,
bytes32 targetRoot
) public view returns (bool);