CommitReveal
Inherits: ICommitReveal
Title: CommitReveal
Author: David Dada <daveproxy80@gmail.com> (https://github.com/dadadave80)
Stateless Diamond facet implementing a generic commit–reveal primitive — a building block for sealed-bid auctions, commit–reveal voting, and MEV mitigation. No ZK / circuits.
All logic lives in CommitRevealLib. Permissionless: anyone may commit and reveal their own. The commitment binds the committer's address, so reveal is front-run-proof.
Notes:
- lattice-version: 0.1.0
- lattice-source: Lattice original
Functions
commit
Records a commitment hash. The hash should be computeCommitment(msg.sender, data, salt).
function commit(bytes32 commitment) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| commitment | bytes32 | The commitment hash to record. |
reveal
Reveals data + salt for a commitment previously made by msg.sender.
Recomputes keccak256(abi.encode(msg.sender, data, salt)) and marks that commitment revealed.
function reveal(bytes calldata data, bytes32 salt) external virtual;Parameters
| Name | Type | Description |
|---|---|---|
| data | bytes | The committed data. |
| salt | bytes32 | The blinding salt used in the commitment. |
commitmentInfo
Returns the record for commitment.
function commitmentInfo(bytes32 commitment) external view virtual returns (Commitment memory);Parameters
| Name | Type | Description |
|---|---|---|
| commitment | bytes32 | The commitment hash to query. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | Commitment | The commitment record (zero committedAt if never committed). |
isRevealed
Returns whether commitment has been revealed.
function isRevealed(bytes32 commitment) external view virtual returns (bool);Parameters
| Name | Type | Description |
|---|---|---|
| commitment | bytes32 | The commitment hash to query. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bool |
computeCommitment
Computes the commitment hash for (committer, data, salt).
keccak256(abi.encode(committer, data, salt)). Use off-chain (or in a consuming contract)
to build the commit hash consistently with reveal.
function computeCommitment(address committer, bytes calldata data, bytes32 salt)
external
pure
virtual
returns (bytes32);Parameters
| Name | Type | Description |
|---|---|---|
| committer | address | The address to bind into the commitment. |
| data | bytes | The data to commit. |
| salt | bytes32 | The blinding salt. |
Returns
| Name | Type | Description |
|---|---|---|
| <none> | bytes32 | The commitment hash. |
exportSelectors
ERC-8153 selector export: this facet's cuttable selectors, tightly packed (4 bytes each).
Excludes exportSelectors() itself (0x0ef22643) - it is never cut into a diamond. Order matches
forge inspect CommitReveal methodIdentifiers (alphabetical by signature); kept in exact parity by
ExportSelectorsParityTest. Chunks:
commit(bytes32) 0xf14fcbc8
commitmentInfo(bytes32) 0xfa3f7e8c
computeCommitment(address,bytes,bytes32) 0xc15f7d29
isRevealed(bytes32) 0xd321c77a
reveal(bytes,bytes32) 0xfa7fe7a0
function exportSelectors() external pure virtual returns (bytes memory selectors);Returns
| Name | Type | Description |
|---|---|---|
| selectors | bytes |