# ingonyama-zk/smallfield-super-sumcheck architecture

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

- Interactive diagram: https://gitdiagram.com/ingonyama-zk/smallfield-super-sumcheck
- Repository: https://github.com/ingonyama-zk/smallfield-super-sumcheck

## Overview

##### Main Components
- Core Library: At the heart is the Rust library (lib.rs) defining key API components.
- Algorithms Module: Under src/algorithms, several files (one.rs, two.rs, three.rs, four.rs) implement the sumcheck algorithms. Each file can be represented as a node, showing the two divergent approaches: Algorithm 1 (collapsing arrays) and Algorithm 2 (precomputations).
- Prover and Verifier: The modules in src/prover.rs and src/verifier.rs encapsulate the main proving logic and the verification processes.
- Transcript Management: There are dedicated modules for handling transcripts (src/transcript.rs, src/btf_transcript.rs, src/extension_transcript.rs), which interface with the merlin library to realize the Fiat-Shamir heuristic.
- Data Structures: The src/data_structures.rs file indicates core, reusable types or data representations in the project that underpin the sumcheck computations.
- Tower Fields Module: In src/tower_fields, files like binius.rs deal with specialized field operations (e.g., binary operations on tower fields) used during polynomial computations.
- Testing & Benchmarks: The tests (both in src/tests and the benches directory) provide validation and performance analysis. Separate nodes for test suites and benchmarks help in reflecting iterative development and performance evaluation.

##### Relationships and Interactions
- The Prover module uses components from the Algorithms, Data Structures, and Transcript modules to compute the sumcheck proof.
- The Transcript modules (including the specialized BTF and extension transcripts) are used by both the prover and the (future) verifier to obtain randomness or challenges via the merlin library.
- The Algorithms in src/algorithms are called by the main prover logic, with each algorithm having its own trade-offs (memory vs. computation).
- The Tower Fields components are integrated with the above modules, particularly in the context of polynomial evaluation and field arithmetic.
- Tests and benchmarking code interacts with all core components to validate functionality and measure performance.

##### Architectural Patterns & Design Principles
- Modularity: Components are separated by functionality (algorithms, prover, verifier, transcript management), which promotes clarity and testing.
- Reusability: Shared helper functions and data structures increase maintainability and reduce code duplication.
- Extensibility: The design supports switching or updating the sumcheck algorithm easily. Future implementations like adding multi-threading or commitment schemes are envisioned.
- Layered interaction: Lower-level modules (e.g. data structures and tower fields) support higher-level components like the prover and transcript, following a clear dependency direction.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Core Layer
    subgraph "Core Layer"
        CL["lib.rs"]:::core
    end

    %% Algorithms Module
    subgraph "Algorithms Module"
        A1["one.rs (Collapsing Arrays)"]:::algo
        A2["two.rs (Collapsing Arrays)"]:::algo
        A3["three.rs (Precomputations)"]:::algo
        A4["four.rs (Precomputations)"]:::algo
    end

    %% Proof System
    subgraph "Proof System"
        P["Prover (prover.rs)"]:::prover
        V["Verifier (verifier.rs)"]:::verifier
        T1["transcript.rs"]:::transcript
        T2["btf_transcript.rs"]:::transcript
        T3["extension_transcript.rs"]:::transcript
        DS["data_structures.rs"]:::data
    end

    %% Field Operations
    subgraph "Field Operations"
        TF1["binius.rs"]:::tower
        TF2["mod.rs"]:::tower
    end

    %% Testing & Benchmarks
    subgraph "Testing & Benchmarks"
        Tst1["src/tests/mod.rs"]:::tests
        Tst2["src/tests/simple_tests.rs"]:::tests
        Tst3["src/tests/btf_sumcheck.ts"]:::tests
        Bench1["benches/binius_tower_field.rs"]:::tests
        Bench2["benches/btf_sumcheck.rs"]:::tests
    end

    %% Relationships
    CL --> DS

    DS --> A1
    DS --> A2
    DS --> A3
    DS --> A4

    P --> A1
    P --> A2
    P --> A3
    P --> A4

    TF1 --> A1
    TF1 --> A2
    TF1 --> A3
    TF1 --> A4

    T1 --> P
    T2 --> P
    T3 --> P

    T1 --> V
    T2 --> V
    T3 --> V

    Tst1 -.-> P
    Tst2 -.-> A1
    Tst3 -.-> V
    Bench1 -.-> A1
    Bench2 -.-> P

    %% Styles
    classDef core fill:#ffebcd,stroke:#d2691e,stroke-width:2px;
    classDef algo fill:#d0e6a5,stroke:#9acd32,stroke-width:2px;
    classDef prover fill:#add8e6,stroke:#00008b,stroke-width:2px;
    classDef verifier fill:#ffa07a,stroke:#ff6347,stroke-width:2px;
    classDef transcript fill:#e6e6fa,stroke:#9370db,stroke-width:2px;
    classDef data fill:#f0e68c,stroke:#b8860b,stroke-width:2px;
    classDef tower fill:#ffe4e1,stroke:#ff4500,stroke-width:2px;
    classDef tests fill:#98fb98,stroke:#32cd32,stroke-width:2px;

    %% Click Events
    click CL "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/lib.rs"
    click A1 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/algorithms/one.rs"
    click A2 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/algorithms/two.rs"
    click A3 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/algorithms/three.rs"
    click A4 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/algorithms/four.rs"
    click P "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/prover.rs"
    click V "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/verifier.rs"
    click T1 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/transcript.rs"
    click T2 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/btf_transcript.rs"
    click T3 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/extension_transcript.rs"
    click DS "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/data_structures.rs"
    click TF1 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/tower_fields/binius.rs"
    click TF2 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/tower_fields/mod.rs"
    click Tst1 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/tests/mod.rs"
    click Tst2 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/tests/simple_tests.rs"
    click Tst3 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/src/tests/btf_sumcheck.ts"
    click Bench1 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/benches/binius_tower_field.rs"
    click Bench2 "https://github.com/ingonyama-zk/smallfield-super-sumcheck/blob/main/benches/btf_sumcheck.rs"
```
