# fplll/g6k architecture

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

- Interactive diagram: https://gitdiagram.com/fplll/g6k
- Repository: https://github.com/fplll/g6k

## Overview

##### Main Components

a) Core Components:
- G6K Kernel (C++)
- Python Interface Layer (Cython)
- Algorithm Implementation Layer
- Utility Services

b) External Dependencies:
- FPyLLL
- FPLLL
- Python Environment

**┌─────────────────────────────────────────────┐**
- Client Layer                  │
- (CLI Tools, Python Scripts, Interactive Use)│
- ┤
- Algorithm Layer                   │
- (BKZ, Pump, Workout, Ducas18, etc.)     │
- ┤
- Python Interface                  │
- (Cython Bindings - .pyx)           │
- ┤
- G6K Kernel                      │
- (C++ Implementation, SIMD, Threading)    │
- ┤
- External Dependencies               │
- (FPLLL, FPyLLL, Python)             │
- ┘

##### Component Details

- Rectangles: Main components
- Hexagons: External dependencies

- Blue: Core C++ components
- Green: Python/Cython interface
- Yellow: Algorithms
- Gray: External dependencies
- Orange: Utilities

##### Key Relationships

a) Data Flow:
- Input lattices → Kernel → Sieve algorithms → Results
- Configuration parameters flow
- Threading and parallel processing

b) Component Interactions:
- Kernel to Python binding communication
- Algorithm layer utilizing kernel operations
- Utility services supporting all layers

##### Implementation Details to Highlight

- Separation between the C++ kernel (performance-critical) and Python interface
- Parallel processing capabilities
- Demonstrate the algorithm pipeline
- Configuration and parameter flow

##### Notes

Annotations for:
- Performance-critical paths
- Scalability points
- Configuration options
- Key optimization features

Remember to include version information and any relevant build configuration options that affect the architecture.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Client["Client Layer"]
        CLI["CLI Tools"]:::util
        SVP["SVP Challenge"]:::client
        LWE["LWE Challenge"]:::client
        EX["Examples"]:::client
    end

    subgraph Algo["Algorithm Layer"]
        BKZ["BKZ"]:::algo
        PUMP["Pump"]:::algo
        WORK["Workout"]:::algo
        DUC["Ducas18"]:::algo
    end

    subgraph PyInterface["Python Interface Layer"]
        SIEVER_PYX["Siever Interface"]:::pyinterface
        SIEVER_PXD["Siever Declarations"]:::pyinterface
        PARAMS["Parameters Interface"]:::pyinterface
    end

    subgraph Kernel["G6K Kernel Layer"]
        SIEVER["Core Siever"]:::kernel
        SIMD["SIMD Operations"]:::kernel
        THREAD["Thread Pool"]:::kernel
        
        subgraph Sieve["Sieve Implementations"]
            BDGL["BDGL Sieve"]:::kernel
            BGJ1["BGJ1 Sieve"]:::kernel
            HK3["HK3 Sieve"]:::kernel
        end
    end

    subgraph Utils["Utility Services"]
        CLIUTIL["CLI Utils"]:::util
        STATS["Statistics"]:::util
        MACHINE["Machine Utils"]:::util
        GENUTIL["General Utils"]:::util
    end

    subgraph SphericalCoding["Spherical Coding"]
        CODES["Code Management"]:::spherical
        DATA["Coding Data"]:::spherical
    end

    subgraph External["External Dependencies"]
        FPLLL["FPLLL"]:::external
        FPYLLL["FPyLLL"]:::external
        PYTHON["Python"]:::external
    end

    %% Relationships
    CLI --> SIEVER_PYX
    SVP --> SIEVER_PYX
    LWE --> SIEVER_PYX
    EX --> SIEVER_PYX

    BKZ & PUMP & WORK & DUC --> SIEVER_PYX
    SIEVER_PYX --> SIEVER_PXD
    SIEVER_PXD --> SIEVER
    PARAMS --> SIEVER

    SIEVER --> SIMD
    SIEVER --> THREAD
    SIEVER --> Sieve
    
    BDGL & BGJ1 & HK3 --> CODES
    
    SIEVER --> FPYLLL
    FPYLLL --> FPLLL
    FPYLLL --> PYTHON

    %% Click Events
    click CLIUTIL "https://github.com/fplll/g6k/blob/master/g6k/utils/cli.py"
    click STATS "https://github.com/fplll/g6k/blob/master/g6k/utils/stats.py"
    click MACHINE "https://github.com/fplll/g6k/blob/master/g6k/utils/machine.py"
    click GENUTIL "https://github.com/fplll/g6k/blob/master/g6k/utils/util.py"
    click BKZ "https://github.com/fplll/g6k/blob/master/g6k/algorithms/bkz.py"
    click PUMP "https://github.com/fplll/g6k/blob/master/g6k/algorithms/pump.py"
    click WORK "https://github.com/fplll/g6k/blob/master/g6k/algorithms/workout.py"
    click DUC "https://github.com/fplll/g6k/blob/master/g6k/algorithms/ducas18.py"
    click SIEVER_PYX "https://github.com/fplll/g6k/blob/master/g6k/siever.pyx"
    click SIEVER_PXD "https://github.com/fplll/g6k/blob/master/g6k/siever.pxd"
    click PARAMS "https://github.com/fplll/g6k/blob/master/g6k/siever_params.pyx"
    click SIEVER "https://github.com/fplll/g6k/blob/master/kernel/siever.h"
    click SIMD "https://github.com/fplll/g6k/blob/master/kernel/simd.h"
    click THREAD "https://github.com/fplll/g6k/blob/master/kernel/thread_pool.hpp"
    click BDGL "https://github.com/fplll/g6k/blob/master/kernel/bdgl_sieve.cpp"
    click BGJ1 "https://github.com/fplll/g6k/blob/master/kernel/bgj1_sieve.cpp"
    click HK3 "https://github.com/fplll/g6k/blob/master/kernel/hk3_sieve.cpp"
    click CODES "https://github.com/fplll/g6k/blob/master/g6k/spherical_coding/codes.py"
    click SVP "https://github.com/fplll/g6k/blob/master/svp_challenge.py"
    click LWE "https://github.com/fplll/g6k/blob/master/lwe_challenge.py"
    click EX "https://github.com/fplll/g6k/tree/master/examples/"

    %% Styles
    classDef kernel fill:#a2d2ff,stroke:#333,stroke-width:2px
    classDef pyinterface fill:#bde0fe,stroke:#333,stroke-width:2px
    classDef algo fill:#ffafcc,stroke:#333,stroke-width:2px
    classDef util fill:#ffc8dd,stroke:#333,stroke-width:2px
    classDef external fill:#cdb4db,stroke:#333,stroke-width:2px
    classDef spherical fill:#fff1e6,stroke:#333,stroke-width:2px
    classDef client fill:#f0efeb,stroke:#333,stroke-width:2px
```
