WitnessConsumer

Git Source (opens in a new tab)

Inherits: IWitnessConsumer

Author: sina.eth

Utility mixin for contracts that want to consume provenance.

See IWitnessConsumer.sol for more information.

State Variables

WITNESS

The Witness contract that this contract uses to verify provenance.

IWitness public immutable WITNESS;

Functions

constructor

Immutably sets the Witness address.

constructor(IWitness _witness);

Parameters

NameTypeDescription
_witnessIWitnessThe address that's used as the Witness 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 Witness 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.

verifyProof

Checks provenance of a leaf via Witness.

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

function verifyProof(Proof calldata proof) public view virtual;

Parameters

NameTypeDescription
proofProofThe proof to be verified.

safeVerifyProof

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

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

function safeVerifyProof(Proof calldata proof) public view virtual returns (bool);