# Nexus Enigma SDK

End-to-end encrypted data ingestion for Nexus Gateway.

## Installation

```bash
pip install nexus-enigma
```

## Quick Start

### HTTP Client (Sender Apps)

```python
from nexus_enigma import NexusEnigma

client = NexusEnigma(
    app_key="your_app_key",
    master_secret="BASE64_MASTER_SECRET_FROM_NEXUS",
    base_url="https://your-nexus-server.com"
)

# Send encrypted sensor data
result = client.send({
    "temperature": 25.5,
    "humidity": 60,
    "sensor_id": "temp_001"
})

print(result)  # {"message": "Data accepted", "message_ids": [...]}
```

### MQTT Client (IoT Devices)

```python
from nexus_enigma import MQTTEnigmaClient

client = MQTTEnigmaClient(
    host="your-mqtt-broker.com",
    port=1883,
    master_secret="BASE64_MASTER_SECRET_FROM_NEXUS",
    source_id=1  # Your MQTT source ID from Nexus
)

# Connect and publish
client.connect()
client.publish("sensors/temperature", {
    "temp": 25.5,
    "humidity": 60
})
client.disconnect()
```

## Features

- **AES-256-GCM Encryption** - Military-grade authenticated encryption
- **HKDF Key Derivation** - Daily rotating keys for forward secrecy
- **Automatic Key Management** - Keys derived from master secret automatically
- **HTTP & MQTT Support** - Choose your transport protocol
- **Zero Configuration Encryption** - Just provide your master secret

## Security

All data is encrypted **before** leaving your device:

1. Daily keys are derived using HKDF-SHA256
2. Each message gets a unique random nonce
3. AES-256-GCM provides encryption + integrity verification
4. Only your Nexus server can decrypt the data

## Requirements

- Python 3.8+
- `cryptography>=3.4.0`
- `requests>=2.25.0`
- `paho-mqtt>=1.6.0`

## License

MIT License - see [LICENSE](LICENSE) for details.
