# karalef/quark architecture

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

- Interactive diagram: https://gitdiagram.com/karalef/quark
- Repository: https://github.com/karalef/quark

## Overview

##### Main Components

a. Core Components:
- Quark Core (main interface)
- Crypto Operations Layer
- Key Management System
- Encryption/Decryption Pipeline
- Extensions Framework

b. Cryptographic Modules:
- AEAD (Authenticated Encryption with Associated Data)
- KEM (Key Encapsulation Mechanism)
- Signature Systems
- Key Derivation Functions (KDF)
- Hash Functions
- MAC (Message Authentication Codes)

##### Component Relationships

Key relationships:
- How the main Quark interface connects to the crypto package
- The flow from high-level operations to low-level cryptographic primitives
- Extension point connections to the core system
- Data flow between encryption, signing, and key management components

##### Important Details

- Post-quantum secure algorithms specifically (like EDDilithium3)
- Separation between standard and post-quantum implementations
- Where streaming operations occur (crypto/sign/stream)
- Relationship between the pack package and the crypto operations

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Public Interface Layer"
        QC[Quark Core Interface]:::public
    end

    subgraph "Core Cryptographic Services"
        CO[Crypto Operations Layer]:::core
        KM[Key Management System]:::core
        ES[Encryption Services]:::core
        SM[Signature Management]:::core
        RNG[Random Number Generation]:::core
    end

    subgraph "Cryptographic Primitives"
        AEAD[AEAD Module]:::crypto
        KEM[KEM Module]:::crypto
        SIG[Signature Systems]:::crypto
        KDF[Key Derivation Functions]:::crypto
        HASH[Hash Functions]:::crypto
        MAC[MAC Implementation]:::crypto
        STR[Stream Operations]:::crypto
    end

    subgraph "Extensions Layer"
        EF[Extensions Framework]:::extension
        MH[Message Handling]:::extension
        BK[Backup Functionality]:::extension
        SK[Subkey Management]:::extension
    end

    %% Core relationships
    QC --> CO
    QC --> KM
    QC --> ES
    QC --> SM

    %% Crypto Operations relationships
    CO --> AEAD
    CO --> KEM
    CO --> SIG
    CO --> KDF
    CO --> HASH
    CO --> MAC
    CO --> RNG

    %% Extension relationships
    EF -.-> MH
    EF -.-> BK
    EF -.-> SK

    %% Stream operations
    SIG --> STR

    %% Component interactions
    ES --> AEAD
    ES --> KEM
    SM --> SIG
    KM --> KDF

    %% Styling
    classDef public fill:#90EE90,stroke:#333,stroke-width:2px
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:2px
    classDef crypto fill:#FFB6C1,stroke:#333,stroke-width:2px
    classDef extension fill:#FFE4B5,stroke:#333,stroke-width:2px

    %% Click events
    click QC "https://github.com/karalef/quark/blob/main/quark.go"
    click CO "https://github.com/karalef/quark/blob/main/crypto/crypto.go"
    click KM "https://github.com/karalef/quark/blob/main/encrypted/key/key.go"
    click ES "https://github.com/karalef/quark/blob/main/encrypted/schemes.go"
    click EF "https://github.com/karalef/quark/tree/main/extensions/"
    click AEAD "https://github.com/karalef/quark/blob/main/crypto/aead/aead.go"
    click KEM "https://github.com/karalef/quark/blob/main/crypto/kem/kem.go"
    click SIG "https://github.com/karalef/quark/blob/main/crypto/sign/sign.go"
    click KDF "https://github.com/karalef/quark/blob/main/crypto/kdf/kdf.go"
    click HASH "https://github.com/karalef/quark/blob/main/crypto/hash/hash.go"
    click MAC "https://github.com/karalef/quark/blob/main/crypto/mac/mac.go"
    click RNG "https://github.com/karalef/quark/blob/main/crypto/rand.go"
    click STR "https://github.com/karalef/quark/blob/main/crypto/sign/stream/stream.go"
    click MH "https://github.com/karalef/quark/blob/main/extensions/message/message.go"
    click BK "https://github.com/karalef/quark/blob/main/extensions/backup/backup.go"
    click SK "https://github.com/karalef/quark/blob/main/extensions/subkey/subkey.go"
    click SM "https://github.com/karalef/quark/blob/main/signature.go"
```
