# nkujyw/distributed-password-hash-mhf-system architecture

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

- Interactive diagram: https://gitdiagram.com/nkujyw/distributed-password-hash-mhf-system
- Repository: https://github.com/nkujyw/distributed-password-hash-mhf-system

## Overview

FuzzyPCFG_SM_Argon2i combines a PCFG-based password-strength model, a FastAPI service for scoring and account operations, and a modified Argon2i password-hashing implementation. The documented path is training data through model training and CDF preparation, then service requests for scoring or registration/login; maintenance can update model components, and a separate tool creates differentially private model files. Several service-to-executable and service-to-hasher details are documented only at a high level, so those links are marked unverified rather than asserting specific call mechanics.

Main entry points: [`score_server.py`](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/score_server.py) (API service), [`fuzzypcfg.cpp`](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/fuzzypcfg.cpp) (PCFG engine), [`SM_Argon2/src/ref.c`](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/ref.c) (Block mixing), [`models_original`](https://github.com/nkujyw/distributed-password-hash-mhf-system/tree/main/models_original) (Original models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_service["Web service"]
  node_server["API service<br/>[score_server.py]"]
  node_db[("User database")]
end

subgraph group_model["PCFG modeling"]
  node_core["PCFG engine<br/>[fuzzypcfg.cpp]"]
  node_trie["Trie structures<br/>[Trie.h]"]
  node_training["Training corpus<br/>[train_dic.txt]"]
  node_dictionary["Base dictionary<br/>[base_dic.txt]"]
  node_models[("Original models")]
  node_cdf["CDF preparation<br/>[build_cdf.py]"]
  node_updates["Incremental updates<br/>[batch_update.py]"]
  node_update_log["Collected patterns"]
end

subgraph group_privacy["Model privacy"]
  node_dp["DP noise tool<br/>[add_noise.py]"]
  node_dp_models[("Private models")]
end

subgraph group_crypto["Password hashing"]
  node_argon_api["Argon2 API<br/>[argon2.h]"]
  node_argon_entry["Hash entry points<br/>[argon2.c]"]
  node_argon_core["Memory-hard core<br/>[core.c]"]
  node_encoding["Hash encoding<br/>[encoding.c]"]
  node_ref["Block mixing<br/>[ref.c]"]
  node_sm3["SM3 hashing<br/>[sm3.c]"]
  node_blake["BLAKE2 primitives<br/>[blake2.h]"]
  node_sm4["SM4 mixing<br/>[sm4-round.h]"]
  node_zuc["ZUC routines<br/>[ZUC.c]"]
end

node_user(("API client"))

node_user -->|"requests"| node_server
node_server -->|"stores account data"| node_db
node_server -.->|"requests scoring"| node_core
node_server -.->|"hashes credentials"| node_argon_entry
node_training -->|"trains from"| node_core
node_dictionary -->|"parses with"| node_core
node_core -->|"uses"| node_trie
node_core -->|"writes or scores"| node_models
node_models -->|"normalizes scoring"| node_cdf
node_server -->|"records patterns"| node_update_log
node_update_log -->|"consumes log"| node_updates
node_updates -->|"updates components"| node_models
node_updates -->|"uses preparation"| node_cdf
node_models -->|"adds noise to"| node_dp
node_dp -->|"writes private models"| node_dp_models
node_argon_api -->|"exposes"| node_argon_entry
node_argon_entry -->|"calls core"| node_argon_core
node_argon_entry -->|"uses encoding"| node_encoding
node_argon_core -->|"initializes blocks with"| node_sm3
node_argon_core -->|"fills memory via"| node_ref
node_ref -->|"uses primitives"| node_blake
node_ref -->|"uses mixing"| node_sm4
node_ref -->|"uses routines"| node_zuc

click node_server "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/score_server.py"
click node_core "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/fuzzypcfg.cpp"
click node_trie "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/Trie.h"
click node_training "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/files/train_dic.txt"
click node_dictionary "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/files/base_dic.txt"
click node_models "https://github.com/nkujyw/distributed-password-hash-mhf-system/tree/main/models_original"
click node_cdf "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/build_cdf.py"
click node_updates "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/batch_update.py"
click node_dp "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/add_noise.py"
click node_dp_models "https://github.com/nkujyw/distributed-password-hash-mhf-system/tree/main/models_dp"
click node_argon_api "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/include/argon2.h"
click node_argon_entry "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/argon2.c"
click node_argon_core "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/core.c"
click node_encoding "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/encoding.c"
click node_ref "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/ref.c"
click node_sm3 "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/sm3/sm3.c"
click node_blake "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/blake2/blake2.h"
click node_sm4 "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/sm4/sm4-round.h"
click node_zuc "https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/zuc/ZUC.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_server,node_db,node_user toneBlue
class node_core,node_trie,node_training,node_dictionary,node_models,node_cdf,node_updates,node_update_log toneAmber
class node_dp,node_dp_models toneMint
class node_argon_api,node_argon_entry,node_argon_core,node_encoding,node_ref,node_sm3,node_blake,node_sm4,node_zuc toneRose
```

## Components

### Web service

- [API service](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/score_server.py): `score_server.py`
- **User database**

### PCFG modeling

- [PCFG engine](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/fuzzypcfg.cpp): `fuzzypcfg.cpp`
- [Trie structures](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/Trie.h): `Trie.h`
- [Training corpus](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/files/train_dic.txt): `files/train_dic.txt`
- [Base dictionary](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/files/base_dic.txt): `files/base_dic.txt`
- [Original models](https://github.com/nkujyw/distributed-password-hash-mhf-system/tree/main/models_original): `models_original`
- [CDF preparation](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/build_cdf.py): `build_cdf.py`
- [Incremental updates](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/batch_update.py): `batch_update.py`
- **Collected patterns**

### Model privacy

- [DP noise tool](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/add_noise.py): `add_noise.py`
- [Private models](https://github.com/nkujyw/distributed-password-hash-mhf-system/tree/main/models_dp): `models_dp`

### Password hashing

- [Argon2 API](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/include/argon2.h): `SM_Argon2/include/argon2.h`
- [Hash entry points](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/argon2.c): `SM_Argon2/src/argon2.c`
- [Memory-hard core](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/core.c): `SM_Argon2/src/core.c`
- [Hash encoding](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/encoding.c): `SM_Argon2/src/encoding.c`
- [Block mixing](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/ref.c): `SM_Argon2/src/ref.c`
- [SM3 hashing](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/sm3/sm3.c): `SM_Argon2/src/sm3/sm3.c`
- [BLAKE2 primitives](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/blake2/blake2.h): `SM_Argon2/src/blake2/blake2.h`
- [SM4 mixing](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/sm4/sm4-round.h): `SM_Argon2/src/sm4/sm4-round.h`
- [ZUC routines](https://github.com/nkujyw/distributed-password-hash-mhf-system/blob/main/SM_Argon2/src/zuc/ZUC.c): `SM_Argon2/src/zuc/ZUC.c`

### Other components

- **API client**

## Connections

- API client → API service: requests (evidence: `README.md`)
- API service → User database: stores account data (evidence: `README.md`)
- API service → PCFG engine: requests scoring
- API service → Hash entry points: hashes credentials
- Training corpus → PCFG engine: trains from (evidence: `README.md`)
- Base dictionary → PCFG engine: parses with (evidence: `README.md`)
- PCFG engine → Trie structures: uses (evidence: `fuzzypcfg.cpp`)
- PCFG engine → Original models: writes or scores (evidence: `README.md`)
- Original models → CDF preparation: normalizes scoring (evidence: `README.md`)
- API service → Collected patterns: records patterns (evidence: `README.md`)
- Collected patterns → Incremental updates: consumes log (evidence: `README.md`)
- Incremental updates → Original models: updates components (evidence: `README.md`)
- Incremental updates → CDF preparation: uses preparation (evidence: `batch_update.py`)
- Original models → DP noise tool: adds noise to (evidence: `README.md`)
- DP noise tool → Private models: writes private models (evidence: `README.md`)
- Argon2 API → Hash entry points: exposes (evidence: `SM_Argon2/src/argon2.c`)
- Hash entry points → Memory-hard core: calls core (evidence: `SM_Argon2/src/argon2.c`)
- Hash entry points → Hash encoding: uses encoding (evidence: `SM_Argon2/src/argon2.c`)
- Memory-hard core → SM3 hashing: initializes blocks with (evidence: `SM_Argon2/src/core.c`)
- Memory-hard core → Block mixing: fills memory via (evidence: `SM_Argon2/src/core.c`)
- Block mixing → BLAKE2 primitives: uses primitives (evidence: `SM_Argon2/src/ref.c`)
- Block mixing → SM4 mixing: uses mixing (evidence: `SM_Argon2/src/ref.c`)
- Block mixing → ZUC routines: uses routines (evidence: `SM_Argon2/src/ref.c`)
