// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.5.2; import "./Ownable.sol"; contract SelladorFederalTitulos is Ownable { address private _owner; struct Item { uint256 timestamp; uint256 blockNumber; } event ItemAdded( bytes32 indexed itemId, uint256 timestamp, uint256 blockNumber ); mapping(bytes32 => Item) public items; constructor() public Ownable() { } function put(bytes32 key) public onlyOwner { if (items[key].timestamp == 0) { items[key] = Item(block.timestamp, block.number); emit ItemAdded(key, block.timestamp, block.number); } } function exists(bytes32 key) public view returns (bool) { return items[key].timestamp > 0; } function get(bytes32 key) public view returns (uint256 timestamp, uint256 blockNumber) { Item storage item = items[key]; return (item.timestamp, item.blockNumber); } function verify(bytes32 leafNode, bytes32[] memory proof) public view returns (bool) { bytes32 currentHash = leafNode; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; if (currentHash < proofElement) { currentHash = _hash(abi.encodePacked(currentHash, proofElement)); } else { currentHash = _hash(abi.encodePacked(proofElement, currentHash)); } } return exists(currentHash); } function _hash(bytes memory packedData) private pure returns (bytes32) { return keccak256(packedData); } }