# sathvik-srivathsan/quantcomm architecture

> Architecture diagram of the GitHub repository sathvik-srivathsan/quantcomm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-11). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/sathvik-srivathsan/quantcomm
- Repository: https://github.com/sathvik-srivathsan/quantcomm

## Overview

QuantComm is a portable C protocol implementation with a Python trust-anchor service and C cryptographic adapters. Its visible principal workflow is a device handshake: the server parses and authenticates a message, applies replay and floor gates, then performs key encapsulation and emits a response. Separate core modules provide policy, risk, optimization, manifests, and persistence. The README also names gateway, simulator, and analysis capabilities, but their directories are absent from this tree, so they are not represented. Relationships for unsampled modules are limited to documented or indexed references.

Main entry points: [`server/srv_crypto.c`](https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/srv_crypto.c) (Crypto Bridge), [`crypto/qc_hmac.c`](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_hmac.c) (HMAC Adapter), [`core/qc_server.c`](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_server.c) (Handshake Pipeline), [`crypto/qc_zeroize.h`](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_zeroize.h) (Secret Wiping)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_protocol["Protocol Core"]
  node_handshake["Handshake Pipeline<br/>[qc_server.c]"]
  node_wire["Wire Codec<br/>[qc_codec.c]"]
  node_frame["Frame Handling<br/>[qc_frame.c]"]
  node_epoch["Epoch Management<br/>[qc_epoch.c]"]
  node_replay[("Replay Cache<br/>[qc_replay.c]")]
end

subgraph group_policy["Policy And Control"]
  node_manifest["Manifest Validation<br/>[qc_manifest.c]"]
  node_floor["Floor Solver<br/>[qc_floor.c]"]
  node_risk["Risk Assessment<br/>[qc_risk.c]"]
  node_energy["Energy Accounting<br/>[qc_energy.c]"]
  node_optimizer["Action Optimizer<br/>[qc_opt.c]"]
  node_governance["Policy Governance<br/>[qc_gov.c]"]
  node_batch["Batch Processing<br/>[qc_batch.c]"]
end

subgraph group_state["State And Storage"]
  node_state[("Protocol State<br/>[qc_state.c]")]
  node_store[("Encrypted Store<br/>[qc_store.c]")]
  node_manifest_persist[("Manifest Persistence")]
  node_buffers["Buffer Management<br/>[qc_buf.c]"]
end

subgraph group_crypto["Cryptographic Adapters"]
  node_kem["KEM Adapter<br/>[qc_kem.c]"]
  node_signatures["Signature Adapter<br/>[qc_dsa.c]"]
  node_aead["AEAD Adapter<br/>[qc_aead.c]"]
  node_key_derivation["HKDF Adapter<br/>[qc_hkdf.c]"]
  node_mac["HMAC Adapter<br/>[qc_hmac.c]"]
  node_hash["SHA-256 Adapter<br/>[qc_sha256.c]"]
  node_random["DRBG<br/>[qc_drbg.c]"]
  node_zeroize["Secret Wiping<br/>[qc_zeroize.h]"]
end

subgraph group_service["Trust Service"]
  node_python_service["Python Service<br/>[__init__.py]"]
  node_registry[("Session Registry<br/>[registry.py]")]
  node_audit["Audit Logging<br/>[audit.py]"]
  node_crypto_bridge["Crypto Bridge<br/>[srv_crypto.c]"]
end

node_device(("Device"))

node_device -.->|"submits handshake"| node_handshake
node_handshake -->|"parses messages"| node_wire
node_handshake -->|"verifies HMAC"| node_mac
node_handshake -.->|"checks replay"| node_replay
node_handshake -.->|"checks floor"| node_floor
node_handshake -.->|"decapsulates"| node_kem
node_manifest -->|"uses signatures"| node_signatures
node_energy -->|"uses floor rules"| node_floor
node_energy -->|"uses batching"| node_batch
node_optimizer -->|"uses feasibility"| node_floor
node_governance -->|"uses HMAC"| node_mac
node_risk -->|"uses HMAC"| node_mac
node_risk -->|"uses hashing"| node_hash
node_store -->|"encrypts data"| node_aead
node_store -->|"derives keys"| node_key_derivation
node_store -->|"uses HMAC"| node_mac
node_random -->|"generates with"| node_mac
node_random -->|"wipes secrets"| node_zeroize
node_mac -->|"uses SHA-256"| node_hash
node_signatures -->|"wipes secrets"| node_zeroize
node_kem -->|"wipes secrets"| node_zeroize
node_crypto_bridge -->|"invokes adapter"| node_kem
node_crypto_bridge -->|"invokes adapter"| node_signatures
node_crypto_bridge -->|"invokes adapter"| node_aead
node_crypto_bridge -->|"invokes adapter"| node_key_derivation
node_crypto_bridge -->|"invokes adapter"| node_mac
node_crypto_bridge -->|"invokes adapter"| node_hash
node_crypto_bridge -->|"invokes adapter"| node_random
node_crypto_bridge -->|"uses wipe"| node_zeroize
node_python_service -->|"loads module"| node_registry
node_python_service -->|"loads module"| node_audit

click node_handshake "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_server.c"
click node_wire "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_codec.c"
click node_frame "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_frame.c"
click node_epoch "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_epoch.c"
click node_replay "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_replay.c"
click node_manifest "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_manifest.c"
click node_floor "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_floor.c"
click node_risk "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_risk.c"
click node_energy "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_energy.c"
click node_optimizer "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_opt.c"
click node_governance "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_gov.c"
click node_batch "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_batch.c"
click node_state "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_state.c"
click node_store "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_store.c"
click node_manifest_persist "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_manifest_persist.c"
click node_buffers "https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_buf.c"
click node_kem "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_kem.c"
click node_signatures "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_dsa.c"
click node_aead "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_aead.c"
click node_key_derivation "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_hkdf.c"
click node_mac "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_hmac.c"
click node_hash "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_sha256.c"
click node_random "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_drbg.c"
click node_zeroize "https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_zeroize.h"
click node_python_service "https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/qcsrv/__init__.py"
click node_registry "https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/qcsrv/registry.py"
click node_audit "https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/qcsrv/audit.py"
click node_crypto_bridge "https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/srv_crypto.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_handshake,node_wire,node_frame,node_epoch,node_replay toneBlue
class node_manifest,node_floor,node_risk,node_energy,node_optimizer,node_governance,node_batch toneAmber
class node_state,node_store,node_manifest_persist,node_buffers toneMint
class node_kem,node_signatures,node_aead,node_key_derivation,node_mac,node_hash,node_random,node_zeroize toneRose
class node_python_service,node_registry,node_audit,node_crypto_bridge,node_device toneIndigo
```

## Components

### Protocol Core

- [Handshake Pipeline](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_server.c): `core/qc_server.c`
- [Wire Codec](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_codec.c): `core/qc_codec.c`
- [Frame Handling](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_frame.c): `core/qc_frame.c`
- [Epoch Management](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_epoch.c): `core/qc_epoch.c`
- [Replay Cache](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_replay.c): `core/qc_replay.c`

### Policy And Control

- [Manifest Validation](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_manifest.c): `core/qc_manifest.c`
- [Floor Solver](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_floor.c): `core/qc_floor.c`
- [Risk Assessment](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_risk.c): `core/qc_risk.c`
- [Energy Accounting](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_energy.c): `core/qc_energy.c`
- [Action Optimizer](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_opt.c): `core/qc_opt.c`
- [Policy Governance](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_gov.c): `core/qc_gov.c`
- [Batch Processing](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_batch.c): `core/qc_batch.c`

### State And Storage

- [Protocol State](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_state.c): `core/qc_state.c`
- [Encrypted Store](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_store.c): `core/qc_store.c`
- [Manifest Persistence](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_manifest_persist.c): `core/qc_manifest_persist.c`
- [Buffer Management](https://github.com/sathvik-srivathsan/quantcomm/blob/main/core/qc_buf.c): `core/qc_buf.c`

### Cryptographic Adapters

- [KEM Adapter](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_kem.c): `crypto/qc_kem.c`
- [Signature Adapter](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_dsa.c): `crypto/qc_dsa.c`
- [AEAD Adapter](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_aead.c): `crypto/qc_aead.c`
- [HKDF Adapter](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_hkdf.c): `crypto/qc_hkdf.c`
- [HMAC Adapter](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_hmac.c): `crypto/qc_hmac.c`
- [SHA-256 Adapter](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_sha256.c): `crypto/qc_sha256.c`
- [DRBG](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_drbg.c): `crypto/qc_drbg.c`
- [Secret Wiping](https://github.com/sathvik-srivathsan/quantcomm/blob/main/crypto/qc_zeroize.h): `crypto/qc_zeroize.h`

### Trust Service

- [Python Service](https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/qcsrv/__init__.py): `server/qcsrv/__init__.py`
- [Session Registry](https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/qcsrv/registry.py): `server/qcsrv/registry.py`
- [Audit Logging](https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/qcsrv/audit.py): `server/qcsrv/audit.py`
- [Crypto Bridge](https://github.com/sathvik-srivathsan/quantcomm/blob/main/server/srv_crypto.c): `server/srv_crypto.c`

### Other components

- **Device**

## Connections

- Device → Handshake Pipeline: submits handshake (evidence: `README.md`)
- Handshake Pipeline → Wire Codec: parses messages (evidence: `core/qc_server.c`)
- Handshake Pipeline → HMAC Adapter: verifies HMAC (evidence: `core/qc_server.c`)
- Handshake Pipeline → Replay Cache: checks replay
- Handshake Pipeline → Floor Solver: checks floor
- Handshake Pipeline → KEM Adapter: decapsulates
- Manifest Validation → Signature Adapter: uses signatures
- Energy Accounting → Floor Solver: uses floor rules (evidence: `core/qc_energy.c`)
- Energy Accounting → Batch Processing: uses batching (evidence: `core/qc_energy.c`)
- Action Optimizer → Floor Solver: uses feasibility
- Policy Governance → HMAC Adapter: uses HMAC (evidence: `core/qc_gov.c`)
- Risk Assessment → HMAC Adapter: uses HMAC (evidence: `core/qc_risk.c`)
- Risk Assessment → SHA-256 Adapter: uses hashing (evidence: `core/qc_risk.c`)
- Encrypted Store → AEAD Adapter: encrypts data (evidence: `core/qc_store.c`)
- Encrypted Store → HKDF Adapter: derives keys (evidence: `core/qc_store.c`)
- Encrypted Store → HMAC Adapter: uses HMAC (evidence: `core/qc_store.c`)
- DRBG → HMAC Adapter: generates with (evidence: `crypto/qc_drbg.c`)
- DRBG → Secret Wiping: wipes secrets (evidence: `crypto/qc_drbg.c`)
- HMAC Adapter → SHA-256 Adapter: uses SHA-256
- Signature Adapter → Secret Wiping: wipes secrets (evidence: `crypto/qc_dsa.c`)
- KEM Adapter → Secret Wiping: wipes secrets (evidence: `crypto/qc_kem.c`)
- Crypto Bridge → KEM Adapter: invokes adapter (evidence: `server/srv_crypto.c`)
- Crypto Bridge → Signature Adapter: invokes adapter (evidence: `server/srv_crypto.c`)
- Crypto Bridge → AEAD Adapter: invokes adapter (evidence: `server/srv_crypto.c`)
- Crypto Bridge → HKDF Adapter: invokes adapter (evidence: `server/srv_crypto.c`)
- Crypto Bridge → HMAC Adapter: invokes adapter (evidence: `server/srv_crypto.c`)
- Crypto Bridge → SHA-256 Adapter: invokes adapter (evidence: `server/srv_crypto.c`)
- Crypto Bridge → DRBG: invokes adapter (evidence: `server/srv_crypto.c`)
- Crypto Bridge → Secret Wiping: uses wipe (evidence: `server/srv_crypto.c`)
- Python Service → Session Registry: loads module (evidence: `server/qcsrv/__init__.py`)
- Python Service → Audit Logging: loads module (evidence: `server/qcsrv/__init__.py`)
