# espressosystems/hyperplonk architecture

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

- Interactive diagram: https://gitdiagram.com/espressosystems/hyperplonk
- Repository: https://github.com/espressosystems/hyperplonk

## Overview

##### Main Components Identification
The project is structured as a Rust workspace with multiple crates:
- arithmetic: Core mathematical operations
- hyperplonk: Main SNARK implementation
- subroutines: Supporting algorithms and protocols
- transcript: Proof transcript handling
- util: Utility functions

**┌─ Core Components ──────────────────────────────────┐**

- ┌─────────────┐        ┌───────────────┐         │
- Arithmetic │◄─────┐ │   Hyperplonk  │         │
- ┘      │ └───────────────┘         │
- ▲                  │
- ┌─────────────┐      └─────────┤                 │
- Subroutines │◄──────────────┤                 │
- ┘               │                 │
- ▲                       │                 │

- ┌─────────────┐        ┌─────┴─────┐          │
- Transcript  │◄───────│   Util    │          │
- ┘        └───────────┘          │

- ┘

##### Arithmetic Module
- Multilinear Polynomial
- Univariate Polynomial
- Virtual Polynomial
- Error Handling

##### Subroutines Module
- PCS (Polynomial Commitment Scheme)
- Multilinear KZG
- Univariate KZG
- Poly IOP
- Sum Check
- Zero Check
- Product Check
- Permutation Check

##### Hyperplonk Core
- Components for:
- SNARK Implementation
- Custom Gates
- Witness Handling
- Selectors

##### Supporting Components
- Transcript Management
- Utility Functions
- Error Handling

- Use blue for core cryptographic components
- Use green for mathematical/arithmetic components
- Use orange for utility and support functions

D. Important Elements to Include:
- How data moves between components during proof generation and verification
- Direction of dependency relationships

##### Interface Points
- Public APIs and entry points
- Interaction points between major components

##### Key Processes
- Proof Generation Flow
- Verification Flow
- Polynomial Commitment Operations

E. Technical Details to Note:
- A section showing the relationship with external dependencies
- FFT-free components (as this is a key feature)
- Parallel processing capabilities (based on bench_results directory)
- Integration points for custom gates and witness generation

- Any special symbols or notations used
- Abbreviations (e.g., PCS, KZG, IOP)

Remember to emphasize the linear-time, FFT-free nature of the system, as this is a key distinguishing feature of the Hyperplonk implementation.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Core["Core Components"]
        direction TB
        
        subgraph Arithmetic["Arithmetic Module"]
            direction TB
            MP["Multilinear Polynomial"]:::math
            UP["Univariate Polynomial"]:::math
            VP["Virtual Polynomial"]:::math
            AE["Error Handling"]:::error
        end

        subgraph Subroutines["Subroutines"]
            direction TB
            
            subgraph PCS["Polynomial Commitment Scheme"]
                direction TB
                MKZG["Multilinear KZG"]:::crypto
                UKZG["Univariate KZG"]:::crypto
            end
            
            subgraph PIOP["Polynomial IOP"]
                direction TB
                SC["Sum Check"]:::crypto
                ZC["Zero Check"]:::crypto
                PC["Product Check"]:::crypto
                PMC["Permutation Check"]:::crypto
            end
        end

        subgraph HP["Hyperplonk Core"]
            direction TB
            SNARK["SNARK Implementation"]:::core
            CG["Custom Gates"]:::core
            WH["Witness Handling"]:::core
            SEL["Selectors"]:::core
        end

        subgraph Support["Supporting Components"]
            direction TB
            TM["Transcript Management"]:::util
            UF["Utility Functions"]:::util
            EH["Error Handling"]:::error
        end
    end

    %% Relationships
    MP & UP & VP --> SNARK
    MKZG & UKZG --> SNARK
    SC & ZC & PC & PMC --> SNARK
    TM --> SNARK
    UF --> HP
    UF --> Arithmetic
    UF --> Subroutines
    EH --> HP

    %% Click Events
    click MP "https://github.com/EspressoSystems/hyperplonk/blob/main/arithmetic/src/multilinear_polynomial.rs"
    click UP "https://github.com/EspressoSystems/hyperplonk/blob/main/arithmetic/src/univariate_polynomial.rs"
    click VP "https://github.com/EspressoSystems/hyperplonk/blob/main/arithmetic/src/virtual_polynomial.rs"
    click AE "https://github.com/EspressoSystems/hyperplonk/blob/main/arithmetic/src/errors.rs"
    click SNARK "https://github.com/EspressoSystems/hyperplonk/blob/main/hyperplonk/src/snark.rs"
    click CG "https://github.com/EspressoSystems/hyperplonk/blob/main/hyperplonk/src/custom_gate.rs"
    click WH "https://github.com/EspressoSystems/hyperplonk/blob/main/hyperplonk/src/witness.rs"
    click SEL "https://github.com/EspressoSystems/hyperplonk/blob/main/hyperplonk/src/selectors.rs"
    click MKZG "https://github.com/EspressoSystems/hyperplonk/blob/main/subroutines/src/pcs/multilinear_kzg/mod.rs"
    click UKZG "https://github.com/EspressoSystems/hyperplonk/blob/main/subroutines/src/pcs/univariate_kzg/mod.rs"
    click SC "https://github.com/EspressoSystems/hyperplonk/blob/main/subroutines/src/poly_iop/sum_check/mod.rs"
    click ZC "https://github.com/EspressoSystems/hyperplonk/blob/main/subroutines/src/poly_iop/zero_check/mod.rs"
    click PC "https://github.com/EspressoSystems/hyperplonk/blob/main/subroutines/src/poly_iop/prod_check/mod.rs"
    click PMC "https://github.com/EspressoSystems/hyperplonk/blob/main/subroutines/src/poly_iop/perm_check/mod.rs"
    click TM "https://github.com/EspressoSystems/hyperplonk/blob/main/transcript/src/lib.rs"
    click UF "https://github.com/EspressoSystems/hyperplonk/blob/main/util/src/lib.rs"

    %% Styling
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef crypto fill:#1976D2,stroke:#0D47A1,color:white
    classDef math fill:#4CAF50,stroke:#2E7D32,color:white
    classDef util fill:#FF9800,stroke:#F57C00,color:white
    classDef error fill:#F44336,stroke:#C62828,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Cryptographic Components"]:::crypto
        L3["Mathematical Components"]:::math
        L4["Utility Components"]:::util
        L5["Error Handling"]:::error
    end
```
