# fireblocks/mpc-lib architecture

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

- Interactive diagram: https://gitdiagram.com/fireblocks/mpc-lib
- Repository: https://github.com/fireblocks/mpc-lib

## Overview

##### Project Type Analysis
This is a specialized cryptographic library implementing MPC algorithms for digital signatures, specifically focusing on ECDSA and EdDSA implementations. It's a C++ library project with a strong focus on security and cryptographic operations.

##### Main Components

A. Core Library Components (libcosigner):
- Cosigner Services Layer
- Cryptographic Primitives Layer
- Blockchain Integration Layer

B. Supporting Components:
- Testing Framework
- Platform Services
- Logging System

**┌─ Signing Services ─────────────────────┐**
- CMP ECDSA Online/Offline Signing     │
- EdDSA Online Signing                 │
- Asymmetric EdDSA                     │
- ┘

**┌─ Cosigner Services ──────────────────┐**
- Setup Service                      │
- Key Persistency                    │
- Refresh Service                    │
- Platform Service                   │
- ┘

**┌─ Cryptographic Primitives ───────────────────────┐**
- Elliptic Curve Algebra (ECDSA, Ed25519)       │
- Zero Knowledge Proofs                          │
- Secret Sharing                                 │
- Commitments                                    │
- Paillier Cryptosystem                         │
- ┘

##### Component Relationships

- Data flow between signing services and core services
- Dependency relationships between cryptographic primitives
- Integration points with external systems

##### Additional Elements

- External Dependencies (OpenSSL, UUID, secp256k1)
- Testing Components
- Logging System

##### Specific Implementation Details

- The separation between online and offline signing paths
- The different signature schemes (ECDSA vs EdDSA)
- Security boundaries between components
- Key management flows

##### Technical Notes

Annotations for:
- Security considerations
- Performance-critical paths
- Cryptographic protocol flows
- Error handling paths

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef public fill:#b3d1ff,stroke:#333,stroke-width:2px
    classDef core fill:#90EE90,stroke:#333,stroke-width:2px
    classDef crypto fill:#FFE5B4,stroke:#333,stroke-width:2px
    classDef external fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef support fill:#FFB6C1,stroke:#333,stroke-width:2px

    %% Public Interfaces Layer
    subgraph Public
        ECDSA["CMP ECDSA Online/Offline Signing"]
        EdDSA["EdDSA Online Signing"]
        AEdDSA["Asymmetric EdDSA"]
    end

    %% Core Services Layer
    subgraph Core
        Setup["Setup Service"]
        KeyPers["Key Persistency"]
        Refresh["Refresh Service"]
        Platform["Platform Service"]
    end

    %% Cryptographic Layer
    subgraph Crypto
        ECC["Elliptic Curve Algebra"]
        ZKP["Zero Knowledge Proofs"]
        SecretShare["Secret Sharing"]
        Commit["Commitments"]
        Paillier["Paillier Cryptosystem"]
    end

    %% Supporting Components
    subgraph Support
        Logging["Logging System"]
        BlockchainInt["Blockchain Integration"]
    end

    %% External Dependencies
    subgraph External
        OpenSSL["OpenSSL"]
        UUID["UUID"]
        Secp256k1["secp256k1"]
    end

    %% Relationships
    ECDSA --> Setup
    ECDSA --> KeyPers
    EdDSA --> Setup
    EdDSA --> KeyPers
    AEdDSA --> Setup
    AEdDSA --> KeyPers

    Setup --> ECC
    Setup --> ZKP
    Setup --> SecretShare
    KeyPers --> Platform
    Refresh --> Platform
    Platform --> Logging

    ECC --> OpenSSL
    ECC --> Secp256k1
    Platform --> UUID
    BlockchainInt --> ECC

    %% Click Events
    click ECDSA "https://github.com/fireblocks/mpc-lib/blob/main/include/cosigner/cmp_ecdsa_online_signing_service.h"
    click EdDSA "https://github.com/fireblocks/mpc-lib/blob/main/include/cosigner/eddsa_online_signing_service.h"
    click AEdDSA "https://github.com/fireblocks/mpc-lib/blob/main/include/cosigner/asymmetric_eddsa_cosigner.h"
    click Setup "https://github.com/fireblocks/mpc-lib/blob/main/include/cosigner/cmp_setup_service.h"
    click KeyPers "https://github.com/fireblocks/mpc-lib/blob/main/include/cosigner/cmp_key_persistency.h"
    click Refresh "https://github.com/fireblocks/mpc-lib/blob/main/include/cosigner/cmp_offline_refresh_service.h"
    click Platform "https://github.com/fireblocks/mpc-lib/blob/main/include/cosigner/platform_service.h"
    click ECC "https://github.com/fireblocks/mpc-lib/blob/main/include/crypto/elliptic_curve_algebra/elliptic_curve256_algebra.h"
    click ZKP "https://github.com/fireblocks/mpc-lib/tree/main/include/crypto/zero_knowledge_proof"
    click SecretShare "https://github.com/fireblocks/mpc-lib/blob/main/include/crypto/shamir_secret_sharing/verifiable_secret_sharing.h"
    click Commit "https://github.com/fireblocks/mpc-lib/tree/main/include/crypto/commitments"
    click Paillier "https://github.com/fireblocks/mpc-lib/blob/main/include/crypto/paillier/paillier.h"
    click BlockchainInt "https://github.com/fireblocks/mpc-lib/blob/main/include/blockchain/mpc/hd_derive.h"
    click Logging "https://github.com/fireblocks/mpc-lib/blob/main/include/logging/logging_t.h"

    %% Style Applications
    class ECDSA,EdDSA,AEdDSA public
    class Setup,KeyPers,Refresh,Platform core
    class ECC,ZKP,SecretShare,Commit,Paillier crypto
    class OpenSSL,UUID,Secp256k1 external
    class Logging,BlockchainInt support
```
