# andywu0913/tron-tss architecture

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

- Interactive diagram: https://gitdiagram.com/andywu0913/tron-tss
- Repository: https://github.com/andywu0913/tron-tss

## Overview

##### Project type and purpose
- This is a Go-based distributed demo application showing multi-party threshold ECDSA (TSS) key generation and signing for the Tron blockchain.
- It supports two modes:
- Single-process (“all_in_one”) demo where all TSS logic runs in one binary
- Distributed demo with one coordinator node plus five party nodes

##### File structure
- cmd/
- secret_manager_all_in_one/ – all-in-one demo binary
- secret_manager_coordinator/ – orchestrator service for distributed mode
- secret_manager_party_1–5/ – five separate party services
- config/
- config.go – loading and parsing of configuration
- data/
- JSON fixtures and checkpoint data used by both demos
- internal/
- secret_manager_coordinator/ – key generation and signing request handlers
- secret_manager_party/ – party-side TSS handlers for keygen and signing
- tron/ – Tron network RPC client
- utils/ – shared helpers (hashing, storage, TSS primitives)
- types/
- shared type definitions (e.g. Tron transaction types, protocol messages)

##### README for additional insights
- Outlines how to run the two modes
- Emphasizes multi-party collaboration without any party holding the full key
- Describes step-by-step demo workflow

##### Elements
- Clear, concise labels for each component (e.g. “Coordinator Service”, “Party Node #1”)
- Blue rectangles for services (coordinator, parties)
- Orange cloud for external Tron network

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Resources
    Config["Configuration Loader"]:::config
    DataStore["JSON Fixtures & Checkpoints"]:::storage
    TronNet["Tron Network"]:::external

    %% Single-Process Demo
    subgraph "All-in-One Demo" 
        direction TB
        AIO_TSS["TSS Logic Module"]:::module
        AIO_Tron["Tron RPC Client"]:::module
        AIO_Utils["Utilities (hash, storage, tss)"]:::module
        AIO_TSS -->|"calls"| AIO_Tron
        AIO_TSS -->|"uses"| AIO_Utils
        AIO_Tron -->|"uses"| AIO_Utils
    end
    Config -->|"loads config"| AIO_TSS
    Config -->|"loads config"| AIO_Tron
    DataStore -->|"reads/writes"| AIO_Utils

    %% Distributed Demo
    subgraph "Distributed Demo"
        direction TB
        subgraph "Coordinator Service"
            direction TB
            Coord_TSS["KeyGen & Sign Handlers"]:::module
            Coord_TSS -->|"uses"| Coord_Utils["Utilities"]:::module
            Coord_TSS -->|"uses"| Coord_Tron["Tron RPC Client"]:::module
        end

        subgraph "Party Nodes"
            direction TB
            Party1["Party Node #1"]:::party
            Party2["Party Node #2"]:::party
            Party3["Party Node #3"]:::party
            Party4["Party Node #4"]:::party
            Party5["Party Node #5"]:::party
        end
    end

    %% Party internal modules (expand one for detail)
    subgraph "Party Node #1 Modules"
        direction TB
        P1_KeyGen["KeyGen Handler"]:::module
        P1_KeySign["Sign Handler"]:::module
        P1_Common["Shared Party Logic"]:::module
        P1_KeyGen --> P1_Common
        P1_KeySign --> P1_Common
    end
    Party1 -->|"handles"| P1_KeyGen
    Party1 -->|"handles"| P1_KeySign
    P1_Common -->|"uses"| Coord_Utils

    %% Interactions
    Coord_TSS -->|"KeyGen_Request / Sign_Request"| Party1
    Party1 -->|"Partial_Signature"| Coord_TSS
    Coord_TSS -->|"Broadcast Transaction"| TronNet
    Party1 -->|"Checkpoint Read/Write"| DataStore

    %% Click Events
    click AIO_TSS "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_all_in_one/main.go"
    click AIO_Utils "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_all_in_one/utils.go"
    click Coord_TSS "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_coordinator/main.go"
    click Party1 "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_party_1/main.go"
    click Party2 "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_party_2/main.go"
    click Party3 "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_party_3/main.go"
    click Party4 "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_party_4/main.go"
    click Party5 "https://github.com/andywu0913/tron-tss/blob/main/cmd/secret_manager_party_5/main.go"
    click Config "https://github.com/andywu0913/tron-tss/blob/main/config/config.go"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/all_in_one/keygen_party_5_threshold_2.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/1/ecdsa_fixtures.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/1/TNUDwnN5nPzp8ps3TdPfboSRpkzd6Tz5Eu.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/2/ecdsa_fixtures.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/2/TNUDwnN5nPzp8ps3TdPfboSRpkzd6Tz5Eu.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/3/ecdsa_fixtures.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/3/TNUDwnN5nPzp8ps3TdPfboSRpkzd6Tz5Eu.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/4/ecdsa_fixtures.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/4/TNUDwnN5nPzp8ps3TdPfboSRpkzd6Tz5Eu.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/5/ecdsa_fixtures.json"
    click DataStore "https://github.com/andywu0913/tron-tss/blob/main/data/5/TNUDwnN5nPzp8ps3TdPfboSRpkzd6Tz5Eu.json"
    click Coord_TSS "https://github.com/andywu0913/tron-tss/blob/main/internal/secret_manager_coordinator/key_gen_request.go"
    click Coord_TSS "https://github.com/andywu0913/tron-tss/blob/main/internal/secret_manager_coordinator/sign_request.go"
    click P1_Common "https://github.com/andywu0913/tron-tss/blob/main/internal/secret_manager_party/handler.go"
    click P1_KeyGen "https://github.com/andywu0913/tron-tss/blob/main/internal/secret_manager_party/handler_key_gen.go"
    click P1_KeySign "https://github.com/andywu0913/tron-tss/blob/main/internal/secret_manager_party/handler_key_sign.go"
    click Coord_Tron "https://github.com/andywu0913/tron-tss/blob/main/internal/tron/tron.go"
    click AIO_Utils "https://github.com/andywu0913/tron-tss/blob/main/internal/utils/hash.go"
    click AIO_Utils "https://github.com/andywu0913/tron-tss/blob/main/internal/utils/storage.go"
    click AIO_Utils "https://github.com/andywu0913/tron-tss/blob/main/internal/utils/tron.go"
    click AIO_Utils "https://github.com/andywu0913/tron-tss/blob/main/internal/utils/tss.go"
    click Config "https://github.com/andywu0913/tron-tss/blob/main/types/tron.go"
    click Config "https://github.com/andywu0913/tron-tss/blob/main/types/types.go"

    %% Styles
    classDef config fill:#f2f2f2,stroke:#333,stroke-width:1px
    classDef storage fill:#ccffcc,stroke:#333,stroke-width:1px
    classDef external fill:#ffeb99,stroke:#333,stroke-width:1px
    classDef module fill:#e6f7ff,stroke:#3399ff,stroke-width:1px
    classDef party fill:#cce5ff,stroke:#004085,stroke-width:1px
    classDef demo fill:#fff0f0,stroke:#d9534f,stroke-width:1px
```
