CommitRevealReceipt
commitrevealreceipt · receipt-attestation · 512 B runtime · registry-info
scores
- usefulness: 70
- safety: 85
- liveness: 90
- authenticity: 80
- extensibility: 75
- bytecodeDiscipline: 95
- practical: 80
source
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.13;
contract CommitRevealReceipt {
mapping(address => bytes32) public commitments;
event Revealed(address indexed committer, bytes32 receiptHash);
function commit(bytes32 receiptHash, bytes32 secret) external {
commitments[msg.sender] = keccak256(abi.encodePacked(uint256(uint160(address(this))), secret, receiptHash));
}
function reveal(bytes32 receiptHash, bytes32 secret) external {
bytes32 commitment = commitments[msg.sender];
require(commitment != bytes32(0));
require(keccak256(abi.encodePacked(uint256(uint160(address(this))), secret, receiptHash)) == commitment);
delete commitments[msg.sender];
emit Revealed(msg.sender, receiptHash);
}
}published
published on mainnet · 0x53a3dA0CB7eAc341a5FB21ab5850486096763798 · tx 0xdb370059f1b99f61… · base (8453) · mainnet · source as deployed
published on testnet · 0xB04995Cd1e1c6e642a9C81Fb23E0c5B19cFFF855 · tx 0x6e2a8efe36138650… · base (84532) · testnet · source as deployed