// SPDX-License-Identifier: MIT pragma solidity 0.8.28; /// @notice Owner-authorized, per-device batch commitments. Verify membership off-chain. contract BatchAnchor { address public immutable owner; mapping(address => bool) public active; mapping(address => uint64) public latestBatch; mapping(address => bytes32) public latestRoot; error NotOwner(); error InvalidDevice(); error Unauthorized(); error InvalidBatch(); error EmptyRoot(); event BatchCommitted(address indexed device, uint64 indexed batch, bytes32 root); constructor() { owner = msg.sender; } function setDevice(address device, bool enabled) external { if (msg.sender != owner) revert NotOwner(); if (device == address(0)) revert InvalidDevice(); active[device] = enabled; } function commit(uint64 batch, bytes32 root) external { if (!active[msg.sender]) revert Unauthorized(); if (batch <= latestBatch[msg.sender]) revert InvalidBatch(); if (root == bytes32(0)) revert EmptyRoot(); latestBatch[msg.sender] = batch; latestRoot[msg.sender] = root; emit BatchCommitted(msg.sender, batch, root); } }