# Module: hardware_service ## Purpose Collects hardware fingerprint information (CPU, GPU, RAM, drive serial) from the host machine for use in hardware-bound encryption key derivation. ## Public Interface | Function | Signature | Returns | |----------|-----------|---------| | `get_hardware_info` | `() -> str` | Formatted string: `CPU: {cpu}. GPU: {gpu}. Memory: {memory}. DriveSerial: {drive_serial}` | ## Internal Logic - Detects OS via `os.name` (`nt` for Windows, else Linux) - **Windows**: PowerShell commands to query `Win32_Processor`, `Win32_VideoController`, `Win32_OperatingSystem`, disk serial - **Linux**: `lscpu`, `lspci`, `free`, `/sys/block/sda/device/` serial - Parses multi-line output: first line = CPU, second = GPU, second-to-last = memory, last = drive serial - Handles multiple GPUs by taking first GPU and last two lines for memory/drive ## Dependencies - `os`, `subprocess` (stdlib) ## Consumers api_client (used in `load_bytes` to generate hardware string for encryption) ## Data Models None. ## Configuration None. ## External Integrations Executes OS-level shell commands to query hardware. ## Security The hardware fingerprint is used as input to `Security.get_hw_hash()` and subsequently `Security.get_api_encryption_key()`, binding API encryption to the specific machine. ## Tests None.