// SPDX-License-Identifier: MIT pragma solidity ^0.8.24; contract RustVitalAudit { struct Record { bytes32 cidHash; bytes32 proofHash; uint256 attestations; address submitter; uint256 timestamp; } address public owner; mapping(bytes32 => Record) public records; mapping(bytes32 => mapping(address => bool)) public attested; event RecordAnchored(bytes32 indexed recordId, bytes32 cidHash, bytes32 proofHash, uint256 attestations, address submitter); event Attested(bytes32 indexed recordId, address indexed hospital, bytes32 attestationHash); modifier onlyOwner() { require(msg.sender == owner, "not owner"); _; } constructor() { owner = msg.sender; } function anchorRecord(bytes32 recordId, bytes32 cidHash, bytes32 proofHash) external { require(records[recordId].timestamp == 0, "already anchored"); records[recordId] = Record({ cidHash: cidHash, proofHash: proofHash, attestations: 0, submitter: msg.sender, timestamp: block.timestamp }); emit RecordAnchored(recordId, cidHash, proofHash, 0, msg.sender); } function attest(bytes32 recordId) external { Record storage record = records[recordId]; require(record.timestamp != 0, "unknown record"); require(!attested[recordId][msg.sender], "already attested"); attested[recordId][msg.sender] = true; record.attestations += 1; bytes32 attestationHash = keccak256(abi.encodePacked(recordId, msg.sender, record.cidHash, record.proofHash, block.timestamp)); emit Attested(recordId, msg.sender, attestationHash); } }