Skip to content

Cryptographic Security and Provisioning

GiZano edited this page Aug 5, 2026 · 2 revisions

Cryptographic Security & Provisioning

QuakeGuard implements a Zero-Trust security model for its IoT edge nodes.

Cryptographic Identity (ECDSA)

Upon its first boot, the ESP32-C3 uses mbedtls to generate a unique ECDSA key pair using the NIST P-256 curve (secp256r1).

  • Private Key: Stored permanently in Non-Volatile Storage (NVS) to sign outgoing telemetry.
  • Public Key: Extracted in DER format, acting as the unforgeable cryptographic identity of the sensor.

Automated Provisioning Handshake

  1. The device sends a POST to /devices/register with its public_key_hex, MAC address, coordinates, and ENROLLMENT_TOKEN.
  2. The backend validates the token and uses PostGIS (ST_Contains) to assign the sensor to the smallest containing geographic polygon.
  3. A unique sensor_id is returned and saved to NVS.

Payload Authentication

Telemetry payloads (value:timestamp) are hashed via SHA-256 and signed with the private key. The validate_iot_payload dependency pipeline enforces:

  1. API Key Verification: Constant-time hmac.compare_digest check.
  2. Sensor Status: Verifies the sensor ID is active.
  3. Anti-Replay Protection: Rejects payloads older than a 300-second threshold.
  4. Signature Verification: Uses the Python cryptography library to verify the ECDSA signature against the device's public key.

Clone this wiki locally