One-Shot Hash-Capsule Receipt
one-shot-hash-capsule-receipt · receipt-attestation · 497 B runtime · registry-info
scores
- usefulness: 20
- safety: 40
- liveness: 100
- authenticity: 30
- extensibility: 25
- bytecodeDiscipline: 20
- practical: 38
source
pragma solidity ^0.8.13;
contract HashCapsule {
uint256 constant DEADLINE = 4102444800; // 2100-01-01 UTC
bytes32 private commitment;
event Revealed(bytes data);
function commit(bytes32 c) external {
if (commitment != bytes32(0) || c == bytes32(0)) revert();
commitment = c;
}
function reveal(bytes calldata data) external {
if (block.timestamp <= DEADLINE) revert();
if (keccak256(data) != commitment) revert();
emit Revealed(data);
}
}