# zkcompiler/zkc architecture

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

- Interactive diagram: https://gitdiagram.com/zkcompiler/zkc
- Repository: https://github.com/zkcompiler/zkc

## Overview

zkc is a Lean-based compiler for zero-knowledge protocols. A programmer describes roles, private values, messages, and acceptance checks in the source language; the active documented workflow follows selected source entries through frontend emission, Core admission, role projection, and formal certificates. Core admission covers mixed function/protocol programs, header checking, function summaries, and loop bounds; checked transformations preserve function behavior under input requirements. The source excerpts chiefly cover auxiliary replay and checking scripts, so the compiler relationships below rely on README statements rather than inspected implementation calls.

Main entry points: [`lean/compiler/Zkc/Core/Admission/Admission.lean`](https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Admission.lean) (Core admission), [`lean/compiler/Zkc/Core/Admission/Programs.lean`](https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Programs.lean) (Mixed definitions), [`language`](https://github.com/zkcompiler/zkc/tree/main/language) (zkc programs), [`lean/compiler/Zkc/Frontend/Emit`](https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Frontend/Emit) (Frontend emission)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_language["Source language"]
  node_source["zkc programs"]
end

subgraph group_frontend["Compiler frontend"]
  node_frontend_emit["Frontend emission"]
end

subgraph group_core["Protocol Core"]
  node_mixed_defs["Mixed definitions<br/>[Programs.lean]"]
  node_header_check["Header checking<br/>[Check.lean]"]
  node_function_summaries["Function summaries<br/>[Theorems.lean]"]
  node_admission["Core admission<br/>[Admission.lean]"]
  node_projection["Role projection"]
  node_loop_bounds["Loop bounds"]
  node_transformation["Checked transformation"]
  node_meaning["Core meaning"]
end

subgraph group_formal["Formal results"]
  node_certificates["Formal certificates"]
  node_proofs["Core proofs"]
end

node_programmer(("Protocol author"))

node_programmer -->|"writes"| node_source
node_source -->|"emits"| node_frontend_emit
node_frontend_emit -->|"admits"| node_admission
node_admission -->|"projects roles"| node_projection
node_admission -->|"feeds certificates"| node_certificates
node_projection -->|"feeds certificates"| node_certificates
node_mixed_defs -->|"checks headers"| node_header_check
node_mixed_defs -->|"proves summaries"| node_function_summaries
node_admission -->|"records bounds"| node_loop_bounds
node_transformation -->|"preserves behavior"| node_meaning
node_meaning -->|"supports proofs"| node_proofs

click node_source "https://github.com/zkcompiler/zkc/tree/main/language"
click node_frontend_emit "https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Frontend/Emit"
click node_mixed_defs "https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Programs.lean"
click node_header_check "https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Check.lean"
click node_function_summaries "https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Theorems.lean"
click node_admission "https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Admission.lean"
click node_projection "https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Projection"
click node_loop_bounds "https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Admission"
click node_transformation "https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Transform"
click node_meaning "https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Meaning"
click node_certificates "https://github.com/zkcompiler/zkc/tree/main/lean/formal/Zkc/Formal/Interactive"
click node_proofs "https://github.com/zkcompiler/zkc/tree/main/lean/formal/Zkc/Formal"

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_source toneBlue
class node_frontend_emit toneAmber
class node_mixed_defs,node_header_check,node_function_summaries,node_admission,node_projection,node_loop_bounds,node_transformation,node_meaning toneMint
class node_certificates,node_proofs toneRose
class node_programmer toneIndigo
```

## Components

### Source language

- [zkc programs](https://github.com/zkcompiler/zkc/tree/main/language): `language`

### Compiler frontend

- [Frontend emission](https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Frontend/Emit): `lean/compiler/Zkc/Frontend/Emit`

### Protocol Core

- [Mixed definitions](https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Programs.lean): `lean/compiler/Zkc/Core/Admission/Programs.lean`
- [Header checking](https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Check.lean): `lean/compiler/Zkc/Core/Admission/Check.lean`
- [Function summaries](https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Theorems.lean): `lean/compiler/Zkc/Core/Admission/Theorems.lean`
- [Core admission](https://github.com/zkcompiler/zkc/blob/main/lean/compiler/Zkc/Core/Admission/Admission.lean): `lean/compiler/Zkc/Core/Admission/Admission.lean`
- [Role projection](https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Projection): `lean/compiler/Zkc/Core/Projection`
- [Loop bounds](https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Admission): `lean/compiler/Zkc/Core/Admission`
- [Checked transformation](https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Transform): `lean/compiler/Zkc/Core/Transform`
- [Core meaning](https://github.com/zkcompiler/zkc/tree/main/lean/compiler/Zkc/Core/Meaning): `lean/compiler/Zkc/Core/Meaning`

### Formal results

- [Formal certificates](https://github.com/zkcompiler/zkc/tree/main/lean/formal/Zkc/Formal/Interactive): `lean/formal/Zkc/Formal/Interactive`
- [Core proofs](https://github.com/zkcompiler/zkc/tree/main/lean/formal/Zkc/Formal): `lean/formal/Zkc/Formal`

### Other components

- **Protocol author**

## Connections

- Protocol author → zkc programs: writes (evidence: `README.md`)
- zkc programs → Frontend emission: emits (evidence: `README.md`)
- Frontend emission → Core admission: admits (evidence: `README.md`)
- Core admission → Role projection: projects roles (evidence: `README.md`)
- Core admission → Formal certificates: feeds certificates (evidence: `README.md`)
- Role projection → Formal certificates: feeds certificates (evidence: `README.md`)
- Mixed definitions → Header checking: checks headers (evidence: `README.md`)
- Mixed definitions → Function summaries: proves summaries (evidence: `README.md`)
- Core admission → Loop bounds: records bounds (evidence: `README.md`)
- Checked transformation → Core meaning: preserves behavior (evidence: `README.md`)
- Core meaning → Core proofs: supports proofs (evidence: `README.md`)
