# homenc/helib architecture

> Architecture diagram of the GitHub repository homenc/helib, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/homenc/helib
- Repository: https://github.com/homenc/helib

## Overview

##### Project Type and Purpose
- HElib is a cryptography library focused on homomorphic encryption, providing both low‑level routines (e.g., basic arithmetic operations, ciphertext packing, bootstrapping) and higher-level abstractions.
- Its purpose is to allow researchers and developers to experiment with and employ homomorphic encryption techniques, with a particular focus on efficiency and advanced features like noise management and bootstrapping.
- The project includes components for documentation, benchmarks, examples, and test cases that help demonstrate the capabilities and optimizations of the encryption schemes.

##### File Structure
- Core Library: Look at the “include/helib” and “src” directories. These contain the principal classes and functions—such as Context, Ctxt, EncryptedArray, EvalMap, key switching, bootstrapping modules, and arithmetic routines. They form the heart of HElib.
- Benchmarks: The “benchmarks” directory shows sample performance tests for different HE operations (e.g., BGV and CKKS benchmarks) demonstrating performance evaluation.
- Examples and Tutorials: The “examples” directory (including tutorials) helps users understand how to interact with the library. They are essential for guiding usage and verifying features.
- Utilities and Miscellaneous: Directories like “misc” and “utils” provide supporting functionality (e.g., parameter generators, encryption/decryption scripts, testing harnesses) that complement the core library.
- Tests: The “tests” directory contains a comprehensive suite of unit and integration tests, indicating a strong emphasis on reliability.
- Build and Configuration: Files like CMakeLists.txt (in various directories), Dockerfile variants, and continuous integration scripts in “.github” and “ci” ensure that building, testing, and deployment are well-controlled.

##### Final Advice
- Layers clearly and use component grouping to reflect the directory structure (e.g., “include/helib” and “src” form one cohesive module).
- Notes for build/test workflows (CI/CD pipelines using GitHub Actions and Docker images) to reflect the modern development practices followed by HElib.
- Every component is clearly labeled with its purpose (e.g., “Benchmarks – performance analysis of HE algorithms”).

## Diagram (Mermaid)

```mermaid
flowchart TD

    %% Client Applications Layer
    subgraph "Client Applications"
        Bench("Benchmarks"):::client
        BGVBench("BGV Benchmark"):::client
        CKKSBench("CKKS Benchmark"):::client
        Examples("Examples & Tutorials"):::client
        Utils("Utilities & Support Scripts"):::client
        Tests("Testing Suite"):::client
        Docs("Documentation"):::client
    end

    %% Core HE Engine Layer
    subgraph "Core HE Engine"
        HElib("HElib Headers"):::core
        HEsrc("HElib Source"):::core
        Boot("Bootstrapping & Noise"):::core
        Legacy("Legacy Boot Tests"):::core
    end

    %% External Dependencies & Build Infrastructure Layer
    subgraph "External & Build"
        GMP("GMP Dependency"):::dependency
        NTL("NTL Dependency"):::dependency
        CMake("CMake Build"):::build
        GH("GitHub Actions"):::build
        CI("CI Scripts"):::build
        Docker("Docker Build"):::build
    end

    %% Connections from Client Applications to Core HE Engine
    Bench -->|"uses"| HElib
    Bench -->|"uses"| HEsrc
    BGVBench -->|"tests"| HElib
    CKKSBench -->|"tests"| HEsrc
    Examples -->|"calls"| HElib
    Utils -->|"supports"| Boot
    Tests -->|"verifies"| Legacy
    Docs -->|"documents"| HElib

    %% Connections from Core HE Engine to External Dependencies & Build Infrastructure
    HElib -->|"relies_on"| GMP
    HElib -->|"relies_on"| NTL
    Boot -->|"relies_on"| GMP
    Boot -->|"relies_on"| NTL

    HElib -->|"built_with"| CMake
    Boot -->|"built_with"| CMake
    Legacy -->|"integrated_in"| GH
    Legacy -->|"integrated_in"| CI
    Legacy -->|"integrated_in"| Docker
    HElib -->|"integrated_in"| GH
    HElib -->|"integrated_in"| CI
    HElib -->|"integrated_in"| Docker

    %% Styles
    classDef client fill:#f9e79f,stroke:#d35400,stroke-width:2px;
    classDef core fill:#aed6f1,stroke:#2980b9,stroke-width:2px;
    classDef dependency fill:#abebc6,stroke:#27ae60,stroke-width:2px;
    classDef build fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;

    %% Click Events for Core HE Engine
    click HElib "https://github.com/homenc/helib/tree/master/include/helib"
    click HEsrc "https://github.com/homenc/helib/tree/master/src"
    click Boot "https://github.com/homenc/helib/blob/master/src/recryption.cpp"
    click Legacy "https://github.com/homenc/helib/blob/master/misc/legacy_tests/Test_bootstrapping.cpp"

    %% Click Events for External Dependencies & Build Infrastructure
    click GMP "https://github.com/homenc/helib/blob/master/cmake/FindGMP.cmake"
    click NTL "https://github.com/homenc/helib/blob/master/cmake/FindNTL.cmake"
    click CMake "https://github.com/homenc/helib/blob/master/CMakeLists.txt"
    click GH "https://github.com/homenc/helib/tree/master/.github/workflows"
    click CI "https://github.com/homenc/helib/tree/master/ci"
    click Docker "https://github.com/homenc/helib/tree/master/docker"

    %% Click Events for Client Applications
    click Bench "https://github.com/homenc/helib/tree/master/benchmarks"
    click BGVBench "https://github.com/homenc/helib/blob/master/benchmarks/bgv_basic.cpp"
    click CKKSBench "https://github.com/homenc/helib/blob/master/benchmarks/ckks_basic.cpp"
    click Examples "https://github.com/homenc/helib/tree/master/examples"
    click Utils "https://github.com/homenc/helib/tree/master/utils"
    click Tests "https://github.com/homenc/helib/tree/master/tests"
    click Docs "https://github.com/homenc/helib/tree/master/documentation"
```
