# ode/audioshamir architecture

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

- Interactive diagram: https://gitdiagram.com/ode/audioshamir
- Repository: https://github.com/ode/audioshamir

## Overview

##### Input/Output Layer
- Input: WAV file (PCM format)
- Output: Multiple WAV shares or reconstructed WAV file

##### Core Processing Components
- Shamir's Secret Sharing Implementation (GF(256) field)
- WAV File Handler
- Metadata Manager

##### Main Flow Components

a) Split Operation Path:
- [Input WAV] → [WAV Parser] → [Byte Splitter (GF256)] → [Metadata Injector] → [Share Generator] → [Output WAV Shares]

b) Reconstruct Operation Path:
- [Input WAV Shares] → [Metadata Extractor] → [Share Combiner (GF256)] → [WAV Assembler] → [Output WAV]

##### Component Details

- Rectangles: Processing modules
- Hexagons: Mathematical operations (GF(256) field operations)

##### Technical Details
- GF(256) field implementation note
- Threshold (k) and total shares (n) parameters
- Metadata embedding mechanism
- WAV format constraints (PCM only)

##### GF(256) Field
- Byte-level operations
- Field arithmetic implementation
- Maximum share limit (255)

##### Metadata Handling
How additional chunks are embedded in WAV shares:
- Share index
- Threshold information
- Field parameters

##### Error Handling
Validation checks for:
- Input file format (PCM WAV)
- Number of shares (≤ 255)
- Threshold requirements

- Special symbols

Level of Detail:
- Technical constraints and limitations

##### The two main operations (split and reconstruct)

This design should accurately represent the project's architecture while maintaining clarity about its cryptographic and audio processing aspects.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph IO ["Input/Output Layer"]
        Input[("Input WAV")]
        OutputShares[("Output WAV Shares")]
        InputShares[("Input WAV Shares")]
        OutputWAV[("Output WAV")]
    end

    subgraph Split ["Split Operation"]
        WAVParser["WAV Parser"]
        ByteSplitter["Byte Splitter"]:::crypto
        MetadataInjector["Metadata Injector"]:::meta
        ShareGen["Share Generator"]:::crypto
    end

    subgraph Reconstruct ["Reconstruct Operation"]
        MetadataExtractor["Metadata Extractor"]:::meta
        ShareCombiner["Share Combiner"]:::crypto
        WAVAssembler["WAV Assembler"]
    end

    subgraph Core ["Core Components"]
        GF256["GF(256) Field Operations"]:::crypto
        WAVHandler["WAV File Handler"]
        MetadataManager["Metadata Manager"]:::meta
    end

    %% Split Path
    Input --> WAVParser
    WAVParser --> ByteSplitter
    ByteSplitter --> MetadataInjector
    MetadataInjector --> ShareGen
    ShareGen --> OutputShares

    %% Reconstruct Path
    InputShares --> MetadataExtractor
    MetadataExtractor --> ShareCombiner
    ShareCombiner --> WAVAssembler
    WAVAssembler --> OutputWAV

    %% Core Component Relations
    ByteSplitter <--> GF256
    ShareCombiner <--> GF256
    WAVParser <--> WAVHandler
    WAVAssembler <--> WAVHandler
    MetadataInjector <--> MetadataManager
    MetadataExtractor <--> MetadataManager

    %% Styling
    classDef default fill:#f9f9f9,stroke:#333,stroke-width:2px
    classDef crypto fill:#FFE5CC,stroke:#FF9933,stroke-width:2px
    classDef meta fill:#E6F3FF,stroke:#3399FF,stroke-width:2px
    classDef io fill:#E6FFE6,stroke:#33CC33,stroke-width:2px

    %% Click Events
    click GF256 "https://github.com/ode/AudioShamir/blob/master/src/Shamir.hs"
    click WAVParser "https://github.com/ode/AudioShamir/blob/master/src/Main.hs"
    click WAVHandler "https://github.com/ode/AudioShamir/blob/master/src/Main.hs"
    click ShareGen "https://github.com/ode/AudioShamir/blob/master/src/Shamir.hs"
    click ShareCombiner "https://github.com/ode/AudioShamir/blob/master/src/Shamir.hs"

    %% Legend
    subgraph Legend
        L1["Processing Module"]
        L2["Cryptographic Operation"]:::crypto
        L3["Metadata Handling"]:::meta
        L4[("File I/O")]:::io
    end
```
