# juliusjh/fault_enabled_cca architecture

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

- Interactive diagram: https://gitdiagram.com/juliusjh/fault_enabled_cca
- Repository: https://github.com/juliusjh/fault_enabled_cca

## Overview

This repository implements fault-enabled chosen-ciphertext attack experiments against Kyber512/768/1024. The principal workflow is documented as running the Python CLI to generate or reuse keys and inequalities, perform belief-propagation iterations, and save outputs. Rust/PQClean Kyber code supplies the cryptographic operations; a Rust check-graph crate provides belief-propagation structures. The README documents the overall workflow, but `python/main.py` and most runtime modules were not excerpted, so those orchestration links reflect documentation rather than inspected calls.

Main entry points: [`python/main.py`](https://github.com/juliusjh/fault_enabled_cca/blob/main/python/main.py) (Attack CLI), [`python_kyber/src/kyber/kyber_sample.rs`](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/kyber_sample.rs) (Kyber samples), [`python/inequalities.py`](https://github.com/juliusjh/fault_enabled_cca/blob/main/python/inequalities.py) (Inequality generation), [`check_bp/src/lib.rs`](https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/lib.rs) (Python binding)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_attack["Attack workflow"]
  node_cli["Attack CLI<br/>[main.py]"]
  node_sampling["Kyber samples<br/>[kyber_sample.rs]"]
  node_inequalities["Inequality generation<br/>[inequalities.py]"]
  node_error["Error terms<br/>[error_term.py]"]
  node_solver["Attack solver<br/>[solver.py]"]
  node_results["Plots and outputs<br/>[plot.py]"]
end

subgraph group_crypto["Kyber operations"]
  node_kyber_api["Kyber API<br/>[wrapper512.rs]"]
  node_kyber_api768["Kyber768 API<br/>[wrapper768.rs]"]
  node_kyber_api1024["Kyber1024 API<br/>[wrapper1024.rs]"]
  node_poly["Polynomial math<br/>[poly.rs]"]
  node_polyvec["Polynomial vectors<br/>[polyvec.rs]"]
  node_public_key["Public keys<br/>[public_key.rs]"]
  node_ciphertext["Ciphertexts<br/>[ciphertext.rs]"]
  node_pqclean512["Kyber512 CPA<br/>[indcpa.c]"]
  node_pqclean768["Kyber768 CPA<br/>[indcpa.c]"]
  node_pqclean1024["Kyber1024 CPA<br/>[indcpa.c]"]
  node_keccak["SHAKE primitives<br/>[fips202.c]"]
end

subgraph group_bp["Belief propagation"]
  node_checkgraph["Check graph<br/>[check_graph.rs]"]
  node_checknode["Check nodes<br/>[check_node.rs]"]
  node_checkmsg["Check messages<br/>[check_msg.rs]"]
  node_varnode["Variable nodes<br/>[bin_var_node.rs]"]
  node_bintree["Binary trees<br/>[bin_tree.rs]"]
  node_binding["Python binding<br/>[lib.rs]"]
end

node_user(("Experimenter"))

node_user -->|"runs"| node_cli
node_cli -.->|"generates samples"| node_sampling
node_cli -->|"generates inequalities"| node_inequalities
node_inequalities -->|"uses samples"| node_sampling
node_inequalities -->|"calculates errors"| node_error
node_cli -->|"runs iterations"| node_solver
node_cli -->|"saves outputs"| node_results
node_sampling -.->|"uses Kyber"| node_kyber_api
node_sampling -.->|"uses Kyber"| node_kyber_api768
node_sampling -.->|"uses Kyber"| node_kyber_api1024
node_kyber_api -->|"calls native code"| node_pqclean512
node_kyber_api768 -.->|"calls native code"| node_pqclean768
node_kyber_api1024 -->|"calls native code"| node_pqclean1024
node_pqclean512 -.->|"uses SHAKE"| node_keccak
node_pqclean768 -.->|"uses SHAKE"| node_keccak
node_pqclean1024 -.->|"uses SHAKE"| node_keccak
node_binding -->|"registers graph"| node_checkgraph
node_binding -->|"registers trees"| node_bintree
node_solver -.->|"uses propagation"| node_binding

click node_cli "https://github.com/juliusjh/fault_enabled_cca/blob/main/python/main.py"
click node_sampling "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/kyber_sample.rs"
click node_inequalities "https://github.com/juliusjh/fault_enabled_cca/blob/main/python/inequalities.py"
click node_error "https://github.com/juliusjh/fault_enabled_cca/blob/main/python/error_term.py"
click node_solver "https://github.com/juliusjh/fault_enabled_cca/blob/main/python/solver.py"
click node_results "https://github.com/juliusjh/fault_enabled_cca/blob/main/python/plot.py"
click node_kyber_api "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/wrapper512.rs"
click node_kyber_api768 "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/wrapper768.rs"
click node_kyber_api1024 "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/wrapper1024.rs"
click node_poly "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/poly.rs"
click node_polyvec "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/polyvec.rs"
click node_public_key "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/public_key.rs"
click node_ciphertext "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/ciphertext.rs"
click node_pqclean512 "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/crypto_kem/kyber512/clean/indcpa.c"
click node_pqclean768 "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/crypto_kem/kyber768/clean/indcpa.c"
click node_pqclean1024 "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/crypto_kem/kyber1024/clean/indcpa.c"
click node_keccak "https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/common/fips202.c"
click node_checkgraph "https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/check_graph.rs"
click node_checknode "https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/check_node.rs"
click node_checkmsg "https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/check_msg.rs"
click node_varnode "https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/bin_var_node.rs"
click node_bintree "https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/bin_tree.rs"
click node_binding "https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/lib.rs"

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_cli,node_sampling,node_inequalities,node_error,node_solver,node_results toneBlue
class node_kyber_api,node_kyber_api768,node_kyber_api1024,node_poly,node_polyvec,node_public_key,node_ciphertext,node_pqclean512,node_pqclean768,node_pqclean1024,node_keccak toneAmber
class node_checkgraph,node_checknode,node_checkmsg,node_varnode,node_bintree,node_binding toneMint
class node_user toneIndigo
```

## Components

### Attack workflow

- [Attack CLI](https://github.com/juliusjh/fault_enabled_cca/blob/main/python/main.py): `python/main.py`
- [Kyber samples](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/kyber_sample.rs): `python_kyber/src/kyber/kyber_sample.rs`
- [Inequality generation](https://github.com/juliusjh/fault_enabled_cca/blob/main/python/inequalities.py): `python/inequalities.py`
- [Error terms](https://github.com/juliusjh/fault_enabled_cca/blob/main/python/error_term.py): `python/error_term.py`
- [Attack solver](https://github.com/juliusjh/fault_enabled_cca/blob/main/python/solver.py): `python/solver.py`
- [Plots and outputs](https://github.com/juliusjh/fault_enabled_cca/blob/main/python/plot.py): `python/plot.py`

### Kyber operations

- [Kyber API](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/wrapper512.rs): `python_kyber/src/kyber/wrapper512.rs`
- [Kyber768 API](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/wrapper768.rs): `python_kyber/src/kyber/wrapper768.rs`
- [Kyber1024 API](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/wrapper1024.rs): `python_kyber/src/kyber/wrapper1024.rs`
- [Polynomial math](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/poly.rs): `python_kyber/src/kyber/poly.rs`
- [Polynomial vectors](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/polyvec.rs): `python_kyber/src/kyber/polyvec.rs`
- [Public keys](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/public_key.rs): `python_kyber/src/kyber/public_key.rs`
- [Ciphertexts](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/src/kyber/ciphertext.rs): `python_kyber/src/kyber/ciphertext.rs`
- [Kyber512 CPA](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/crypto_kem/kyber512/clean/indcpa.c): `python_kyber/PQClean/crypto_kem/kyber512/clean/indcpa.c`
- [Kyber768 CPA](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/crypto_kem/kyber768/clean/indcpa.c): `python_kyber/PQClean/crypto_kem/kyber768/clean/indcpa.c`
- [Kyber1024 CPA](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/crypto_kem/kyber1024/clean/indcpa.c): `python_kyber/PQClean/crypto_kem/kyber1024/clean/indcpa.c`
- [SHAKE primitives](https://github.com/juliusjh/fault_enabled_cca/blob/main/python_kyber/PQClean/common/fips202.c): `python_kyber/PQClean/common/fips202.c`

### Belief propagation

- [Check graph](https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/check_graph.rs): `check_bp/src/check_graph.rs`
- [Check nodes](https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/check_node.rs): `check_bp/src/check_node.rs`
- [Check messages](https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/check_msg.rs): `check_bp/src/check_msg.rs`
- [Variable nodes](https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/bin_var_node.rs): `check_bp/src/bin_var_node.rs`
- [Binary trees](https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/bin_tree.rs): `check_bp/src/bin_tree.rs`
- [Python binding](https://github.com/juliusjh/fault_enabled_cca/blob/main/check_bp/src/lib.rs): `check_bp/src/lib.rs`

### Other components

- **Experimenter**

## Connections

- Experimenter → Attack CLI: runs
- Attack CLI → Kyber samples: generates samples
- Attack CLI → Inequality generation: generates inequalities
- Inequality generation → Kyber samples: uses samples (evidence: `python/inequalities.py`)
- Inequality generation → Error terms: calculates errors (evidence: `python/inequalities.py`)
- Attack CLI → Attack solver: runs iterations
- Attack CLI → Plots and outputs: saves outputs
- Kyber samples → Kyber API: uses Kyber
- Kyber samples → Kyber768 API: uses Kyber
- Kyber samples → Kyber1024 API: uses Kyber
- Kyber API → Kyber512 CPA: calls native code (evidence: `python_kyber/src/kyber/wrapper512.rs`)
- Kyber768 API → Kyber768 CPA: calls native code
- Kyber1024 API → Kyber1024 CPA: calls native code (evidence: `python_kyber/src/kyber/wrapper1024.rs`)
- Kyber512 CPA → SHAKE primitives: uses SHAKE
- Kyber768 CPA → SHAKE primitives: uses SHAKE
- Kyber1024 CPA → SHAKE primitives: uses SHAKE
- Python binding → Check graph: registers graph (evidence: `check_bp/src/lib.rs`)
- Python binding → Binary trees: registers trees (evidence: `check_bp/src/lib.rs`)
- Attack solver → Python binding: uses propagation
