# qblockq/pqc-bitcoin architecture

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

- Interactive diagram: https://gitdiagram.com/qblockq/pqc-bitcoin
- Repository: https://github.com/qblockq/pqc-bitcoin

## Overview

This project is a specialized fork of Bitcoin Core that integrates post‐quantum cryptography (PQC) into the Bitcoin node, wallet, and signing systems to safeguard against future quantum threats. In short, it’s an enhanced blockchain node implementation that not only maintains backward compatibility with classical Bitcoin cryptography but also adds new digital signature schemes and key encapsulation methods (KEMs) as part of a “quantum‐resistant” evolution.

##### Main Components
- Bitcoin Node Core (“bitcoind”) – the central engine.
- Wallet Subsystem – handles key management, transactions, and hybrid key signing.
- Network & P2P Layer – responsible for block propagation and peer communications.
- Consensus Engine – includes block validation, mempool management, and blockchain ledger storage.
- Crypto Modules – splits into two:
– Classical Cryptography (ECC-based components)
– PQC Modules integrating algorithms from two groups:
▪ Digital Signature Schemes (e.g. SPHINCS+, CRYSTALS-Dilithium, FALCON, SQIsign)
▪ Key Encapsulation Mechanisms (e.g. Kyber, FrodoKEM, NTRU)
- RPC Interface – exposes commands and configuration options (e.g., enabling hybrid modes or PQC algorithm selection).
- Auxiliary Components – such as test frameworks (functional, fuzz, and unit tests), documentation, and build/dependency management (“depends”, “ci”, “doc”).

- How the Bitcoin Node core interacts with the network layer to receive blocks and transactions.
- That the RPC interface and CLI commands control the node’s operation, including enabling/disabling PQC features with parameters (e.g., -pqc=1, -pqcalgo, -pqcsig).
- How the consensus engine uses components from the network layer and interacts with storage (blockchain data, mempool) and error-logging systems.
- Optionally, include the test suite as a parallel component that interacts with core modules for continuous integration, fuzz testing, and functional tests.

##### Architectural Patterns and Integration Details
- Modular design by grouping code into logical entities (e.g., src/crypto, src/wallet, src/node, src/rpc, etc.).
- That the project maintains backward compatibility while offering “quantum-safe” alternatives; this can be depicted by having two “branches” in the crypto module (traditional vs. PQC).
- Dependency and build management tools (e.g., “depends”, “ci”, “Makefile.am”), which support multiple platforms and are integral to the build process.

##### Additional Details
- Under “Crypto Modules,” list the PQC algorithms (both Group 1 for digital signatures and Group 2 for key encapsulation) to indicate the breadth of support.
- “Hybrid Key Management System” as a subcomponent under Wallet/Crypto integration.
- Optionally, show the testing ecosystem (unit, functional, fuzz tests) and auxiliary scripts (build automation and linting) that contribute to reliability.

– Clear labels for each major component,
– Annotations on configuration options and integration points (e.g., hybrid keys, PQC algorithm choices).

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Core Components
    subgraph "Core Components"
        nodeCore("Bitcoin Node Core"):::nodeCore
        wallet("Wallet Subsystem"):::wallet
        network("Network & P2P Layer"):::network
        consensus("Consensus Engine<br/>(Block Validation, Mempool, Ledger)"):::consensus
        rpc("RPC Interface"):::rpc
    end

    %% Crypto Modules
    subgraph "Crypto Modules"
        crypto_classic("Classical Cryptography"):::crypto
        crypto_pqc("PQC Modules<br/>(Digital Signature Schemes & KEMs)"):::pqc
    end

    %% Auxiliary Components
    subgraph "Auxiliary Components"
        testing("Testing Frameworks"):::auxiliary
        documentation("Documentation"):::auxiliary
        build("Build/Dependency Management"):::auxiliary
    end

    %% Relationships
    network -->|"receives_blocks_tx"| nodeCore
    nodeCore -->|"validates"| consensus
    network -->|"feeds_blocks"| consensus
    wallet -->|"HybridKey_signing"| crypto_classic
    wallet -->|"HybridKey_signing"| crypto_pqc
    wallet -->|"broadcast_tx"| nodeCore
    rpc -->|"controls_node"| nodeCore
    rpc -->|"controls_wallet"| wallet
    rpc -->|"configures_crypto"| crypto_classic
    rpc -->|"configures_crypto"| crypto_pqc
    testing --- nodeCore
    testing --- wallet
    testing --- consensus
    testing --- network
    testing --- crypto_classic
    testing --- crypto_pqc
    build --- nodeCore
    build --- wallet
    build --- consensus
    documentation --- nodeCore

    %% Click Events
    click nodeCore "https://github.com/qblockq/pqc-bitcoin/blob/main/src/bitcoind.cpp"
    click wallet "https://github.com/qblockq/pqc-bitcoin/tree/main/src/wallet/"
    click network "https://github.com/qblockq/pqc-bitcoin/blob/main/src/net.cpp"
    click consensus "https://github.com/qblockq/pqc-bitcoin/tree/main/src/consensus/"
    click crypto_classic "https://github.com/qblockq/pqc-bitcoin/tree/main/src/crypto/"
    click crypto_pqc "https://github.com/qblockq/pqc-bitcoin/tree/main/src/crypto/pqc/"
    click rpc "https://github.com/qblockq/pqc-bitcoin/tree/main/src/rpc/"
    click testing "https://github.com/qblockq/pqc-bitcoin/tree/main/test/"
    click documentation "https://github.com/qblockq/pqc-bitcoin/tree/main/doc/"
    click build "https://github.com/qblockq/pqc-bitcoin/blob/main/Makefile.am"

    %% Styles
    classDef nodeCore fill:#AED6F1,stroke:#1F618D,stroke-width:2px;
    classDef wallet fill:#A9DFBF,stroke:#196F3D,stroke-width:2px;
    classDef network fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef consensus fill:#D2B4DE,stroke:#6C3483,stroke-width:2px;
    classDef crypto fill:#F5B7B1,stroke:#922B21,stroke-width:2px;
    classDef pqc fill:#FADBD8,stroke:#641E16,stroke-width:2px;
    classDef rpc fill:#FDEBD0,stroke:#AF601A,stroke-width:2px;
    classDef auxiliary fill:#D5DBDB,stroke:#566573,stroke-width:2px;
```
