# microsoft/seal architecture

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

- Interactive diagram: https://gitdiagram.com/microsoft/seal
- Repository: https://github.com/microsoft/seal

## Overview

##### High-Level Architecture Components

- Native C++ Library (primary implementation)
- SEAL_C Wrapper (C interface layer)
- .NET Wrapper (SEALNet)

b) Encryption Schemes (Top section):
- BFV Scheme
- BGV Scheme
- CKKS Scheme

c) Support Systems (Bottom section):
- Memory Management System
- Serialization System
- Random Number Generation

##### Key Relationships and Interactions

- How the C++ core components are wrapped by SEAL_C
- How SEALNet depends on SEAL_C
- Encryption schemes to their respective encoders and evaluators
- Memory management system interactions with all components

##### Component Details

- Encryptors
- Decryptors
- Evaluators
- KeyGenerators

- BatchEncoder
- CKKSEncoder
- Serialization Components

- Memory Management
- PRNG Systems

##### Integration Points

External integration points:
- Optional dependencies (Intel HEXL, ZLIB, etc.)
- Platform-specific optimizations
- Build system connections

##### Implementation Details

- Line styles for different types of dependencies

##### Specific Elements

**Core Classes:**
- SEALContext
- EncryptionParameters
- Ciphertext/Plaintext
- PublicKey/SecretKey
- GaloisKeys/RelinKeys

**Utility Classes:**
- MemoryPoolHandle
- BatchEncoder
- CKKSEncoder
- Evaluator

##### Cross-Platform Support

A section showing supported platforms:
- Windows
- Linux
- macOS
- Android
- iOS
- WebAssembly

##### Cross-platform support

Use a hierarchical layout with:
- Core components in the center
- Supporting systems radiating outward
- Clear boundaries between native and managed code
- Distinct sections for different encryption schemes

Remember to:
- Use consistent styling
- Version information
- Document key dependencies

This will create a comprehensive visualization of Microsoft SEAL's architecture while maintaining clarity and usefulness for development purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Core Components
    subgraph Core
        NativeLib["Native C++ Library"]
        SEALC["SEAL_C Wrapper"]
        DotNet[".NET Wrapper"]
    end

    %% Encryption Schemes
    subgraph Schemes
        BFV["BFV Scheme"]
        BGV["BGV Scheme"]
        CKKS["CKKS Scheme"]
    end

    %% Core Classes
    subgraph CoreClasses
        Encryptor["Encryptor"]:::core
        Decryptor["Decryptor"]:::core
        Evaluator["Evaluator"]:::core
        KeyGen["Key Generator"]:::core
        SEALCtx["SEAL Context"]:::core
        BatchEnc["Batch Encoder"]:::core
        CKKSEnc["CKKS Encoder"]:::core
    end

    %% Support Systems
    subgraph Support
        MemMgmt["Memory Management"]:::support
        Serial["Serialization"]:::support
        RNG["Random Number Generation"]:::support
    end

    %% Platform Support
    subgraph Platforms
        Windows:::platform
        Linux:::platform
        MacOS:::platform
        Android:::platform
        iOS:::platform
        WASM["WebAssembly"]:::platform
    end

    %% Utility Systems
    subgraph Utils
        MemPool["Memory Pool"]:::util
        NTT["NTT Operations"]:::util
        RLWE["RLWE"]:::util
    end

    %% Relationships
    NativeLib --> SEALC
    SEALC --> DotNet
    NativeLib --> |Implements| Schemes
    CoreClasses --> NativeLib
    Support --> NativeLib
    Utils --> NativeLib

    %% Component Mappings
    click NativeLib "https://github.com/microsoft/SEAL/tree/main/native/src/seal/"
    click SEALC "https://github.com/microsoft/SEAL/tree/main/native/src/seal/c/"
    click DotNet "https://github.com/microsoft/SEAL/tree/main/dotnet/src/"
    click BFV "https://github.com/microsoft/SEAL/blob/main/native/examples/1_bfv_basics.cpp"
    click BGV "https://github.com/microsoft/SEAL/blob/main/native/examples/4_bgv_basics.cpp"
    click CKKS "https://github.com/microsoft/SEAL/blob/main/native/src/seal/ckks.h"
    click MemMgmt "https://github.com/microsoft/SEAL/blob/main/native/src/seal/memorymanager.h"
    click Serial "https://github.com/microsoft/SEAL/blob/main/native/src/seal/serialization.h"
    click Encryptor "https://github.com/microsoft/SEAL/blob/main/native/src/seal/encryptor.h"
    click Decryptor "https://github.com/microsoft/SEAL/blob/main/native/src/seal/decryptor.h"
    click Evaluator "https://github.com/microsoft/SEAL/blob/main/native/src/seal/evaluator.h"
    click KeyGen "https://github.com/microsoft/SEAL/blob/main/native/src/seal/keygenerator.h"
    click SEALCtx "https://github.com/microsoft/SEAL/blob/main/native/src/seal/context.h"
    click BatchEnc "https://github.com/microsoft/SEAL/blob/main/native/src/seal/batchencoder.h"
    click CKKSEnc "https://github.com/microsoft/SEAL/blob/main/native/src/seal/ckks.h"
    click RNG "https://github.com/microsoft/SEAL/blob/main/native/src/seal/randomgen.h"
    click Android "https://github.com/microsoft/SEAL/tree/main/android/"
    click iOS "https://github.com/microsoft/SEAL/blob/main/pipelines/ios.yml"
    click MemPool "https://github.com/microsoft/SEAL/blob/main/native/src/seal/util/mempool.h"
    click NTT "https://github.com/microsoft/SEAL/blob/main/native/src/seal/util/ntt.h"
    click RLWE "https://github.com/microsoft/SEAL/blob/main/native/src/seal/util/rlwe.h"

    %% Styling
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef support fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef platform fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef util fill:#FFE4B5,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        CoreComp["Core Component"]:::core
        SupportComp["Support System"]:::support
        PlatformComp["Platform"]:::platform
        UtilComp["Utility"]:::util
    end
```
