pragma solidity ^0.8.13; contract BloomReceiptAttestor { uint256[8] private bloom; event ReceiptAdded(bytes32 indexed receiptId); function _position(bytes32 receiptId, uint256 salt) private view returns (uint256) { return uint256(keccak256(abi.encodePacked(block.chainid, receiptId, salt))) & 2047; } function add(bytes32 receiptId) external { for (uint256 i = 0; i < 3; i++) { uint256 p = _position(receiptId, i); bloom[p >> 8] |= uint256(1) << uint8(p & 255); } emit ReceiptAdded(receiptId); } function contains(bytes32 receiptId) external view returns (bool) { for (uint256 i = 0; i < 3; i++) { uint256 p = _position(receiptId, i); if ((bloom[p >> 8] & (uint256(1) << uint8(p & 255))) == 0) return false; } return true; } }