Class Diagrams
Automatically generated visual documentation of the Cryptnox SDK architecture
This section provides automatically generated class diagrams for the Cryptnox SDK Python package.
These diagrams are generated directly from the source code and update automatically when the code changes.
π What youβll find here:
Class Hierarchies - Inheritance relationships between card, exception, and enum classes
System Architecture - High-level component interactions and data flows
Connection Patterns - Reader and connection class structures
Process Flows - Card initialization and operation sequences
All diagrams are interactive SVG graphics that update automatically with code changes.
Overview
The Cryptnox SDK follows an object-oriented design with a clear class hierarchy. The diagrams below
illustrate the relationships between classes, inheritance structures, and key components.
Card Class Hierarchy
The main card classes follow an inheritance pattern with a base abstract class and specific implementations.
Complete Card Module
Complete class hierarchy for all card-related classes:
digraph card_module {
rankdir=TB;
node [shape=box, style="rounded,filled", fontsize=10, color=black, fontcolor=black, fillcolor=lightgray];
edge [arrowsize=0.7, color=black];
// Base abstract class
Base [label="<<abstract>>\nBase\nβββββββββββββββββ\nserial_number\napplet_version\nconnection\nβββββββββββββββββ\nverify_pin()\nsign()\nderive()\nget_public_key()\n...", fillcolor=gray];
// Concrete card implementations
BasicG1 [label="BasicG1\nβββββββββββββββββ\nBasic G1 Card\nβββββββββββββββββ\ngenerate_seed()\nload_seed()\ndual_seed_**()"];
Nft [label="Nft\nβββββββββββββββββ\nNFT Card\nβββββββββββββββββ\nslot operations\nRSA operations"];
// Support classes
UserData [label="UserData\nβββββββββββββββββ\nread()\nwrite()", fontsize=9];
CustomBits [label="CustomBits\nβββββββββββββββββ\nread()\nwrite()", fontsize=9];
Authenticity [label="authenticity\n(module)\nβββββββββββββββββ\ngenuine_check()", fontsize=9];
// Inheritance
Base -> BasicG1;
Base -> Nft;
// Composition relationships
Base -> UserData [style=dashed, arrowhead=diamond, label="has"];
Base -> CustomBits [style=dashed, arrowhead=diamond, label="has"];
}
Complete card module class hierarchy
Exception Hierarchy
The SDK defines a custom exception hierarchy for different error scenarios:
digraph exceptions {
rankdir=LR;
nodesep=0.3;
ranksep=1.5;
size="20,14";
node [shape=box, style="rounded,filled", fontsize=12, color=black, fontcolor=black, fillcolor=lightgray];
edge [arrowsize=0.8, color=black];
// Base exception
CryptnoxException [fontsize=14, label="CryptnoxException\n(Base)", fillcolor=gray];
// All child exceptions
CardException;
CardClosedException;
CardNotBlocked;
CardTypeException;
CertificateException;
ConnectionException;
DataException;
DataValidationException;
DerivationSelectionException;
EOSKeyError;
FirmwareException;
GenericException;
GenuineCheckException;
InitializationException;
KeyAlreadyGenerated;
KeyGenerationException;
KeySelectionException;
PinAuthenticationException;
PinException;
PukException;
ReadPublicKeyException;
ReaderException;
SecureChannelException;
SeedException;
SoftLock;
// All edges from base
CryptnoxException -> CardException;
CryptnoxException -> CardClosedException;
CryptnoxException -> CardNotBlocked;
CryptnoxException -> CardTypeException;
CryptnoxException -> CertificateException;
CryptnoxException -> ConnectionException;
CryptnoxException -> DataException;
CryptnoxException -> DataValidationException;
CryptnoxException -> DerivationSelectionException;
CryptnoxException -> EOSKeyError;
CryptnoxException -> FirmwareException;
CryptnoxException -> GenericException;
CryptnoxException -> GenuineCheckException;
CryptnoxException -> InitializationException;
CryptnoxException -> KeyAlreadyGenerated;
CryptnoxException -> KeyGenerationException;
CryptnoxException -> KeySelectionException;
CryptnoxException -> PinAuthenticationException;
CryptnoxException -> PinException;
CryptnoxException -> PukException;
CryptnoxException -> ReadPublicKeyException;
CryptnoxException -> ReaderException;
CryptnoxException -> SecureChannelException;
CryptnoxException -> SeedException;
CryptnoxException -> SoftLock;
}
Exception class hierarchy (expanded view)
Enum Classes
The SDK uses several enumerations for type safety:
digraph enums {
rankdir=TB;
node [shape=box, style="rounded,filled", fontsize=10, color=black, fontcolor=black, fillcolor=lightgray];
edge [arrowsize=0.7, color=black];
// Python base classes
Enum [label="enum.Enum", fontsize=9, fillcolor=gray];
IntEnum [label="enum.IntEnum", fontsize=9, fillcolor=gray];
// SDK Enums inheriting from Enum
AuthType [label="AuthType\nβββββββββ\nNO_AUTH = 0\nPIN = 1\nUSER_KEY = 2"];
Origin [label="Origin\nβββββββββ\nUNKNOWN = 0\nORIGINAL = 1\nFAKE = 2"];
SeedSource [label="SeedSource\nβββββββββ\nNO_SEED\nSINGLE\nEXTENDED\nEXTERNAL\nINTERNAL\nDUAL\nWRAPPED"];
// SDK Enums inheriting from IntEnum
Derivation [label="Derivation\nβββββββββ\nCURRENT_KEY\nDERIVE\nDERIVE_AND_MAKE_CURRENT\nPINLESS_PATH"];
KeyType [label="KeyType\nβββββββββ\nK1 = 0x00\nR1 = 0x10"];
SlotIndex [label="SlotIndex\nβββββββββ\nEC256R1 = 0x01\nRSA = 0x02\nFIDO = 0x03"];
// Inheritance relationships
Enum -> AuthType;
Enum -> Origin;
Enum -> SeedSource;
IntEnum -> Derivation;
IntEnum -> KeyType;
IntEnum -> SlotIndex;
}
Enumeration classes
Connection Components
Classes related to card connection and communication:
digraph connection_components {
rankdir=TB;
node [shape=box, style="rounded,filled", fontsize=10, color=black, fontcolor=black, fillcolor=lightgray];
edge [arrowsize=0.7, color=black];
// Python base classes
ContextDecorator [label="contextlib.ContextDecorator", fontsize=9, fillcolor=gray];
ABCMeta [label="abc.ABCMeta\n(metaclass)", fontsize=9, fillcolor=gray];
// Connection class
Connection [label="Connection\nβββββββββββββββββ\nindex: int\ndebug: bool\nremote: bool\nsession_public_key: str\nβββββββββββββββββ\nsend_apdu()\nsend_encrypted()\ndisconnect()\nremote_read()"];
// Reader abstract class
Reader [label="<<abstract>>\nReader\nβββββββββββββββββ\n_connection\nβββββββββββββββββ\nconnect()\nsend()\nbool()", fillcolor=gray];
// Inheritance
ContextDecorator -> Connection;
ABCMeta -> Reader [style=dashed, label="metaclass"];
}
Connection and Reader classes
Custom Architecture Diagram
The following diagram shows the high-level architecture of the SDK:
digraph cryptnox_architecture {
rankdir=LR;
node [shape=box, style="rounded,filled", color=black, fontcolor=black, fillcolor=lightgray];
edge [color=black];
// Main components
User [label="User Application", fillcolor=gray];
Factory [label="Factory\n(get_card)"];
Reader [label="Reader"];
Connection [label="Connection"];
Card [label="Card Classes\n(Base, BasicG1, Nft)"];
// Utilities
CryptoUtils [label="Crypto Utils"];
BinaryUtils [label="Binary Utils"];
// External
SmartCard [label="Smart Card\nHardware", fillcolor=gray];
// Relationships
User -> Factory [label="creates"];
Factory -> Reader [label="uses"];
Reader -> Connection [label="creates"];
Factory -> Card [label="instantiates"];
Card -> Connection [label="uses"];
Connection -> SmartCard [label="communicates"];
Card -> CryptoUtils [label="uses"];
Card -> BinaryUtils [label="uses"];
}
Cryptnox SDK Architecture
Data Flow Diagram
The following diagram illustrates the data flow during card operations:
digraph card_operation_flow {
rankdir=TB;
node [shape=box, style="rounded,filled", color=black, fontcolor=black, fillcolor=lightgray];
edge [color=black];
Start [label="Application Request", shape=ellipse, fillcolor=gray];
Card [label="Card Object"];
Connection [label="Connection Layer"];
APDU [label="APDU Command"];
SmartCard [label="Smart Card"];
Response [label="Card Response"];
Process [label="Process Response"];
Result [label="Return Result", shape=ellipse, fillcolor=gray];
Start -> Card [label="method call"];
Card -> Connection [label="send request"];
Connection -> APDU [label="format"];
APDU -> SmartCard [label="transmit"];
SmartCard -> Response [label="receive"];
Response -> Connection [label="parse"];
Connection -> Card [label="return data"];
Card -> Process [label="validate"];
Process -> Result;
}
Card Operation Data Flow
Card Initialization Sequence
digraph card_init {
rankdir=TB;
node [shape=box, style="rounded,filled", color=black, fontcolor=black, fillcolor=lightgray];
edge [color=black];
GetCard [label="get_card()", shape=ellipse, fillcolor=gray];
Detect [label="Detect Card Type"];
Select [label="Select Applet"];
Serial [label="Get Serial Number"];
SessionKey [label="Get Session Key"];
Instantiate [label="Instantiate Card Class"];
Ready [label="Card Ready", shape=ellipse, fillcolor=gray];
GetCard -> Detect;
Detect -> Select;
Select -> Serial;
Serial -> SessionKey;
SessionKey -> Instantiate;
Instantiate -> Ready;
}
Card Initialization Process
Reader Class Hierarchy
The SDK supports different types of card readers:
digraph reader_hierarchy {
rankdir=TB;
node [shape=box, style="rounded,filled", fontsize=10, color=black, fontcolor=black, fillcolor=lightgray];
edge [arrowsize=0.7, color=black];
// Base abstract class
Reader [label="<<abstract>>\nReader\nβββββββββββββββββ\n_connection\nβββββββββββββββββ\nconnect()\nsend()\nbool()", fillcolor=gray];
// Concrete implementations
NfcReader [label="NfcReader\nβββββββββββββββββ\nxantares/nfc-binding\nβββββββββββββββββ\nconnect()\nsend()"];
SmartCardReader [label="SmartCard\nβββββββββββββββββ\npyscard/smartcard\nβββββββββββββββββ\nconnect()\nsend()"];
// Reader module exceptions
ReaderException [label="ReaderException", fontsize=9];
CardException [label="CardException", fontsize=9];
ConnException [label="ConnectionException", fontsize=9];
// Inheritance
Reader -> NfcReader;
Reader -> SmartCardReader;
// Group exceptions
subgraph cluster_exceptions {
label="Reader Module Exceptions";
style=dashed;
fontsize=9;
color=black;
fontcolor=black;
ReaderException; CardException; ConnException;
}
}
Reader implementations (NfcReader and SmartCard reader)
Notes on Diagram Generation
Automatic Updates : All diagrams on this page are generated automatically from the Python source code
during the Sphinx build process. When you modify the code structure, simply rebuild the documentation to
see updated diagrams.
Technologies Used :
Sphinx : Documentation generator
sphinx.ext.inheritance_diagram : For class hierarchy diagrams
sphinx.ext.graphviz : For custom architecture and flow diagrams
Graphviz : Graph visualization software
Build Requirements : Make sure Graphviz is installed on your system and available in your PATH.
See the documentation guides for detailed setup instructions.
For Developers
If youβre a developer working on this project and need to regenerate or customize diagrams, please refer to:
Quick rebuild command :
cd docs
sphinx-build -b html . _build/html